From 1944dcd040e036e63d0a8115a4d3dcbd2e3a1c29 Mon Sep 17 00:00:00 2001 From: naumov Date: Tue, 3 Feb 2026 18:31:23 +0100 Subject: [PATCH 1/2] dbeaver/pro#8197 add connection preferences plugin --- .../src/CONNECTION_CONFIG_SCHEMA.ts | 51 +++++++++++ webapp/packages/core-connections/src/index.ts | 1 + .../plugin-connection-preferences/.gitignore | 17 ++++ .../package.json | 52 ++++++++++++ .../src/ConnectionPreferencesBootstrap.ts | 57 +++++++++++++ .../ConnectionPreferencesForm.tsx | 85 +++++++++++++++++++ ...ConnectionPreferencesFormActionsContext.ts | 16 ++++ .../ConnectionPreferencesFormBaseActions.tsx | 38 +++++++++ .../ConnectionPreferencesFormInfo.tsx | 29 +++++++ .../ConnectionPreferencesFormInfoPart.ts | 44 ++++++++++ .../ConnectionPreferencesInfoTabService.ts | 32 +++++++ .../IConnectionPreferencesFormInfoState.ts | 14 +++ .../getConnectionPreferencesFormInfoPart.ts | 25 ++++++ .../ConnectionPreferencesFormLoader.ts | 13 +++ .../ConnectionPreferencesFormService.ts | 30 +++++++ .../ConnectionPreferencesFormState.ts | 18 ++++ .../IConnectionPreferencesFormState.ts | 20 +++++ .../src/ConnectionPreferencesPanel.tsx | 30 +++++++ .../src/ConnectionPreferencesPanelService.ts | 50 +++++++++++ .../src/LocaleService.ts | 38 +++++++++ .../actions/ACTION_CONNECTION_PREFERENCES.ts | 13 +++ .../src/index.ts | 9 ++ .../src/locales/en.ts | 3 + .../src/locales/fr.ts | 3 + .../src/locales/it.ts | 3 + .../src/locales/ru.ts | 3 + .../src/locales/vi.ts | 3 + .../src/locales/zh.ts | 3 + .../src/module.ts | 30 +++++++ .../tsconfig.json | 64 ++++++++++++++ .../packages/plugin-set-common/package.json | 1 + .../packages/plugin-set-common/src/index.ts | 2 + .../packages/plugin-set-common/tsconfig.json | 3 + webapp/yarn.lock | 32 +++++++ 34 files changed, 832 insertions(+) create mode 100644 webapp/packages/core-connections/src/CONNECTION_CONFIG_SCHEMA.ts create mode 100644 webapp/packages/plugin-connection-preferences/.gitignore create mode 100644 webapp/packages/plugin-connection-preferences/package.json create mode 100644 webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesBootstrap.ts create mode 100644 webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesForm.tsx create mode 100644 webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesFormActionsContext.ts create mode 100644 webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesFormBaseActions.tsx create mode 100644 webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesFormInfo/ConnectionPreferencesFormInfo.tsx create mode 100644 webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesFormInfo/ConnectionPreferencesFormInfoPart.ts create mode 100644 webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesFormInfo/ConnectionPreferencesInfoTabService.ts create mode 100644 webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesFormInfo/IConnectionPreferencesFormInfoState.ts create mode 100644 webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesFormInfo/getConnectionPreferencesFormInfoPart.ts create mode 100644 webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesFormLoader.ts create mode 100644 webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesFormService.ts create mode 100644 webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesFormState.ts create mode 100644 webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/IConnectionPreferencesFormState.ts create mode 100644 webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesPanel.tsx create mode 100644 webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesPanelService.ts create mode 100644 webapp/packages/plugin-connection-preferences/src/LocaleService.ts create mode 100644 webapp/packages/plugin-connection-preferences/src/actions/ACTION_CONNECTION_PREFERENCES.ts create mode 100644 webapp/packages/plugin-connection-preferences/src/index.ts create mode 100644 webapp/packages/plugin-connection-preferences/src/locales/en.ts create mode 100644 webapp/packages/plugin-connection-preferences/src/locales/fr.ts create mode 100644 webapp/packages/plugin-connection-preferences/src/locales/it.ts create mode 100644 webapp/packages/plugin-connection-preferences/src/locales/ru.ts create mode 100644 webapp/packages/plugin-connection-preferences/src/locales/vi.ts create mode 100644 webapp/packages/plugin-connection-preferences/src/locales/zh.ts create mode 100644 webapp/packages/plugin-connection-preferences/src/module.ts create mode 100644 webapp/packages/plugin-connection-preferences/tsconfig.json diff --git a/webapp/packages/core-connections/src/CONNECTION_CONFIG_SCHEMA.ts b/webapp/packages/core-connections/src/CONNECTION_CONFIG_SCHEMA.ts new file mode 100644 index 00000000000..9549220ddb6 --- /dev/null +++ b/webapp/packages/core-connections/src/CONNECTION_CONFIG_SCHEMA.ts @@ -0,0 +1,51 @@ +/* + * 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 { DriverConfigurationType, NetworkHandlerAuthType } from '@cloudbeaver/core-sdk'; +import { schema } from '@cloudbeaver/core-utils'; + +export const CONNECTION_PROPERTIES_SCHEMA = schema.record(schema.string(), schema.any()); + +export const CONNECTION_NETWORK_HANDLER_SCHEMA = schema.object({ + id: schema.string(), + authType: schema.nativeEnum(NetworkHandlerAuthType).optional(), + enabled: schema.boolean().optional(), + key: schema.string().optional(), + password: schema.string().optional(), + properties: schema.record(schema.string(), schema.any()).optional(), + savePassword: schema.boolean().optional(), + secureProperties: schema.record(schema.string(), schema.any()).optional(), + userName: schema.string().optional(), +}); + +export const CONNECTION_CONFIG_SCHEMA = schema.object({ + authModelId: schema.string().optional(), + configurationType: schema.enum([DriverConfigurationType.Manual, DriverConfigurationType.Url]).optional(), + connectionId: schema.string().optional(), + credentials: schema.record(schema.string(), schema.any()).optional(), + dataSourceId: schema.string().optional(), + databaseName: schema.string().optional(), + description: schema.string().optional(), + driverId: schema.string().optional(), + folder: schema.string().optional(), + host: schema.string().optional(), + mainPropertyValues: schema.record(schema.string(), schema.any()).optional(), + expertSettingsValues: schema.record(schema.string(), schema.any()).optional(), + name: schema.string().optional(), + networkHandlersConfig: schema.array(CONNECTION_NETWORK_HANDLER_SCHEMA).optional(), + port: schema.string().optional(), + properties: CONNECTION_PROPERTIES_SCHEMA.optional(), + providerProperties: schema.record(schema.string(), schema.any()).optional(), + saveCredentials: schema.boolean().optional(), + selectedSecretId: schema.string().optional(), + serverName: schema.string().optional(), + sharedCredentials: schema.boolean().optional(), + url: schema.string().optional(), + userName: schema.string().optional(), + userPassword: schema.string().optional(), +}); diff --git a/webapp/packages/core-connections/src/index.ts b/webapp/packages/core-connections/src/index.ts index cf3a56fe406..de251b4ecd1 100644 --- a/webapp/packages/core-connections/src/index.ts +++ b/webapp/packages/core-connections/src/index.ts @@ -64,3 +64,4 @@ export * from './useDBDriver.js'; export * from './USER_NAME_PROPERTY_ID.js'; export * from './parseConnectionKey.js'; export * from './DBDriverExpertSettingsResource.js'; +export * from './CONNECTION_CONFIG_SCHEMA.js'; diff --git a/webapp/packages/plugin-connection-preferences/.gitignore b/webapp/packages/plugin-connection-preferences/.gitignore new file mode 100644 index 00000000000..15bc16c7c31 --- /dev/null +++ b/webapp/packages/plugin-connection-preferences/.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-connection-preferences/package.json b/webapp/packages/plugin-connection-preferences/package.json new file mode 100644 index 00000000000..5b938f6da7c --- /dev/null +++ b/webapp/packages/plugin-connection-preferences/package.json @@ -0,0 +1,52 @@ +{ + "name": "@cloudbeaver/plugin-connection-preferences", + "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", + "validate-dependencies": "core-cli-validate-dependencies" + }, + "dependencies": { + "@cloudbeaver/core-blocks": "workspace:*", + "@cloudbeaver/core-connections": "workspace:*", + "@cloudbeaver/core-data-context": "workspace:*", + "@cloudbeaver/core-di": "workspace:*", + "@cloudbeaver/core-events": "workspace:*", + "@cloudbeaver/core-executor": "workspace:*", + "@cloudbeaver/core-localization": "workspace:*", + "@cloudbeaver/core-navigation-tree": "workspace:*", + "@cloudbeaver/core-sdk": "workspace:*", + "@cloudbeaver/core-ui": "workspace:*", + "@cloudbeaver/core-utils": "workspace:*", + "@cloudbeaver/core-view": "workspace:*", + "@dbeaver/js-helpers": "workspace:*", + "mobx": "^6", + "mobx-react-lite": "^4", + "react": "^19", + "react-dom": "^19", + "tslib": "^2" + }, + "devDependencies": { + "@cloudbeaver/core-cli": "workspace:*", + "@cloudbeaver/tsconfig": "workspace:*", + "@types/react": "^19", + "rimraf": "^6", + "typescript": "^5", + "typescript-plugin-css-modules": "^5" + } +} diff --git a/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesBootstrap.ts b/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesBootstrap.ts new file mode 100644 index 00000000000..8a98d0b63df --- /dev/null +++ b/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesBootstrap.ts @@ -0,0 +1,57 @@ +/* + * 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 { DATA_CONTEXT_CONNECTION } from '@cloudbeaver/core-connections'; +import { Bootstrap, injectable } from '@cloudbeaver/core-di'; +import { ActionService, MenuService } from '@cloudbeaver/core-view'; +import { DATA_CONTEXT_NAV_NODE, EObjectFeature } from '@cloudbeaver/core-navigation-tree'; + +import { ACTION_CONNECTION_PREFERENCES } from './actions/ACTION_CONNECTION_PREFERENCES.js'; +import { ConnectionPreferencesPanelService } from './ConnectionPreferencesPanelService.js'; + +@injectable(() => [ActionService, MenuService, ConnectionPreferencesPanelService]) +export class ConnectionPreferencesBootstrap extends Bootstrap { + constructor( + private readonly actionService: ActionService, + private readonly menuService: MenuService, + private readonly connectionPreferencesPanelService: ConnectionPreferencesPanelService, + ) { + super(); + } + + override register(): void { + this.menuService.addCreator({ + root: true, + contexts: [DATA_CONTEXT_CONNECTION, DATA_CONTEXT_NAV_NODE], + isApplicable: context => { + const node = context.get(DATA_CONTEXT_NAV_NODE)!; + return node.objectFeatures.includes(EObjectFeature.dataSource); + }, + getItems: (context, items) => [...items, ACTION_CONNECTION_PREFERENCES], + }); + + this.actionService.addHandler({ + id: 'connection-preferences', + actions: [ACTION_CONNECTION_PREFERENCES], + contexts: [DATA_CONTEXT_CONNECTION], + isActionApplicable: (context, action) => { + if (action === ACTION_CONNECTION_PREFERENCES) { + const connectionKey = context.get(DATA_CONTEXT_CONNECTION)!; + console.log(connectionKey); + return true; + } + + return true; + }, + handler: async (context, action) => { + const connectionKey = context.get(DATA_CONTEXT_CONNECTION)!; + await this.connectionPreferencesPanelService.open(connectionKey); + }, + }); + } +} diff --git a/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesForm.tsx b/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesForm.tsx new file mode 100644 index 00000000000..7b7da9dbf85 --- /dev/null +++ b/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesForm.tsx @@ -0,0 +1,85 @@ +/* + * 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 { Form, Loader, Placeholder, StatusMessage, useForm, useObjectRef } from '@cloudbeaver/core-blocks'; +import { useService } from '@cloudbeaver/core-di'; +import { ENotificationType, NotificationService } from '@cloudbeaver/core-events'; +import type { ConnectionConfig } from '@cloudbeaver/core-sdk'; +import { ExecutionContext } from '@cloudbeaver/core-executor'; +import { TabList, TabPanelList, TabsState, type IFormState } from '@cloudbeaver/core-ui'; +import { getFirstException } from '@cloudbeaver/core-utils'; + +import { ConnectionPreferencesFormService } from './ConnectionPreferencesFormService.js'; +import type { ConnectionPreferencesFormState } from './ConnectionPreferencesFormState.js'; +import type { IConnectionPreferencesFormState } from './IConnectionPreferencesFormState.js'; +import { ConnectionPreferencesFormActionsContext, type IConnectionPreferencesFormActionsContext } from './ConnectionPreferencesFormActionsContext.js'; +import { getConnectionPreferencesFormInfoPart } from './ConnectionPreferencesFormInfo/getConnectionPreferencesFormInfoPart.js'; + +export interface ConnectionPreferencesFormProps { + formState: ConnectionPreferencesFormState; + onCancel?: () => void; + onSave?: (config: ConnectionConfig) => void; +} + +export const ConnectionPreferencesForm = observer(function ConnectionPreferencesForm({ formState, onCancel, onSave = () => { } }) { + const connectionPreferencesFormServicee = useService(ConnectionPreferencesFormService); + const notificationService = useService(NotificationService); + + const infoPart = getConnectionPreferencesFormInfoPart(formState); + const exception = getFirstException(formState.exception); + + const form = useForm({ + onSubmit: async event => { + const context = new ExecutionContext>(formState); + + const saved = await formState.save(context); + + if (saved) { + notificationService.notify( + { + title: 'core_connections_connection_update_success', + message: infoPart.state.name, + }, + ENotificationType.Success, + ); + + onSave(infoPart.state); + } + }, + }); + + const actionsContext = useObjectRef(() => ({ + save: () => form.submit(new SubmitEvent('submit')), + onCancel, + })); + + return ( +
+ + + +
+ + + + + +
+ +
+
+
+
+ ); +}); diff --git a/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesFormActionsContext.ts b/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesFormActionsContext.ts new file mode 100644 index 00000000000..a796a7b4238 --- /dev/null +++ b/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesFormActionsContext.ts @@ -0,0 +1,16 @@ +/* + * 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 { createContext } from 'react'; + +export interface IConnectionPreferencesFormActionsContext { + save: () => Promise; + onCancel?: () => void; +} + +export const ConnectionPreferencesFormActionsContext = createContext(null); diff --git a/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesFormBaseActions.tsx b/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesFormBaseActions.tsx new file mode 100644 index 00000000000..be7158d0fb1 --- /dev/null +++ b/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesFormBaseActions.tsx @@ -0,0 +1,38 @@ +/* + * 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 { useContext } from 'react'; + +import { Button, type PlaceholderComponent, useTranslate } from '@cloudbeaver/core-blocks'; + +import { ConnectionPreferencesFormActionsContext } from './ConnectionPreferencesFormActionsContext.js'; +import type { IConnectionPreferencesFormProps } from './IConnectionPreferencesFormState.js'; + +export const ConnectionPreferencesFormBaseActions: PlaceholderComponent = observer(function ConnectionPreferencesFormBaseActions({ formState }) { + const actions = useContext(ConnectionPreferencesFormActionsContext); + + if (!actions) { + throw new Error('ConnectionPreferencesFormActionsContext not provided'); + } + + const translate = useTranslate(); + + return ( + <> + {actions.onCancel && ( + + )} + + + ); +}); diff --git a/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesFormInfo/ConnectionPreferencesFormInfo.tsx b/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesFormInfo/ConnectionPreferencesFormInfo.tsx new file mode 100644 index 00000000000..7db9a598aed --- /dev/null +++ b/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesFormInfo/ConnectionPreferencesFormInfo.tsx @@ -0,0 +1,29 @@ +/* + * 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 { useTab, type TabContainerPanelComponent } from '@cloudbeaver/core-ui'; +import { useAutoLoad } from '@cloudbeaver/core-blocks'; + +import type { IConnectionPreferencesFormProps } from '../IConnectionPreferencesFormState.js'; +import { getConnectionPreferencesFormInfoPart } from './getConnectionPreferencesFormInfoPart.js'; + + +export const ConnectionPreferencesFormInfo: TabContainerPanelComponent = observer(function ConnectionPreferencesFormInfo({ formState, tabId }) { + const infoPart = getConnectionPreferencesFormInfoPart(formState); + const tab = useTab(tabId); + + useAutoLoad(ConnectionPreferencesFormInfo, infoPart, tab.selected); + + return ( +
+ {infoPart.state.name} +
+ ); +}); \ No newline at end of file diff --git a/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesFormInfo/ConnectionPreferencesFormInfoPart.ts b/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesFormInfo/ConnectionPreferencesFormInfoPart.ts new file mode 100644 index 00000000000..f54036daa08 --- /dev/null +++ b/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesFormInfo/ConnectionPreferencesFormInfoPart.ts @@ -0,0 +1,44 @@ +/* + * 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 { FormPart, type IFormState } from '@cloudbeaver/core-ui'; +import { createConnectionParam, type ConnectionInfoResource } from '@cloudbeaver/core-connections'; + +import type { IConnectionPreferencesFormState } from '../IConnectionPreferencesFormState.js'; +import type { IConnectionPreferencesFormInfoState } from './IConnectionPreferencesFormInfoState.js'; + +function getInitialState(): IConnectionPreferencesFormInfoState { + return {}; +} + +export class ConnectionPreferencesFormInfoPart extends FormPart { + constructor( + formState: IFormState, + private readonly connectionInfoResource: ConnectionInfoResource, + ) { + super(formState, getInitialState()); + } + + protected override async loader(): Promise { + if (this.formState.mode === 'edit' && this.formState.state) { + const key = createConnectionParam(this.formState.state.projectId, this.formState.state.connectionId); + const connection = await this.connectionInfoResource.load(key); + + this.setInitialState({ + name: connection.name, + folder: connection.folder, + }); + + return; + } + + this.setInitialState(getInitialState()); + } + + protected override async saveChanges(): Promise {} +} diff --git a/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesFormInfo/ConnectionPreferencesInfoTabService.ts b/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesFormInfo/ConnectionPreferencesInfoTabService.ts new file mode 100644 index 00000000000..e22c62c32a5 --- /dev/null +++ b/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesFormInfo/ConnectionPreferencesInfoTabService.ts @@ -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 { Bootstrap, injectable } from '@cloudbeaver/core-di'; +import { importLazyComponent } from '@cloudbeaver/core-blocks'; + +import { ConnectionPreferencesFormService } from '../ConnectionPreferencesFormService.js'; + +const ConnectionPreferencesFormInfo = importLazyComponent(() => + import('./ConnectionPreferencesFormInfo.js').then(m => m.ConnectionPreferencesFormInfo), +); + +@injectable(() => [ConnectionPreferencesFormService]) +export class ConnectionPreferencesInfoTabService extends Bootstrap { + constructor(private readonly connectionFormService: ConnectionPreferencesFormService) { + super(); + } + + override register(): void { + this.connectionFormService.parts.add({ + key: 'preferences-info', + name: 'Info', + order: 1, + panel: () => ConnectionPreferencesFormInfo, + }); + } +} diff --git a/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesFormInfo/IConnectionPreferencesFormInfoState.ts b/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesFormInfo/IConnectionPreferencesFormInfoState.ts new file mode 100644 index 00000000000..434ffd7d7e4 --- /dev/null +++ b/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesFormInfo/IConnectionPreferencesFormInfoState.ts @@ -0,0 +1,14 @@ +/* + * 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 { schema } from '@cloudbeaver/core-utils'; +import { CONNECTION_CONFIG_SCHEMA } from '@cloudbeaver/core-connections'; + +export const CONNECTION_PREFERENCES_FORM_INFO_STATE_SCHEMA = CONNECTION_CONFIG_SCHEMA.pick({ name: true, folder: true }); + +export type IConnectionPreferencesFormInfoState = schema.infer; diff --git a/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesFormInfo/getConnectionPreferencesFormInfoPart.ts b/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesFormInfo/getConnectionPreferencesFormInfoPart.ts new file mode 100644 index 00000000000..2cda2a5b0ed --- /dev/null +++ b/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesFormInfo/getConnectionPreferencesFormInfoPart.ts @@ -0,0 +1,25 @@ +/* + * 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 { createDataContext, DATA_CONTEXT_DI_PROVIDER } from '@cloudbeaver/core-data-context'; +import type { IFormState } from '@cloudbeaver/core-ui'; +import { ConnectionInfoResource } from '@cloudbeaver/core-connections'; + +import { ConnectionPreferencesFormInfoPart } from './ConnectionPreferencesFormInfoPart.js'; +import type { IConnectionPreferencesFormState } from '../IConnectionPreferencesFormState.js'; + +const DATA_CONTEXT_TEAM_FORM_OPTIONS_PART = createDataContext('Connection Preferences Info Part'); + +export function getConnectionPreferencesFormInfoPart(formState: IFormState): ConnectionPreferencesFormInfoPart { + return formState.getPart(DATA_CONTEXT_TEAM_FORM_OPTIONS_PART, context => { + const di = context.get(DATA_CONTEXT_DI_PROVIDER)!; + const connectionInfoResource = di.getService(ConnectionInfoResource); + + return new ConnectionPreferencesFormInfoPart(formState, connectionInfoResource); + }); +} diff --git a/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesFormLoader.ts b/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesFormLoader.ts new file mode 100644 index 00000000000..5a8a69c384f --- /dev/null +++ b/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesFormLoader.ts @@ -0,0 +1,13 @@ +/* + * 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 ConnectionPreferencesFormLoader = importLazyComponent(() => + import('./ConnectionPreferencesForm.js').then(m => m.ConnectionPreferencesForm), +); diff --git a/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesFormService.ts b/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesFormService.ts new file mode 100644 index 00000000000..481d58a5563 --- /dev/null +++ b/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesFormService.ts @@ -0,0 +1,30 @@ +/* + * CloudBeaver - Cloud Database Manager + * Copyright (C) 2020-2025 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 { NotificationService } from '@cloudbeaver/core-events'; +import { LocalizationService } from '@cloudbeaver/core-localization'; +import { FormBaseService, type IFormState } from '@cloudbeaver/core-ui'; +import { importLazyComponent } from '@cloudbeaver/core-blocks'; + +import type { IConnectionPreferencesFormProps, IConnectionPreferencesFormState } from './IConnectionPreferencesFormState.js'; + +const ConnectionFormBaseActionsLoader = importLazyComponent(() => + import('./ConnectionPreferencesFormBaseActions.js').then(m => m.ConnectionPreferencesFormBaseActions), +); + +export type ConnectionFormContainerProps = { + formState: IFormState; +}; + +@injectable(() => [LocalizationService, NotificationService]) +export class ConnectionPreferencesFormService extends FormBaseService { + constructor(localizationService: LocalizationService, notificationService: NotificationService) { + super(localizationService, notificationService, 'Connection preferences form'); + this.actionsContainer.add(ConnectionFormBaseActionsLoader); + } +} diff --git a/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesFormState.ts b/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesFormState.ts new file mode 100644 index 00000000000..9e0439c237b --- /dev/null +++ b/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesFormState.ts @@ -0,0 +1,18 @@ +/* + * CloudBeaver - Cloud Database Manager + * Copyright (C) 2020-2025 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 { IServiceProvider } from '@cloudbeaver/core-di'; +import { FormState } from '@cloudbeaver/core-ui'; + +import type { IConnectionPreferencesFormState } from './IConnectionPreferencesFormState.js'; +import type { ConnectionPreferencesFormService } from './ConnectionPreferencesFormService.js'; + +export class ConnectionPreferencesFormState extends FormState { + constructor(serviceProvider: IServiceProvider, service: ConnectionPreferencesFormService, config: IConnectionPreferencesFormState) { + super(serviceProvider, service, config); + } +} diff --git a/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/IConnectionPreferencesFormState.ts b/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/IConnectionPreferencesFormState.ts new file mode 100644 index 00000000000..1da7b5d5849 --- /dev/null +++ b/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/IConnectionPreferencesFormState.ts @@ -0,0 +1,20 @@ +/* + * 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 { schema } from '@cloudbeaver/core-utils'; +import type { IFormProps } from '@cloudbeaver/core-ui'; + +export const CONNECTION_PREFERENCES_FORM_STATE_SCHEMA = schema + .object({ + projectId: schema.string(), + connectionId: schema.string(), + }) + .strict(); + +export type IConnectionPreferencesFormState = schema.infer; +export type IConnectionPreferencesFormProps = IFormProps; diff --git a/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesPanel.tsx b/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesPanel.tsx new file mode 100644 index 00000000000..07d1b15d93c --- /dev/null +++ b/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesPanel.tsx @@ -0,0 +1,30 @@ +/* + * 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 { useCallback } from 'react'; + +import { ColoredContainer, Loader } from '@cloudbeaver/core-blocks'; +import { useService } from '@cloudbeaver/core-di'; + +import { ConnectionPreferencesPanelService } from './ConnectionPreferencesPanelService.js'; +import { ConnectionPreferencesFormLoader } from './ConnectionPreferencesForm/ConnectionPreferencesFormLoader.js'; + +export const ConnectionPreferencesPanel: React.FC = observer(function ConnectionPreferencesPanel() { + const service = useService(ConnectionPreferencesPanelService); + + const close = useCallback(() => service.close(), [service]); + + return ( + + + {service.formState && } + + + ); +}); diff --git a/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesPanelService.ts b/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesPanelService.ts new file mode 100644 index 00000000000..ffb9c81aed7 --- /dev/null +++ b/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesPanelService.ts @@ -0,0 +1,50 @@ +/* + * 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, IServiceProvider } from '@cloudbeaver/core-di'; +import { FormMode, OptionsPanelService } from '@cloudbeaver/core-ui'; +import { importLazyComponent } from '@cloudbeaver/core-blocks'; +import type { IConnectionInfoParams } from '@cloudbeaver/core-connections'; + +import { ConnectionPreferencesFormState } from './ConnectionPreferencesForm/ConnectionPreferencesFormState.js'; +import { ConnectionPreferencesFormService } from './ConnectionPreferencesForm/ConnectionPreferencesFormService.js'; + +const ConnectionPreferencesPanel = importLazyComponent(() => import('./ConnectionPreferencesPanel.js').then(m => m.ConnectionPreferencesPanel)); + +const formGetter = () => ConnectionPreferencesPanel; + +@injectable(() => [OptionsPanelService, IServiceProvider, ConnectionPreferencesFormService]) +export class ConnectionPreferencesPanelService { + formState: ConnectionPreferencesFormState | null; + + constructor( + private readonly optionsPanelService: OptionsPanelService, + private readonly serviceProvider: IServiceProvider, + private readonly connectionPreferencesFormService: ConnectionPreferencesFormService, + ) { + this.formState = null; + } + + async open(connectionKey: IConnectionInfoParams): Promise { + const opened = await this.optionsPanelService.open(formGetter); + + if (opened) { + this.formState = new ConnectionPreferencesFormState(this.serviceProvider, this.connectionPreferencesFormService, { + projectId: connectionKey.projectId, + connectionId: connectionKey.connectionId, + }).setMode(FormMode.Edit); + } + } + + async close(): Promise { + await this.optionsPanelService.close(); + + this.formState?.dispose(); + this.formState = null; + } +} diff --git a/webapp/packages/plugin-connection-preferences/src/LocaleService.ts b/webapp/packages/plugin-connection-preferences/src/LocaleService.ts new file mode 100644 index 00000000000..5dec550ef8b --- /dev/null +++ b/webapp/packages/plugin-connection-preferences/src/LocaleService.ts @@ -0,0 +1,38 @@ +/* + * 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(); + } + + override register(): void { + 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; + default: + return (await import('./locales/en.js')).default; + } + } +} diff --git a/webapp/packages/plugin-connection-preferences/src/actions/ACTION_CONNECTION_PREFERENCES.ts b/webapp/packages/plugin-connection-preferences/src/actions/ACTION_CONNECTION_PREFERENCES.ts new file mode 100644 index 00000000000..582f4cff64e --- /dev/null +++ b/webapp/packages/plugin-connection-preferences/src/actions/ACTION_CONNECTION_PREFERENCES.ts @@ -0,0 +1,13 @@ +/* + * 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_PREFERENCES = createAction('connection-preferences', { + label: 'Preferences', +}); diff --git a/webapp/packages/plugin-connection-preferences/src/index.ts b/webapp/packages/plugin-connection-preferences/src/index.ts new file mode 100644 index 00000000000..36eb47b0b19 --- /dev/null +++ b/webapp/packages/plugin-connection-preferences/src/index.ts @@ -0,0 +1,9 @@ +/* + * 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 './module.js'; diff --git a/webapp/packages/plugin-connection-preferences/src/locales/en.ts b/webapp/packages/plugin-connection-preferences/src/locales/en.ts new file mode 100644 index 00000000000..074112722f4 --- /dev/null +++ b/webapp/packages/plugin-connection-preferences/src/locales/en.ts @@ -0,0 +1,3 @@ +export default [ + ['plugin_connection_preferences', 'Preferences'], +]; diff --git a/webapp/packages/plugin-connection-preferences/src/locales/fr.ts b/webapp/packages/plugin-connection-preferences/src/locales/fr.ts new file mode 100644 index 00000000000..074112722f4 --- /dev/null +++ b/webapp/packages/plugin-connection-preferences/src/locales/fr.ts @@ -0,0 +1,3 @@ +export default [ + ['plugin_connection_preferences', 'Preferences'], +]; diff --git a/webapp/packages/plugin-connection-preferences/src/locales/it.ts b/webapp/packages/plugin-connection-preferences/src/locales/it.ts new file mode 100644 index 00000000000..074112722f4 --- /dev/null +++ b/webapp/packages/plugin-connection-preferences/src/locales/it.ts @@ -0,0 +1,3 @@ +export default [ + ['plugin_connection_preferences', 'Preferences'], +]; diff --git a/webapp/packages/plugin-connection-preferences/src/locales/ru.ts b/webapp/packages/plugin-connection-preferences/src/locales/ru.ts new file mode 100644 index 00000000000..074112722f4 --- /dev/null +++ b/webapp/packages/plugin-connection-preferences/src/locales/ru.ts @@ -0,0 +1,3 @@ +export default [ + ['plugin_connection_preferences', 'Preferences'], +]; diff --git a/webapp/packages/plugin-connection-preferences/src/locales/vi.ts b/webapp/packages/plugin-connection-preferences/src/locales/vi.ts new file mode 100644 index 00000000000..074112722f4 --- /dev/null +++ b/webapp/packages/plugin-connection-preferences/src/locales/vi.ts @@ -0,0 +1,3 @@ +export default [ + ['plugin_connection_preferences', 'Preferences'], +]; diff --git a/webapp/packages/plugin-connection-preferences/src/locales/zh.ts b/webapp/packages/plugin-connection-preferences/src/locales/zh.ts new file mode 100644 index 00000000000..074112722f4 --- /dev/null +++ b/webapp/packages/plugin-connection-preferences/src/locales/zh.ts @@ -0,0 +1,3 @@ +export default [ + ['plugin_connection_preferences', 'Preferences'], +]; diff --git a/webapp/packages/plugin-connection-preferences/src/module.ts b/webapp/packages/plugin-connection-preferences/src/module.ts new file mode 100644 index 00000000000..05ae884d942 --- /dev/null +++ b/webapp/packages/plugin-connection-preferences/src/module.ts @@ -0,0 +1,30 @@ +/* + * 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, proxy } from '@cloudbeaver/core-di'; + +import { ConnectionPreferencesBootstrap } from './ConnectionPreferencesBootstrap.js'; +import { LocaleService } from './LocaleService.js'; +import { ConnectionPreferencesPanelService } from './ConnectionPreferencesPanelService.js'; +import { ConnectionPreferencesFormService } from './ConnectionPreferencesForm/ConnectionPreferencesFormService.js'; +import { ConnectionPreferencesInfoTabService } from './ConnectionPreferencesForm/ConnectionPreferencesFormInfo/ConnectionPreferencesInfoTabService.js'; + +export default ModuleRegistry.add({ + name: '@cloudbeaver/plugin-connection-preferences', + + configure: serviceCollection => { + serviceCollection + .addSingleton(Bootstrap, LocaleService) + .addSingleton(Bootstrap, proxy(ConnectionPreferencesBootstrap)) + .addSingleton(Bootstrap, proxy(ConnectionPreferencesInfoTabService)) + .addSingleton(ConnectionPreferencesInfoTabService) + .addSingleton(ConnectionPreferencesBootstrap) + .addSingleton(ConnectionPreferencesPanelService) + .addSingleton(ConnectionPreferencesFormService); + }, +}); diff --git a/webapp/packages/plugin-connection-preferences/tsconfig.json b/webapp/packages/plugin-connection-preferences/tsconfig.json new file mode 100644 index 00000000000..484cece16c3 --- /dev/null +++ b/webapp/packages/plugin-connection-preferences/tsconfig.json @@ -0,0 +1,64 @@ +{ + "extends": "@cloudbeaver/tsconfig/tsconfig.json", + "compilerOptions": { + "rootDir": "src", + "outDir": "lib", + "tsBuildInfoFile": "lib/tsconfig.tsbuildinfo", + "composite": true + }, + "references": [ + { + "path": "../../common-typescript/@dbeaver/js-helpers" + }, + { + "path": "../core-blocks" + }, + { + "path": "../core-cli" + }, + { + "path": "../core-connections" + }, + { + "path": "../core-data-context" + }, + { + "path": "../core-di" + }, + { + "path": "../core-events" + }, + { + "path": "../core-executor" + }, + { + "path": "../core-localization" + }, + { + "path": "../core-navigation-tree" + }, + { + "path": "../core-sdk" + }, + { + "path": "../core-ui" + }, + { + "path": "../core-utils" + }, + { + "path": "../core-view" + } + ], + "include": [ + "__custom_mocks__/**/*", + "src/**/*", + "src/**/*.json", + "src/**/*.css", + "src/**/*.scss" + ], + "exclude": [ + "**/node_modules", + "lib/**/*" + ] +} diff --git a/webapp/packages/plugin-set-common/package.json b/webapp/packages/plugin-set-common/package.json index 55960b942f2..df2262d75e0 100644 --- a/webapp/packages/plugin-set-common/package.json +++ b/webapp/packages/plugin-set-common/package.json @@ -65,6 +65,7 @@ "@cloudbeaver/plugin-browser": "workspace:*", "@cloudbeaver/plugin-codemirror6": "workspace:*", "@cloudbeaver/plugin-connection-custom": "workspace:*", + "@cloudbeaver/plugin-connection-preferences": "workspace:*", "@cloudbeaver/plugin-connection-search": "workspace:*", "@cloudbeaver/plugin-connection-view": "workspace:*", "@cloudbeaver/plugin-connections": "workspace:*", diff --git a/webapp/packages/plugin-set-common/src/index.ts b/webapp/packages/plugin-set-common/src/index.ts index 419481cbf7d..b493f11bb3a 100644 --- a/webapp/packages/plugin-set-common/src/index.ts +++ b/webapp/packages/plugin-set-common/src/index.ts @@ -110,6 +110,7 @@ import pluginAsyncTaskConfirmation from '@cloudbeaver/plugin-async-task-confirma import pluginSqlAsyncTaskConfirmation from '@cloudbeaver/plugin-sql-async-task-confirmation/module'; import pluginDataViewerConditionalFormatting from '@cloudbeaver/plugin-data-viewer-conditional-formatting/module'; import pluginConnectionView from '@cloudbeaver/plugin-connection-view/module'; +import pluginConnectionPreferences from '@cloudbeaver/plugin-connection-preferences/module'; const core = [ coreRouting, // important, should be first because the router starts in load phase first after all plugins register phase @@ -219,4 +220,5 @@ export const commonSet = [ pluginSqlAsyncTaskConfirmation, pluginDataViewerConditionalFormatting, pluginConnectionView, + pluginConnectionPreferences, ]; diff --git a/webapp/packages/plugin-set-common/tsconfig.json b/webapp/packages/plugin-set-common/tsconfig.json index 4190a27b9c3..2c341834f0f 100644 --- a/webapp/packages/plugin-set-common/tsconfig.json +++ b/webapp/packages/plugin-set-common/tsconfig.json @@ -139,6 +139,9 @@ { "path": "../plugin-connection-custom" }, + { + "path": "../plugin-connection-preferences" + }, { "path": "../plugin-connection-search" }, diff --git a/webapp/yarn.lock b/webapp/yarn.lock index df3ef509454..da5e2092464 100644 --- a/webapp/yarn.lock +++ b/webapp/yarn.lock @@ -2649,6 +2649,37 @@ __metadata: languageName: unknown linkType: soft +"@cloudbeaver/plugin-connection-preferences@workspace:*, @cloudbeaver/plugin-connection-preferences@workspace:packages/plugin-connection-preferences": + version: 0.0.0-use.local + resolution: "@cloudbeaver/plugin-connection-preferences@workspace:packages/plugin-connection-preferences" + dependencies: + "@cloudbeaver/core-blocks": "workspace:*" + "@cloudbeaver/core-cli": "workspace:*" + "@cloudbeaver/core-connections": "workspace:*" + "@cloudbeaver/core-data-context": "workspace:*" + "@cloudbeaver/core-di": "workspace:*" + "@cloudbeaver/core-events": "workspace:*" + "@cloudbeaver/core-executor": "workspace:*" + "@cloudbeaver/core-localization": "workspace:*" + "@cloudbeaver/core-navigation-tree": "workspace:*" + "@cloudbeaver/core-sdk": "workspace:*" + "@cloudbeaver/core-ui": "workspace:*" + "@cloudbeaver/core-utils": "workspace:*" + "@cloudbeaver/core-view": "workspace:*" + "@cloudbeaver/tsconfig": "workspace:*" + "@dbeaver/js-helpers": "workspace:*" + "@types/react": "npm:^19" + mobx: "npm:^6" + mobx-react-lite: "npm:^4" + react: "npm:^19" + react-dom: "npm:^19" + rimraf: "npm:^6" + tslib: "npm:^2" + typescript: "npm:^5" + typescript-plugin-css-modules: "npm:^5" + languageName: unknown + linkType: soft + "@cloudbeaver/plugin-connection-search@workspace:*, @cloudbeaver/plugin-connection-search@workspace:packages/plugin-connection-search": version: 0.0.0-use.local resolution: "@cloudbeaver/plugin-connection-search@workspace:packages/plugin-connection-search" @@ -3873,6 +3904,7 @@ __metadata: "@cloudbeaver/plugin-browser": "workspace:*" "@cloudbeaver/plugin-codemirror6": "workspace:*" "@cloudbeaver/plugin-connection-custom": "workspace:*" + "@cloudbeaver/plugin-connection-preferences": "workspace:*" "@cloudbeaver/plugin-connection-search": "workspace:*" "@cloudbeaver/plugin-connection-view": "workspace:*" "@cloudbeaver/plugin-connections": "workspace:*" From cdb54405c9c5ef8403f2e1f252e7519d7fe7e3ce Mon Sep 17 00:00:00 2001 From: naumov Date: Fri, 6 Feb 2026 23:17:32 +0100 Subject: [PATCH 2/2] dbeaver/pro#8197 add preferences form --- .../package.json | 1 + .../src/ConnectionPreferencesBootstrap.ts | 11 +----- .../ConnectionPreferencesForm.tsx | 34 ++++++++++------- .../ConnectionPreferencesFormInfo.tsx | 37 +++++++++++++++++-- .../ConnectionPreferencesFormInfoPart.ts | 2 + .../IConnectionPreferencesFormInfoState.ts | 7 +++- .../ConnectionPreferencesFormService.ts | 3 +- .../ConnectionPreferencesFormState.ts | 3 +- .../src/ConnectionPreferencesPanel.tsx | 2 +- .../src/index.ts | 3 ++ .../tsconfig.json | 3 ++ webapp/yarn.lock | 1 + 12 files changed, 76 insertions(+), 31 deletions(-) diff --git a/webapp/packages/plugin-connection-preferences/package.json b/webapp/packages/plugin-connection-preferences/package.json index 5b938f6da7c..84b7afe89e2 100644 --- a/webapp/packages/plugin-connection-preferences/package.json +++ b/webapp/packages/plugin-connection-preferences/package.json @@ -30,6 +30,7 @@ "@cloudbeaver/core-executor": "workspace:*", "@cloudbeaver/core-localization": "workspace:*", "@cloudbeaver/core-navigation-tree": "workspace:*", + "@cloudbeaver/core-projects": "workspace:*", "@cloudbeaver/core-sdk": "workspace:*", "@cloudbeaver/core-ui": "workspace:*", "@cloudbeaver/core-utils": "workspace:*", diff --git a/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesBootstrap.ts b/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesBootstrap.ts index 8a98d0b63df..bf49fc4b47b 100644 --- a/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesBootstrap.ts +++ b/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesBootstrap.ts @@ -39,16 +39,7 @@ export class ConnectionPreferencesBootstrap extends Bootstrap { id: 'connection-preferences', actions: [ACTION_CONNECTION_PREFERENCES], contexts: [DATA_CONTEXT_CONNECTION], - isActionApplicable: (context, action) => { - if (action === ACTION_CONNECTION_PREFERENCES) { - const connectionKey = context.get(DATA_CONTEXT_CONNECTION)!; - console.log(connectionKey); - return true; - } - - return true; - }, - handler: async (context, action) => { + handler: async context => { const connectionKey = context.get(DATA_CONTEXT_CONNECTION)!; await this.connectionPreferencesPanelService.open(connectionKey); }, diff --git a/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesForm.tsx b/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesForm.tsx index 7b7da9dbf85..5f38454502c 100644 --- a/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesForm.tsx +++ b/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesForm.tsx @@ -63,19 +63,27 @@ export const ConnectionPreferencesForm = observer - - -
- - - - - -
+
+
+
+
+ +
+ +
+
+ + + + + +
+
+
diff --git a/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesFormInfo/ConnectionPreferencesFormInfo.tsx b/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesFormInfo/ConnectionPreferencesFormInfo.tsx index 7db9a598aed..ddf279fb0f2 100644 --- a/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesFormInfo/ConnectionPreferencesFormInfo.tsx +++ b/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesFormInfo/ConnectionPreferencesFormInfo.tsx @@ -9,21 +9,50 @@ import { observer } from 'mobx-react-lite'; import { useTab, type TabContainerPanelComponent } from '@cloudbeaver/core-ui'; -import { useAutoLoad } from '@cloudbeaver/core-blocks'; +import { InputField, Textarea, useAutoLoad, useTranslate, useResource, Group, ColoredContainer, IconOrImage } from '@cloudbeaver/core-blocks'; +import { ProjectInfoResource } from '@cloudbeaver/core-projects'; +import { DBDriverResource } from '@cloudbeaver/core-connections'; import type { IConnectionPreferencesFormProps } from '../IConnectionPreferencesFormState.js'; import { getConnectionPreferencesFormInfoPart } from './getConnectionPreferencesFormInfoPart.js'; export const ConnectionPreferencesFormInfo: TabContainerPanelComponent = observer(function ConnectionPreferencesFormInfo({ formState, tabId }) { + const translate = useTranslate(); const infoPart = getConnectionPreferencesFormInfoPart(formState); const tab = useTab(tabId); useAutoLoad(ConnectionPreferencesFormInfo, infoPart, tab.selected); + const projectInfoResource = useResource(ConnectionPreferencesFormInfo, ProjectInfoResource, formState.state.projectId); + const dbDriverResource = useResource(ConnectionPreferencesFormInfo, DBDriverResource, infoPart.state.driverId ?? null); + return ( -
- {infoPart.state.name} -
+ + + {dbDriverResource.data && ( + +
+ {dbDriverResource.data.icon && } + {translate('connections_connection_driver')} +
+
+ )} + + {translate('connections_connection_name')} + + {projectInfoResource.data && ( + + {translate('plugin_projects_project_select_label')} + + )} + + {translate('plugin_connections_connection_form_part_main_folder')} + + +
+
); }); \ No newline at end of file diff --git a/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesFormInfo/ConnectionPreferencesFormInfoPart.ts b/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesFormInfo/ConnectionPreferencesFormInfoPart.ts index f54036daa08..31730f682d8 100644 --- a/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesFormInfo/ConnectionPreferencesFormInfoPart.ts +++ b/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesFormInfo/ConnectionPreferencesFormInfoPart.ts @@ -30,8 +30,10 @@ export class ConnectionPreferencesFormInfoPart extends FormPart; diff --git a/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesFormService.ts b/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesFormService.ts index 481d58a5563..e16447be00a 100644 --- a/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesFormService.ts +++ b/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesFormService.ts @@ -1,10 +1,11 @@ /* * 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 { injectable } from '@cloudbeaver/core-di'; import { NotificationService } from '@cloudbeaver/core-events'; import { LocalizationService } from '@cloudbeaver/core-localization'; diff --git a/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesFormState.ts b/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesFormState.ts index 9e0439c237b..b7820e5bd94 100644 --- a/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesFormState.ts +++ b/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesForm/ConnectionPreferencesFormState.ts @@ -1,10 +1,11 @@ /* * 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 type { IServiceProvider } from '@cloudbeaver/core-di'; import { FormState } from '@cloudbeaver/core-ui'; diff --git a/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesPanel.tsx b/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesPanel.tsx index 07d1b15d93c..975200db069 100644 --- a/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesPanel.tsx +++ b/webapp/packages/plugin-connection-preferences/src/ConnectionPreferencesPanel.tsx @@ -21,7 +21,7 @@ export const ConnectionPreferencesPanel: React.FC = observer(function Connection const close = useCallback(() => service.close(), [service]); return ( - + {service.formState && } diff --git a/webapp/packages/plugin-connection-preferences/src/index.ts b/webapp/packages/plugin-connection-preferences/src/index.ts index 36eb47b0b19..0a1f485cf1d 100644 --- a/webapp/packages/plugin-connection-preferences/src/index.ts +++ b/webapp/packages/plugin-connection-preferences/src/index.ts @@ -7,3 +7,6 @@ */ import './module.js'; + +export * from './ConnectionPreferencesForm/ConnectionPreferencesFormService.js'; +export * from './ConnectionPreferencesForm/IConnectionPreferencesFormState.js'; diff --git a/webapp/packages/plugin-connection-preferences/tsconfig.json b/webapp/packages/plugin-connection-preferences/tsconfig.json index 484cece16c3..827a3cbedb7 100644 --- a/webapp/packages/plugin-connection-preferences/tsconfig.json +++ b/webapp/packages/plugin-connection-preferences/tsconfig.json @@ -37,6 +37,9 @@ { "path": "../core-navigation-tree" }, + { + "path": "../core-projects" + }, { "path": "../core-sdk" }, diff --git a/webapp/yarn.lock b/webapp/yarn.lock index da5e2092464..5cd957bd6af 100644 --- a/webapp/yarn.lock +++ b/webapp/yarn.lock @@ -2662,6 +2662,7 @@ __metadata: "@cloudbeaver/core-executor": "workspace:*" "@cloudbeaver/core-localization": "workspace:*" "@cloudbeaver/core-navigation-tree": "workspace:*" + "@cloudbeaver/core-projects": "workspace:*" "@cloudbeaver/core-sdk": "workspace:*" "@cloudbeaver/core-ui": "workspace:*" "@cloudbeaver/core-utils": "workspace:*"