mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-10-24 23:05:29 +08:00
CB-2974 feat: allow private connections selecting for sql editor (#2167)
* CB-2974 feat: allow private connections selecting for sql editor * CB-2974 fix: typo * CB-2974 chore: decrease message delay --------- Co-authored-by: Evgenia Bezborodova <139753579+EvgeniaBzzz@users.noreply.github.com>
This commit is contained in:
co-authored by
Evgenia Bezborodova
parent
660c175c66
commit
76a440c482
+14
-7
@@ -14,7 +14,7 @@ import {
|
||||
NOT_INITIALIZED_CONTEXT_ID,
|
||||
} from '@cloudbeaver/core-connections';
|
||||
import { TaskScheduler } from '@cloudbeaver/core-executor';
|
||||
import type { ProjectInfoResource } from '@cloudbeaver/core-projects';
|
||||
import type { ProjectInfoResource, ProjectsService } from '@cloudbeaver/core-projects';
|
||||
import { isResourceAlias, ResourceKey, ResourceKeyUtils } from '@cloudbeaver/core-resource';
|
||||
import { getRmResourceKey, ResourceManagerResource } from '@cloudbeaver/core-resource-manager';
|
||||
import type { NetworkStateService } from '@cloudbeaver/core-root';
|
||||
@@ -37,6 +37,7 @@ interface IResourceActions {
|
||||
}
|
||||
|
||||
const VALUE_SYNC_DELAY = 1 * 1000;
|
||||
const DIFFERENT_PROJECT_MESSAGE_DISPLAY_DELAY = 4 * 1000;
|
||||
|
||||
export class ResourceSqlDataSource extends BaseSqlDataSource {
|
||||
static key = 'resource';
|
||||
@@ -113,6 +114,7 @@ export class ResourceSqlDataSource extends BaseSqlDataSource {
|
||||
private readonly connectionInfoResource: ConnectionInfoResource,
|
||||
private readonly resourceManagerResource: ResourceManagerResource,
|
||||
private readonly sqlEditorService: SqlEditorService,
|
||||
private readonly projectsService: ProjectsService,
|
||||
state: IResourceSqlDataSourceState,
|
||||
) {
|
||||
super();
|
||||
@@ -235,12 +237,6 @@ export class ResourceSqlDataSource extends BaseSqlDataSource {
|
||||
executionContext = JSON.parse(JSON.stringify(toJS(executionContext) ?? {}));
|
||||
}
|
||||
|
||||
const projectId = executionContext?.projectId;
|
||||
|
||||
if (this.resourceKey && isNotNullDefined(projectId) && getRmResourceKey(this.resourceKey).projectId !== projectId) {
|
||||
throw new Error('Resource SQL Data Source and Execution context projects don\t match');
|
||||
}
|
||||
|
||||
if (!isObjectsEqual(toJS(this.state.executionContext), executionContext)) {
|
||||
const initNew =
|
||||
!isValuesEqual(executionContext?.connectionId, this.executionContext?.connectionId, undefined) ||
|
||||
@@ -371,6 +367,17 @@ export class ResourceSqlDataSource extends BaseSqlDataSource {
|
||||
try {
|
||||
this.exception = null;
|
||||
|
||||
const projectId = this.executionContext?.projectId;
|
||||
const resourceProjectId = getRmResourceKey(this.resourceKey).projectId;
|
||||
const userProjectId = this.projectsService.userProject?.id;
|
||||
|
||||
if (isNotNullDefined(projectId) && resourceProjectId !== projectId && resourceProjectId !== userProjectId) {
|
||||
this.message = 'plugin_sql_editor_navigation_tab_script_state_different_project';
|
||||
|
||||
await new Promise(resolve => setTimeout(resolve, DIFFERENT_PROJECT_MESSAGE_DISPLAY_DELAY));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.isReadonly()) {
|
||||
this.message = 'plugin_sql_editor_navigation_tab_script_state_updating';
|
||||
const executionContext = await this.actions.setProperties(this, this.resourceKey, this.executionContext);
|
||||
|
||||
+3
-1
@@ -12,7 +12,7 @@ import { ConnectionInfoResource, IConnectionExecutionContextInfo } from '@cloudb
|
||||
import { Bootstrap, injectable } from '@cloudbeaver/core-di';
|
||||
import { CommonDialogService, DialogueStateResult } from '@cloudbeaver/core-dialogs';
|
||||
import { NotificationService } from '@cloudbeaver/core-events';
|
||||
import { ProjectInfoResource } from '@cloudbeaver/core-projects';
|
||||
import { ProjectInfoResource, ProjectsService } from '@cloudbeaver/core-projects';
|
||||
import { ICachedTreeMoveData, resourceKeyList, ResourceKeySimple, ResourceKeyUtils } from '@cloudbeaver/core-resource';
|
||||
import { ResourceManagerResource } from '@cloudbeaver/core-resource-manager';
|
||||
import { NetworkStateService } from '@cloudbeaver/core-root';
|
||||
@@ -50,6 +50,7 @@ export class ResourceSqlDataSourceBootstrap extends Bootstrap {
|
||||
private readonly projectInfoResource: ProjectInfoResource,
|
||||
private readonly sqlEditorTabResourceService: SqlEditorTabResourceService,
|
||||
private readonly sqlEditorService: SqlEditorService,
|
||||
private readonly projectsService: ProjectsService,
|
||||
localStorageSaveService: LocalStorageSaveService,
|
||||
) {
|
||||
super();
|
||||
@@ -96,6 +97,7 @@ export class ResourceSqlDataSourceBootstrap extends Bootstrap {
|
||||
this.connectionInfoResource,
|
||||
this.resourceManagerResource,
|
||||
this.sqlEditorService,
|
||||
this.projectsService,
|
||||
this.createState(editorId, options?.script),
|
||||
);
|
||||
|
||||
|
||||
@@ -4,6 +4,10 @@ export default [
|
||||
['plugin_sql_editor_navigation_tab_script_state_reading', 'Reading script...'],
|
||||
['plugin_sql_editor_navigation_tab_script_state_saving', 'Saving script...'],
|
||||
['plugin_sql_editor_navigation_tab_script_state_updating', 'Updating script info...'],
|
||||
[
|
||||
'plugin_sql_editor_navigation_tab_script_state_different_project',
|
||||
'The connection project differs from the script project—the connection change is not saved.',
|
||||
],
|
||||
['plugin_sql_editor_navigation_tab_resource_save_script_success', 'Script successfully saved'],
|
||||
['plugin_sql_editor_navigation_tab_resource_open_script_error', 'Failed to open the script'],
|
||||
['plugin_sql_editor_navigation_tab_resource_save_script_error', 'Error occurred while trying to save the script'],
|
||||
|
||||
@@ -4,6 +4,10 @@ export default [
|
||||
['plugin_sql_editor_navigation_tab_script_state_reading', 'Reading script...'],
|
||||
['plugin_sql_editor_navigation_tab_script_state_saving', 'Saving script...'],
|
||||
['plugin_sql_editor_navigation_tab_script_state_updating', 'Updating script info...'],
|
||||
[
|
||||
'plugin_sql_editor_navigation_tab_script_state_different_project',
|
||||
'The connection project differs from the script project—the connection change is not saved.',
|
||||
],
|
||||
['plugin_sql_editor_navigation_tab_resource_save_script_success', 'Script successfully saved'],
|
||||
['plugin_sql_editor_navigation_tab_resource_open_script_error', 'Failed to open the script'],
|
||||
['plugin_sql_editor_navigation_tab_resource_save_script_error', 'Error occurred while trying to save the script'],
|
||||
|
||||
@@ -4,6 +4,10 @@ export default [
|
||||
['plugin_sql_editor_navigation_tab_script_state_reading', 'Чтение скрипта...'],
|
||||
['plugin_sql_editor_navigation_tab_script_state_saving', 'Сохранение скрипта...'],
|
||||
['plugin_sql_editor_navigation_tab_script_state_updating', 'Обновление информации о скрипте...'],
|
||||
[
|
||||
'plugin_sql_editor_navigation_tab_script_state_different_project',
|
||||
'Проект подключения отличается от проекта скрипта. Изменение подключения не сохранено.',
|
||||
],
|
||||
['plugin_sql_editor_navigation_tab_resource_save_script_success', 'Скрипт успешно сохранен'],
|
||||
['plugin_sql_editor_navigation_tab_resource_open_script_error', 'Не удалось открыть скрипт'],
|
||||
['plugin_sql_editor_navigation_tab_resource_save_script_error', 'Возникла ошибка при попытки сохранить скрипт'],
|
||||
|
||||
@@ -4,6 +4,10 @@ export default [
|
||||
['plugin_sql_editor_navigation_tab_script_state_reading', 'Reading script...'],
|
||||
['plugin_sql_editor_navigation_tab_script_state_saving', 'Saving script...'],
|
||||
['plugin_sql_editor_navigation_tab_script_state_updating', 'Updating script info...'],
|
||||
[
|
||||
'plugin_sql_editor_navigation_tab_script_state_different_project',
|
||||
'The connection project differs from the script project—the connection change is not saved.',
|
||||
],
|
||||
['plugin_sql_editor_navigation_tab_resource_save_script_success', '脚本保存成功'],
|
||||
['plugin_sql_editor_navigation_tab_resource_open_script_error', '打开脚本失败'],
|
||||
['plugin_sql_editor_navigation_tab_resource_save_script_error', '打开脚本出错'],
|
||||
|
||||
Reference in New Issue
Block a user