diff --git a/webapp/packages/core-connections/src/ConnectionExecutionContext/ConnectionExecutionContext.ts b/webapp/packages/core-connections/src/ConnectionExecutionContext/ConnectionExecutionContext.ts index af82ec540f..733f973b63 100644 --- a/webapp/packages/core-connections/src/ConnectionExecutionContext/ConnectionExecutionContext.ts +++ b/webapp/packages/core-connections/src/ConnectionExecutionContext/ConnectionExecutionContext.ts @@ -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: observable.ref, + context: computed, + executing: computed, + cancellable: computed, }); } diff --git a/webapp/packages/core-executor/src/TaskScheduler/Task.ts b/webapp/packages/core-executor/src/TaskScheduler/Task.ts index 080019bde6..16d8201f2c 100644 --- a/webapp/packages/core-executor/src/TaskScheduler/Task.ts +++ b/webapp/packages/core-executor/src/TaskScheduler/Task.ts @@ -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 implements ITask { 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 implements ITask { this.executing = false; makeObservable(this, { + cancellable: computed, cancelled: observable, executing: observable, }); @@ -107,6 +112,10 @@ export class Task implements ITask { } cancel(): Promise | void { + if (this.cancelled) { + return; + } + this.cancelled = true; if (!this.executing) { diff --git a/webapp/packages/plugin-data-viewer/src/ContainerDataSource.ts b/webapp/packages/plugin-data-viewer/src/ContainerDataSource.ts index 2639eebeec..db1b513db5 100644 --- a/webapp/packages/plugin-data-viewer/src/ContainerDataSource.ts +++ b/webapp/packages/plugin-data-viewer/src/ContainerDataSource.ts @@ -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