mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
Merge branch 'devel' of https://github.com/dbeaver/cloudbeaver into devel
This commit is contained in:
@@ -10,6 +10,7 @@ import { INodeNavigationData, NavigationTabsService, NavNodeInfoResource, NavNod
|
||||
import { Bootstrap, injectable } from '@cloudbeaver/core-di';
|
||||
import { CommonDialogService, DialogueStateResult } from '@cloudbeaver/core-dialogs';
|
||||
import { NotificationService } from '@cloudbeaver/core-events';
|
||||
import { DATA_CONTEXT_TAB_ID } from '@cloudbeaver/core-ui';
|
||||
import { createPath } from '@cloudbeaver/core-utils';
|
||||
import { ActionService, ACTION_SAVE, DATA_CONTEXT_MENU, MenuService } from '@cloudbeaver/core-view';
|
||||
import { NavResourceNodeService, RESOURCE_NODE_TYPE, SaveScriptDialog, ResourceManagerService, ProjectsResource, RESOURCES_NODE_PATH } from '@cloudbeaver/plugin-resource-manager';
|
||||
@@ -50,9 +51,10 @@ export class PluginBootstrap extends Bootstrap {
|
||||
id: 'scripts-base-handler',
|
||||
isActionApplicable: (context, action): boolean => {
|
||||
if (action === ACTION_SAVE) {
|
||||
const tabId = context.tryGet(DATA_CONTEXT_TAB_ID);
|
||||
const state = context.tryGet(DATA_CONTEXT_SQL_EDITOR_STATE);
|
||||
|
||||
if (!state) {
|
||||
if (!state || !tabId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -62,9 +64,11 @@ export class PluginBootstrap extends Bootstrap {
|
||||
return false;
|
||||
},
|
||||
handler: async (context, action) => {
|
||||
const tabId = context.get(DATA_CONTEXT_TAB_ID);
|
||||
const state = context.get(DATA_CONTEXT_SQL_EDITOR_STATE);
|
||||
|
||||
const dataSource = this.sqlDataSourceService.get(state.editorId);
|
||||
const tab = this.navigationTabsService.currentTab;
|
||||
const tab = this.navigationTabsService.getTab(tabId);
|
||||
|
||||
if (!dataSource) {
|
||||
return;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
import type { TabHandlerPanelComponent } from '@cloudbeaver/core-app';
|
||||
import { useTab } from '@cloudbeaver/core-ui';
|
||||
import { DATA_CONTEXT_TAB_ID, useTab } from '@cloudbeaver/core-ui';
|
||||
import { useCaptureViewContext } from '@cloudbeaver/core-view';
|
||||
import { DATA_CONTEXT_SQL_EDITOR_STATE, ISqlEditorTabState, SqlEditor } from '@cloudbeaver/plugin-sql-editor';
|
||||
|
||||
@@ -16,6 +16,7 @@ export const SqlEditorPanel: TabHandlerPanelComponent<ISqlEditorTabState> = func
|
||||
|
||||
useCaptureViewContext(context => {
|
||||
if (baseTab.selected) {
|
||||
context?.set(DATA_CONTEXT_TAB_ID, tab.id);
|
||||
context?.set(DATA_CONTEXT_SQL_EDITOR_STATE, tab.handlerState);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -10,7 +10,7 @@ import { observer } from 'mobx-react-lite';
|
||||
|
||||
import type { ComponentStyle } from '@cloudbeaver/core-theming';
|
||||
import { MenuBar } from '@cloudbeaver/core-ui';
|
||||
import { useMenu } from '@cloudbeaver/core-view';
|
||||
import { IDataContext, useMenu } from '@cloudbeaver/core-view';
|
||||
|
||||
import { DATA_CONTEXT_SQL_EDITOR_STATE } from '../DATA_CONTEXT_SQL_EDITOR_STATE';
|
||||
import type { ISqlEditorTabState } from '../ISqlEditorTabState';
|
||||
@@ -19,11 +19,12 @@ import { SQL_EDITOR_ACTIONS_MENU_STYLES } from './SQL_EDITOR_ACTIONS_MENU_STYLES
|
||||
|
||||
interface Props {
|
||||
state: ISqlEditorTabState;
|
||||
context?: IDataContext;
|
||||
style?: ComponentStyle;
|
||||
}
|
||||
|
||||
export const SqlEditorActionsMenu = observer<Props>(function SqlEditorActionsMenu({ state, style }) {
|
||||
const menu = useMenu({ menu: SQL_EDITOR_ACTIONS_MENU });
|
||||
export const SqlEditorActionsMenu = observer<Props>(function SqlEditorActionsMenu({ state, context, style }) {
|
||||
const menu = useMenu({ menu: SQL_EDITOR_ACTIONS_MENU, context });
|
||||
menu.context.set(DATA_CONTEXT_SQL_EDITOR_STATE, state);
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user