From da26626128391e73296039233adeda85cc6a40eb Mon Sep 17 00:00:00 2001 From: Naumov Alexey Date: Wed, 2 Feb 2022 15:52:57 +0300 Subject: [PATCH 1/3] feat(plugin-info): CB-1450 add shortcuts info --- .../packages/core-app/public/icons/icons.svg | 3 + webapp/packages/core-blocks/src/Link.tsx | 18 ++- .../core-localization/src/locales/en.ts | 1 + .../core-localization/src/locales/it.ts | 1 + .../core-localization/src/locales/ru.ts | 1 + .../core-localization/src/locales/zh.ts | 7 +- webapp/packages/plugin-info/.gitignore | 17 +++ webapp/packages/plugin-info/package.json | 46 ++++++ webapp/packages/plugin-info/src/Info.tsx | 48 +++++++ .../packages/plugin-info/src/LocaleService.ts | 36 +++++ .../plugin-info/src/PluginBootstrap.ts | 27 ++++ .../plugin-info/src/Shortcuts/IShortcut.ts | 20 +++ .../src/Shortcuts/SHORTCUTS_DATA.ts | 132 ++++++++++++++++++ .../plugin-info/src/Shortcuts/Shortcut.tsx | 42 ++++++ .../src/Shortcuts/ShortcutBody.tsx | 69 +++++++++ .../src/Shortcuts/ShortcutsDialog.tsx | 76 ++++++++++ webapp/packages/plugin-info/src/index.ts | 3 + webapp/packages/plugin-info/src/locales/en.ts | 17 +++ webapp/packages/plugin-info/src/locales/it.ts | 17 +++ webapp/packages/plugin-info/src/locales/ru.ts | 17 +++ webapp/packages/plugin-info/src/locales/zh.ts | 17 +++ webapp/packages/plugin-info/src/manifest.ts | 23 +++ webapp/packages/plugin-info/tsconfig.json | 11 ++ .../src/PluginBootstrap.ts | 3 +- .../src/PluginBootstrap.ts | 2 +- webapp/packages/product-default/src/index.ts | 10 +- 26 files changed, 654 insertions(+), 10 deletions(-) create mode 100644 webapp/packages/plugin-info/.gitignore create mode 100644 webapp/packages/plugin-info/package.json create mode 100644 webapp/packages/plugin-info/src/Info.tsx create mode 100644 webapp/packages/plugin-info/src/LocaleService.ts create mode 100644 webapp/packages/plugin-info/src/PluginBootstrap.ts create mode 100644 webapp/packages/plugin-info/src/Shortcuts/IShortcut.ts create mode 100644 webapp/packages/plugin-info/src/Shortcuts/SHORTCUTS_DATA.ts create mode 100644 webapp/packages/plugin-info/src/Shortcuts/Shortcut.tsx create mode 100644 webapp/packages/plugin-info/src/Shortcuts/ShortcutBody.tsx create mode 100644 webapp/packages/plugin-info/src/Shortcuts/ShortcutsDialog.tsx create mode 100644 webapp/packages/plugin-info/src/index.ts create mode 100644 webapp/packages/plugin-info/src/locales/en.ts create mode 100644 webapp/packages/plugin-info/src/locales/it.ts create mode 100644 webapp/packages/plugin-info/src/locales/ru.ts create mode 100644 webapp/packages/plugin-info/src/locales/zh.ts create mode 100644 webapp/packages/plugin-info/src/manifest.ts create mode 100644 webapp/packages/plugin-info/tsconfig.json diff --git a/webapp/packages/core-app/public/icons/icons.svg b/webapp/packages/core-app/public/icons/icons.svg index fff77bb643..7fa0c782b1 100644 --- a/webapp/packages/core-app/public/icons/icons.svg +++ b/webapp/packages/core-app/public/icons/icons.svg @@ -328,4 +328,7 @@ + + + diff --git a/webapp/packages/core-blocks/src/Link.tsx b/webapp/packages/core-blocks/src/Link.tsx index 1e70b6da73..60f3d4dbc9 100644 --- a/webapp/packages/core-blocks/src/Link.tsx +++ b/webapp/packages/core-blocks/src/Link.tsx @@ -8,12 +8,16 @@ import styled, { css, use } from 'reshadow'; +import { IconOrImage } from './IconOrImage'; + interface Props extends React.AnchorHTMLAttributes { wrapper?: boolean; + indicator?: boolean; } const styles = css` a { + position: relative; cursor: pointer; } a[|wrapper] { @@ -23,17 +27,29 @@ const styles = css` outline: none; } } + IconOrImage { + position: absolute; + width: 8px; + left: calc(100% + 4px); + } `; export const Link: React.FC = function Link({ wrapper, + indicator, className, children, ...rest }) { return styled(styles)(
- {children} + + {indicator && } + {children} +
); }; diff --git a/webapp/packages/core-localization/src/locales/en.ts b/webapp/packages/core-localization/src/locales/en.ts index 10c802f867..9d12629725 100644 --- a/webapp/packages/core-localization/src/locales/en.ts +++ b/webapp/packages/core-localization/src/locales/en.ts @@ -66,6 +66,7 @@ export const defaultENLocale = [ ['ui_close_others', 'Close others'], ['ui_close_all_to_the_right', 'Close all to the Right'], ['ui_close_all_to_the_left', 'Close all to the Left'], + ['ui_or', 'Or'], ['root_permission_denied', "You don't have permissions"], ['root_permission_no_permission', "You don't have permission for this action"], diff --git a/webapp/packages/core-localization/src/locales/it.ts b/webapp/packages/core-localization/src/locales/it.ts index f5c115e4b2..dbf35b6dad 100644 --- a/webapp/packages/core-localization/src/locales/it.ts +++ b/webapp/packages/core-localization/src/locales/it.ts @@ -45,6 +45,7 @@ export const defaultITLocale = [ ['ui_close_others', 'Close others'], ['ui_close_all_to_the_right', 'Close all to the Right'], ['ui_close_all_to_the_left', 'Close all to the Left'], + ['ui_or', 'Or'], ['root_permission_denied', 'Non hai i permessi'], ['app_root_session_expire_warning_title', 'La sessione sta per scadere'], diff --git a/webapp/packages/core-localization/src/locales/ru.ts b/webapp/packages/core-localization/src/locales/ru.ts index 2cdc886248..4a394f4b99 100644 --- a/webapp/packages/core-localization/src/locales/ru.ts +++ b/webapp/packages/core-localization/src/locales/ru.ts @@ -64,6 +64,7 @@ export const defaultRULocale = [ ['ui_close_others', 'Закрыть другие'], ['ui_close_all_to_the_right', 'Закрыть все справа'], ['ui_close_all_to_the_left', 'Закрыть все слева'], + ['ui_or', 'Или'], ['root_permission_denied', 'Отказано в доступе'], ['root_permission_no_permission', 'У вас нет разрешения на это действие'], diff --git a/webapp/packages/core-localization/src/locales/zh.ts b/webapp/packages/core-localization/src/locales/zh.ts index 3d5706496b..dbc7b05495 100644 --- a/webapp/packages/core-localization/src/locales/zh.ts +++ b/webapp/packages/core-localization/src/locales/zh.ts @@ -43,7 +43,7 @@ export const defaultZHLocale = [ ['ui_rename', '重命名'], ['ui_rename_processing', '重命名中...'], ['ui_name', '名称'], - ['ui_cant_delete_item', "此项目不能删除"], + ['ui_cant_delete_item', '此项目不能删除'], ['ui_no_items_placeholder', '还没有项目'], ['ui_search_no_result_placeholder', '没有找到结果'], ['ui_save_reminder', '您有未保存的更改'], @@ -66,9 +66,10 @@ export const defaultZHLocale = [ ['ui_close_others', 'Close others'], ['ui_close_all_to_the_right', 'Close all to the Right'], ['ui_close_all_to_the_left', 'Close all to the Left'], + ['ui_or', 'Or'], - ['root_permission_denied', "您没有权限"], - ['root_permission_no_permission', "您没有权限执行此操作"], + ['root_permission_denied', '您没有权限'], + ['root_permission_no_permission', '您没有权限执行此操作'], ['app_root_session_expire_warning_title', '会话即将过期'], ['app_root_session_expire_warning_message', '您的会话将在5分钟内到期。要继续工作,请关闭此弹出窗口。'], ['app_root_session_expire_warning_button', '我在'], diff --git a/webapp/packages/plugin-info/.gitignore b/webapp/packages/plugin-info/.gitignore new file mode 100644 index 0000000000..15bc16c7c3 --- /dev/null +++ b/webapp/packages/plugin-info/.gitignore @@ -0,0 +1,17 @@ +# dependencies +/node_modules + +# testing +/coverage + +# production +/lib + +# misc +.DS_Store +.env* + +# debug +npm-debug.log* +yarn-debug.log* +yarn-error.log* diff --git a/webapp/packages/plugin-info/package.json b/webapp/packages/plugin-info/package.json new file mode 100644 index 0000000000..61974e0217 --- /dev/null +++ b/webapp/packages/plugin-info/package.json @@ -0,0 +1,46 @@ +{ + "name": "@cloudbeaver/plugin-info", + "sideEffects": false, + "version": "0.1.0", + "description": "", + "license": "Apache-2.0", + "main": "lib/index.js", + "module": "lib/index.js", + "types": "src/index.ts", + "scripts": { + "prebuild": "rimraf lib/*", + "build": "webpack --config ../../configs/webpack.plugin.config.js", + "postbuild": "tsc", + "lint": "eslint ./src/ --ext .ts,.tsx", + "lint-fix": "eslint ./src/ --ext .ts,.tsx --fix" + }, + "peerDependencies": { + "@cloudbeaver/core-administration": "^0.1.0", + "@cloudbeaver/core-app": "^0.1.0", + "@cloudbeaver/core-authentication": "^0.1.0", + "@cloudbeaver/core-blocks": "^0.1.0", + "@cloudbeaver/core-connections": "^0.1.0", + "@cloudbeaver/core-di": "^0.1.0", + "@cloudbeaver/core-dialogs": "^0.1.0", + "@cloudbeaver/core-events": "^0.1.0", + "@cloudbeaver/core-executor": "^0.1.0", + "@cloudbeaver/core-extensions": "^0.1.0", + "@cloudbeaver/core-localization": "^0.1.0", + "@cloudbeaver/core-notifications": "^0.1.0", + "@cloudbeaver/core-plugin": "^0.1.0", + "@cloudbeaver/core-product": "^0.1.0", + "@cloudbeaver/core-root": "^0.1.0", + "@cloudbeaver/core-routing": "^0.1.0", + "@cloudbeaver/core-sdk": "^0.1.0", + "@cloudbeaver/core-settings": "^0.1.0", + "@cloudbeaver/core-theming": "^0.1.0", + "@cloudbeaver/core-ui": "^0.1.0", + "@cloudbeaver/core-utils": "^0.1.0", + "@cloudbeaver/core-version-update": "^0.1.0", + "@cloudbeaver/core-view": "^0.1.0", + "mobx": "^6.x.x", + "mobx-react-lite": "^3.x.x", + "react": "^17.x.x", + "reshadow": "^0.x.x" + } +} diff --git a/webapp/packages/plugin-info/src/Info.tsx b/webapp/packages/plugin-info/src/Info.tsx new file mode 100644 index 0000000000..b18378df98 --- /dev/null +++ b/webapp/packages/plugin-info/src/Info.tsx @@ -0,0 +1,48 @@ +/* + * CloudBeaver - Cloud Database Manager + * Copyright (C) 2020-2022 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 { observer } from 'mobx-react-lite'; +import styled, { css } from 'reshadow'; + +import { IconOrImage } from '@cloudbeaver/core-blocks'; +import { useService } from '@cloudbeaver/core-di'; +import { CommonDialogService } from '@cloudbeaver/core-dialogs'; +import { composes, useStyles } from '@cloudbeaver/core-theming'; + +import { ShortcutsDialog } from './Shortcuts/ShortcutsDialog'; + +const styles = composes( + css` + container { + composes: theme-ripple from global; + } + `, + css` + container { + height: 100%; + display: flex; + align-items: center; + padding: 0 16px; + cursor: pointer; + & IconOrImage { + width: 24px; + } + } + ` +); + +export const Info = observer(function Info() { + const style = useStyles(styles); + const commonDialogService = useService(CommonDialogService); + + return styled(style)( + commonDialogService.open(ShortcutsDialog, null)}> + + + ); +}); \ No newline at end of file diff --git a/webapp/packages/plugin-info/src/LocaleService.ts b/webapp/packages/plugin-info/src/LocaleService.ts new file mode 100644 index 0000000000..c6a5d9b3c9 --- /dev/null +++ b/webapp/packages/plugin-info/src/LocaleService.ts @@ -0,0 +1,36 @@ +/* + * CloudBeaver - Cloud Database Manager + * Copyright (C) 2020-2022 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 { Bootstrap, injectable } from '@cloudbeaver/core-di'; +import { LocalizationService } from '@cloudbeaver/core-localization'; + +@injectable() +export class LocaleService extends Bootstrap { + constructor(private readonly localizationService: LocalizationService) { + super(); + } + + register(): void | Promise { + this.localizationService.addProvider(this.provider.bind(this)); + } + + load(): void | Promise { } + + private async provider(locale: string) { + switch (locale) { + case 'ru': + return (await import('./locales/ru')).default; + case 'it': + return (await import('./locales/it')).default; + case 'zh': + return (await import('./locales/zh')).default; + default: + return (await import('./locales/en')).default; + } + } +} diff --git a/webapp/packages/plugin-info/src/PluginBootstrap.ts b/webapp/packages/plugin-info/src/PluginBootstrap.ts new file mode 100644 index 0000000000..e30807d624 --- /dev/null +++ b/webapp/packages/plugin-info/src/PluginBootstrap.ts @@ -0,0 +1,27 @@ +/* + * CloudBeaver - Cloud Database Manager + * Copyright (C) 2020-2022 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 { TopNavService } from '@cloudbeaver/core-app'; +import { Bootstrap, injectable } from '@cloudbeaver/core-di'; + +import { Info } from './Info'; + +@injectable() +export class PluginBootstrap extends Bootstrap { + constructor( + private readonly topNavService: TopNavService + ) { + super(); + } + + async load(): Promise { } + + register(): void { + this.topNavService.placeholder.add(Info, 4); + } +} diff --git a/webapp/packages/plugin-info/src/Shortcuts/IShortcut.ts b/webapp/packages/plugin-info/src/Shortcuts/IShortcut.ts new file mode 100644 index 0000000000..52ded6b7f6 --- /dev/null +++ b/webapp/packages/plugin-info/src/Shortcuts/IShortcut.ts @@ -0,0 +1,20 @@ +/* + * CloudBeaver - Cloud Database Manager + * Copyright (C) 2020-2022 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 type { TLocalizationToken } from '@cloudbeaver/core-localization'; + +export interface IShortcutBody { + code: string; + and?: IShortcutBody; + or?: IShortcutBody; +} + +export interface IShortcut { + label: TLocalizationToken; + body: IShortcutBody; +} \ No newline at end of file diff --git a/webapp/packages/plugin-info/src/Shortcuts/SHORTCUTS_DATA.ts b/webapp/packages/plugin-info/src/Shortcuts/SHORTCUTS_DATA.ts new file mode 100644 index 0000000000..47e8429997 --- /dev/null +++ b/webapp/packages/plugin-info/src/Shortcuts/SHORTCUTS_DATA.ts @@ -0,0 +1,132 @@ +/* + * CloudBeaver - Cloud Database Manager + * Copyright (C) 2020-2022 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 type { IShortcut } from './IShortcut'; + +export const DATA_VIEWER_SHORTCUTS: IShortcut[] = [ + { + label: 'data_viewer_shortcut_start_inline_editing', + body: { + code: 'Enter', + or: { + code: 'Backspace', + }, + }, + }, + { + label: 'data_viewer_shortcut_add_new_row', + body: { + code: 'Alt', + and: { + code: 'Insert', + }, + }, + }, + { + label: 'data_viewer_shortcut_duplicate_row', + body: { + code: 'Ctrl', + and: { + code: 'Alt', + and: { + code: 'Insert', + }, + }, + }, + }, + { + label: 'data_viewer_shortcut_delete_row', + body: { + code: 'Delete', + }, + }, + { + label: 'data_viewer_shortcut_revert_inline_editor_changes', + body: { + code: 'Escape', + }, + }, + { + label: 'data_viewer_shortcut_past_value', + body: { + code: 'Ctrl', + and: { + code: 'V', + }, + }, + }, + { + label: 'data_viewer_shortcut_copy_value', + body: { + code: 'Ctrl', + and: { + code: 'C', + }, + }, + }, +]; + +export const SQL_EDITOR_SHORTCUTS: IShortcut[] = [ + { + label: 'sql_editor_shortcut_execute_statement', + body: { + code: 'Ctrl', + and: { + code: 'Enter', + }, + }, + }, + { + label: 'sql_editor_shortcut_execute_statement_new_tab', + body: { + code: 'Ctrl', + and: { + code: '\\', + }, + or: { + code: 'Ctrl', + and: { + code: 'Shift', + and: { + code: 'Enter', + }, + }, + }, + }, + }, + { + label: 'sql_editor_shortcut_execute_script', + body: { + code: 'Alt', + and: { + code: 'X', + }, + }, + }, + { + label: 'sql_editor_shortcut_show_execution_plan', + body: { + code: 'Shift', + and: { + code: 'Ctrl', + and: { + code: 'E', + }, + }, + }, + }, + { + label: 'sql_editor_shortcut_open_editor_in_new_tab', + body: { + code: 'Alt', + and: { + code: 'T', + }, + }, + }, +]; \ No newline at end of file diff --git a/webapp/packages/plugin-info/src/Shortcuts/Shortcut.tsx b/webapp/packages/plugin-info/src/Shortcuts/Shortcut.tsx new file mode 100644 index 0000000000..b6f60588d6 --- /dev/null +++ b/webapp/packages/plugin-info/src/Shortcuts/Shortcut.tsx @@ -0,0 +1,42 @@ +/* + * CloudBeaver - Cloud Database Manager + * Copyright (C) 2020-2022 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 styled, { css } from 'reshadow'; + +import { useTranslate } from '@cloudbeaver/core-localization'; + +import type { IShortcut } from './IShortcut'; +import { ShortcutBody } from './ShortcutBody'; + +interface Props { + shortcut: IShortcut; +} + +const style = css` + shortcut-container { + display: flex; + align-items: center; + justify-content: space-between; + } + shortcut-label { + margin-right: 8px; + } +`; + +export const Shortcut: React.FC = function Shortcut({ shortcut }) { + const translate = useTranslate(); + + return styled(style)( + + + {translate(shortcut.label)} + + + + ); +}; \ No newline at end of file diff --git a/webapp/packages/plugin-info/src/Shortcuts/ShortcutBody.tsx b/webapp/packages/plugin-info/src/Shortcuts/ShortcutBody.tsx new file mode 100644 index 0000000000..0c2e991cf6 --- /dev/null +++ b/webapp/packages/plugin-info/src/Shortcuts/ShortcutBody.tsx @@ -0,0 +1,69 @@ +/* + * CloudBeaver - Cloud Database Manager + * Copyright (C) 2020-2022 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 styled, { css } from 'reshadow'; + +import { useTranslate } from '@cloudbeaver/core-localization'; +import { composes, useStyles } from '@cloudbeaver/core-theming'; + +import type { IShortcutBody } from './IShortcut'; + +interface Props { + body: IShortcutBody; +} + +const style = composes( + css` + shortcut-code { + composes: theme-background-secondary theme-text-on-secondary from global; + } + `, + css` + shortcut-body { + display: flex; + align-items: center; + gap: 4px; + } + shortcut-code { + flex-shrink: 0; + font-family: monospace; + font-weight: bold; + border-radius: 4px; + width: max-content; + padding: 4px 8px; + } + span { + white-space: nowrap; + text-transform: lowercase; + } +`); + +export const ShortcutBody: React.FC = function ShortcutBody({ body }) { + const translate = useTranslate(); + const styles = useStyles(style); + + return styled(styles)( + + + {body.code} + + {body.and && ( + <> + + + + + )} + {body.or && ( + <> + {translate('ui_or')} + + + )} + + ); +}; \ No newline at end of file diff --git a/webapp/packages/plugin-info/src/Shortcuts/ShortcutsDialog.tsx b/webapp/packages/plugin-info/src/Shortcuts/ShortcutsDialog.tsx new file mode 100644 index 0000000000..a6feb60901 --- /dev/null +++ b/webapp/packages/plugin-info/src/Shortcuts/ShortcutsDialog.tsx @@ -0,0 +1,76 @@ +/* + * CloudBeaver - Cloud Database Manager + * Copyright (C) 2020-2022 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 styled, { css } from 'reshadow'; + +import { BASE_CONTAINERS_STYLES, Button, Container, Group, GroupTitle, Link } from '@cloudbeaver/core-blocks'; +import { CommonDialogWrapper, DialogComponent } from '@cloudbeaver/core-dialogs'; +import { useTranslate } from '@cloudbeaver/core-localization'; +import { useStyles } from '@cloudbeaver/core-theming'; + +import { Shortcut } from './Shortcut'; +import { DATA_VIEWER_SHORTCUTS, SQL_EDITOR_SHORTCUTS } from './SHORTCUTS_DATA'; + + +const style = css` + CommonDialogWrapper { + max-width: 1100px; + } + Button { + margin-left: auto; + } + Container { + composes: theme-typography--body2 from global; + gap: 16px; + } + Group { + gap: 16px; + } + GroupTitle, Group { + padding: 0 !important; + } +`; + +export const ShortcutsDialog: DialogComponent = function ShortcutsDialog({ + rejectDialog, +}) { + const translate = useTranslate(); + const styles = useStyles(BASE_CONTAINERS_STYLES, style); + + return styled(styles)( + + {translate('ui_close')} + + )} + size='large' + onReject={rejectDialog} + > + + + + + Data Viewer + + + {DATA_VIEWER_SHORTCUTS.map(shortcut => )} + + + + + SQL Editor + + + {SQL_EDITOR_SHORTCUTS.map(shortcut => )} + + + + ); +}; \ No newline at end of file diff --git a/webapp/packages/plugin-info/src/index.ts b/webapp/packages/plugin-info/src/index.ts new file mode 100644 index 0000000000..15bc2512af --- /dev/null +++ b/webapp/packages/plugin-info/src/index.ts @@ -0,0 +1,3 @@ +import { manifest } from './manifest'; + +export default manifest; \ No newline at end of file diff --git a/webapp/packages/plugin-info/src/locales/en.ts b/webapp/packages/plugin-info/src/locales/en.ts new file mode 100644 index 0000000000..69695c68e9 --- /dev/null +++ b/webapp/packages/plugin-info/src/locales/en.ts @@ -0,0 +1,17 @@ +export default [ + ['shortcuts_title', 'Shortcuts'], + + ['data_viewer_shortcut_start_inline_editing', 'Open Inline Editor for the selected Cell'], + ['data_viewer_shortcut_add_new_row', 'Add a new Row'], + ['data_viewer_shortcut_duplicate_row', 'Duplicate row'], + ['data_viewer_shortcut_delete_row', 'Delete row'], + ['data_viewer_shortcut_revert_inline_editor_changes', 'Revert Inline Editor changes'], + ['data_viewer_shortcut_past_value', 'Past value to the Cell from the Clipboard'], + ['data_viewer_shortcut_copy_value', 'Copy Cell value to the Clipboard'], + + ['sql_editor_shortcut_execute_statement', 'Execute SQL statement'], + ['sql_editor_shortcut_execute_statement_new_tab', 'Execute SQL statement in the new Tab'], + ['sql_editor_shortcut_execute_script', 'Execute script'], + ['sql_editor_shortcut_show_execution_plan', 'Show Execution plan'], + ['sql_editor_shortcut_open_editor_in_new_tab', 'Open SQL Editor in the separate browser Tab'], +]; diff --git a/webapp/packages/plugin-info/src/locales/it.ts b/webapp/packages/plugin-info/src/locales/it.ts new file mode 100644 index 0000000000..69695c68e9 --- /dev/null +++ b/webapp/packages/plugin-info/src/locales/it.ts @@ -0,0 +1,17 @@ +export default [ + ['shortcuts_title', 'Shortcuts'], + + ['data_viewer_shortcut_start_inline_editing', 'Open Inline Editor for the selected Cell'], + ['data_viewer_shortcut_add_new_row', 'Add a new Row'], + ['data_viewer_shortcut_duplicate_row', 'Duplicate row'], + ['data_viewer_shortcut_delete_row', 'Delete row'], + ['data_viewer_shortcut_revert_inline_editor_changes', 'Revert Inline Editor changes'], + ['data_viewer_shortcut_past_value', 'Past value to the Cell from the Clipboard'], + ['data_viewer_shortcut_copy_value', 'Copy Cell value to the Clipboard'], + + ['sql_editor_shortcut_execute_statement', 'Execute SQL statement'], + ['sql_editor_shortcut_execute_statement_new_tab', 'Execute SQL statement in the new Tab'], + ['sql_editor_shortcut_execute_script', 'Execute script'], + ['sql_editor_shortcut_show_execution_plan', 'Show Execution plan'], + ['sql_editor_shortcut_open_editor_in_new_tab', 'Open SQL Editor in the separate browser Tab'], +]; diff --git a/webapp/packages/plugin-info/src/locales/ru.ts b/webapp/packages/plugin-info/src/locales/ru.ts new file mode 100644 index 0000000000..c93b206974 --- /dev/null +++ b/webapp/packages/plugin-info/src/locales/ru.ts @@ -0,0 +1,17 @@ +export default [ + ['shortcuts_title', 'Горячие клавиши'], + + ['data_viewer_shortcut_start_inline_editing', 'Начать редактирование ячейки во встроенном редакторе'], + ['data_viewer_shortcut_add_new_row', 'Добавить новую строку'], + ['data_viewer_shortcut_duplicate_row', 'Продублировать строку'], + ['data_viewer_shortcut_delete_row', 'Удалить строку'], + ['data_viewer_shortcut_revert_inline_editor_changes', 'Отменить изменения во встроенном редакторе'], + ['data_viewer_shortcut_past_value', 'Вставить значение из буфера обмена в ячейку'], + ['data_viewer_shortcut_copy_value', 'Скопировать значение ячейки в буфер обмена'], + + ['sql_editor_shortcut_execute_statement', 'Выполнить SQL выражение'], + ['sql_editor_shortcut_execute_statement_new_tab', 'Выполнить SQL выражение в новой вкладке'], + ['sql_editor_shortcut_execute_script', 'Выполнить скрипт'], + ['sql_editor_shortcut_show_execution_plan', 'Показать план выполнения'], + ['sql_editor_shortcut_open_editor_in_new_tab', 'Открыть SQL редактор в новой бразуерной вкладке'], +]; diff --git a/webapp/packages/plugin-info/src/locales/zh.ts b/webapp/packages/plugin-info/src/locales/zh.ts new file mode 100644 index 0000000000..69695c68e9 --- /dev/null +++ b/webapp/packages/plugin-info/src/locales/zh.ts @@ -0,0 +1,17 @@ +export default [ + ['shortcuts_title', 'Shortcuts'], + + ['data_viewer_shortcut_start_inline_editing', 'Open Inline Editor for the selected Cell'], + ['data_viewer_shortcut_add_new_row', 'Add a new Row'], + ['data_viewer_shortcut_duplicate_row', 'Duplicate row'], + ['data_viewer_shortcut_delete_row', 'Delete row'], + ['data_viewer_shortcut_revert_inline_editor_changes', 'Revert Inline Editor changes'], + ['data_viewer_shortcut_past_value', 'Past value to the Cell from the Clipboard'], + ['data_viewer_shortcut_copy_value', 'Copy Cell value to the Clipboard'], + + ['sql_editor_shortcut_execute_statement', 'Execute SQL statement'], + ['sql_editor_shortcut_execute_statement_new_tab', 'Execute SQL statement in the new Tab'], + ['sql_editor_shortcut_execute_script', 'Execute script'], + ['sql_editor_shortcut_show_execution_plan', 'Show Execution plan'], + ['sql_editor_shortcut_open_editor_in_new_tab', 'Open SQL Editor in the separate browser Tab'], +]; diff --git a/webapp/packages/plugin-info/src/manifest.ts b/webapp/packages/plugin-info/src/manifest.ts new file mode 100644 index 0000000000..f1196de74b --- /dev/null +++ b/webapp/packages/plugin-info/src/manifest.ts @@ -0,0 +1,23 @@ +/* + * CloudBeaver - Cloud Database Manager + * Copyright (C) 2020-2022 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 type { PluginManifest } from '@cloudbeaver/core-di'; + +import { LocaleService } from './LocaleService'; +import { PluginBootstrap } from './PluginBootstrap'; + +export const manifest: PluginManifest = { + info: { + name: 'Info plugin', + }, + + providers: [ + PluginBootstrap, + LocaleService, + ], +}; diff --git a/webapp/packages/plugin-info/tsconfig.json b/webapp/packages/plugin-info/tsconfig.json new file mode 100644 index 0000000000..2a4cc370f7 --- /dev/null +++ b/webapp/packages/plugin-info/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "rootDir": "src", + "outDir": "lib", + "composite": true + }, + "include": ["src"], + "exclude": ["**/node_modules", "**/.*/"], + "references": [{ "path": "../*" }] +} diff --git a/webapp/packages/plugin-settings-menu/src/PluginBootstrap.ts b/webapp/packages/plugin-settings-menu/src/PluginBootstrap.ts index 2411eeeada..27486d6f96 100644 --- a/webapp/packages/plugin-settings-menu/src/PluginBootstrap.ts +++ b/webapp/packages/plugin-settings-menu/src/PluginBootstrap.ts @@ -8,6 +8,7 @@ import { TopNavService } from '@cloudbeaver/core-app'; import { Bootstrap, injectable } from '@cloudbeaver/core-di'; + import { SettingsMenu } from './SettingsMenu/SettingsMenu'; @injectable() @@ -19,7 +20,7 @@ export class PluginBootstrap extends Bootstrap { } register(): void | Promise { - this.topNavService.placeholder.add(SettingsMenu, 5); + this.topNavService.placeholder.add(SettingsMenu, 6); } load(): void | Promise { } diff --git a/webapp/packages/plugin-user-profile/src/PluginBootstrap.ts b/webapp/packages/plugin-user-profile/src/PluginBootstrap.ts index 5349a46cb4..8c28886ed7 100644 --- a/webapp/packages/plugin-user-profile/src/PluginBootstrap.ts +++ b/webapp/packages/plugin-user-profile/src/PluginBootstrap.ts @@ -20,7 +20,7 @@ export class PluginBootstrap extends Bootstrap { } register(): void { - this.topNavService.placeholder.add(UserMenu, 4); + this.topNavService.placeholder.add(UserMenu, 5); } load(): void { } diff --git a/webapp/packages/product-default/src/index.ts b/webapp/packages/product-default/src/index.ts index d0e21384ba..fbff9cc513 100644 --- a/webapp/packages/product-default/src/index.ts +++ b/webapp/packages/product-default/src/index.ts @@ -5,8 +5,6 @@ import type { PluginManifest } from '@cloudbeaver/core-di'; import administration from '@cloudbeaver/plugin-administration'; import authentication from '@cloudbeaver/plugin-authentication'; import authenticationAdministration from '@cloudbeaver/plugin-authentication-administration'; -import theme from '@cloudbeaver/plugin-theme'; -import localization from '@cloudbeaver/plugin-localization'; import connectionCustom from '@cloudbeaver/plugin-connection-custom'; import connectionTemplate from '@cloudbeaver/plugin-connection-template'; import connectionPlugin from '@cloudbeaver/plugin-connections'; @@ -16,16 +14,19 @@ import spreadsheetNew from '@cloudbeaver/plugin-data-spreadsheet-new'; import dataViewer from '@cloudbeaver/plugin-data-viewer'; import ddlViewer from '@cloudbeaver/plugin-ddl-viewer'; import gisViewer from '@cloudbeaver/plugin-gis-viewer'; +import info from '@cloudbeaver/plugin-info'; +import localization from '@cloudbeaver/plugin-localization'; import objectViewer from '@cloudbeaver/plugin-object-viewer'; import productPlugin from '@cloudbeaver/plugin-product'; +import settingsMenu from '@cloudbeaver/plugin-settings-menu'; +import settingsMenuAdministration from '@cloudbeaver/plugin-settings-menu-administration'; import sqlEditor from '@cloudbeaver/plugin-sql-editor'; import sqlEditorTab from '@cloudbeaver/plugin-sql-editor-navigation-tab'; import sqlEditorScreen from '@cloudbeaver/plugin-sql-editor-screen'; +import theme from '@cloudbeaver/plugin-theme'; import userProfile from '@cloudbeaver/plugin-user-profile'; import userProfileAdministration from '@cloudbeaver/plugin-user-profile-administration'; import versionUpdate from '@cloudbeaver/plugin-version-update-administration'; -import settingsMenu from '@cloudbeaver/plugin-settings-menu'; -import settingsMenuAdministration from '@cloudbeaver/plugin-settings-menu-administration'; import { defaultProductManifest } from './manifest'; @@ -55,6 +56,7 @@ const PLUGINS: PluginManifest[] = [ productPlugin, settingsMenu, settingsMenuAdministration, + info, ]; bootstrap(PLUGINS); From 21e65a4341f020036a2d8fac4f86f2cef28a1ba2 Mon Sep 17 00:00:00 2001 From: Naumov Alexey Date: Wed, 2 Feb 2022 16:55:47 +0300 Subject: [PATCH 2/3] feat(plugin-info): CB-1450 change plugin name --- .../{plugin-info => plugin-help}/.gitignore | 0 .../{plugin-info => plugin-help}/package.json | 2 +- .../{plugin-info => plugin-help}/src/Info.tsx | 0 .../src/LocaleService.ts | 0 .../src/PluginBootstrap.ts | 0 .../src/Shortcuts/IShortcut.ts | 8 +- .../src/Shortcuts/SHORTCUTS_DATA.ts | 63 +++++++++ .../src/Shortcuts/Shortcut.tsx} | 54 ++++--- .../src/Shortcuts/ShortcutsDialog.tsx | 0 .../{plugin-info => plugin-help}/src/index.ts | 0 .../src/locales/en.ts | 0 .../src/locales/it.ts | 0 .../src/locales/ru.ts | 0 .../src/locales/zh.ts | 0 .../src/manifest.ts | 2 +- .../tsconfig.json | 0 .../src/Shortcuts/SHORTCUTS_DATA.ts | 132 ------------------ .../plugin-info/src/Shortcuts/Shortcut.tsx | 42 ------ webapp/packages/product-default/src/index.ts | 4 +- 19 files changed, 99 insertions(+), 208 deletions(-) rename webapp/packages/{plugin-info => plugin-help}/.gitignore (100%) rename webapp/packages/{plugin-info => plugin-help}/package.json (97%) rename webapp/packages/{plugin-info => plugin-help}/src/Info.tsx (100%) rename webapp/packages/{plugin-info => plugin-help}/src/LocaleService.ts (100%) rename webapp/packages/{plugin-info => plugin-help}/src/PluginBootstrap.ts (100%) rename webapp/packages/{plugin-info => plugin-help}/src/Shortcuts/IShortcut.ts (74%) create mode 100644 webapp/packages/plugin-help/src/Shortcuts/SHORTCUTS_DATA.ts rename webapp/packages/{plugin-info/src/Shortcuts/ShortcutBody.tsx => plugin-help/src/Shortcuts/Shortcut.tsx} (51%) rename webapp/packages/{plugin-info => plugin-help}/src/Shortcuts/ShortcutsDialog.tsx (100%) rename webapp/packages/{plugin-info => plugin-help}/src/index.ts (100%) rename webapp/packages/{plugin-info => plugin-help}/src/locales/en.ts (100%) rename webapp/packages/{plugin-info => plugin-help}/src/locales/it.ts (100%) rename webapp/packages/{plugin-info => plugin-help}/src/locales/ru.ts (100%) rename webapp/packages/{plugin-info => plugin-help}/src/locales/zh.ts (100%) rename webapp/packages/{plugin-info => plugin-help}/src/manifest.ts (95%) rename webapp/packages/{plugin-info => plugin-help}/tsconfig.json (100%) delete mode 100644 webapp/packages/plugin-info/src/Shortcuts/SHORTCUTS_DATA.ts delete mode 100644 webapp/packages/plugin-info/src/Shortcuts/Shortcut.tsx diff --git a/webapp/packages/plugin-info/.gitignore b/webapp/packages/plugin-help/.gitignore similarity index 100% rename from webapp/packages/plugin-info/.gitignore rename to webapp/packages/plugin-help/.gitignore diff --git a/webapp/packages/plugin-info/package.json b/webapp/packages/plugin-help/package.json similarity index 97% rename from webapp/packages/plugin-info/package.json rename to webapp/packages/plugin-help/package.json index 61974e0217..6c66b2f746 100644 --- a/webapp/packages/plugin-info/package.json +++ b/webapp/packages/plugin-help/package.json @@ -1,5 +1,5 @@ { - "name": "@cloudbeaver/plugin-info", + "name": "@cloudbeaver/plugin-help", "sideEffects": false, "version": "0.1.0", "description": "", diff --git a/webapp/packages/plugin-info/src/Info.tsx b/webapp/packages/plugin-help/src/Info.tsx similarity index 100% rename from webapp/packages/plugin-info/src/Info.tsx rename to webapp/packages/plugin-help/src/Info.tsx diff --git a/webapp/packages/plugin-info/src/LocaleService.ts b/webapp/packages/plugin-help/src/LocaleService.ts similarity index 100% rename from webapp/packages/plugin-info/src/LocaleService.ts rename to webapp/packages/plugin-help/src/LocaleService.ts diff --git a/webapp/packages/plugin-info/src/PluginBootstrap.ts b/webapp/packages/plugin-help/src/PluginBootstrap.ts similarity index 100% rename from webapp/packages/plugin-info/src/PluginBootstrap.ts rename to webapp/packages/plugin-help/src/PluginBootstrap.ts diff --git a/webapp/packages/plugin-info/src/Shortcuts/IShortcut.ts b/webapp/packages/plugin-help/src/Shortcuts/IShortcut.ts similarity index 74% rename from webapp/packages/plugin-info/src/Shortcuts/IShortcut.ts rename to webapp/packages/plugin-help/src/Shortcuts/IShortcut.ts index 52ded6b7f6..83a79c7ee8 100644 --- a/webapp/packages/plugin-info/src/Shortcuts/IShortcut.ts +++ b/webapp/packages/plugin-help/src/Shortcuts/IShortcut.ts @@ -8,13 +8,7 @@ import type { TLocalizationToken } from '@cloudbeaver/core-localization'; -export interface IShortcutBody { - code: string; - and?: IShortcutBody; - or?: IShortcutBody; -} - export interface IShortcut { label: TLocalizationToken; - body: IShortcutBody; + code: string[]; } \ No newline at end of file diff --git a/webapp/packages/plugin-help/src/Shortcuts/SHORTCUTS_DATA.ts b/webapp/packages/plugin-help/src/Shortcuts/SHORTCUTS_DATA.ts new file mode 100644 index 0000000000..cd66ec14ca --- /dev/null +++ b/webapp/packages/plugin-help/src/Shortcuts/SHORTCUTS_DATA.ts @@ -0,0 +1,63 @@ +/* + * CloudBeaver - Cloud Database Manager + * Copyright (C) 2020-2022 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 type { IShortcut } from './IShortcut'; + +export const DATA_VIEWER_SHORTCUTS: IShortcut[] = [ + { + label: 'data_viewer_shortcut_start_inline_editing', + code: ['Enter', 'Backspace'], + }, + { + label: 'data_viewer_shortcut_add_new_row', + code: ['Alt + Insert'], + }, + { + label: 'data_viewer_shortcut_duplicate_row', + code: ['Ctrl + Alt + Insert'], + }, + { + label: 'data_viewer_shortcut_delete_row', + code: ['Delete'], + }, + { + label: 'data_viewer_shortcut_revert_inline_editor_changes', + code: ['Escape'], + }, + { + label: 'data_viewer_shortcut_past_value', + code: ['Ctrl + V'], + }, + { + label: 'data_viewer_shortcut_copy_value', + code: ['Ctrl + C'], + }, +]; + +export const SQL_EDITOR_SHORTCUTS: IShortcut[] = [ + { + label: 'sql_editor_shortcut_execute_statement', + code: ['Ctrl + Enter'], + }, + { + label: 'sql_editor_shortcut_execute_statement_new_tab', + code: ['Ctrl + \\', 'Ctrl + Shift + Enter'], + }, + { + label: 'sql_editor_shortcut_execute_script', + code: ['Alt + X'], + }, + { + label: 'sql_editor_shortcut_show_execution_plan', + code: ['Shift + Ctrl + E'], + }, + { + label: 'sql_editor_shortcut_open_editor_in_new_tab', + code: ['Alt + T'], + }, +]; \ No newline at end of file diff --git a/webapp/packages/plugin-info/src/Shortcuts/ShortcutBody.tsx b/webapp/packages/plugin-help/src/Shortcuts/Shortcut.tsx similarity index 51% rename from webapp/packages/plugin-info/src/Shortcuts/ShortcutBody.tsx rename to webapp/packages/plugin-help/src/Shortcuts/Shortcut.tsx index 0c2e991cf6..a87fcbfedc 100644 --- a/webapp/packages/plugin-info/src/Shortcuts/ShortcutBody.tsx +++ b/webapp/packages/plugin-help/src/Shortcuts/Shortcut.tsx @@ -11,10 +11,10 @@ import styled, { css } from 'reshadow'; import { useTranslate } from '@cloudbeaver/core-localization'; import { composes, useStyles } from '@cloudbeaver/core-theming'; -import type { IShortcutBody } from './IShortcut'; +import type { IShortcut } from './IShortcut'; interface Props { - body: IShortcutBody; + shortcut: IShortcut; } const style = composes( @@ -24,7 +24,15 @@ const style = composes( } `, css` - shortcut-body { + shortcut-container { + display: flex; + align-items: center; + justify-content: space-between; + } + shortcut-label { + margin-right: 8px; + } + shortcut-content { display: flex; align-items: center; gap: 4px; @@ -43,27 +51,27 @@ const style = composes( } `); -export const ShortcutBody: React.FC = function ShortcutBody({ body }) { +export const Shortcut: React.FC = function Shortcut({ shortcut }) { const translate = useTranslate(); - const styles = useStyles(style); - return styled(styles)( - - - {body.code} - - {body.and && ( - <> - + - - - )} - {body.or && ( - <> - {translate('ui_or')} - - - )} - + return styled(useStyles(style))( + + + {translate(shortcut.label)} + + + {shortcut.code.map((code, index, array) => { + const next = !!array[index + 1]; + return ( + <> + + {code} + + {next && {translate('ui_or')}} + + ); + })} + + ); }; \ No newline at end of file diff --git a/webapp/packages/plugin-info/src/Shortcuts/ShortcutsDialog.tsx b/webapp/packages/plugin-help/src/Shortcuts/ShortcutsDialog.tsx similarity index 100% rename from webapp/packages/plugin-info/src/Shortcuts/ShortcutsDialog.tsx rename to webapp/packages/plugin-help/src/Shortcuts/ShortcutsDialog.tsx diff --git a/webapp/packages/plugin-info/src/index.ts b/webapp/packages/plugin-help/src/index.ts similarity index 100% rename from webapp/packages/plugin-info/src/index.ts rename to webapp/packages/plugin-help/src/index.ts diff --git a/webapp/packages/plugin-info/src/locales/en.ts b/webapp/packages/plugin-help/src/locales/en.ts similarity index 100% rename from webapp/packages/plugin-info/src/locales/en.ts rename to webapp/packages/plugin-help/src/locales/en.ts diff --git a/webapp/packages/plugin-info/src/locales/it.ts b/webapp/packages/plugin-help/src/locales/it.ts similarity index 100% rename from webapp/packages/plugin-info/src/locales/it.ts rename to webapp/packages/plugin-help/src/locales/it.ts diff --git a/webapp/packages/plugin-info/src/locales/ru.ts b/webapp/packages/plugin-help/src/locales/ru.ts similarity index 100% rename from webapp/packages/plugin-info/src/locales/ru.ts rename to webapp/packages/plugin-help/src/locales/ru.ts diff --git a/webapp/packages/plugin-info/src/locales/zh.ts b/webapp/packages/plugin-help/src/locales/zh.ts similarity index 100% rename from webapp/packages/plugin-info/src/locales/zh.ts rename to webapp/packages/plugin-help/src/locales/zh.ts diff --git a/webapp/packages/plugin-info/src/manifest.ts b/webapp/packages/plugin-help/src/manifest.ts similarity index 95% rename from webapp/packages/plugin-info/src/manifest.ts rename to webapp/packages/plugin-help/src/manifest.ts index f1196de74b..7fdc69a18a 100644 --- a/webapp/packages/plugin-info/src/manifest.ts +++ b/webapp/packages/plugin-help/src/manifest.ts @@ -13,7 +13,7 @@ import { PluginBootstrap } from './PluginBootstrap'; export const manifest: PluginManifest = { info: { - name: 'Info plugin', + name: 'Help plugin', }, providers: [ diff --git a/webapp/packages/plugin-info/tsconfig.json b/webapp/packages/plugin-help/tsconfig.json similarity index 100% rename from webapp/packages/plugin-info/tsconfig.json rename to webapp/packages/plugin-help/tsconfig.json diff --git a/webapp/packages/plugin-info/src/Shortcuts/SHORTCUTS_DATA.ts b/webapp/packages/plugin-info/src/Shortcuts/SHORTCUTS_DATA.ts deleted file mode 100644 index 47e8429997..0000000000 --- a/webapp/packages/plugin-info/src/Shortcuts/SHORTCUTS_DATA.ts +++ /dev/null @@ -1,132 +0,0 @@ -/* - * CloudBeaver - Cloud Database Manager - * Copyright (C) 2020-2022 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 type { IShortcut } from './IShortcut'; - -export const DATA_VIEWER_SHORTCUTS: IShortcut[] = [ - { - label: 'data_viewer_shortcut_start_inline_editing', - body: { - code: 'Enter', - or: { - code: 'Backspace', - }, - }, - }, - { - label: 'data_viewer_shortcut_add_new_row', - body: { - code: 'Alt', - and: { - code: 'Insert', - }, - }, - }, - { - label: 'data_viewer_shortcut_duplicate_row', - body: { - code: 'Ctrl', - and: { - code: 'Alt', - and: { - code: 'Insert', - }, - }, - }, - }, - { - label: 'data_viewer_shortcut_delete_row', - body: { - code: 'Delete', - }, - }, - { - label: 'data_viewer_shortcut_revert_inline_editor_changes', - body: { - code: 'Escape', - }, - }, - { - label: 'data_viewer_shortcut_past_value', - body: { - code: 'Ctrl', - and: { - code: 'V', - }, - }, - }, - { - label: 'data_viewer_shortcut_copy_value', - body: { - code: 'Ctrl', - and: { - code: 'C', - }, - }, - }, -]; - -export const SQL_EDITOR_SHORTCUTS: IShortcut[] = [ - { - label: 'sql_editor_shortcut_execute_statement', - body: { - code: 'Ctrl', - and: { - code: 'Enter', - }, - }, - }, - { - label: 'sql_editor_shortcut_execute_statement_new_tab', - body: { - code: 'Ctrl', - and: { - code: '\\', - }, - or: { - code: 'Ctrl', - and: { - code: 'Shift', - and: { - code: 'Enter', - }, - }, - }, - }, - }, - { - label: 'sql_editor_shortcut_execute_script', - body: { - code: 'Alt', - and: { - code: 'X', - }, - }, - }, - { - label: 'sql_editor_shortcut_show_execution_plan', - body: { - code: 'Shift', - and: { - code: 'Ctrl', - and: { - code: 'E', - }, - }, - }, - }, - { - label: 'sql_editor_shortcut_open_editor_in_new_tab', - body: { - code: 'Alt', - and: { - code: 'T', - }, - }, - }, -]; \ No newline at end of file diff --git a/webapp/packages/plugin-info/src/Shortcuts/Shortcut.tsx b/webapp/packages/plugin-info/src/Shortcuts/Shortcut.tsx deleted file mode 100644 index b6f60588d6..0000000000 --- a/webapp/packages/plugin-info/src/Shortcuts/Shortcut.tsx +++ /dev/null @@ -1,42 +0,0 @@ -/* - * CloudBeaver - Cloud Database Manager - * Copyright (C) 2020-2022 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 styled, { css } from 'reshadow'; - -import { useTranslate } from '@cloudbeaver/core-localization'; - -import type { IShortcut } from './IShortcut'; -import { ShortcutBody } from './ShortcutBody'; - -interface Props { - shortcut: IShortcut; -} - -const style = css` - shortcut-container { - display: flex; - align-items: center; - justify-content: space-between; - } - shortcut-label { - margin-right: 8px; - } -`; - -export const Shortcut: React.FC = function Shortcut({ shortcut }) { - const translate = useTranslate(); - - return styled(style)( - - - {translate(shortcut.label)} - - - - ); -}; \ No newline at end of file diff --git a/webapp/packages/product-default/src/index.ts b/webapp/packages/product-default/src/index.ts index fbff9cc513..11367ef31d 100644 --- a/webapp/packages/product-default/src/index.ts +++ b/webapp/packages/product-default/src/index.ts @@ -14,7 +14,7 @@ import spreadsheetNew from '@cloudbeaver/plugin-data-spreadsheet-new'; import dataViewer from '@cloudbeaver/plugin-data-viewer'; import ddlViewer from '@cloudbeaver/plugin-ddl-viewer'; import gisViewer from '@cloudbeaver/plugin-gis-viewer'; -import info from '@cloudbeaver/plugin-info'; +import help from '@cloudbeaver/plugin-help'; import localization from '@cloudbeaver/plugin-localization'; import objectViewer from '@cloudbeaver/plugin-object-viewer'; import productPlugin from '@cloudbeaver/plugin-product'; @@ -56,7 +56,7 @@ const PLUGINS: PluginManifest[] = [ productPlugin, settingsMenu, settingsMenuAdministration, - info, + help, ]; bootstrap(PLUGINS); From 6819905aa7256b64260c8122e1a6633a57e5e120 Mon Sep 17 00:00:00 2001 From: Naumov Alexey Date: Wed, 2 Feb 2022 17:15:29 +0300 Subject: [PATCH 3/3] feat(plugin-info): CB-1450 simplify code --- .../plugin-help/src/{Info.tsx => Help.tsx} | 2 +- .../plugin-help/src/PluginBootstrap.ts | 4 ++-- .../plugin-help/src/Shortcuts/Shortcut.tsx | 19 ++++++++----------- 3 files changed, 11 insertions(+), 14 deletions(-) rename webapp/packages/plugin-help/src/{Info.tsx => Help.tsx} (96%) diff --git a/webapp/packages/plugin-help/src/Info.tsx b/webapp/packages/plugin-help/src/Help.tsx similarity index 96% rename from webapp/packages/plugin-help/src/Info.tsx rename to webapp/packages/plugin-help/src/Help.tsx index b18378df98..2132866d36 100644 --- a/webapp/packages/plugin-help/src/Info.tsx +++ b/webapp/packages/plugin-help/src/Help.tsx @@ -36,7 +36,7 @@ const styles = composes( ` ); -export const Info = observer(function Info() { +export const Help = observer(function Help() { const style = useStyles(styles); const commonDialogService = useService(CommonDialogService); diff --git a/webapp/packages/plugin-help/src/PluginBootstrap.ts b/webapp/packages/plugin-help/src/PluginBootstrap.ts index e30807d624..36b2e2d21e 100644 --- a/webapp/packages/plugin-help/src/PluginBootstrap.ts +++ b/webapp/packages/plugin-help/src/PluginBootstrap.ts @@ -9,7 +9,7 @@ import { TopNavService } from '@cloudbeaver/core-app'; import { Bootstrap, injectable } from '@cloudbeaver/core-di'; -import { Info } from './Info'; +import { Help } from './Help'; @injectable() export class PluginBootstrap extends Bootstrap { @@ -22,6 +22,6 @@ export class PluginBootstrap extends Bootstrap { async load(): Promise { } register(): void { - this.topNavService.placeholder.add(Info, 4); + this.topNavService.placeholder.add(Help, 4); } } diff --git a/webapp/packages/plugin-help/src/Shortcuts/Shortcut.tsx b/webapp/packages/plugin-help/src/Shortcuts/Shortcut.tsx index a87fcbfedc..23f756cb4d 100644 --- a/webapp/packages/plugin-help/src/Shortcuts/Shortcut.tsx +++ b/webapp/packages/plugin-help/src/Shortcuts/Shortcut.tsx @@ -60,17 +60,14 @@ export const Shortcut: React.FC = function Shortcut({ shortcut }) { {translate(shortcut.label)} - {shortcut.code.map((code, index, array) => { - const next = !!array[index + 1]; - return ( - <> - - {code} - - {next && {translate('ui_or')}} - - ); - })} + {shortcut.code.map((code, index) => ( + <> + {index > 0 && {translate('ui_or')}} + + {code} + + + ))} );