diff --git a/webapp/packages/plugin-app-logo-administration/tsconfig.json b/webapp/packages/plugin-app-logo-administration/tsconfig.json index 715a037c69..c5fef33116 100644 --- a/webapp/packages/plugin-app-logo-administration/tsconfig.json +++ b/webapp/packages/plugin-app-logo-administration/tsconfig.json @@ -19,6 +19,16 @@ "path": "../plugin-app-logo/tsconfig.json" } ], - "include": ["__custom_mocks__/**/*", "src/**/*", "src/**/*.json", "src/**/*.css", "src/**/*.scss"], - "exclude": ["**/node_modules", "lib/**/*", "dist/**/*"] + "include": [ + "__custom_mocks__/**/*", + "src/**/*", + "src/**/*.json", + "src/**/*.css", + "src/**/*.scss" + ], + "exclude": [ + "**/node_modules", + "lib/**/*", + "dist/**/*" + ] } diff --git a/webapp/packages/plugin-connection-custom/package.json b/webapp/packages/plugin-connection-custom/package.json index d9162a81d1..085d644794 100644 --- a/webapp/packages/plugin-connection-custom/package.json +++ b/webapp/packages/plugin-connection-custom/package.json @@ -30,6 +30,7 @@ "@cloudbeaver/core-utils": "^0", "@cloudbeaver/core-view": "^0", "@cloudbeaver/plugin-connections": "^0", + "@cloudbeaver/plugin-navigation-tree": "^0", "mobx": "^6", "mobx-react-lite": "^4", "react": "^18" diff --git a/webapp/packages/plugin-connection-custom/src/CustomConnectionPluginBootstrap.ts b/webapp/packages/plugin-connection-custom/src/CustomConnectionPluginBootstrap.ts index dccb54acfc..e7bd40f2ec 100644 --- a/webapp/packages/plugin-connection-custom/src/CustomConnectionPluginBootstrap.ts +++ b/webapp/packages/plugin-connection-custom/src/CustomConnectionPluginBootstrap.ts @@ -12,7 +12,8 @@ import { CommonDialogService } from '@cloudbeaver/core-dialogs'; import { ProjectInfoResource } from '@cloudbeaver/core-projects'; import { CachedMapAllKey, getCachedMapResourceLoaderState } from '@cloudbeaver/core-resource'; import { ActionService, MenuService } from '@cloudbeaver/core-view'; -import { MENU_CONNECTIONS } from '@cloudbeaver/plugin-connections'; +import { ACTION_CREATE_CONNECTION, MENU_CONNECTIONS } from '@cloudbeaver/plugin-connections'; +import { MENU_NAVIGATION_TREE_CREATE } from '@cloudbeaver/plugin-navigation-tree'; import { ACTION_CONNECTION_CUSTOM } from './Actions/ACTION_CONNECTION_CUSTOM.js'; import { CustomConnectionSettingsService } from './CustomConnectionSettingsService.js'; @@ -38,6 +39,22 @@ export class CustomConnectionPluginBootstrap extends Bootstrap { getItems: (context, items) => [...items, ACTION_CONNECTION_CUSTOM], }); + this.menuService.addCreator({ + menus: [MENU_NAVIGATION_TREE_CREATE], + getItems: (context, items) => [...items, ACTION_CREATE_CONNECTION], + }); + + this.actionService.addHandler({ + id: 'nav-tree-create-create-connection-handler', + menus: [MENU_NAVIGATION_TREE_CREATE], + actions: [ACTION_CREATE_CONNECTION], + handler: async (context, action) => { + if (action === ACTION_CREATE_CONNECTION) { + await this.openConnectionsDialog(); + } + }, + }); + this.actionService.addHandler({ id: 'connection-custom', actions: [ACTION_CONNECTION_CUSTOM], diff --git a/webapp/packages/plugin-connection-custom/tsconfig.json b/webapp/packages/plugin-connection-custom/tsconfig.json index 0ae63b1262..66bc585ad6 100644 --- a/webapp/packages/plugin-connection-custom/tsconfig.json +++ b/webapp/packages/plugin-connection-custom/tsconfig.json @@ -41,6 +41,9 @@ }, { "path": "../plugin-connections/tsconfig.json" + }, + { + "path": "../plugin-navigation-tree/tsconfig.json" } ], "include": [ diff --git a/webapp/packages/plugin-connections/src/Actions/ACTION_CREATE_CONNECTION.ts b/webapp/packages/plugin-connections/src/Actions/ACTION_CREATE_CONNECTION.ts new file mode 100644 index 0000000000..cf272a2604 --- /dev/null +++ b/webapp/packages/plugin-connections/src/Actions/ACTION_CREATE_CONNECTION.ts @@ -0,0 +1,12 @@ +/* + * CloudBeaver - Cloud Database Manager + * Copyright (C) 2020-2024 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0. + * you may not use this file except in compliance with the License. + */ +import { createAction } from '@cloudbeaver/core-view'; + +export const ACTION_CREATE_CONNECTION = createAction('create-connection', { + label: 'plugin_connections_connection_create_menu_title', +}); diff --git a/webapp/packages/plugin-connections/src/Actions/ACTION_CREATE_FOLDER.ts b/webapp/packages/plugin-connections/src/Actions/ACTION_CREATE_FOLDER.ts new file mode 100644 index 0000000000..6dc5b384c8 --- /dev/null +++ b/webapp/packages/plugin-connections/src/Actions/ACTION_CREATE_FOLDER.ts @@ -0,0 +1,12 @@ +/* + * CloudBeaver - Cloud Database Manager + * Copyright (C) 2020-2024 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0. + * you may not use this file except in compliance with the License. + */ +import { createAction } from '@cloudbeaver/core-view'; + +export const ACTION_CREATE_FOLDER = createAction('create-folder', { + label: 'ui_folder_new', +}); diff --git a/webapp/packages/plugin-connections/src/NavNodes/ConnectionFoldersBootstrap.ts b/webapp/packages/plugin-connections/src/NavNodes/ConnectionFoldersBootstrap.ts index ce69635c20..a1757edd91 100644 --- a/webapp/packages/plugin-connections/src/NavNodes/ConnectionFoldersBootstrap.ts +++ b/webapp/packages/plugin-connections/src/NavNodes/ConnectionFoldersBootstrap.ts @@ -46,9 +46,15 @@ import { getProjectNodeId, NAV_NODE_TYPE_PROJECT, ProjectInfoResource } from '@c import { CachedMapAllKey, resourceKeyList, type ResourceKeySimple, ResourceKeyUtils } from '@cloudbeaver/core-resource'; import { createPath } from '@cloudbeaver/core-utils'; import { ACTION_NEW_FOLDER, ActionService, type IAction, MenuService } from '@cloudbeaver/core-view'; -import { DATA_CONTEXT_ELEMENTS_TREE, type IElementsTree, MENU_ELEMENTS_TREE_TOOLS } from '@cloudbeaver/plugin-navigation-tree'; +import { + DATA_CONTEXT_ELEMENTS_TREE, + type IElementsTree, + MENU_ELEMENTS_TREE_TOOLS, + MENU_NAVIGATION_TREE_CREATE, +} from '@cloudbeaver/plugin-navigation-tree'; import { FolderDialog } from '@cloudbeaver/plugin-projects'; +import { ACTION_CREATE_FOLDER } from '../Actions/ACTION_CREATE_FOLDER.js'; import { NAV_NODE_TYPE_CONNECTION } from './NAV_NODE_TYPE_CONNECTION.js'; interface ITargetNode { @@ -134,21 +140,6 @@ export class ConnectionFoldersBootstrap extends Bootstrap { return targetNode !== undefined; }, - // isDisabled: (context, action) => { - // const tree = context.get(DATA_CONTEXT_ELEMENTS_TREE); - - // if (!tree) { - // return true; - // } - - // if (action === ACTION_NEW_FOLDER) { - // const targetNode = this.getTargetNode(tree); - - // return targetNode === undefined; - // } - - // return false; - // }, handler: this.elementsTreeActionHandler.bind(this), }); @@ -162,6 +153,19 @@ export class ConnectionFoldersBootstrap extends Bootstrap { return items; }, }); + + this.menuService.addCreator({ + menus: [MENU_NAVIGATION_TREE_CREATE], + getItems: (context, items) => [...items, ACTION_CREATE_FOLDER], + }); + + this.actionService.addHandler({ + id: 'nav-tree-create-create-folder-handler', + menus: [MENU_NAVIGATION_TREE_CREATE], + actions: [ACTION_CREATE_FOLDER], + contexts: [DATA_CONTEXT_ELEMENTS_TREE], + handler: this.elementsTreeActionHandler.bind(this), + }); } private async moveConnectionToFolder({ type, targetNode, moveContexts }: INodeMoveData, contexts: IExecutionContextProvider) { @@ -246,6 +250,7 @@ export class ConnectionFoldersBootstrap extends Bootstrap { } switch (action) { + case ACTION_CREATE_FOLDER: case ACTION_NEW_FOLDER: { const targetNode = this.getTargetNode(tree); diff --git a/webapp/packages/plugin-connections/src/index.ts b/webapp/packages/plugin-connections/src/index.ts index c5f442faa6..3894e58858 100644 --- a/webapp/packages/plugin-connections/src/index.ts +++ b/webapp/packages/plugin-connections/src/index.ts @@ -30,5 +30,6 @@ export * from './PublicConnectionForm/PublicConnectionFormService.js'; export * from './ConnectionAuthService.js'; export * from './PluginConnectionsSettingsService.js'; export * from './ConnectionShieldLazy.js'; +export * from './Actions/ACTION_CREATE_CONNECTION.js'; export default connectionPlugin; diff --git a/webapp/packages/plugin-connections/src/locales/en.ts b/webapp/packages/plugin-connections/src/locales/en.ts index 8c55100259..61d5f9f09f 100644 --- a/webapp/packages/plugin-connections/src/locales/en.ts +++ b/webapp/packages/plugin-connections/src/locales/en.ts @@ -44,4 +44,5 @@ export default [ 'plugin_connections_connection_auth_secret_description', 'There are multiple credentials available for authentication.\nPlease choose credentials you want to use.', ], + ['plugin_connections_connection_create_menu_title', 'Connection'], ]; diff --git a/webapp/packages/plugin-connections/src/locales/fr.ts b/webapp/packages/plugin-connections/src/locales/fr.ts index 89b98319ce..5fb33cc349 100644 --- a/webapp/packages/plugin-connections/src/locales/fr.ts +++ b/webapp/packages/plugin-connections/src/locales/fr.ts @@ -53,4 +53,5 @@ export default [ ['plugin_connections_connection_form_shared_credentials_manage_info', "Vous pouvez gérer les identifiants dans l'onglet "], ['plugin_connections_connection_form_shared_credentials_manage_info_tab_link', 'Onglet Identifiants'], ['plugin_connections_connection_auth_secret_description', 'Veuillez sélectionner les identifiants fournis par une de vos équipes'], + ['plugin_connections_connection_create_menu_title', 'Connection'], ]; diff --git a/webapp/packages/plugin-connections/src/locales/it.ts b/webapp/packages/plugin-connections/src/locales/it.ts index 986ec92b9b..1789dfe180 100644 --- a/webapp/packages/plugin-connections/src/locales/it.ts +++ b/webapp/packages/plugin-connections/src/locales/it.ts @@ -46,4 +46,5 @@ export default [ 'plugin_connections_connection_auth_secret_description', 'There are multiple credentials available for authentication.\nPlease choose credentials you want to use.', ], + ['plugin_connections_connection_create_menu_title', 'Connection'], ]; diff --git a/webapp/packages/plugin-connections/src/locales/ru.ts b/webapp/packages/plugin-connections/src/locales/ru.ts index 9b810049bf..e85d1f46cc 100644 --- a/webapp/packages/plugin-connections/src/locales/ru.ts +++ b/webapp/packages/plugin-connections/src/locales/ru.ts @@ -44,4 +44,5 @@ export default [ 'plugin_connections_connection_auth_secret_description', 'У вас есть несколько учетных записей для авторизации.\nВыберите учетную запись из списка.', ], + ['plugin_connections_connection_create_menu_title', 'Подключение'], ]; diff --git a/webapp/packages/plugin-connections/src/locales/zh.ts b/webapp/packages/plugin-connections/src/locales/zh.ts index ae9b7f3715..c22e3872d0 100644 --- a/webapp/packages/plugin-connections/src/locales/zh.ts +++ b/webapp/packages/plugin-connections/src/locales/zh.ts @@ -40,4 +40,5 @@ export default [ ['plugin_connections_connection_form_shared_credentials_manage_info', '您可在此管理凭证 '], ['plugin_connections_connection_form_shared_credentials_manage_info_tab_link', '凭证页签'], ['plugin_connections_connection_auth_secret_description', '有多个凭证可用于身份验证.\n请选择您要使用的凭证。'], + ['plugin_connections_connection_create_menu_title', 'Connection'], ]; diff --git a/webapp/packages/plugin-navigation-tree/src/NavigationTree/ElementsTree/NavigationTreeNode/TreeNodeMenu/MENU_NAVIGATION_TREE_CREATE.ts b/webapp/packages/plugin-navigation-tree/src/NavigationTree/ElementsTree/NavigationTreeNode/TreeNodeMenu/MENU_NAVIGATION_TREE_CREATE.ts new file mode 100644 index 0000000000..fc314a1c3e --- /dev/null +++ b/webapp/packages/plugin-navigation-tree/src/NavigationTree/ElementsTree/NavigationTreeNode/TreeNodeMenu/MENU_NAVIGATION_TREE_CREATE.ts @@ -0,0 +1,10 @@ +/* + * CloudBeaver - Cloud Database Manager + * Copyright (C) 2020-2024 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0. + * you may not use this file except in compliance with the License. + */ +import { createMenu } from '@cloudbeaver/core-view'; + +export const MENU_NAVIGATION_TREE_CREATE = createMenu('navigation-tree-create-menu', 'Create'); diff --git a/webapp/packages/plugin-navigation-tree/src/NodesManager/NavNodeContextMenuService.ts b/webapp/packages/plugin-navigation-tree/src/NodesManager/NavNodeContextMenuService.ts index 18fd02b79e..de9232a820 100644 --- a/webapp/packages/plugin-navigation-tree/src/NodesManager/NavNodeContextMenuService.ts +++ b/webapp/packages/plugin-navigation-tree/src/NodesManager/NavNodeContextMenuService.ts @@ -38,6 +38,7 @@ import { } from '@cloudbeaver/core-view'; import { DATA_CONTEXT_NAV_NODE_ACTIONS } from '../NavigationTree/ElementsTree/NavigationTreeNode/TreeNodeMenu/DATA_CONTEXT_NAV_NODE_ACTIONS.js'; +import { MENU_NAVIGATION_TREE_CREATE } from '../NavigationTree/ElementsTree/NavigationTreeNode/TreeNodeMenu/MENU_NAVIGATION_TREE_CREATE.js'; export interface INodeMenuData { node: NavNode; @@ -184,7 +185,7 @@ export class NavNodeContextMenuService extends Bootstrap { root: true, contexts: [DATA_CONTEXT_NAV_NODE], getItems: (context, items) => { - items = [ACTION_OPEN, ACTION_REFRESH, ...items]; + items = [MENU_NAVIGATION_TREE_CREATE, ACTION_OPEN, ACTION_REFRESH, ...items]; if (this.navTreeSettingsService.editing) { items.push(ACTION_RENAME); diff --git a/webapp/packages/plugin-navigation-tree/src/index.ts b/webapp/packages/plugin-navigation-tree/src/index.ts index 3f84713274..d63700afc8 100644 --- a/webapp/packages/plugin-navigation-tree/src/index.ts +++ b/webapp/packages/plugin-navigation-tree/src/index.ts @@ -15,6 +15,7 @@ export * from './NavigationTree/ElementsTree/ElementsTreeTools/NavigationTreeSet export * from './NavigationTree/ElementsTree/NavigationTreeNode/NavigationNode/NavigationNodeLoaders.js'; export * from './NavigationTree/ElementsTree/NavigationTreeNode/TreeNodeMenu/DATA_CONTEXT_NAV_NODE_ACTIONS.js'; export * from './NavigationTree/ElementsTree/NavigationTreeNode/TreeNodeMenu/TreeNodeMenuLoader.js'; +export * from './NavigationTree/ElementsTree/NavigationTreeNode/TreeNodeMenu/MENU_NAVIGATION_TREE_CREATE.js'; export * from './NavigationTree/ElementsTree/NavigationTreeNode/NavigationNodeRendererLoader.js'; export * from './NavigationTree/ElementsTree/NavigationTreeNode/isDraggingInsideProject.js';