mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-10-24 01:23:21 +08:00
refactor: CB-2243 add navigation-tabs, root, tools-panel, top-app-bar, version plugins
This commit is contained in:
@@ -7,7 +7,9 @@
|
||||
*/
|
||||
|
||||
import { Bootstrap, injectable } from '@cloudbeaver/core-di';
|
||||
import { ResultDataFormat } from '@cloudbeaver/core-sdk';
|
||||
import { ActionService, KeyBindingService, MenuService, IAction, IDataContextProvider } from '@cloudbeaver/core-view';
|
||||
import { DatabaseEditAction, TableFooterMenuService } from '@cloudbeaver/plugin-data-viewer';
|
||||
|
||||
import { ACTION_SQL_EDITOR_EXECUTE } from './actions/ACTION_SQL_EDITOR_EXECUTE';
|
||||
import { ACTION_SQL_EDITOR_EXECUTE_NEW } from './actions/ACTION_SQL_EDITOR_EXECUTE_NEW';
|
||||
@@ -19,6 +21,7 @@ import { KEY_BINDING_SQL_EDITOR_EXECUTE_NEW } from './actions/bindings/KEY_BINDI
|
||||
import { KEY_BINDING_SQL_EDITOR_EXECUTE_SCRIPT } from './actions/bindings/KEY_BINDING_SQL_EDITOR_EXECUTE_SCRIPT';
|
||||
import { KEY_BINDING_SQL_EDITOR_FORMAT } from './actions/bindings/KEY_BINDING_SQL_EDITOR_FORMAT';
|
||||
import { KEY_BINDING_SQL_EDITOR_SHOW_EXECUTION_PLAN } from './actions/bindings/KEY_BINDING_SQL_EDITOR_SHOW_EXECUTION_PLAN';
|
||||
import { ScriptPreviewService } from './ScriptPreview/ScriptPreviewService';
|
||||
import { DATA_CONTEXT_SQL_EDITOR_DATA } from './SqlEditor/DATA_CONTEXT_SQL_EDITOR_DATA';
|
||||
|
||||
@injectable()
|
||||
@@ -26,6 +29,8 @@ export class MenuBootstrap extends Bootstrap {
|
||||
constructor(
|
||||
private readonly actionService: ActionService,
|
||||
private readonly keyBindingService: KeyBindingService,
|
||||
private readonly scriptPreviewService: ScriptPreviewService,
|
||||
private readonly tableFooterMenuService: TableFooterMenuService,
|
||||
private readonly menuService: MenuService
|
||||
) {
|
||||
super();
|
||||
@@ -93,6 +98,38 @@ export class MenuBootstrap extends Bootstrap {
|
||||
// ...items,
|
||||
// ],
|
||||
// });
|
||||
|
||||
this.tableFooterMenuService.registerMenuItem({
|
||||
id: 'script',
|
||||
order: 3,
|
||||
title: 'data_viewer_script_preview',
|
||||
tooltip: 'data_viewer_script_preview',
|
||||
icon: 'sql-script-preview',
|
||||
isPresent(context) {
|
||||
return context.contextType === TableFooterMenuService.nodeContextType;
|
||||
},
|
||||
isHidden(context) {
|
||||
return context.data.model.isReadonly()
|
||||
|| context.data.model.source.getResult(context.data.resultIndex)?.dataFormat !== ResultDataFormat.Resultset;
|
||||
},
|
||||
isDisabled(context) {
|
||||
if (
|
||||
context.data.model.isLoading()
|
||||
|| context.data.model.isDisabled(context.data.resultIndex)
|
||||
|| !context.data.model.source.hasResult(context.data.resultIndex)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
const editor = context.data.model.source.getActionImplementation(
|
||||
context.data.resultIndex,
|
||||
DatabaseEditAction
|
||||
);
|
||||
return !editor?.isEdited();
|
||||
},
|
||||
onClick: async context => {
|
||||
await this.scriptPreviewService.open(context.data.model, context.data.resultIndex);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
private sqlEditorActionHandler(context: IDataContextProvider, action: IAction): void {
|
||||
|
||||
Reference in New Issue
Block a user