-
Notifications
You must be signed in to change notification settings - Fork 525
Save scripts to custom locations (use import/export buttons) #4258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
devnaumov
merged 34 commits into
devel
from
7880-save-scripts-to-custom-locations-use-importexport-buttons
Apr 15, 2026
Merged
Changes from 25 commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
7f30576
dbeaver/pro#7880 adds MVP for saving script to cloud storage
sergeyteleshev 1fe973e
removes registerScriptExportController
sergeyteleshev be0c9c0
Merge branch 'devel' into 7880-save-scripts-to-custom-locations-use-i…
sergeyteleshev df24f91
finalizes the ui
sergeyteleshev 35c8d27
adds missing locales
sergeyteleshev 524e81d
introduces footer slot to use CommonDialog api
sergeyteleshev 21d66bf
adds locales
sergeyteleshev 7d26fd8
moves success message to the tab components itself
sergeyteleshev e2a6a83
Merge branch 'devel' into 7880-save-scripts-to-custom-locations-use-i…
sergeyteleshev 51138cf
Merge branch 'devel' into 7880-save-scripts-to-custom-locations-use-i…
sergeyteleshev c343a4c
pr small fixes
sergeyteleshev 1202f53
saves file with timestamp
sergeyteleshev 6719762
send notification with correct filename
sergeyteleshev 895cc1e
fixes locales
sergeyteleshev d1c7d51
uses different approach for handling dialog save
sergeyteleshev 6f8f985
cleanup
sergeyteleshev 6a36867
self review fixes
sergeyteleshev bae6e32
adds lazy import for export dialog
sergeyteleshev 066d16a
uses form API to save the dialog
sergeyteleshev b2235f1
fixes imports (tab -> panel)
sergeyteleshev af18122
uses react state for filename
sergeyteleshev fb5008f
Merge branch 'devel' into 7880-save-scripts-to-custom-locations-use-i…
sergeyteleshev 428f64e
build fix
sergeyteleshev 55068a7
handles form validation
sergeyteleshev 727dde8
sanitizes file name
sergeyteleshev 244cc0e
removes redundant form layout
sergeyteleshev 691f721
Merge branch 'devel' into 7880-save-scripts-to-custom-locations-use-i…
sergeyteleshev c04f44f
fixes bug: allows to load tree root with useTreeData
sergeyteleshev 36704c5
uses context api to resolve export script dialog instead of throwing …
sergeyteleshev 5feff49
Merge branch 'devel' into 7880-save-scripts-to-custom-locations-use-i…
dariamarutkina 9e963c9
dbeaver/pro#7880 do not show notification on local export
devnaumov 49021d3
Merge branch 'devel' into 7880-save-scripts-to-custom-locations-use-i…
dariamarutkina d121b49
dbeaver/pro#7880 remove notification from local export
devnaumov 697a245
Merge branch 'devel' into 7880-save-scripts-to-custom-locations-use-i…
dariamarutkina File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| { | ||
| "name": "@cloudbeaver/plugin-script-export", | ||
| "type": "module", | ||
| "sideEffects": [ | ||
| "./lib/module.js", | ||
| "./lib/index.js", | ||
| "src/**/*.css", | ||
| "src/**/*.scss", | ||
| "public/**/*" | ||
| ], | ||
| "version": "0.1.0", | ||
| "description": "", | ||
| "license": "Apache-2.0", | ||
| "exports": { | ||
| ".": "./lib/index.js", | ||
| "./module": "./lib/module.js" | ||
| }, | ||
| "scripts": { | ||
| "build": "tsc -b", | ||
| "clean": "rimraf --glob lib", | ||
| "lint": "eslint ./src/ --ext .ts,.tsx", | ||
| "test": "dbeaver-test", | ||
| "validate-dependencies": "core-cli-validate-dependencies" | ||
| }, | ||
| "dependencies": { | ||
| "@cloudbeaver/core-blocks": "workspace:*", | ||
| "@cloudbeaver/core-di": "workspace:*", | ||
| "@cloudbeaver/core-dialogs": "workspace:*", | ||
| "@cloudbeaver/core-localization": "workspace:*", | ||
| "@cloudbeaver/core-ui": "workspace:*", | ||
| "mobx": "^6", | ||
| "mobx-react-lite": "^4", | ||
| "react": "^19", | ||
| "react-dom": "^19", | ||
| "tslib": "^2" | ||
| }, | ||
| "devDependencies": { | ||
| "@cloudbeaver/core-cli": "workspace:*", | ||
| "@cloudbeaver/tsconfig": "workspace:*", | ||
| "@dbeaver/cli": "workspace:*", | ||
| "@types/react": "^19", | ||
| "@types/react-dom": "^19", | ||
| "rimraf": "^6", | ||
| "tslib": "^2", | ||
| "typescript": "^5" | ||
| } | ||
| } |
70 changes: 70 additions & 0 deletions
70
webapp/packages/plugin-script-export/src/ExportScriptDialog/ExportScriptDialog.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| /* | ||
| * CloudBeaver - Cloud Database Manager | ||
| * Copyright (C) 2020-2026 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 { useState } from 'react'; | ||
|
|
||
| import { | ||
| Button, | ||
| CommonDialogBody, | ||
| CommonDialogFooter, | ||
| CommonDialogHeader, | ||
| CommonDialogWrapper, | ||
| Fill, | ||
| Form, | ||
| Translate, | ||
| useForm, | ||
| } from '@cloudbeaver/core-blocks'; | ||
| import type { DialogComponent } from '@cloudbeaver/core-dialogs'; | ||
| import { useService } from '@cloudbeaver/core-di'; | ||
|
|
||
| import { ScriptExportService, type IScriptExportTabProps } from '../ScriptExportService.js'; | ||
| import { TabList, TabPanelList, TabsState } from '@cloudbeaver/core-ui'; | ||
|
|
||
| export const ExportScriptDialog: DialogComponent<IScriptExportTabProps> = observer(function ExportScriptDialog({ | ||
| payload, | ||
| resolveDialog, | ||
| rejectDialog, | ||
| className, | ||
| }) { | ||
| const scriptExportService = useService(ScriptExportService); | ||
| const [selectedTabId, setSelectedTabId] = useState<string | undefined>(undefined); | ||
| const form = useForm({ | ||
| onSubmit() { | ||
| resolveDialog(); | ||
| }, | ||
| }); | ||
|
|
||
| return ( | ||
| <Form context={form}> | ||
| <CommonDialogWrapper size="large" className={className} fixedWidth> | ||
| <CommonDialogHeader title="plugin_script_export_dialog_title" icon="/icons/export.svg" onReject={rejectDialog} /> | ||
| <TabsState | ||
| container={scriptExportService.tabsContainer} | ||
| currentTabId={selectedTabId} | ||
| lazy | ||
| onChange={tab => setSelectedTabId(tab.tabId)} | ||
| {...payload} | ||
| > | ||
| <CommonDialogBody noBodyPadding noOverflow> | ||
| <TabList className="theme-border-color-background tw:shrink-0 tw:px-3" underline /> | ||
| <TabPanelList className="tw:flex-col tw:gap-4 tw:p-6 tw:w-full tw:overflow-auto" /> | ||
| </CommonDialogBody> | ||
| <CommonDialogFooter> | ||
| <Button type="button" variant="secondary" onClick={() => rejectDialog()}> | ||
| <Translate token="ui_processing_cancel" /> | ||
| </Button> | ||
| <Fill /> | ||
| <Button type="button" onClick={() => form.submit()}> | ||
| <Translate token="ui_processing_save" /> | ||
| </Button> | ||
| </CommonDialogFooter> | ||
| </TabsState> | ||
| </CommonDialogWrapper> | ||
| </Form> | ||
| ); | ||
| }); | ||
11 changes: 11 additions & 0 deletions
11
webapp/packages/plugin-script-export/src/ExportScriptDialog/ExportScriptDialogLazy.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| /* | ||
| * CloudBeaver - Cloud Database Manager | ||
| * Copyright (C) 2020-2026 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 { importLazyComponent } from '@cloudbeaver/core-blocks'; | ||
|
|
||
| export const ExportScriptDialog = importLazyComponent(() => import('./ExportScriptDialog.js').then(module => module.ExportScriptDialog)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| /* | ||
| * CloudBeaver - Cloud Database Manager | ||
| * Copyright (C) 2020-2026 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(() => [LocalizationService]) | ||
| export class LocaleService extends Bootstrap { | ||
| constructor(private readonly localizationService: LocalizationService) { | ||
| super(); | ||
|
|
||
| this.localizationService.addProvider(this.provider.bind(this)); | ||
| } | ||
|
|
||
| private async provider(locale: string) { | ||
| switch (locale) { | ||
| case 'ru': | ||
| return (await import('./locales/ru.js')).default; | ||
| case 'it': | ||
| return (await import('./locales/it.js')).default; | ||
| case 'zh': | ||
| return (await import('./locales/zh.js')).default; | ||
| case 'fr': | ||
| return (await import('./locales/fr.js')).default; | ||
| case 'vi': | ||
| return (await import('./locales/vi.js')).default; | ||
| case 'en': | ||
| default: | ||
| return (await import('./locales/en.js')).default; | ||
| } | ||
| } | ||
| } |
32 changes: 32 additions & 0 deletions
32
webapp/packages/plugin-script-export/src/ScriptExportService.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| /* | ||
| * CloudBeaver - Cloud Database Manager | ||
| * Copyright (C) 2020-2026 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 { injectable } from '@cloudbeaver/core-di'; | ||
| import { TabsContainer } from '@cloudbeaver/core-ui'; | ||
| import { CommonDialogService } from '@cloudbeaver/core-dialogs'; | ||
| import { ExportScriptDialog } from './ExportScriptDialog/ExportScriptDialogLazy.js'; | ||
|
|
||
| export interface IScriptExportTabProps { | ||
| script: string; | ||
| fileName: string; | ||
| editorId: string; | ||
| projectId?: string; | ||
| connectionId?: string; | ||
| } | ||
|
|
||
| @injectable(() => [CommonDialogService]) | ||
| export class ScriptExportService { | ||
| readonly tabsContainer: TabsContainer<IScriptExportTabProps>; | ||
|
devnaumov marked this conversation as resolved.
|
||
|
|
||
| constructor(private readonly commonDialogService: CommonDialogService) { | ||
| this.tabsContainer = new TabsContainer('script_export_tabs'); | ||
| } | ||
|
|
||
| openExportDialog(props: IScriptExportTabProps) { | ||
| return this.commonDialogService.open(ExportScriptDialog, props); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| /* | ||
| * CloudBeaver - Cloud Database Manager | ||
| * Copyright (C) 2020-2026 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 * from './ScriptExportService.js'; | ||
| export * from './ExportScriptDialog/ExportScriptDialogLazy.js'; | ||
|
|
||
| import './module.js'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export default [['plugin_script_export_dialog_title', 'Export SQL Script']]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export default [['plugin_script_export_dialog_title', 'Exporter le script SQL']]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export default [['plugin_script_export_dialog_title', 'Esporta script SQL']]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export default [['plugin_script_export_dialog_title', 'Экспорт SQL-скрипта']]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export default [['plugin_script_export_dialog_title', 'Xuất tập lệnh SQL']]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export default [['plugin_script_export_dialog_title', '导出 SQL 脚本']]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| /* | ||
| * CloudBeaver - Cloud Database Manager | ||
| * Copyright (C) 2020-2026 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, ModuleRegistry } from '@cloudbeaver/core-di'; | ||
| import { LocaleService } from './LocaleService.js'; | ||
| import { ScriptExportService } from './ScriptExportService.js'; | ||
|
|
||
| export default ModuleRegistry.add({ | ||
| name: '@cloudbeaver/plugin-script-export', | ||
|
|
||
| configure: serviceCollection => { | ||
| serviceCollection.addSingleton(Bootstrap, LocaleService).addSingleton(ScriptExportService); | ||
| }, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| { | ||
| "extends": "@cloudbeaver/tsconfig/tsconfig.json", | ||
| "compilerOptions": { | ||
| "rootDir": "src", | ||
| "outDir": "lib", | ||
| "tsBuildInfoFile": "lib/tsconfig.tsbuildinfo", | ||
| "composite": true | ||
| }, | ||
| "references": [ | ||
| { | ||
| "path": "../../common-typescript/@dbeaver/cli" | ||
| }, | ||
| { | ||
| "path": "../core-blocks" | ||
| }, | ||
| { | ||
| "path": "../core-cli" | ||
| }, | ||
| { | ||
| "path": "../core-di" | ||
| }, | ||
| { | ||
| "path": "../core-di/tsconfig.json" | ||
| }, | ||
| { | ||
| "path": "../core-dialogs" | ||
| }, | ||
| { | ||
| "path": "../core-localization" | ||
| }, | ||
| { | ||
| "path": "../core-ui" | ||
| } | ||
| ], | ||
| "include": [ | ||
| "__custom_mocks__/**/*", | ||
| "src/**/*", | ||
| "src/**/*.json", | ||
| "src/**/*.css", | ||
| "src/**/*.scss" | ||
| ], | ||
| "exclude": [ | ||
| "**/node_modules", | ||
| "lib/**/*" | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like you are using this state just to pass to TabsState, you can omit it and keep only container