Skip to content

Commit

Permalink
CB-5832 Add SQL editor shortcut to save script (#3167)
Browse files Browse the repository at this point in the history
* CB-5832 feat: add shortcut for save as script action

* CB-5832 feat: add info about a shortcut to Shortcuts modal

* CB-5832 fix: ru localization

* CB-5832 refactor: use SqlEditorView for action registration

* CB-5832 refactor: use SqlEditorView for action registration

* CB-5832 refactor: check action in handler

* CB-5832 refactor: bind function in constructor

---------

Co-authored-by: Daria Marutkina <[email protected]>
  • Loading branch information
SychevAndrey and dariamarutkina authored Jan 7, 2025
1 parent 60d90b9 commit de6f9b7
Show file tree
Hide file tree
Showing 20 changed files with 182 additions and 102 deletions.
3 changes: 3 additions & 0 deletions webapp/packages/plugin-connection-custom/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
{
"path": "../core-connections/tsconfig.json"
},
{
"path": "../core-data-context/tsconfig.json"
},
{
"path": "../core-di/tsconfig.json"
},
Expand Down
1 change: 1 addition & 0 deletions webapp/packages/plugin-help/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"@cloudbeaver/plugin-data-spreadsheet-new": "^0",
"@cloudbeaver/plugin-navigation-tree": "^0",
"@cloudbeaver/plugin-sql-editor": "^0",
"@cloudbeaver/plugin-sql-editor-navigation-tab-script": "^0",
"@cloudbeaver/plugin-top-app-bar": "^0",
"react": "^18"
},
Expand Down
5 changes: 5 additions & 0 deletions webapp/packages/plugin-help/src/Shortcuts/SHORTCUTS_DATA.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
KEY_BINDING_SQL_EDITOR_FORMAT,
KEY_BINDING_SQL_EDITOR_SHOW_EXECUTION_PLAN,
} from '@cloudbeaver/plugin-sql-editor';
import { KEY_BINDING_SQL_EDITOR_SAVE_AS_SCRIPT } from '@cloudbeaver/plugin-sql-editor-navigation-tab-script';

import type { IShortcut } from './IShortcut.js';

Expand Down Expand Up @@ -64,6 +65,10 @@ export const SQL_EDITOR_SHORTCUTS: IShortcut[] = [
label: 'sql_editor_shortcut_format',
code: transformKeys(KEY_BINDING_SQL_EDITOR_FORMAT),
},
{
label: 'sql_editor_shortcut_save_as_script',
code: transformKeys(KEY_BINDING_SQL_EDITOR_SAVE_AS_SCRIPT),
},
{
label: 'sql_editor_shortcut_undo',
code: transformKeys(KEY_BINDING_UNDO),
Expand Down
8 changes: 8 additions & 0 deletions webapp/packages/plugin-help/src/locales/en.ts
Original file line number Diff line number Diff line change
@@ -1,3 +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.
*/
export default [
['shortcuts_title', 'Shortcuts'],

Expand All @@ -14,6 +21,7 @@ export default [
['sql_editor_shortcut_execute_script', 'Execute script'],
['sql_editor_shortcut_show_execution_plan', 'Show Execution plan'],
['sql_editor_shortcut_format', 'Format script'],
['sql_editor_shortcut_save_as_script', 'Save as script'],
['sql_editor_shortcut_open_editor_in_new_tab', 'Open SQL Editor in the separate browser Tab'],
['sql_editor_shortcut_undo', 'Undo'],
['sql_editor_shortcut_redo', 'Redo'],
Expand Down
1 change: 1 addition & 0 deletions webapp/packages/plugin-help/src/locales/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default [
['sql_editor_shortcut_execute_script', 'Exécuter le script'],
['sql_editor_shortcut_show_execution_plan', "Afficher le plan d'exécution"],
['sql_editor_shortcut_format', 'Formater le script'],
['sql_editor_shortcut_save_as_script', 'Save as script'],
['sql_editor_shortcut_open_editor_in_new_tab', "Ouvrir l'éditeur SQL dans un nouvel onglet"],
['sql_editor_shortcut_undo', 'Annuler'],
['sql_editor_shortcut_redo', 'Rétablir'],
Expand Down
8 changes: 8 additions & 0 deletions webapp/packages/plugin-help/src/locales/it.ts
Original file line number Diff line number Diff line change
@@ -1,3 +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.
*/
export default [
['shortcuts_title', 'Shortcuts'],

Expand All @@ -14,6 +21,7 @@ export default [
['sql_editor_shortcut_execute_script', 'Execute script'],
['sql_editor_shortcut_show_execution_plan', 'Show Execution plan'],
['sql_editor_shortcut_format', 'Format script'],
['sql_editor_shortcut_save_as_script', 'Save as script'],
['sql_editor_shortcut_open_editor_in_new_tab', 'Open SQL Editor in the separate browser Tab'],
['sql_editor_shortcut_undo', 'Undo'],
['sql_editor_shortcut_redo', 'Redo'],
Expand Down
8 changes: 8 additions & 0 deletions webapp/packages/plugin-help/src/locales/ru.ts
Original file line number Diff line number Diff line change
@@ -1,3 +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.
*/
export default [
['shortcuts_title', 'Горячие клавиши'],

Expand All @@ -14,6 +21,7 @@ export default [
['sql_editor_shortcut_execute_script', 'Выполнить скрипт'],
['sql_editor_shortcut_show_execution_plan', 'Показать план выполнения'],
['sql_editor_shortcut_format', 'Форматировать скрипт'],
['sql_editor_shortcut_save_as_script', 'Сохранить как скрипт'],
['sql_editor_shortcut_open_editor_in_new_tab', 'Открыть SQL редактор в новой бразуерной вкладке'],
['sql_editor_shortcut_undo', 'Отменить'],
['sql_editor_shortcut_redo', 'Повторить'],
Expand Down
1 change: 1 addition & 0 deletions webapp/packages/plugin-help/src/locales/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default [
['sql_editor_shortcut_execute_script', '执行脚本'],
['sql_editor_shortcut_show_execution_plan', '显示执行计划'],
['sql_editor_shortcut_format', '格式化脚本'],
['sql_editor_shortcut_save_as_script', 'Save as script'],
['sql_editor_shortcut_open_editor_in_new_tab', '在单独的浏览器标签下打开SQL编辑器'],
['sql_editor_shortcut_undo', '撤销'],
['sql_editor_shortcut_redo', '重做'],
Expand Down
3 changes: 3 additions & 0 deletions webapp/packages/plugin-help/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
{
"path": "../plugin-navigation-tree/tsconfig.json"
},
{
"path": "../plugin-sql-editor-navigation-tab-script/tsconfig.json"
},
{
"path": "../plugin-sql-editor/tsconfig.json"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"dependencies": {
"@cloudbeaver/core-blocks": "^0",
"@cloudbeaver/core-connections": "^0",
"@cloudbeaver/core-data-context": "^0",
"@cloudbeaver/core-di": "^0",
"@cloudbeaver/core-dialogs": "^0",
"@cloudbeaver/core-events": "^0",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* 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 { createKeyBinding } from '@cloudbeaver/core-view';

export const KEY_BINDING_SQL_EDITOR_SAVE_AS_SCRIPT = createKeyBinding({
id: 'save-as-script',
keys: 'shift+mod+s',
preventDefault: true,
});
Loading

0 comments on commit de6f9b7

Please sign in to comment.