-
Notifications
You must be signed in to change notification settings - Fork 529
[CB] Ability to clone connections #4107
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
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
cfe3b36
dbeaver/pro#6998 adds clone connection in context menu
sergeyteleshev 642e1ec
adds copy to cloned connection
sergeyteleshev e0f7552
Merge branch 'devel' into 6998-cb-ability-to-clone-connections
EvgeniaBzzz 58ec90a
dbeaver/pro#6998 fix copy navigator settings
yagudin10 92bed85
preload connections names to create correct name for cloned node
sergeyteleshev 09f31e9
pr fixes: adds translation + unique name among all connections
sergeyteleshev 4fdca40
Merge branch 'devel' into 6998-cb-ability-to-clone-connections
sergeyteleshev 29d75cc
adds "копия" locale
sergeyteleshev 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
12 changes: 12 additions & 0 deletions
12
webapp/packages/plugin-connections/src/ContextMenu/Actions/ACTION_CONNECTION_CLONE.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,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. | ||
| */ | ||
| import { createAction } from '@cloudbeaver/core-view'; | ||
|
|
||
| export const ACTION_CONNECTION_CLONE = createAction('connection-clone', { | ||
| label: 'plugin_connections_connection_clone', | ||
| }); |
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 |
|---|---|---|
| @@ -1,28 +1,32 @@ | ||
| /* | ||
| * CloudBeaver - Cloud Database Manager | ||
| * Copyright (C) 2020-2025 DBeaver Corp and others | ||
| * 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 { | ||
| ConnectionInfoAuthPropertiesResource, | ||
| ConnectionInfoProjectKey, | ||
| ConnectionInfoResource, | ||
| ConnectionsManagerService, | ||
| ConnectionsSettingsService, | ||
| createConnectionParam, | ||
| DATA_CONTEXT_CONNECTION, | ||
| } from '@cloudbeaver/core-connections'; | ||
| import { Bootstrap, injectable } from '@cloudbeaver/core-di'; | ||
| import { LocalizationService } from '@cloudbeaver/core-localization'; | ||
| import { NotificationService } from '@cloudbeaver/core-events'; | ||
| import { DATA_CONTEXT_NAV_NODE, EObjectFeature } from '@cloudbeaver/core-navigation-tree'; | ||
| import { getCachedMapResourceLoaderState } from '@cloudbeaver/core-resource'; | ||
| import { ServerConfigResource } from '@cloudbeaver/core-root'; | ||
| import { getUniqueName } from '@cloudbeaver/core-utils'; | ||
| import { ACTION_DELETE, ActionService, MenuService } from '@cloudbeaver/core-view'; | ||
| import { MENU_APP_ACTIONS } from '@cloudbeaver/plugin-top-app-bar'; | ||
|
|
||
| import { PublicConnectionFormService } from '../PublicConnectionForm/PublicConnectionFormService.js'; | ||
| import { ACTION_CONNECTION_CHANGE_CREDENTIALS } from './Actions/ACTION_CONNECTION_CHANGE_CREDENTIALS.js'; | ||
| import { ACTION_CONNECTION_CLONE } from './Actions/ACTION_CONNECTION_CLONE.js'; | ||
| import { ACTION_CONNECTION_DISCONNECT } from './Actions/ACTION_CONNECTION_DISCONNECT.js'; | ||
| import { ACTION_CONNECTION_DISCONNECT_ALL } from './Actions/ACTION_CONNECTION_DISCONNECT_ALL.js'; | ||
| import { ACTION_CONNECTION_EDIT } from './Actions/ACTION_CONNECTION_EDIT.js'; | ||
|
|
@@ -38,6 +42,7 @@ import { MENU_CONNECTIONS } from './MENU_CONNECTIONS.js'; | |
| PublicConnectionFormService, | ||
| ConnectionsSettingsService, | ||
| ServerConfigResource, | ||
| LocalizationService, | ||
| ]) | ||
| export class ConnectionMenuBootstrap extends Bootstrap { | ||
| constructor( | ||
|
|
@@ -50,6 +55,7 @@ export class ConnectionMenuBootstrap extends Bootstrap { | |
| private readonly publicConnectionFormService: PublicConnectionFormService, | ||
| private readonly connectionsSettingsService: ConnectionsSettingsService, | ||
| private readonly serverConfigResource: ServerConfigResource, | ||
| private readonly localizationService: LocalizationService, | ||
| ) { | ||
| super(); | ||
| } | ||
|
|
@@ -64,6 +70,7 @@ export class ConnectionMenuBootstrap extends Bootstrap { | |
| ...items, | ||
| ACTION_CONNECTION_CHANGE_CREDENTIALS, | ||
| ACTION_CONNECTION_EDIT, | ||
| ACTION_CONNECTION_CLONE, | ||
| ACTION_CONNECTION_DISCONNECT, | ||
| ACTION_CONNECTION_DISCONNECT_ALL, | ||
| ], | ||
|
|
@@ -75,6 +82,7 @@ export class ConnectionMenuBootstrap extends Bootstrap { | |
| ACTION_DELETE, | ||
| ACTION_CONNECTION_CHANGE_CREDENTIALS, | ||
| ACTION_CONNECTION_EDIT, | ||
| ACTION_CONNECTION_CLONE, | ||
| ACTION_CONNECTION_DISCONNECT, | ||
| ACTION_CONNECTION_DISCONNECT_ALL, | ||
| ], | ||
|
|
@@ -108,6 +116,10 @@ export class ConnectionMenuBootstrap extends Bootstrap { | |
| return !(connection.canEdit || connection.canViewSettings); | ||
| } | ||
|
|
||
| if (action === ACTION_CONNECTION_CLONE) { | ||
| return !connection.canEdit; | ||
| } | ||
|
|
||
| if (action === ACTION_CONNECTION_CHANGE_CREDENTIALS) { | ||
| const auth = this.connectionInfoAuthPropertiesResource.get(connectionKey); | ||
| return !this.serverConfigResource.distributed || !!auth?.sharedCredentials; | ||
|
|
@@ -152,6 +164,27 @@ export class ConnectionMenuBootstrap extends Bootstrap { | |
| await this.connectionsManagerService.requireConnection({ connectionId: connection.id, projectId: connection.projectId }, true); | ||
| break; | ||
| } | ||
| case ACTION_CONNECTION_CLONE: { | ||
| try { | ||
| // Load all connections for the project first to ensure we have them all to generate a unique name for the cloned connection | ||
| const projectConnections = await this.connectionInfoResource.load(ConnectionInfoProjectKey(connection.projectId)); | ||
| const connectionNames = projectConnections.map(connection => connection.name); | ||
| const uniqueName = getUniqueName( | ||
| connection.name.concat(` ${this.localizationService.translate('ui_copy').toLowerCase()}`), | ||
| connectionNames, | ||
| ); | ||
|
|
||
| if (!connection.nodePath) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Its strange that we are relying on the nodePath and its optional, probably we need a new method where we can use connection Id to clone it |
||
| this.notificationService.logException(new Error('Connection node path is undefined'), 'plugin_connections_connection_clone_error'); | ||
| return; | ||
| } | ||
|
|
||
| await this.connectionInfoResource.createFromNode(connection.projectId, connection.nodePath, uniqueName); | ||
| } catch (exception: any) { | ||
| this.notificationService.logException(exception, 'plugin_connections_connection_clone_error'); | ||
| } | ||
| break; | ||
| } | ||
| } | ||
| }, | ||
| }); | ||
|
|
||
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
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.
This is possibly a heavy operation; maybe we should pass it to the backend side, so we can call the
clonemethod without specifying the name, and the backend will choose the right oneThere 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.
we've talked about it on standup call. backend said this is not a heavy calculation