diff --git a/webapp/packages/core-blocks/src/CommonDialog/RenameDialog.tsx b/webapp/packages/core-blocks/src/CommonDialog/RenameDialog.tsx index 2dd2b39eac..9ab7d3a555 100644 --- a/webapp/packages/core-blocks/src/CommonDialog/RenameDialog.tsx +++ b/webapp/packages/core-blocks/src/CommonDialog/RenameDialog.tsx @@ -33,7 +33,7 @@ interface IRenameDialogState { message: string | undefined; valid: boolean; payload: RenameDialogPayload; - validate: () => void; + validate: () => Promise; setMessage: (message: string) => void; } @@ -97,7 +97,7 @@ export const RenameDialog: DialogComponent = observ ); useEffect(() => { - state.validate(); + state.validate().catch(() => {}); }, [name]); const errorMessage = state.valid ? ' ' : translate(state.message ?? 'ui_rename_taken_or_invalid'); @@ -108,7 +108,7 @@ export const RenameDialog: DialogComponent = observ
resolveDialog(state.name)}> - state.validate()}> + state.validate().catch(() => {})}> {translate('ui_name') + ':'} diff --git a/webapp/packages/core-connections/src/ConnectionExecutionContext/ConnectionExecutionContextResource.ts b/webapp/packages/core-connections/src/ConnectionExecutionContext/ConnectionExecutionContextResource.ts index ad12575d22..cfdecf5753 100644 --- a/webapp/packages/core-connections/src/ConnectionExecutionContext/ConnectionExecutionContextResource.ts +++ b/webapp/packages/core-connections/src/ConnectionExecutionContext/ConnectionExecutionContextResource.ts @@ -119,24 +119,23 @@ export class ConnectionExecutionContextResource extends CachedMapResource { - const context = this.get(contextId); + await this.performUpdate(contextId, [], async () => { + const context = this.get(contextId); - if (!context) { - return; - } + if (!context) { + return; + } - await this.performUpdate(contextId, [], async () => { await this.graphQLService.sdk.executionContextDestroy({ contextId: context.id, connectionId: context.connectionId, projectId: context.projectId, }); - this.onDataOutdated.execute(contextId); + this.delete(contextId); }); runInAction(() => { this.markOutdated(); // TODO: should be removed, currently multiple contexts for same connection may change catalog/schema for all contexts of connection - this.delete(contextId); }); } diff --git a/webapp/packages/plugin-data-viewer/src/ContainerDataSource.ts b/webapp/packages/plugin-data-viewer/src/ContainerDataSource.ts index 1e6faa5d96..d2af27e1a2 100644 --- a/webapp/packages/plugin-data-viewer/src/ContainerDataSource.ts +++ b/webapp/packages/plugin-data-viewer/src/ContainerDataSource.ts @@ -138,8 +138,6 @@ export class ContainerDataSource extends ResultSetDataSource { + async dispose(keepExecutionContext = false): Promise { await this.onDispose.execute(); - await this.source.dispose(); + await this.source.dispose(keepExecutionContext); } async requestSaveAction(action: () => Promise | void): Promise { diff --git a/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/DatabaseDataSource.ts b/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/DatabaseDataSource.ts index f5278b30c8..2f79fd236b 100644 --- a/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/DatabaseDataSource.ts +++ b/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/DatabaseDataSource.ts @@ -372,9 +372,11 @@ export abstract class DatabaseDataSource { + async dispose(keepExecutionContext = false): Promise { await this.cancel(); - await this.executionContext?.destroy(); + if (!keepExecutionContext) { + await this.executionContext?.destroy(); + } } abstract request(prevResults: TResult[]): TResult[] | Promise; diff --git a/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/IDatabaseDataModel.ts b/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/IDatabaseDataModel.ts index 209005db21..dc7d1c5f51 100644 --- a/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/IDatabaseDataModel.ts +++ b/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/IDatabaseDataModel.ts @@ -57,5 +57,5 @@ export interface IDatabaseDataModel Promise; cancel: () => Promise | void; resetData: () => void; - dispose: () => Promise; + dispose: (keepExecutionContext?: boolean) => Promise; } diff --git a/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/IDatabaseDataSource.ts b/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/IDatabaseDataSource.ts index 7a7f9baa4f..1b5b3f8a97 100644 --- a/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/IDatabaseDataSource.ts +++ b/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/IDatabaseDataSource.ts @@ -97,5 +97,5 @@ export interface IDatabaseDataSource Promise | void; clearError: () => this; resetData: () => this; - dispose: () => Promise; + dispose: (keepExecutionContext?: boolean) => Promise; } diff --git a/webapp/packages/plugin-data-viewer/src/ResultSetDataSource.ts b/webapp/packages/plugin-data-viewer/src/ResultSetDataSource.ts index 04aa079a52..00d21abd5b 100644 --- a/webapp/packages/plugin-data-viewer/src/ResultSetDataSource.ts +++ b/webapp/packages/plugin-data-viewer/src/ResultSetDataSource.ts @@ -77,13 +77,26 @@ export abstract class ResultSetDataSource extends DatabaseDataSource { + setResults(results: IDatabaseResultSet[]): this { + this.closeResults(this.results); + return super.setResults(results); + } + + async dispose(keepExecutionContext?: boolean): Promise { + if (keepExecutionContext) { + await this.closeResults(this.results); + } + return super.dispose(keepExecutionContext); + } + + private async closeResults(results: IDatabaseResultSet[]): Promise { if (!this.executionContext?.context) { return; } for (const result of results) { - if (result.id === null) { + // TODO: it's better to track that context is closed with subscription + if (result.id === null || result.contextId !== this.executionContext.context.id) { continue; } try { diff --git a/webapp/packages/plugin-projects/src/FolderDialog.tsx b/webapp/packages/plugin-projects/src/FolderDialog.tsx index e9587ab7d2..d47c500488 100644 --- a/webapp/packages/plugin-projects/src/FolderDialog.tsx +++ b/webapp/packages/plugin-projects/src/FolderDialog.tsx @@ -112,7 +112,10 @@ export const FolderDialog: DialogComponent { - state.validate(); + state.validate().catch(() => {}); }, [state.value, state.projectId]); const errorMessage = state.valid ? ' ' : translate(state.message ?? 'ui_rename_taken_or_invalid'); @@ -169,7 +174,7 @@ export const FolderDialog: DialogComponent state.validate()} + onChange={() => state.validate().catch(() => {})} > {translate('ui_name') + ':'} diff --git a/webapp/packages/plugin-sql-editor/src/QueryDataSource.ts b/webapp/packages/plugin-sql-editor/src/QueryDataSource.ts index 5cb9acace8..1f5c2810c2 100644 --- a/webapp/packages/plugin-sql-editor/src/QueryDataSource.ts +++ b/webapp/packages/plugin-sql-editor/src/QueryDataSource.ts @@ -246,8 +246,6 @@ export class QueryDataSource