diff --git a/webapp/packages/core-app/public/icons/export.svg b/webapp/packages/core-app/public/icons/export.svg new file mode 100644 index 0000000000..3669b1c7e9 --- /dev/null +++ b/webapp/packages/core-app/public/icons/export.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/webapp/packages/core-app/public/icons/import.svg b/webapp/packages/core-app/public/icons/import.svg new file mode 100644 index 0000000000..7dc1e5b391 --- /dev/null +++ b/webapp/packages/core-app/public/icons/import.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/webapp/packages/core-app/public/icons/load.svg b/webapp/packages/core-app/public/icons/load.svg deleted file mode 100644 index adf27b30d5..0000000000 --- a/webapp/packages/core-app/public/icons/load.svg +++ /dev/null @@ -1,15 +0,0 @@ - - - load - - - - - - - - - - - - \ No newline at end of file diff --git a/webapp/packages/core-app/public/icons/save.svg b/webapp/packages/core-app/public/icons/save.svg index 5068a1f702..45c88c723f 100644 --- a/webapp/packages/core-app/public/icons/save.svg +++ b/webapp/packages/core-app/public/icons/save.svg @@ -1,26 +1,5 @@ - - - save - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + + + + + diff --git a/webapp/packages/plugin-resource-manager/src/PluginBootstrap.ts b/webapp/packages/plugin-resource-manager/src/PluginBootstrap.ts index 648411ab11..57cd1dab99 100644 --- a/webapp/packages/plugin-resource-manager/src/PluginBootstrap.ts +++ b/webapp/packages/plugin-resource-manager/src/PluginBootstrap.ts @@ -7,7 +7,7 @@ */ import { DATA_CONTEXT_NAV_NODE, EMainMenu, MainMenuService } from '@cloudbeaver/core-app'; -import { AppAuthService } from '@cloudbeaver/core-authentication'; +import { AuthInfoService } from '@cloudbeaver/core-authentication'; import { Bootstrap, injectable } from '@cloudbeaver/core-di'; import { CommonDialogService, ConfirmationDialogDelete, DialogueStateResult } from '@cloudbeaver/core-dialogs'; import { SideBarPanelService } from '@cloudbeaver/core-ui'; @@ -25,7 +25,7 @@ export class PluginBootstrap extends Bootstrap { private readonly resourceManagerService: ResourceManagerService, private readonly sideBarPanelService: SideBarPanelService, private readonly navResourceNodeService: NavResourceNodeService, - private readonly appAuthService: AppAuthService, + private readonly authInfoService: AuthInfoService, private readonly commonDialogService: CommonDialogService, private readonly actionService: ActionService, private readonly menuService: MenuService, @@ -41,7 +41,7 @@ export class PluginBootstrap extends Bootstrap { order: 3, type: 'checkbox', title: 'plugin_resource_manager_title', - isHidden: () => !this.resourceManagerService.enabled || !this.appAuthService.authenticated, + isHidden: () => !this.resourceManagerService.enabled || !this.authInfoService.userInfo, isChecked: () => this.resourceManagerService.panelEnabled, onClick: this.resourceManagerService.togglePanel, } @@ -53,7 +53,7 @@ export class PluginBootstrap extends Bootstrap { name: 'plugin_resource_manager_title', isHidden: () => !this.resourceManagerService.enabled || !this.resourceManagerService.panelEnabled - || !this.appAuthService.authenticated, + || !this.authInfoService.userInfo, onClose: this.resourceManagerService.togglePanel, panel: () => ResourceManager, }); diff --git a/webapp/packages/plugin-sql-editor-navigation-tab-resource/src/SqlEditorTabResourceService.ts b/webapp/packages/plugin-sql-editor-navigation-tab-resource/src/SqlEditorTabResourceService.ts index bb1e245873..a676bfea78 100644 --- a/webapp/packages/plugin-sql-editor-navigation-tab-resource/src/SqlEditorTabResourceService.ts +++ b/webapp/packages/plugin-sql-editor-navigation-tab-resource/src/SqlEditorTabResourceService.ts @@ -9,6 +9,7 @@ import { makeObservable, observable } from 'mobx'; import { ITab, NavigationTabsService, NavTreeResource, NodeManagerUtils } from '@cloudbeaver/core-app'; +import { UserInfoResource } from '@cloudbeaver/core-authentication'; import { injectable } from '@cloudbeaver/core-di'; import { NotificationService } from '@cloudbeaver/core-events'; import { WindowEventsService } from '@cloudbeaver/core-root'; @@ -44,6 +45,7 @@ export class SqlEditorTabResourceService { private readonly resourceManagerService: ResourceManagerService, private readonly windowEventsService: WindowEventsService, private readonly localStorageSaveService: LocalStorageSaveService, + private readonly userInfoResource: UserInfoResource ) { this.state = new Map(); @@ -112,38 +114,27 @@ export class SqlEditorTabResourceService { return null; } - private onTabResourceValueChangeHandler(data: IQueryChangeData) { - if (data.prevQuery !== data.query) { - this.updateResource(data.query); - } - } - - private async updateResource(value: string) { - if (!this.resourceManagerService.enabled) { + private async onTabResourceValueChangeHandler(data: IQueryChangeData) { + const tabId = this.navigationTabsService.currentTab?.id; + if (!tabId) { return; } - const currentTab = this.navigationTabsService.currentTab; - - if (currentTab && this.state.has(currentTab.id)) { - const state = this.state.get(currentTab.id)!; - try { - await this.navResourceNodeService.write(state.nodeId, value); - } catch (exception) { - this.notificationService.logException(exception as any, 'plugin_resource_manager_update_script_error'); - } + const tab = this.getTab(tabId); + if (tab && data.prevQuery !== data.query) { + await this.updateResource(tab, data.query); } } - private onFocusChangeHandler(focused: boolean) { + private async onFocusChangeHandler(focused: boolean) { if (focused) { - this.syncCurrentTab(); + await this.syncCurrentTab(); } } - private onTabSelectHandler(tab: ITab) { + private async onTabSelectHandler(tab: ITab) { if (isSQLEditorTab(tab)) { - this.updateTabQuery(tab); + await this.updateTabQuery(tab); } } @@ -166,42 +157,58 @@ export class SqlEditorTabResourceService { }); } + private getTab(tabId: string) { + return this.sqlEditorTabService.sqlEditorTabs.find(tab => tab.id === tabId); + } + private closeTab(tabId: string) { this.navigationTabsService.closeTab(tabId); } private async syncCurrentTab() { - const current = this.sqlEditorTabService.sqlEditorTabs.find( - tab => tab.id === this.navigationTabsService.currentTabId - ); + const tab = this.getTab(this.navigationTabsService.currentTabId); - if (current) { - await this.updateTabQuery(current); + if (tab) { + await this.updateTabQuery(tab); } } - private async updateTabQuery(tab: ITab) { - if (!this.resourceManagerService.enabled) { + private handleNotFound(tab: ITab) { + this.notificationService.logInfo({ + title: 'plugin_resource_manager_script_not_found_title', + message: tab.handlerState.name, + persistent: true, + }); + + this.unlinkTab(tab.id); + } + + private async updateResource(tab: ITab, value: string) { + const state = this.state.get(tab.id); + + if (!this.resourceManagerService.enabled || !state || this.userInfoResource.getId() !== tab.userId) { return; } try { - const state = this.state.get(tab.id); + await this.navResourceNodeService.write(state.nodeId, value); + } catch (exception) { + this.notificationService.logException(exception as any, 'plugin_resource_manager_update_script_error'); + } + } - if (!state) { - return; - } + private async updateTabQuery(tab: ITab) { + const state = this.state.get(tab.id); + if (!this.resourceManagerService.enabled || !state || this.userInfoResource.getId() !== tab.userId) { + return; + } + + try { const found = await this.navTreeResource.preloadNodeParents(state.parents, state.nodeId); if (!found) { - this.notificationService.logInfo({ - title: 'plugin_resource_manager_script_not_found_title', - message: tab.handlerState.name, - persistent: true, - }); - - this.unlinkTab(tab.id); + this.handleNotFound(tab); return; } diff --git a/webapp/packages/plugin-sql-editor/src/SqlEditor/SqlEditor.tsx b/webapp/packages/plugin-sql-editor/src/SqlEditor/SqlEditor.tsx index e09655774d..de0096376b 100644 --- a/webapp/packages/plugin-sql-editor/src/SqlEditor/SqlEditor.tsx +++ b/webapp/packages/plugin-sql-editor/src/SqlEditor/SqlEditor.tsx @@ -205,7 +205,7 @@ export const SqlEditor = observer(function SqlEditor({ state, c hidden={data.activeSegmentMode.activeSegmentMode} onClick={() => tools.downloadScript(trimmedValue)} > - + {!data.activeSegmentMode.activeSegmentMode && ( (function SqlEditor({ state, c onChange={handleScriptUpload} > - + )}