mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
Merge remote-tracking branch 'origin/devel' into devel
This commit is contained in:
+4
-1
@@ -6,7 +6,7 @@
|
||||
* you may not use this file except in compliance with the License.
|
||||
*/
|
||||
|
||||
import { makeObservable, observable } from 'mobx';
|
||||
import { computed, makeObservable, observable } from 'mobx';
|
||||
|
||||
import type { ITask, TaskScheduler } from '@cloudbeaver/core-executor';
|
||||
|
||||
@@ -37,6 +37,9 @@ export class ConnectionExecutionContext implements IConnectionExecutionContext {
|
||||
this.currentTask = null;
|
||||
makeObservable<this, 'currentTask'>(this, {
|
||||
currentTask: observable.ref,
|
||||
context: computed,
|
||||
executing: computed,
|
||||
cancellable: computed,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* you may not use this file except in compliance with the License.
|
||||
*/
|
||||
|
||||
import { makeObservable, observable } from 'mobx';
|
||||
import { computed, makeObservable, observable } from 'mobx';
|
||||
|
||||
import type { ITask } from './ITask';
|
||||
|
||||
@@ -15,7 +15,11 @@ export class Task<TValue> implements ITask<TValue> {
|
||||
executing: boolean;
|
||||
|
||||
get cancellable(): boolean {
|
||||
return !this.cancelled && (!this.executing || !!this.externalCancel);
|
||||
if (this.cancelled) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !this.executing || this.externalCancel !== undefined;
|
||||
}
|
||||
|
||||
private resolve!: (value: TValue) => void;
|
||||
@@ -38,6 +42,7 @@ export class Task<TValue> implements ITask<TValue> {
|
||||
this.executing = false;
|
||||
|
||||
makeObservable(this, {
|
||||
cancellable: computed,
|
||||
cancelled: observable,
|
||||
executing: observable,
|
||||
});
|
||||
@@ -107,6 +112,10 @@ export class Task<TValue> implements ITask<TValue> {
|
||||
}
|
||||
|
||||
cancel(): Promise<void> | void {
|
||||
if (this.cancelled) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.cancelled = true;
|
||||
|
||||
if (!this.executing) {
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
* you may not use this file except in compliance with the License.
|
||||
*/
|
||||
|
||||
import { computed, makeObservable, observable } from 'mobx';
|
||||
|
||||
import type { ConnectionExecutionContextService, IConnectionExecutionContext, IConnectionExecutionContextInfo } from '@cloudbeaver/core-connections';
|
||||
import type { NotificationService } from '@cloudbeaver/core-events';
|
||||
import type { ITask } from '@cloudbeaver/core-executor';
|
||||
@@ -38,6 +40,11 @@ export class ContainerDataSource extends DatabaseDataSource<IDataContainerOption
|
||||
|
||||
this.currentTask = null;
|
||||
this.executionContext = null;
|
||||
|
||||
makeObservable(this, {
|
||||
currentTask: observable.ref,
|
||||
canCancel: computed,
|
||||
});
|
||||
}
|
||||
|
||||
isDisabled(resultIndex: number): boolean {
|
||||
|
||||
+4
-11
@@ -174,23 +174,16 @@ export class ResultSetEditAction
|
||||
}
|
||||
|
||||
add(key?: IResultSetElementKey): void {
|
||||
let row = key?.row;
|
||||
let column = key?.column;
|
||||
this.addRow(key?.row, undefined, key?.column);
|
||||
}
|
||||
|
||||
addRow(row?: IResultSetRowKey, value?: IResultSetValue[], column?: IResultSetColumnKey): void {
|
||||
if (!row) {
|
||||
row = this.data.getDefaultKey().row;
|
||||
} else if (!('key' in row)) {
|
||||
row = { ...row, index: row.index + 1 };
|
||||
}
|
||||
|
||||
if (!column) {
|
||||
column = this.data.getDefaultKey().column;
|
||||
}
|
||||
|
||||
this.addRow(row, undefined, column);
|
||||
}
|
||||
|
||||
addRow(row: IResultSetRowKey, value?: IResultSetValue[], column?: IResultSetColumnKey): void {
|
||||
if (value === undefined) {
|
||||
value = this.data.columns.map(() => null);
|
||||
}
|
||||
@@ -340,7 +333,7 @@ export class ResultSetEditAction
|
||||
}
|
||||
|
||||
case DatabaseEditChangeType.delete: {
|
||||
const insertShift = insertedRows.filter(row => row.index < update.row.index).length;
|
||||
const insertShift = insertedRows.filter(row => row.index <= update.row.index).length;
|
||||
const newRow = this.data.removeRow(update.row, deleteShift + insertShift);
|
||||
|
||||
if (newRow) {
|
||||
|
||||
Reference in New Issue
Block a user