From 52916b6a99ac267df025f910589e58362d48e67a Mon Sep 17 00:00:00 2001 From: Ainur Date: Fri, 7 Jun 2024 12:08:37 +0200 Subject: [PATCH 01/17] CB-5238 add main properties for connections --- .../cloudbeaver/model/WebConnectionInfo.java | 10 ++++ .../schema/service.core.graphqls | 21 ++++++-- .../src/io/cloudbeaver/WebServiceUtils.java | 49 +++++++++++++------ .../model/WebConnectionConfig.java | 7 +++ .../model/WebDatabaseDriverInfo.java | 7 +++ 5 files changed, 73 insertions(+), 21 deletions(-) diff --git a/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/WebConnectionInfo.java b/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/WebConnectionInfo.java index b4a22bb6a0..eca19edf52 100644 --- a/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/WebConnectionInfo.java +++ b/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/WebConnectionInfo.java @@ -384,6 +384,16 @@ public void fireCloseListeners() { } } + @Property + public Map getMainProperties() { + Map mainProperties = new LinkedHashMap<>(); + mainProperties.put(DBConstants.PROP_HOST, dataSourceContainer.getConnectionConfiguration().getHostName()); + mainProperties.put(DBConstants.PROP_PORT, dataSourceContainer.getConnectionConfiguration().getHostPort()); + mainProperties.put(DBConstants.PROP_DATABASE, dataSourceContainer.getConnectionConfiguration().getDatabaseName()); + mainProperties.put(DBConstants.PROP_SERVER, dataSourceContainer.getConnectionConfiguration().getServerName()); + return mainProperties; + } + @Property public Map getProviderProperties() { return dataSourceContainer.getConnectionConfiguration().getProviderProperties(); diff --git a/server/bundles/io.cloudbeaver.server/schema/service.core.graphqls b/server/bundles/io.cloudbeaver.server/schema/service.core.graphqls index 9aa007ffb4..cd6b9c9e2f 100644 --- a/server/bundles/io.cloudbeaver.server/schema/service.core.graphqls +++ b/server/bundles/io.cloudbeaver.server/schema/service.core.graphqls @@ -248,6 +248,10 @@ type DriverInfo { # Driver parameters (map name->value) driverParameters: Object! + # Main driver properties + # Contains info about main fields (host, port, database, server name) + mainProperties: [ObjectPropertyInfo!]! + # Additional driver provider properties # These properties can be configured by user on main connection page # to provide important connection settings @@ -281,7 +285,8 @@ enum ResultDataFormat { enum DriverConfigurationType { MANUAL, - URL + URL, + CUSTOM } ## Network handler config @@ -340,6 +345,8 @@ type ConnectionInfo { databaseName: String url: String + mainProperties: [ObjectPropertyInfo!] + keepAliveInterval: Int! properties: Object @@ -494,10 +501,14 @@ input ConnectionConfig { # Custom connection parameters (all optional) - host: String - port: String - serverName: String - databaseName: String + host: String @deprecated(reason: "24.1.1, use mainProperties") + port: String @deprecated(reason: "24.1.1, use mainProperties") + serverName: String @deprecated(reason: "24.1.1, use mainProperties") + databaseName: String @deprecated(reason: "24.1.1, use mainProperties") + + # Host, port, serverName, databaseName are stored and mainProperties + mainProperties: Object + # Connection url jdbc:{driver}://{host}[:{port}]/[{database}] url: String # Properties diff --git a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/WebServiceUtils.java b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/WebServiceUtils.java index d04e25b561..1cd403b9ea 100644 --- a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/WebServiceUtils.java +++ b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/WebServiceUtils.java @@ -33,6 +33,7 @@ import org.jkiss.code.NotNull; import org.jkiss.code.Nullable; import org.jkiss.dbeaver.Log; +import org.jkiss.dbeaver.model.DBConstants; import org.jkiss.dbeaver.model.DBPDataSourceContainer; import org.jkiss.dbeaver.model.access.DBAAuthCredentials; import org.jkiss.dbeaver.model.app.DBPDataSourceRegistry; @@ -150,22 +151,7 @@ public static DBPDataSourceContainer createConnectionFromConfig(WebConnectionCon } public static void setConnectionConfiguration(DBPDriver driver, DBPConnectionConfiguration dsConfig, WebConnectionConfig config) { - if (!CommonUtils.isEmpty(config.getUrl())) { - dsConfig.setUrl(config.getUrl()); - } else { - if (config.getHost() != null) { - dsConfig.setHostName(config.getHost()); - } - if (config.getPort() != null) { - dsConfig.setHostPort(config.getPort()); - } - if (config.getDatabaseName() != null) { - dsConfig.setDatabaseName(config.getDatabaseName()); - } - if (config.getServerName() != null) { - dsConfig.setServerName(config.getServerName()); - } - } + setMainProperties(dsConfig, config); if (config.getProperties() != null) { Map newProps = new LinkedHashMap<>(); for (Map.Entry pe : config.getProperties().entrySet()) { @@ -219,6 +205,37 @@ public static void setConnectionConfiguration(DBPDriver driver, DBPConnectionCon } } + private static void setMainProperties(DBPConnectionConfiguration dsConfig, WebConnectionConfig config) { + if (config.getMainProperties() != null) { + for (Map.Entry e : config.getMainProperties().entrySet()) { + switch (e.getKey()) { + case DBConstants.PROP_HOST -> dsConfig.setHostName(CommonUtils.toString(e.getValue())); + case DBConstants.PROP_PORT -> dsConfig.setHostPort(CommonUtils.toString(e.getValue())); + case DBConstants.PROP_DATABASE -> dsConfig.setDatabaseName(CommonUtils.toString(e.getValue())); + case DBConstants.PROP_SERVER -> dsConfig.setServerName(CommonUtils.toString(e.getValue())); + default -> throw new IllegalStateException("Unexpected value: " + e.getKey()); + } + } + return; + } + if (!CommonUtils.isEmpty(config.getUrl())) { + dsConfig.setUrl(config.getUrl()); + return; + } + if (config.getHost() != null) { + dsConfig.setHostName(config.getHost()); + } + if (config.getPort() != null) { + dsConfig.setHostPort(config.getPort()); + } + if (config.getDatabaseName() != null) { + dsConfig.setDatabaseName(config.getDatabaseName()); + } + if (config.getServerName() != null) { + dsConfig.setServerName(config.getServerName()); + } + } + public static void saveAuthProperties( @NotNull DBPDataSourceContainer dataSourceContainer, @NotNull DBPConnectionConfiguration configuration, diff --git a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/model/WebConnectionConfig.java b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/model/WebConnectionConfig.java index 758ece7742..5527481a5e 100644 --- a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/model/WebConnectionConfig.java +++ b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/model/WebConnectionConfig.java @@ -57,6 +57,7 @@ public class WebConnectionConfig { private Map credentials; private boolean saveCredentials; private boolean sharedCredentials; + private Map mainProperties; private Map providerProperties; private List networkHandlersConfig; private DBPDriverConfigurationType configurationType; @@ -100,6 +101,7 @@ public WebConnectionConfig(Map params) { saveCredentials = JSONUtils.getBoolean(params, "saveCredentials"); sharedCredentials = JSONUtils.getBoolean(params, "sharedCredentials"); + mainProperties = JSONUtils.getObjectOrNull(params, "mainProperties"); providerProperties = JSONUtils.getObjectOrNull(params, "providerProperties"); String configType = JSONUtils.getString(params, "configurationType"); @@ -225,6 +227,11 @@ public void setSaveCredentials(boolean saveCredentials) { this.saveCredentials = saveCredentials; } + @Property + public Map getMainProperties() { + return mainProperties; + } + @Property public Map getProviderProperties() { return providerProperties; diff --git a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/model/WebDatabaseDriverInfo.java b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/model/WebDatabaseDriverInfo.java index 61f0a8e970..dc6119e5b1 100644 --- a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/model/WebDatabaseDriverInfo.java +++ b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/model/WebDatabaseDriverInfo.java @@ -233,6 +233,13 @@ public String getDefaultAuthModel() { return AuthModelDatabaseNative.ID; } + @Property + public WebPropertyInfo[] getMainProperties() { + return Arrays.stream(driver.getMainPropertyDescriptors()) + .map(p -> new WebPropertyInfo(webSession, p, null)) + .toArray(WebPropertyInfo[]::new); + } + @Property public WebPropertyInfo[] getProviderProperties() { return Arrays.stream(driver.getProviderPropertyDescriptors()) From 2f2ded9ae51c71a377f4f6c877808bf438bcf80d Mon Sep 17 00:00:00 2001 From: naumov Date: Mon, 10 Jun 2024 16:16:00 +0200 Subject: [PATCH 02/17] CB-5197 render main properties --- .../queries/fragments/DatabaseConnection.gql | 4 ++++ .../src/queries/fragments/DatabaseDriver.gql | 8 +++++-- .../Options/ConnectionOptionsTabService.ts | 8 +++++++ .../src/ConnectionForm/Options/Options.tsx | 22 ++++++++++++++++--- 4 files changed, 37 insertions(+), 5 deletions(-) diff --git a/webapp/packages/core-sdk/src/queries/fragments/DatabaseConnection.gql b/webapp/packages/core-sdk/src/queries/fragments/DatabaseConnection.gql index 62008518d6..7eed02cc81 100644 --- a/webapp/packages/core-sdk/src/queries/fragments/DatabaseConnection.gql +++ b/webapp/packages/core-sdk/src/queries/fragments/DatabaseConnection.gql @@ -17,6 +17,10 @@ fragment DatabaseConnection on ConnectionInfo { folder nodePath + mainProperties { + ...ObjectPropertyInfo + } + configurationType @include(if: $customIncludeOptions) useUrl @include(if: $customIncludeOptions) host @include(if: $customIncludeOptions) diff --git a/webapp/packages/core-sdk/src/queries/fragments/DatabaseDriver.gql b/webapp/packages/core-sdk/src/queries/fragments/DatabaseDriver.gql index e01ef408d4..809246bae9 100644 --- a/webapp/packages/core-sdk/src/queries/fragments/DatabaseDriver.gql +++ b/webapp/packages/core-sdk/src/queries/fragments/DatabaseDriver.gql @@ -22,8 +22,12 @@ fragment DatabaseDriver on DriverInfo { applicableNetworkHandlers configurationTypes + mainProperties { + ...ObjectPropertyInfo + } + providerProperties @include(if: $includeProviderProperties) { - ...DriverProviderPropertyInfo + ...DriverProviderPropertyInfo } driverProperties @include(if: $includeDriverProperties) { @@ -42,4 +46,4 @@ fragment DatabaseDriver on DriverInfo { name icon } -} \ No newline at end of file +} diff --git a/webapp/packages/plugin-connections/src/ConnectionForm/Options/ConnectionOptionsTabService.ts b/webapp/packages/plugin-connections/src/ConnectionForm/Options/ConnectionOptionsTabService.ts index 86c45f8abd..a76c5aaf21 100644 --- a/webapp/packages/plugin-connections/src/ConnectionForm/Options/ConnectionOptionsTabService.ts +++ b/webapp/packages/plugin-connections/src/ConnectionForm/Options/ConnectionOptionsTabService.ts @@ -242,6 +242,10 @@ export class ConnectionOptionsTabService extends Bootstrap { if (state.info.providerProperties) { state.config.providerProperties = { ...state.info.providerProperties }; } + + if (state.info.mainProperties) { + state.config.mainProperties = { ...state.info.mainProperties }; + } } private configure(data: IConnectionFormState, contexts: IExecutionContextProvider) { @@ -359,6 +363,10 @@ export class ConnectionOptionsTabService extends Bootstrap { } } + if (driver.mainProperties.length > 0) { + tempConfig.mainProperties = { ...state.config.mainProperties }; + } + runInAction(() => { Object.assign(config, tempConfig); }); diff --git a/webapp/packages/plugin-connections/src/ConnectionForm/Options/Options.tsx b/webapp/packages/plugin-connections/src/ConnectionForm/Options/Options.tsx index 8c9e53e45c..32e5e0ac82 100644 --- a/webapp/packages/plugin-connections/src/ConnectionForm/Options/Options.tsx +++ b/webapp/packages/plugin-connections/src/ConnectionForm/Options/Options.tsx @@ -21,6 +21,7 @@ import { GroupTitle, InputField, Link, + ObjectPropertyInfoForm, Radio, RadioGroup, s, @@ -36,6 +37,7 @@ import { useService } from '@cloudbeaver/core-di'; import { ServerConfigResource } from '@cloudbeaver/core-root'; import { DriverConfigurationType } from '@cloudbeaver/core-sdk'; import { type TabContainerPanelComponent, TabsContext, useAuthenticationAction } from '@cloudbeaver/core-ui'; +import { EMPTY_ARRAY } from '@cloudbeaver/core-utils'; import { ProjectSelect } from '@cloudbeaver/plugin-projects'; import { ConnectionAuthModelCredentialsForm } from '../ConnectionAuthModelCredentials/ConnectionAuthModelCredentialsForm'; @@ -67,6 +69,10 @@ const driverConfiguration: IDriverConfiguration[] = [ name: 'URL', value: DriverConfigurationType.Url, }, + { + name: 'Custom', + value: DriverConfigurationType.Custom, + }, ]; export const Options: TabContainerPanelComponent = observer(function Options({ state }) { @@ -141,7 +147,6 @@ export const Options: TabContainerPanelComponent = observe providerId: authModel?.requiredAuth ?? info?.requiredAuth ?? AUTH_PROVIDER_LOCAL_ID, }); - const isURLConfiguration = config.configurationType === DriverConfigurationType.Url; const edit = state.mode === 'edit'; const originLocal = !info || isLocalConnection(info); @@ -221,7 +226,7 @@ export const Options: TabContainerPanelComponent = observe )} - {isURLConfiguration ? ( + {config.configurationType === DriverConfigurationType.Url && ( = observe > {translate('customConnection_url_JDBC')} - ) : ( + )} + + {config.configurationType === DriverConfigurationType.Manual && ( = observe originLocal={originLocal} /> )} + + {config.configurationType === DriverConfigurationType.Custom && ( + + )} From f0ce0c37c52d807bed5ab34f2bf52ab114dc01a7 Mon Sep 17 00:00:00 2001 From: naumov Date: Tue, 11 Jun 2024 21:56:11 +0200 Subject: [PATCH 03/17] CB-5197 render main properties --- .../schema/service.core.graphqls | 2 +- .../ObjectPropertyInfoForm/RenderField.tsx | 15 +++- .../core-sdk/src/getObjectPropertyType.ts | 4 +- .../queries/fragments/DatabaseConnection.gql | 4 +- .../src/queries/fragments/DatabaseDriver.gql | 2 +- .../fragments/DriverMainPropertyInfo.gql | 14 ++++ .../Options/ConnectionOptionsTabService.ts | 75 ++++++++----------- .../src/ConnectionForm/Options/Options.tsx | 62 +++++++-------- .../Options/getDefaultConfigurationType.ts | 20 +++++ .../src/ConnectionForm/Options/useOptions.ts | 5 +- 10 files changed, 112 insertions(+), 91 deletions(-) create mode 100644 webapp/packages/core-sdk/src/queries/fragments/DriverMainPropertyInfo.gql create mode 100644 webapp/packages/plugin-connections/src/ConnectionForm/Options/getDefaultConfigurationType.ts diff --git a/server/bundles/io.cloudbeaver.server/schema/service.core.graphqls b/server/bundles/io.cloudbeaver.server/schema/service.core.graphqls index cd6b9c9e2f..293ff9b569 100644 --- a/server/bundles/io.cloudbeaver.server/schema/service.core.graphqls +++ b/server/bundles/io.cloudbeaver.server/schema/service.core.graphqls @@ -345,7 +345,7 @@ type ConnectionInfo { databaseName: String url: String - mainProperties: [ObjectPropertyInfo!] + mainProperties: Object keepAliveInterval: Int! diff --git a/webapp/packages/core-blocks/src/ObjectPropertyInfo/ObjectPropertyInfoForm/RenderField.tsx b/webapp/packages/core-blocks/src/ObjectPropertyInfo/ObjectPropertyInfoForm/RenderField.tsx index 20f73297ca..026954f0a6 100644 --- a/webapp/packages/core-blocks/src/ObjectPropertyInfo/ObjectPropertyInfoForm/RenderField.tsx +++ b/webapp/packages/core-blocks/src/ObjectPropertyInfo/ObjectPropertyInfoForm/RenderField.tsx @@ -6,6 +6,7 @@ * you may not use this file except in compliance with the License. */ import { observer } from 'mobx-react-lite'; +import type { HTMLInputTypeAttribute } from 'react'; import { getObjectPropertyType, type ObjectPropertyInfo, type ObjectPropertyType } from '@cloudbeaver/core-sdk'; import { removeMetadataFromDataURL } from '@cloudbeaver/core-utils'; @@ -229,11 +230,21 @@ export const RenderField = observer(function RenderField({ ); } + let type: HTMLInputTypeAttribute = 'text'; + + if (controlType === 'input:number') { + type = 'number'; + } + + if (password) { + type = 'password'; + } + if (state !== undefined) { return ( (function RenderField({ return ( { const { Options } = await import('./Options'); @@ -174,10 +175,7 @@ export class ConnectionOptionsTabService extends Bootstrap { const driver = await this.dbDriverResource.load(state.config.driverId, ['includeProviderProperties']); state.config.authModelId = driver?.defaultAuthModel; - - state.config.configurationType = driver?.configurationTypes.includes(DriverConfigurationType.Manual) - ? DriverConfigurationType.Manual - : DriverConfigurationType.Url; + state.config.configurationType = driver ? getDefaultConfigurationType(driver) : DriverConfigurationType.Manual; state.config.host = driver?.defaultServer || 'localhost'; state.config.port = driver?.defaultPort; @@ -205,6 +203,10 @@ export class ConnectionOptionsTabService extends Bootstrap { state.config.providerProperties = {}; } + if (!state.config.mainProperties || updated) { + state.config.mainProperties = {}; + } + if (!state.info) { await this.setDefaults(state); return; @@ -254,19 +256,6 @@ export class ConnectionOptionsTabService extends Bootstrap { configuration.include('includeOrigin', 'includeAuthProperties', 'includeCredentialsSaved', 'customIncludeOptions'); } - private getTrimmedPropertiesConfig(authProperties: ObjectPropertyInfo[], credentials: Record): Record { - const trimmedProperties: Record = toJS(credentials); - for (const property of authProperties) { - const value = credentials?.[property.id!]; - - if (typeof value === 'string' && value) { - trimmedProperties[property.id!] = value?.trim(); - } - } - - return trimmedProperties; - } - private async prepareConfig({ state }: IConnectionFormSubmitData, contexts: IExecutionContextProvider) { const config = contexts.getContext(connectionConfigContext); const credentialsState = contexts.getContext(connectionCredentialsStateContext); @@ -326,7 +315,7 @@ export class ConnectionOptionsTabService extends Bootstrap { const properties = await this.getConnectionAuthModelProperties(tempConfig.authModelId, state.info); if (this.isCredentialsChanged(properties, state.config.credentials)) { - tempConfig.credentials = this.getTrimmedPropertiesConfig(properties, { ...state.config.credentials }); + tempConfig.credentials = this.prepareDynamicProperties(properties, toJS(state.config.credentials)); } if (!tempConfig.saveCredentials) { @@ -335,41 +324,39 @@ export class ConnectionOptionsTabService extends Bootstrap { } if (driver.providerProperties.length > 0) { - const providerProperties: Record = { ...state.config.providerProperties }; + tempConfig.providerProperties = this.prepareDynamicProperties(driver.providerProperties, toJS(state.config.providerProperties)); + } - for (const providerProperty of driver.providerProperties) { - if (!providerProperty.id) { - continue; - } + if (driver.mainProperties.length > 0) { + tempConfig.mainProperties = this.prepareDynamicProperties(driver.mainProperties, toJS(state.config.mainProperties)); + } - const supported = providerProperty.supportedConfigurationTypes?.some(t => t === tempConfig.configurationType); + runInAction(() => { + Object.assign(config, tempConfig); + }); + } - if (!supported) { - delete providerProperties[providerProperty.id]; - } else { - const isDefault = isNotNullDefined(providerProperty.defaultValue); - if (!(providerProperty.id in providerProperties) && isDefault) { - providerProperties[providerProperty.id] = providerProperty.defaultValue; - } - } - } + private prepareDynamicProperties(propertiesInfo: ObjectPropertyInfo[], properties: Record) { + const result: Record = { ...properties }; - tempConfig.providerProperties = providerProperties; + for (const propertyInfo of propertiesInfo) { + if (!propertyInfo.id) { + continue; + } - for (const key of Object.keys(tempConfig.providerProperties)) { - if (typeof tempConfig.providerProperties[key] === 'string') { - tempConfig.providerProperties[key] = tempConfig.providerProperties[key]?.trim(); - } + const isDefault = isNotNullDefined(propertyInfo.defaultValue); + if (!(propertyInfo.id in result) && isDefault) { + result[propertyInfo.id] = propertyInfo.defaultValue; } } - if (driver.mainProperties.length > 0) { - tempConfig.mainProperties = { ...state.config.mainProperties }; + for (const key of Object.keys(result)) { + if (typeof result[key] === 'string') { + result[key] = result[key]?.trim(); + } } - runInAction(() => { - Object.assign(config, tempConfig); - }); + return result; } private async formAuthState(data: IConnectionFormState, contexts: IExecutionContextProvider) { @@ -420,6 +407,8 @@ export class ConnectionOptionsTabService extends Bootstrap { (config.sharedCredentials !== undefined && config.sharedCredentials !== data.info.sharedCredentials) || (config.providerProperties !== undefined && !isObjectPropertyInfoStateEqual(driver.providerProperties, config.providerProperties, data.info.providerProperties)) || + (config.mainProperties !== undefined && + !isObjectPropertyInfoStateEqual(driver.mainProperties, config.mainProperties, data.info.mainProperties)) || (config.keepAliveInterval !== undefined && !isValuesEqual(config.keepAliveInterval, data.info.keepAliveInterval)) ) { stateContext.markEdited(); diff --git a/webapp/packages/plugin-connections/src/ConnectionForm/Options/Options.tsx b/webapp/packages/plugin-connections/src/ConnectionForm/Options/Options.tsx index 32e5e0ac82..7b015614b3 100644 --- a/webapp/packages/plugin-connections/src/ConnectionForm/Options/Options.tsx +++ b/webapp/packages/plugin-connections/src/ConnectionForm/Options/Options.tsx @@ -32,7 +32,7 @@ import { useS, useTranslate, } from '@cloudbeaver/core-blocks'; -import { DatabaseAuthModelsResource, DBDriverResource, isLocalConnection } from '@cloudbeaver/core-connections'; +import { DatabaseAuthModelsResource, DBDriver, DBDriverResource, isLocalConnection } from '@cloudbeaver/core-connections'; import { useService } from '@cloudbeaver/core-di'; import { ServerConfigResource } from '@cloudbeaver/core-root'; import { DriverConfigurationType } from '@cloudbeaver/core-sdk'; @@ -58,20 +58,24 @@ interface IDriverConfiguration { value: DriverConfigurationType; description?: string; icon?: string; + isVisible: (driver: DBDriver) => boolean; } const driverConfiguration: IDriverConfiguration[] = [ { name: 'Manual', value: DriverConfigurationType.Manual, + isVisible: driver => driver.configurationTypes.includes(DriverConfigurationType.Manual), }, { name: 'URL', value: DriverConfigurationType.Url, + isVisible: driver => driver.configurationTypes.includes(DriverConfigurationType.Url), }, { name: 'Custom', value: DriverConfigurationType.Custom, + isVisible: driver => driver.configurationTypes.includes(DriverConfigurationType.Custom) && driver.mainProperties.length > 0, }, ]; @@ -104,7 +108,7 @@ export const Options: TabContainerPanelComponent = observe ); const driver = driverMap.data; - const configurationTypes = driverConfiguration.filter(conf => driver?.configurationTypes.includes(conf.value)); + const configurationTypes = driverConfiguration.filter(configuration => driver && configuration.isVisible(driver)); function handleFormChange(value?: unknown, name?: string) { if (name !== 'name' && optionsHook.isNameAutoFill()) { @@ -189,41 +193,25 @@ export const Options: TabContainerPanelComponent = observe {translate('connections_connection_driver')} {configurationTypes.length > 1 && ( - <> - {/* conf.value} - valueSelector={conf => conf.name} - titleSelector={conf => conf.description} - readOnly={readonly || configurationTypes.length < 2} - disabled={disabled} - tiny - fill - > - {translate('connections_connection_configuration')} - */} - - - - {driverConfiguration.map(conf => ( - - {conf.name} - - ))} - - - - + + + + {configurationTypes.map(conf => ( + + {conf.name} + + ))} + + + )} {config.configurationType === DriverConfigurationType.Url && ( diff --git a/webapp/packages/plugin-connections/src/ConnectionForm/Options/getDefaultConfigurationType.ts b/webapp/packages/plugin-connections/src/ConnectionForm/Options/getDefaultConfigurationType.ts new file mode 100644 index 0000000000..a67647039d --- /dev/null +++ b/webapp/packages/plugin-connections/src/ConnectionForm/Options/getDefaultConfigurationType.ts @@ -0,0 +1,20 @@ +/* + * CloudBeaver - Cloud Database Manager + * Copyright (C) 2020-2024 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0. + * you may not use this file except in compliance with the License. + */ +import type { DBDriver } from '@cloudbeaver/core-connections'; +import { DriverConfigurationType } from '@cloudbeaver/core-sdk'; + +export function getDefaultConfigurationType(driver: DBDriver) { + const isCustomConfiguration = driver?.configurationTypes.includes(DriverConfigurationType.Custom) && driver.mainProperties.length > 0; + const isManualConfiguration = driver?.configurationTypes.includes(DriverConfigurationType.Manual); + + if (isCustomConfiguration) { + return DriverConfigurationType.Custom; + } + + return isManualConfiguration ? DriverConfigurationType.Manual : DriverConfigurationType.Url; +} diff --git a/webapp/packages/plugin-connections/src/ConnectionForm/Options/useOptions.ts b/webapp/packages/plugin-connections/src/ConnectionForm/Options/useOptions.ts index cfaa66f6ea..dd1e315a63 100644 --- a/webapp/packages/plugin-connections/src/ConnectionForm/Options/useOptions.ts +++ b/webapp/packages/plugin-connections/src/ConnectionForm/Options/useOptions.ts @@ -14,6 +14,7 @@ import { DatabaseAuthModel, DriverConfigurationType } from '@cloudbeaver/core-sd import type { IConnectionFormState } from '../IConnectionFormProps'; import { getConnectionName } from './getConnectionName'; +import { getDefaultConfigurationType } from './getDefaultConfigurationType'; export function useOptions(state: IConnectionFormState) { const dbDriverResource = useService(DBDriverResource); @@ -71,9 +72,7 @@ export function useOptions(state: IConnectionFormState) { refObject.prevDriverId = driver?.id || null; if (!config.configurationType || !driver?.configurationTypes.includes(config.configurationType)) { - config.configurationType = driver?.configurationTypes.includes(DriverConfigurationType.Manual) - ? DriverConfigurationType.Manual - : DriverConfigurationType.Url; + state.config.configurationType = driver ? getDefaultConfigurationType(driver) : DriverConfigurationType.Manual; } if ((!prevDriver && config.host === undefined) || config.host === prevDriver?.defaultServer) { From c7723dc2a9cffc60637a3c6e046cfd4acf4f02ee Mon Sep 17 00:00:00 2001 From: Ainur Date: Wed, 12 Jun 2024 10:02:25 +0200 Subject: [PATCH 04/17] CB-5238 set default values to main properties --- .../cloudbeaver/model/WebDatabaseDriverInfo.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/model/WebDatabaseDriverInfo.java b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/model/WebDatabaseDriverInfo.java index dc6119e5b1..efa81f5413 100644 --- a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/model/WebDatabaseDriverInfo.java +++ b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/model/WebDatabaseDriverInfo.java @@ -39,6 +39,7 @@ import org.jkiss.utils.CommonUtils; import java.util.Arrays; +import java.util.LinkedHashMap; import java.util.Map; /** @@ -235,8 +236,17 @@ public String getDefaultAuthModel() { @Property public WebPropertyInfo[] getMainProperties() { - return Arrays.stream(driver.getMainPropertyDescriptors()) - .map(p -> new WebPropertyInfo(webSession, p, null)) + DBPPropertyDescriptor[] properties = driver.getMainPropertyDescriptors(); + // set default values to main properties + Map defaultValues = new LinkedHashMap<>(); + defaultValues.put(DBConstants.PROP_HOST, getDefaultHost()); + defaultValues.put(DBConstants.PROP_PORT, getDefaultPort()); + defaultValues.put(DBConstants.PROP_DATABASE, getDefaultDatabase()); + defaultValues.put(DBConstants.PROP_SERVER, getDefaultServer()); + PropertySourceCustom propertySource = new PropertySourceCustom(properties, defaultValues); + + return Arrays.stream(properties) + .map(p -> new WebPropertyInfo(webSession, p, propertySource)) .toArray(WebPropertyInfo[]::new); } From 5baa81ecd013d8925c4329cca3e80b97f0d4d2e5 Mon Sep 17 00:00:00 2001 From: Aleksei Potsetsuev Date: Thu, 13 Jun 2024 14:00:07 +0800 Subject: [PATCH 05/17] CB-5197 fix(ci/cd): respect base and target branches --- .github/workflows/backend-build.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/backend-build.yml b/.github/workflows/backend-build.yml index 7b1dcb97b5..987763d5a6 100644 --- a/.github/workflows/backend-build.yml +++ b/.github/workflows/backend-build.yml @@ -32,6 +32,17 @@ jobs: sudo chmod 777 ../ shell: bash + - name: Determine branches + id: determine-branch + run: | + echo "pr_branch=${{ github.head_ref }}" >> $GITHUB_ENV + echo "base_branch=${{ github.event.pull_request.base.ref }}" >> $GITHUB_ENV + + - name: Clone dbeaver/dbeaver + id: clone-repo + run: | + git clone -b ${{ env.pr_branch }} https://github.com/dbeaver/dbeaver.git ../dbeaver || git clone -b ${{ env.base_branch }} https://github.com/dbeaver/dbeaver.git ../dbeaver + - name: Run build script run: ./build-backend.sh shell: bash From c6d0a98df5c23206089d337efe258f630c1ea132 Mon Sep 17 00:00:00 2001 From: Ainur Date: Thu, 13 Jun 2024 15:57:33 +0200 Subject: [PATCH 06/17] CB-5238 fixes after review --- .../io/cloudbeaver/model/WebConnectionInfo.java | 8 ++++---- .../schema/service.core.graphqls | 16 ++++++++-------- .../src/io/cloudbeaver/WebServiceUtils.java | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/WebConnectionInfo.java b/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/WebConnectionInfo.java index eca19edf52..fd3fa7164d 100644 --- a/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/WebConnectionInfo.java +++ b/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/WebConnectionInfo.java @@ -387,10 +387,10 @@ public void fireCloseListeners() { @Property public Map getMainProperties() { Map mainProperties = new LinkedHashMap<>(); - mainProperties.put(DBConstants.PROP_HOST, dataSourceContainer.getConnectionConfiguration().getHostName()); - mainProperties.put(DBConstants.PROP_PORT, dataSourceContainer.getConnectionConfiguration().getHostPort()); - mainProperties.put(DBConstants.PROP_DATABASE, dataSourceContainer.getConnectionConfiguration().getDatabaseName()); - mainProperties.put(DBConstants.PROP_SERVER, dataSourceContainer.getConnectionConfiguration().getServerName()); + mainProperties.put(DBConstants.PROP_HOST, getHost()); + mainProperties.put(DBConstants.PROP_PORT, getPort()); + mainProperties.put(DBConstants.PROP_DATABASE, getDatabaseName()); + mainProperties.put(DBConstants.PROP_SERVER, getServerName()); return mainProperties; } diff --git a/server/bundles/io.cloudbeaver.server/schema/service.core.graphqls b/server/bundles/io.cloudbeaver.server/schema/service.core.graphqls index 293ff9b569..d7acb0a7b6 100644 --- a/server/bundles/io.cloudbeaver.server/schema/service.core.graphqls +++ b/server/bundles/io.cloudbeaver.server/schema/service.core.graphqls @@ -217,10 +217,10 @@ type DriverInfo { providerId: ID # Driver Java class name driverClassName: String - defaultHost: String - defaultPort: String - defaultDatabase: String - defaultServer: String + defaultHost: String @deprecated(reason: "24.1.1, use mainProperties") + defaultPort: String @deprecated(reason: "24.1.1, use mainProperties") + defaultDatabase: String @deprecated(reason: "24.1.1, use mainProperties") + defaultServer: String @deprecated(reason: "24.1.1, use mainProperties") defaultUser: String sampleURL: String driverInfoURL: String @@ -250,7 +250,7 @@ type DriverInfo { # Main driver properties # Contains info about main fields (host, port, database, server name) - mainProperties: [ObjectPropertyInfo!]! + mainProperties: [ObjectPropertyInfo!]! @since(version: "24.1.1") # Additional driver provider properties # These properties can be configured by user on main connection page @@ -286,7 +286,7 @@ enum ResultDataFormat { enum DriverConfigurationType { MANUAL, URL, - CUSTOM + CUSTOM @since(version: "24.1.1") } ## Network handler config @@ -345,7 +345,7 @@ type ConnectionInfo { databaseName: String url: String - mainProperties: Object + mainProperties: Object @since(version: "24.1.1") keepAliveInterval: Int! @@ -507,7 +507,7 @@ input ConnectionConfig { databaseName: String @deprecated(reason: "24.1.1, use mainProperties") # Host, port, serverName, databaseName are stored and mainProperties - mainProperties: Object + mainProperties: Object @since(version: "24.1.1") # Connection url jdbc:{driver}://{host}[:{port}]/[{database}] url: String diff --git a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/WebServiceUtils.java b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/WebServiceUtils.java index 1cd403b9ea..add1a32710 100644 --- a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/WebServiceUtils.java +++ b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/WebServiceUtils.java @@ -218,7 +218,7 @@ private static void setMainProperties(DBPConnectionConfiguration dsConfig, WebCo } return; } - if (!CommonUtils.isEmpty(config.getUrl())) { + if (CommonUtils.isNotEmpty(config.getUrl())) { dsConfig.setUrl(config.getUrl()); return; } From 24f42a7f51389f3599cee8e534dc5bb9d4610c40 Mon Sep 17 00:00:00 2001 From: naumov Date: Fri, 14 Jun 2024 13:46:34 +0200 Subject: [PATCH 07/17] CB-5197 review fixes --- .../ObjectPropertyInfoForm/RenderField.tsx | 22 ++++-------- .../core-sdk/src/getObjectPropertyType.ts | 4 +-- .../src/getObjectPropertyValueType.ts | 24 +++++++++++++ webapp/packages/core-sdk/src/index.ts | 1 + .../src/queries/fragments/DatabaseDriver.gql | 4 +-- .../fragments/DriverMainPropertyInfo.gql | 14 -------- .../queries/fragments/DriverPropertyInfo.gql | 4 +++ .../fragments/DriverProviderPropertyInfo.gql | 14 -------- .../Options/ConnectionOptionsTabService.ts | 34 ++++++++++++++----- .../Options/ProviderPropertiesForm.tsx | 8 ++--- .../Options/getDefaultConfigurationType.ts | 14 +++++--- .../src/ConnectionForm/Options/useOptions.ts | 4 +-- 12 files changed, 79 insertions(+), 68 deletions(-) create mode 100644 webapp/packages/core-sdk/src/getObjectPropertyValueType.ts delete mode 100644 webapp/packages/core-sdk/src/queries/fragments/DriverMainPropertyInfo.gql create mode 100644 webapp/packages/core-sdk/src/queries/fragments/DriverPropertyInfo.gql delete mode 100644 webapp/packages/core-sdk/src/queries/fragments/DriverProviderPropertyInfo.gql diff --git a/webapp/packages/core-blocks/src/ObjectPropertyInfo/ObjectPropertyInfoForm/RenderField.tsx b/webapp/packages/core-blocks/src/ObjectPropertyInfo/ObjectPropertyInfoForm/RenderField.tsx index 026954f0a6..0d82228881 100644 --- a/webapp/packages/core-blocks/src/ObjectPropertyInfo/ObjectPropertyInfoForm/RenderField.tsx +++ b/webapp/packages/core-blocks/src/ObjectPropertyInfo/ObjectPropertyInfoForm/RenderField.tsx @@ -6,9 +6,8 @@ * you may not use this file except in compliance with the License. */ import { observer } from 'mobx-react-lite'; -import type { HTMLInputTypeAttribute } from 'react'; -import { getObjectPropertyType, type ObjectPropertyInfo, type ObjectPropertyType } from '@cloudbeaver/core-sdk'; +import { getObjectPropertyType, getObjectPropertyValueType, type ObjectPropertyInfo, type ObjectPropertyType } from '@cloudbeaver/core-sdk'; import { removeMetadataFromDataURL } from '@cloudbeaver/core-utils'; import { FieldCheckbox } from '../../FormControls/Checkboxes/FieldCheckbox'; @@ -71,7 +70,8 @@ export const RenderField = observer(function RenderField({ const translate = useTranslate(); const controlType = getObjectPropertyType(property); - const password = property.features.includes('password'); + const type = getObjectPropertyValueType(property); + const isPassword = type === 'password'; const required = property.required && !readOnly; const value = getValue(property.value, controlType); @@ -173,7 +173,7 @@ export const RenderField = observer(function RenderField({ ); } - const passwordSaved = showRememberTip && ((password && !!property.value) || saved); + const passwordSaved = showRememberTip && ((isPassword && !!property.value) || saved); const passwordSavedMessage = passwordSaved ? translate('core_blocks_object_property_info_password_saved') : undefined; if (controlType === 'file' && state) { @@ -230,22 +230,12 @@ export const RenderField = observer(function RenderField({ ); } - let type: HTMLInputTypeAttribute = 'text'; - - if (controlType === 'input:number') { - type = 'number'; - } - - if (password) { - type = 'password'; - } - if (state !== undefined) { return ( (function RenderField({ 0) { - tempConfig.providerProperties = this.prepareDynamicProperties(driver.providerProperties, toJS(state.config.providerProperties)); + tempConfig.providerProperties = this.prepareDynamicProperties( + driver.providerProperties, + toJS(state.config.providerProperties), + tempConfig.configurationType, + ); } if (driver.mainProperties.length > 0) { - tempConfig.mainProperties = this.prepareDynamicProperties(driver.mainProperties, toJS(state.config.mainProperties)); + tempConfig.mainProperties = this.prepareDynamicProperties( + driver.mainProperties, + toJS(state.config.mainProperties), + tempConfig.configurationType, + ); } runInAction(() => { @@ -336,7 +344,11 @@ export class ConnectionOptionsTabService extends Bootstrap { }); } - private prepareDynamicProperties(propertiesInfo: ObjectPropertyInfo[], properties: Record) { + private prepareDynamicProperties( + propertiesInfo: ObjectPropertyInfo[], + properties: Record, + configurationType: DriverConfigurationType | undefined, + ) { const result: Record = { ...properties }; for (const propertyInfo of propertiesInfo) { @@ -344,9 +356,15 @@ export class ConnectionOptionsTabService extends Bootstrap { continue; } - const isDefault = isNotNullDefined(propertyInfo.defaultValue); - if (!(propertyInfo.id in result) && isDefault) { - result[propertyInfo.id] = propertyInfo.defaultValue; + const supported = propertyInfo.supportedConfigurationTypes?.some(type => type === configurationType); + + if (!supported) { + delete result[propertyInfo.id]; + } else { + const isDefault = isNotNullDefined(propertyInfo.defaultValue); + if (!(propertyInfo.id in result) && isDefault) { + result[propertyInfo.id] = propertyInfo.defaultValue; + } } } diff --git a/webapp/packages/plugin-connections/src/ConnectionForm/Options/ProviderPropertiesForm.tsx b/webapp/packages/plugin-connections/src/ConnectionForm/Options/ProviderPropertiesForm.tsx index e00cedbe10..3cb75d3bb5 100644 --- a/webapp/packages/plugin-connections/src/ConnectionForm/Options/ProviderPropertiesForm.tsx +++ b/webapp/packages/plugin-connections/src/ConnectionForm/Options/ProviderPropertiesForm.tsx @@ -17,13 +17,13 @@ import { useObjectPropertyCategories, useTranslate, } from '@cloudbeaver/core-blocks'; -import { type ConnectionConfig, type DriverProviderPropertyInfoFragment, getObjectPropertyType } from '@cloudbeaver/core-sdk'; +import { type ConnectionConfig, type DriverPropertyInfoFragment, getObjectPropertyType } from '@cloudbeaver/core-sdk'; -type DriverProviderPropertyInfo = DriverProviderPropertyInfoFragment; +type DriverPropertyInfo = DriverPropertyInfoFragment; interface Props { config: ConnectionConfig; - properties: DriverProviderPropertyInfo[]; + properties: DriverPropertyInfo[]; disabled?: boolean; readonly?: boolean; } @@ -114,6 +114,6 @@ export const ProviderPropertiesForm = observer(function ProviderPropertie ); }); -function isOnlyBooleans(properties: DriverProviderPropertyInfo[], category?: string): boolean { +function isOnlyBooleans(properties: DriverPropertyInfo[], category?: string): boolean { return properties.filter(property => !category || property.category === category).every(property => property.dataType === 'Boolean'); } diff --git a/webapp/packages/plugin-connections/src/ConnectionForm/Options/getDefaultConfigurationType.ts b/webapp/packages/plugin-connections/src/ConnectionForm/Options/getDefaultConfigurationType.ts index a67647039d..b9c071c2c9 100644 --- a/webapp/packages/plugin-connections/src/ConnectionForm/Options/getDefaultConfigurationType.ts +++ b/webapp/packages/plugin-connections/src/ConnectionForm/Options/getDefaultConfigurationType.ts @@ -8,13 +8,17 @@ import type { DBDriver } from '@cloudbeaver/core-connections'; import { DriverConfigurationType } from '@cloudbeaver/core-sdk'; -export function getDefaultConfigurationType(driver: DBDriver) { - const isCustomConfiguration = driver?.configurationTypes.includes(DriverConfigurationType.Custom) && driver.mainProperties.length > 0; - const isManualConfiguration = driver?.configurationTypes.includes(DriverConfigurationType.Manual); +export function getDefaultConfigurationType(driver: DBDriver | undefined) { + if (!driver) { + return DriverConfigurationType.Url; + } + + const supportCustom = driver.configurationTypes.includes(DriverConfigurationType.Custom); + const supportManual = driver.configurationTypes.includes(DriverConfigurationType.Manual); - if (isCustomConfiguration) { + if (supportCustom && driver.mainProperties.length > 0) { return DriverConfigurationType.Custom; } - return isManualConfiguration ? DriverConfigurationType.Manual : DriverConfigurationType.Url; + return supportManual ? DriverConfigurationType.Manual : DriverConfigurationType.Url; } diff --git a/webapp/packages/plugin-connections/src/ConnectionForm/Options/useOptions.ts b/webapp/packages/plugin-connections/src/ConnectionForm/Options/useOptions.ts index dd1e315a63..473de8dce7 100644 --- a/webapp/packages/plugin-connections/src/ConnectionForm/Options/useOptions.ts +++ b/webapp/packages/plugin-connections/src/ConnectionForm/Options/useOptions.ts @@ -10,7 +10,7 @@ import { runInAction } from 'mobx'; import { useObjectRef } from '@cloudbeaver/core-blocks'; import { DBDriver, DBDriverResource, isJDBCConnection } from '@cloudbeaver/core-connections'; import { useService } from '@cloudbeaver/core-di'; -import { DatabaseAuthModel, DriverConfigurationType } from '@cloudbeaver/core-sdk'; +import type { DatabaseAuthModel } from '@cloudbeaver/core-sdk'; import type { IConnectionFormState } from '../IConnectionFormProps'; import { getConnectionName } from './getConnectionName'; @@ -72,7 +72,7 @@ export function useOptions(state: IConnectionFormState) { refObject.prevDriverId = driver?.id || null; if (!config.configurationType || !driver?.configurationTypes.includes(config.configurationType)) { - state.config.configurationType = driver ? getDefaultConfigurationType(driver) : DriverConfigurationType.Manual; + state.config.configurationType = getDefaultConfigurationType(driver); } if ((!prevDriver && config.host === undefined) || config.host === prevDriver?.defaultServer) { From 616ff40f59d341d50138d5c8ad813174e3148279 Mon Sep 17 00:00:00 2001 From: naumov Date: Mon, 17 Jun 2024 16:55:30 +0200 Subject: [PATCH 08/17] CB-5197 switch to new model --- .../core-connections/src/DBDriverResource.ts | 1 + .../src/queries/connections/driverList.gql | 9 +++- .../src/queries/fragments/DatabaseDriver.gql | 2 +- .../Options/ConnectionOptionsTabService.ts | 50 ++++++++++--------- .../src/ConnectionForm/Options/Options.tsx | 4 +- .../Options/getDefaultConfigurationType.ts | 2 +- 6 files changed, 39 insertions(+), 29 deletions(-) diff --git a/webapp/packages/core-connections/src/DBDriverResource.ts b/webapp/packages/core-connections/src/DBDriverResource.ts index afe61974ed..351a63f5f2 100644 --- a/webapp/packages/core-connections/src/DBDriverResource.ts +++ b/webapp/packages/core-connections/src/DBDriverResource.ts @@ -112,6 +112,7 @@ export class DBDriverResource extends CachedMapResource { return { default: Options }; }); +const MAIN_PROPERTY_DATABASE_KEY = 'database'; +const MAIN_PROPERTY_HOST_KEY = 'host'; +const MAIN_PROPERTY_PORT_KEY = 'port'; +const MAIN_PROPERTY_SERVER_KEY = 'server'; + @injectable() export class ConnectionOptionsTabService extends Bootstrap { constructor( - private readonly serverConfigResource: ServerConfigResource, private readonly projectInfoResource: ProjectInfoResource, private readonly connectionFormService: ConnectionFormService, private readonly dbDriverResource: DBDriverResource, @@ -220,10 +223,11 @@ export class ConnectionOptionsTabService extends Bootstrap { state.config.template = state.info.template; state.config.driverId = state.info.driverId; - state.config.host = state.info.host; - state.config.port = state.info.port; - state.config.serverName = state.info.serverName; - state.config.databaseName = state.info.databaseName; + state.config.host = state.info.mainProperties[MAIN_PROPERTY_HOST_KEY]; + state.config.port = state.info.mainProperties[MAIN_PROPERTY_PORT_KEY]; + state.config.serverName = state.info.mainProperties[MAIN_PROPERTY_SERVER_KEY]; + state.config.databaseName = state.info.mainProperties[MAIN_PROPERTY_DATABASE_KEY]; + state.config.url = state.info.url; state.config.folder = state.info.folder; @@ -264,7 +268,7 @@ export class ConnectionOptionsTabService extends Bootstrap { return; } - const driver = await this.dbDriverResource.load(state.config.driverId, ['includeProviderProperties']); + const driver = await this.dbDriverResource.load(state.config.driverId, ['includeProviderProperties', 'includeMainProperties']); const tempConfig = toJS(config); if (state.mode === 'edit') { @@ -272,7 +276,6 @@ export class ConnectionOptionsTabService extends Bootstrap { } tempConfig.configurationType = state.config.configurationType; - tempConfig.name = state.config.name?.trim(); if (tempConfig.name && state.mode === 'create') { @@ -283,11 +286,8 @@ export class ConnectionOptionsTabService extends Bootstrap { } tempConfig.description = state.config.description?.trim(); - tempConfig.template = state.config.template; - tempConfig.driverId = state.config.driverId; - tempConfig.keepAliveInterval = Number(state.config.keepAliveInterval); if (!state.config.template && state.config.folder) { @@ -296,15 +296,21 @@ export class ConnectionOptionsTabService extends Bootstrap { if (tempConfig.configurationType === DriverConfigurationType.Url) { tempConfig.url = state.config.url?.trim(); - } else { + } + + tempConfig.mainProperties = toJS(state.config.mainProperties); + + if (tempConfig.configurationType === DriverConfigurationType.Manual) { + tempConfig.mainProperties[MAIN_PROPERTY_DATABASE_KEY] = state.config.databaseName?.trim(); + if (!driver.embedded) { - tempConfig.host = state.config.host?.trim(); - tempConfig.port = state.config.port?.trim(); + tempConfig.mainProperties[MAIN_PROPERTY_HOST_KEY] = state.config.host?.trim(); + tempConfig.mainProperties[MAIN_PROPERTY_PORT_KEY] = state.config.port?.trim(); } + if (driver.requiresServerName) { - tempConfig.serverName = state.config.serverName?.trim(); + tempConfig.mainProperties[MAIN_PROPERTY_SERVER_KEY] = state.config.serverName?.trim(); } - tempConfig.databaseName = state.config.databaseName?.trim(); } if ((state.config.authModelId || driver.defaultAuthModel) && !driver.anonymousAccess) { @@ -331,12 +337,8 @@ export class ConnectionOptionsTabService extends Bootstrap { ); } - if (driver.mainProperties.length > 0) { - tempConfig.mainProperties = this.prepareDynamicProperties( - driver.mainProperties, - toJS(state.config.mainProperties), - tempConfig.configurationType, - ); + if (tempConfig.configurationType === DriverConfigurationType.Custom && !!driver.mainProperties?.length) { + tempConfig.mainProperties = this.prepareDynamicProperties(driver.mainProperties, tempConfig.mainProperties, tempConfig.configurationType); } runInAction(() => { @@ -381,7 +383,7 @@ export class ConnectionOptionsTabService extends Bootstrap { const config = contexts.getContext(connectionConfigContext); const stateContext = contexts.getContext(formStateContext); - const driver = await this.dbDriverResource.load(config.driverId!, ['includeProviderProperties']); + const driver = await this.dbDriverResource.load(config.driverId!, ['includeProviderProperties', 'includeMainProperties']); const authModel = await this.databaseAuthModelsResource.load(config.authModelId ?? data.info?.authModel ?? driver.defaultAuthModel); const providerId = authModel.requiredAuth ?? data.info?.requiredAuth ?? AUTH_PROVIDER_LOCAL_ID; @@ -405,7 +407,7 @@ export class ConnectionOptionsTabService extends Bootstrap { const config = contexts.getContext(connectionConfigContext); const stateContext = contexts.getContext(formStateContext); - const driver = await this.dbDriverResource.load(data.config.driverId!, ['includeProviderProperties']); + const driver = await this.dbDriverResource.load(data.config.driverId!, ['includeProviderProperties', 'includeMainProperties']); if ( !isValuesEqual(config.name, data.info.name, '') || diff --git a/webapp/packages/plugin-connections/src/ConnectionForm/Options/Options.tsx b/webapp/packages/plugin-connections/src/ConnectionForm/Options/Options.tsx index 7b015614b3..5665423993 100644 --- a/webapp/packages/plugin-connections/src/ConnectionForm/Options/Options.tsx +++ b/webapp/packages/plugin-connections/src/ConnectionForm/Options/Options.tsx @@ -75,7 +75,7 @@ const driverConfiguration: IDriverConfiguration[] = [ { name: 'Custom', value: DriverConfigurationType.Custom, - isVisible: driver => driver.configurationTypes.includes(DriverConfigurationType.Custom) && driver.mainProperties.length > 0, + isVisible: driver => driver.configurationTypes.includes(DriverConfigurationType.Custom) && !!driver.mainProperties?.length, }, ]; @@ -99,7 +99,7 @@ export const Options: TabContainerPanelComponent = observe const driverMap = useResource( Options, DBDriverResource, - { key: config.driverId || null, includes: ['includeProviderProperties'] as const }, + { key: config.driverId || null, includes: ['includeProviderProperties', 'includeMainProperties'] as const }, { onData: data => { optionsHook.setDefaults(data); diff --git a/webapp/packages/plugin-connections/src/ConnectionForm/Options/getDefaultConfigurationType.ts b/webapp/packages/plugin-connections/src/ConnectionForm/Options/getDefaultConfigurationType.ts index b9c071c2c9..0162289e7c 100644 --- a/webapp/packages/plugin-connections/src/ConnectionForm/Options/getDefaultConfigurationType.ts +++ b/webapp/packages/plugin-connections/src/ConnectionForm/Options/getDefaultConfigurationType.ts @@ -16,7 +16,7 @@ export function getDefaultConfigurationType(driver: DBDriver | undefined) { const supportCustom = driver.configurationTypes.includes(DriverConfigurationType.Custom); const supportManual = driver.configurationTypes.includes(DriverConfigurationType.Manual); - if (supportCustom && driver.mainProperties.length > 0) { + if (supportCustom && !!driver.mainProperties?.length) { return DriverConfigurationType.Custom; } From 802c4e1f5da2ea6f40913672ae57cf00bd9910e6 Mon Sep 17 00:00:00 2001 From: Ainur Date: Tue, 25 Jun 2024 16:24:16 +0200 Subject: [PATCH 09/17] CB-5238 fixes after review --- .../schema/service.core.graphqls | 21 ++++++++++--------- .../model/WebDatabaseDriverInfo.java | 6 ++++++ 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/server/bundles/io.cloudbeaver.server/schema/service.core.graphqls b/server/bundles/io.cloudbeaver.server/schema/service.core.graphqls index d7acb0a7b6..b9c1ae7692 100644 --- a/server/bundles/io.cloudbeaver.server/schema/service.core.graphqls +++ b/server/bundles/io.cloudbeaver.server/schema/service.core.graphqls @@ -217,10 +217,10 @@ type DriverInfo { providerId: ID # Driver Java class name driverClassName: String - defaultHost: String @deprecated(reason: "24.1.1, use mainProperties") - defaultPort: String @deprecated(reason: "24.1.1, use mainProperties") - defaultDatabase: String @deprecated(reason: "24.1.1, use mainProperties") - defaultServer: String @deprecated(reason: "24.1.1, use mainProperties") + defaultHost: String + defaultPort: String + defaultDatabase: String + defaultServer: String defaultUser: String sampleURL: String driverInfoURL: String @@ -229,6 +229,7 @@ type DriverInfo { enabled: Boolean! requiresServerName: Boolean requiresDatabaseName: Boolean + useCustomPage: Boolean! @since(version: "24.1.2") # if host, port, database, server name fields are custom licenseRequired: Boolean license: String @@ -501,13 +502,13 @@ input ConnectionConfig { # Custom connection parameters (all optional) - host: String @deprecated(reason: "24.1.1, use mainProperties") - port: String @deprecated(reason: "24.1.1, use mainProperties") - serverName: String @deprecated(reason: "24.1.1, use mainProperties") - databaseName: String @deprecated(reason: "24.1.1, use mainProperties") + host: String + port: String + serverName: String + databaseName: String - # Host, port, serverName, databaseName are stored and mainProperties - mainProperties: Object @since(version: "24.1.1") + # Host, port, serverName, databaseName are also stored in mainProperties for custom pages + mainProperties: Object @since(version: "24.1.2") # Connection url jdbc:{driver}://{host}[:{port}]/[{database}] url: String diff --git a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/model/WebDatabaseDriverInfo.java b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/model/WebDatabaseDriverInfo.java index efa81f5413..f9e207bbcb 100644 --- a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/model/WebDatabaseDriverInfo.java +++ b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/model/WebDatabaseDriverInfo.java @@ -36,6 +36,7 @@ import org.jkiss.dbeaver.registry.network.NetworkHandlerDescriptor; import org.jkiss.dbeaver.registry.network.NetworkHandlerRegistry; import org.jkiss.dbeaver.runtime.properties.PropertySourceCustom; +import org.jkiss.utils.ArrayUtils; import org.jkiss.utils.CommonUtils; import java.util.Arrays; @@ -293,4 +294,9 @@ public WebDriverLibraryInfo[] getDriverLibraries() { .map(dbpDriverLibrary -> new WebDriverLibraryInfo(webSession, dbpDriverLibrary)) .toArray(WebDriverLibraryInfo[]::new); } + + @Property + public boolean getUseCustomPage() { + return !ArrayUtils.isEmpty(driver.getMainPropertyDescriptors()); + } } From 5babb3cd0f7d518294971fb24f35c3bbc3f655d8 Mon Sep 17 00:00:00 2001 From: naumov Date: Thu, 27 Jun 2024 14:24:41 +0200 Subject: [PATCH 10/17] CB-5197 remove custom configuration type --- .../src/queries/fragments/DatabaseDriver.gql | 1 + .../Options/ConnectionOptionsTabService.ts | 4 +- .../src/ConnectionForm/Options/Options.tsx | 42 ++++++++----------- .../Options/getDefaultConfigurationType.ts | 6 --- 4 files changed, 21 insertions(+), 32 deletions(-) diff --git a/webapp/packages/core-sdk/src/queries/fragments/DatabaseDriver.gql b/webapp/packages/core-sdk/src/queries/fragments/DatabaseDriver.gql index 58d768e0b4..ef5943883b 100644 --- a/webapp/packages/core-sdk/src/queries/fragments/DatabaseDriver.gql +++ b/webapp/packages/core-sdk/src/queries/fragments/DatabaseDriver.gql @@ -11,6 +11,7 @@ fragment DatabaseDriver on DriverInfo { embedded enabled requiresServerName + useCustomPage anonymousAccess promotedScore providerId diff --git a/webapp/packages/plugin-connections/src/ConnectionForm/Options/ConnectionOptionsTabService.ts b/webapp/packages/plugin-connections/src/ConnectionForm/Options/ConnectionOptionsTabService.ts index 07c9271867..e79c0124e6 100644 --- a/webapp/packages/plugin-connections/src/ConnectionForm/Options/ConnectionOptionsTabService.ts +++ b/webapp/packages/plugin-connections/src/ConnectionForm/Options/ConnectionOptionsTabService.ts @@ -300,7 +300,7 @@ export class ConnectionOptionsTabService extends Bootstrap { tempConfig.mainProperties = toJS(state.config.mainProperties); - if (tempConfig.configurationType === DriverConfigurationType.Manual) { + if (tempConfig.configurationType === DriverConfigurationType.Manual && !driver.useCustomPage) { tempConfig.mainProperties[MAIN_PROPERTY_DATABASE_KEY] = state.config.databaseName?.trim(); if (!driver.embedded) { @@ -337,7 +337,7 @@ export class ConnectionOptionsTabService extends Bootstrap { ); } - if (tempConfig.configurationType === DriverConfigurationType.Custom && !!driver.mainProperties?.length) { + if (driver.useCustomPage && driver.mainProperties.length > 0) { tempConfig.mainProperties = this.prepareDynamicProperties(driver.mainProperties, tempConfig.mainProperties, tempConfig.configurationType); } diff --git a/webapp/packages/plugin-connections/src/ConnectionForm/Options/Options.tsx b/webapp/packages/plugin-connections/src/ConnectionForm/Options/Options.tsx index 7a2e892edb..0bbad04a87 100644 --- a/webapp/packages/plugin-connections/src/ConnectionForm/Options/Options.tsx +++ b/webapp/packages/plugin-connections/src/ConnectionForm/Options/Options.tsx @@ -73,11 +73,6 @@ const driverConfiguration: IDriverConfiguration[] = [ value: DriverConfigurationType.Url, isVisible: driver => driver.configurationTypes.includes(DriverConfigurationType.Url), }, - { - name: 'Custom', - value: DriverConfigurationType.Custom, - isVisible: driver => driver.configurationTypes.includes(DriverConfigurationType.Custom) && !!driver.mainProperties?.length, - }, ]; export const Options: TabContainerPanelComponent = observer(function Options({ state }) { @@ -228,25 +223,24 @@ export const Options: TabContainerPanelComponent = observe )} - {config.configurationType === DriverConfigurationType.Manual && ( - - )} - - {config.configurationType === DriverConfigurationType.Custom && ( - - )} + {config.configurationType === DriverConfigurationType.Manual && + (driver?.useCustomPage ? ( + + ) : ( + + ))} diff --git a/webapp/packages/plugin-connections/src/ConnectionForm/Options/getDefaultConfigurationType.ts b/webapp/packages/plugin-connections/src/ConnectionForm/Options/getDefaultConfigurationType.ts index 0162289e7c..b25fc1519f 100644 --- a/webapp/packages/plugin-connections/src/ConnectionForm/Options/getDefaultConfigurationType.ts +++ b/webapp/packages/plugin-connections/src/ConnectionForm/Options/getDefaultConfigurationType.ts @@ -13,12 +13,6 @@ export function getDefaultConfigurationType(driver: DBDriver | undefined) { return DriverConfigurationType.Url; } - const supportCustom = driver.configurationTypes.includes(DriverConfigurationType.Custom); const supportManual = driver.configurationTypes.includes(DriverConfigurationType.Manual); - - if (supportCustom && !!driver.mainProperties?.length) { - return DriverConfigurationType.Custom; - } - return supportManual ? DriverConfigurationType.Manual : DriverConfigurationType.Url; } From d3afe0e48424c029588ae4bc551eb863fb67755f Mon Sep 17 00:00:00 2001 From: Ainur Date: Thu, 27 Jun 2024 14:27:48 +0200 Subject: [PATCH 11/17] CB-5238 remove custom config type from gql schema --- .../bundles/io.cloudbeaver.server/schema/service.core.graphqls | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/server/bundles/io.cloudbeaver.server/schema/service.core.graphqls b/server/bundles/io.cloudbeaver.server/schema/service.core.graphqls index b9c1ae7692..aa85be062d 100644 --- a/server/bundles/io.cloudbeaver.server/schema/service.core.graphqls +++ b/server/bundles/io.cloudbeaver.server/schema/service.core.graphqls @@ -286,8 +286,7 @@ enum ResultDataFormat { enum DriverConfigurationType { MANUAL, - URL, - CUSTOM @since(version: "24.1.1") + URL } ## Network handler config From 31311f04e8deb273ffe556e32f089863932ead94 Mon Sep 17 00:00:00 2001 From: naumov Date: Thu, 27 Jun 2024 15:57:35 +0200 Subject: [PATCH 12/17] CB-5197 do not check configuration type for creds --- .../src/ConnectionForm/Options/ConnectionOptionsTabService.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webapp/packages/plugin-connections/src/ConnectionForm/Options/ConnectionOptionsTabService.ts b/webapp/packages/plugin-connections/src/ConnectionForm/Options/ConnectionOptionsTabService.ts index e79c0124e6..e27f29e8b3 100644 --- a/webapp/packages/plugin-connections/src/ConnectionForm/Options/ConnectionOptionsTabService.ts +++ b/webapp/packages/plugin-connections/src/ConnectionForm/Options/ConnectionOptionsTabService.ts @@ -321,7 +321,7 @@ export class ConnectionOptionsTabService extends Bootstrap { const properties = await this.getConnectionAuthModelProperties(tempConfig.authModelId, state.info); if (this.isCredentialsChanged(properties, state.config.credentials)) { - tempConfig.credentials = this.prepareDynamicProperties(properties, toJS(state.config.credentials), tempConfig.configurationType); + tempConfig.credentials = this.prepareDynamicProperties(properties, toJS(state.config.credentials)); } if (!tempConfig.saveCredentials) { @@ -358,7 +358,7 @@ export class ConnectionOptionsTabService extends Bootstrap { continue; } - const supported = propertyInfo.supportedConfigurationTypes?.some(type => type === configurationType); + const supported = configurationType === undefined || propertyInfo.supportedConfigurationTypes?.some(type => type === configurationType); if (!supported) { delete result[propertyInfo.id]; From de1ad0e5b69b49676f371113e4574abd52b8ccaf Mon Sep 17 00:00:00 2001 From: naumov Date: Thu, 27 Jun 2024 16:06:28 +0200 Subject: [PATCH 13/17] CB-5197 make argument optional --- .../src/ConnectionForm/Options/ConnectionOptionsTabService.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/packages/plugin-connections/src/ConnectionForm/Options/ConnectionOptionsTabService.ts b/webapp/packages/plugin-connections/src/ConnectionForm/Options/ConnectionOptionsTabService.ts index e27f29e8b3..83d78c79bb 100644 --- a/webapp/packages/plugin-connections/src/ConnectionForm/Options/ConnectionOptionsTabService.ts +++ b/webapp/packages/plugin-connections/src/ConnectionForm/Options/ConnectionOptionsTabService.ts @@ -349,7 +349,7 @@ export class ConnectionOptionsTabService extends Bootstrap { private prepareDynamicProperties( propertiesInfo: ObjectPropertyInfo[], properties: Record, - configurationType: DriverConfigurationType | undefined, + configurationType?: DriverConfigurationType, ) { const result: Record = { ...properties }; From eee54dcc738461db13731ec4ded2e72e51993932 Mon Sep 17 00:00:00 2001 From: Ainur Date: Thu, 27 Jun 2024 16:51:14 +0200 Subject: [PATCH 14/17] CB-5238 fix creating connection with url --- .../src/io/cloudbeaver/WebServiceUtils.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/WebServiceUtils.java b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/WebServiceUtils.java index add1a32710..e63ed012c9 100644 --- a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/WebServiceUtils.java +++ b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/WebServiceUtils.java @@ -206,6 +206,10 @@ public static void setConnectionConfiguration(DBPDriver driver, DBPConnectionCon } private static void setMainProperties(DBPConnectionConfiguration dsConfig, WebConnectionConfig config) { + if (CommonUtils.isNotEmpty(config.getUrl())) { + dsConfig.setUrl(config.getUrl()); + return; + } if (config.getMainProperties() != null) { for (Map.Entry e : config.getMainProperties().entrySet()) { switch (e.getKey()) { @@ -218,10 +222,6 @@ private static void setMainProperties(DBPConnectionConfiguration dsConfig, WebCo } return; } - if (CommonUtils.isNotEmpty(config.getUrl())) { - dsConfig.setUrl(config.getUrl()); - return; - } if (config.getHost() != null) { dsConfig.setHostName(config.getHost()); } From e7b02255a30342b69272364a1dca32cf8dea6aa3 Mon Sep 17 00:00:00 2001 From: Ainur Date: Thu, 27 Jun 2024 17:37:48 +0200 Subject: [PATCH 15/17] CB-5238 rename param --- .../src/io/cloudbeaver/model/WebConnectionInfo.java | 2 +- .../bundles/io.cloudbeaver.server/schema/service.core.graphqls | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/WebConnectionInfo.java b/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/WebConnectionInfo.java index fd3fa7164d..5831853ff7 100644 --- a/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/WebConnectionInfo.java +++ b/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/WebConnectionInfo.java @@ -385,7 +385,7 @@ public void fireCloseListeners() { } @Property - public Map getMainProperties() { + public Map getMainPropertyValues() { Map mainProperties = new LinkedHashMap<>(); mainProperties.put(DBConstants.PROP_HOST, getHost()); mainProperties.put(DBConstants.PROP_PORT, getPort()); diff --git a/server/bundles/io.cloudbeaver.server/schema/service.core.graphqls b/server/bundles/io.cloudbeaver.server/schema/service.core.graphqls index aa85be062d..229c79798e 100644 --- a/server/bundles/io.cloudbeaver.server/schema/service.core.graphqls +++ b/server/bundles/io.cloudbeaver.server/schema/service.core.graphqls @@ -345,7 +345,7 @@ type ConnectionInfo { databaseName: String url: String - mainProperties: Object @since(version: "24.1.1") + mainPropertyValues: Object @since(version: "24.1.2") keepAliveInterval: Int! From 3b80984ca1af6f14a3b9e38e2b90a38cd09df6d0 Mon Sep 17 00:00:00 2001 From: Ainur Date: Thu, 27 Jun 2024 17:52:12 +0200 Subject: [PATCH 16/17] CB-5238 rename param --- .../io.cloudbeaver.server/schema/service.core.graphqls | 6 +++--- .../src/io/cloudbeaver/WebServiceUtils.java | 4 ++-- .../src/io/cloudbeaver/model/WebConnectionConfig.java | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/server/bundles/io.cloudbeaver.server/schema/service.core.graphqls b/server/bundles/io.cloudbeaver.server/schema/service.core.graphqls index 229c79798e..d7cc2f7fd6 100644 --- a/server/bundles/io.cloudbeaver.server/schema/service.core.graphqls +++ b/server/bundles/io.cloudbeaver.server/schema/service.core.graphqls @@ -251,7 +251,7 @@ type DriverInfo { # Main driver properties # Contains info about main fields (host, port, database, server name) - mainProperties: [ObjectPropertyInfo!]! @since(version: "24.1.1") + mainProperties: [ObjectPropertyInfo!]! @since(version: "24.1.2") # Additional driver provider properties # These properties can be configured by user on main connection page @@ -506,8 +506,8 @@ input ConnectionConfig { serverName: String databaseName: String - # Host, port, serverName, databaseName are also stored in mainProperties for custom pages - mainProperties: Object @since(version: "24.1.2") + # Host, port, serverName, databaseName are also stored in mainPropertyValues for custom pages + mainPropertyValues: Object @since(version: "24.1.2") # Connection url jdbc:{driver}://{host}[:{port}]/[{database}] url: String diff --git a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/WebServiceUtils.java b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/WebServiceUtils.java index e63ed012c9..99738ff787 100644 --- a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/WebServiceUtils.java +++ b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/WebServiceUtils.java @@ -210,8 +210,8 @@ private static void setMainProperties(DBPConnectionConfiguration dsConfig, WebCo dsConfig.setUrl(config.getUrl()); return; } - if (config.getMainProperties() != null) { - for (Map.Entry e : config.getMainProperties().entrySet()) { + if (config.getMainPropertyValues() != null) { + for (Map.Entry e : config.getMainPropertyValues().entrySet()) { switch (e.getKey()) { case DBConstants.PROP_HOST -> dsConfig.setHostName(CommonUtils.toString(e.getValue())); case DBConstants.PROP_PORT -> dsConfig.setHostPort(CommonUtils.toString(e.getValue())); diff --git a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/model/WebConnectionConfig.java b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/model/WebConnectionConfig.java index 5527481a5e..981b09ed9a 100644 --- a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/model/WebConnectionConfig.java +++ b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/model/WebConnectionConfig.java @@ -57,7 +57,7 @@ public class WebConnectionConfig { private Map credentials; private boolean saveCredentials; private boolean sharedCredentials; - private Map mainProperties; + private Map mainPropertyValues; private Map providerProperties; private List networkHandlersConfig; private DBPDriverConfigurationType configurationType; @@ -101,7 +101,7 @@ public WebConnectionConfig(Map params) { saveCredentials = JSONUtils.getBoolean(params, "saveCredentials"); sharedCredentials = JSONUtils.getBoolean(params, "sharedCredentials"); - mainProperties = JSONUtils.getObjectOrNull(params, "mainProperties"); + mainPropertyValues = JSONUtils.getObjectOrNull(params, "mainPropertyValues"); providerProperties = JSONUtils.getObjectOrNull(params, "providerProperties"); String configType = JSONUtils.getString(params, "configurationType"); @@ -228,8 +228,8 @@ public void setSaveCredentials(boolean saveCredentials) { } @Property - public Map getMainProperties() { - return mainProperties; + public Map getMainPropertyValues() { + return mainPropertyValues; } @Property From ef232def3206e9903c08e72828d7a1ab9f511c42 Mon Sep 17 00:00:00 2001 From: naumov Date: Thu, 27 Jun 2024 18:02:21 +0200 Subject: [PATCH 17/17] CB-5197 rename field --- .../queries/fragments/DatabaseConnection.gql | 2 +- .../Options/ConnectionOptionsTabService.ts | 36 ++++++++++--------- .../src/ConnectionForm/Options/Options.tsx | 2 +- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/webapp/packages/core-sdk/src/queries/fragments/DatabaseConnection.gql b/webapp/packages/core-sdk/src/queries/fragments/DatabaseConnection.gql index 5a14284ae0..aebfaf67a7 100644 --- a/webapp/packages/core-sdk/src/queries/fragments/DatabaseConnection.gql +++ b/webapp/packages/core-sdk/src/queries/fragments/DatabaseConnection.gql @@ -17,7 +17,7 @@ fragment DatabaseConnection on ConnectionInfo { folder nodePath - mainProperties + mainPropertyValues configurationType @include(if: $customIncludeOptions) useUrl @include(if: $customIncludeOptions) diff --git a/webapp/packages/plugin-connections/src/ConnectionForm/Options/ConnectionOptionsTabService.ts b/webapp/packages/plugin-connections/src/ConnectionForm/Options/ConnectionOptionsTabService.ts index 83d78c79bb..b4e3ace6af 100644 --- a/webapp/packages/plugin-connections/src/ConnectionForm/Options/ConnectionOptionsTabService.ts +++ b/webapp/packages/plugin-connections/src/ConnectionForm/Options/ConnectionOptionsTabService.ts @@ -206,8 +206,8 @@ export class ConnectionOptionsTabService extends Bootstrap { state.config.providerProperties = {}; } - if (!state.config.mainProperties || updated) { - state.config.mainProperties = {}; + if (!state.config.mainPropertyValues || updated) { + state.config.mainPropertyValues = {}; } if (!state.info) { @@ -223,10 +223,10 @@ export class ConnectionOptionsTabService extends Bootstrap { state.config.template = state.info.template; state.config.driverId = state.info.driverId; - state.config.host = state.info.mainProperties[MAIN_PROPERTY_HOST_KEY]; - state.config.port = state.info.mainProperties[MAIN_PROPERTY_PORT_KEY]; - state.config.serverName = state.info.mainProperties[MAIN_PROPERTY_SERVER_KEY]; - state.config.databaseName = state.info.mainProperties[MAIN_PROPERTY_DATABASE_KEY]; + state.config.host = state.info.mainPropertyValues[MAIN_PROPERTY_HOST_KEY]; + state.config.port = state.info.mainPropertyValues[MAIN_PROPERTY_PORT_KEY]; + state.config.serverName = state.info.mainPropertyValues[MAIN_PROPERTY_SERVER_KEY]; + state.config.databaseName = state.info.mainPropertyValues[MAIN_PROPERTY_DATABASE_KEY]; state.config.url = state.info.url; state.config.folder = state.info.folder; @@ -249,8 +249,8 @@ export class ConnectionOptionsTabService extends Bootstrap { state.config.providerProperties = { ...state.info.providerProperties }; } - if (state.info.mainProperties) { - state.config.mainProperties = { ...state.info.mainProperties }; + if (state.info.mainPropertyValues) { + state.config.mainPropertyValues = { ...state.info.mainPropertyValues }; } } @@ -298,18 +298,18 @@ export class ConnectionOptionsTabService extends Bootstrap { tempConfig.url = state.config.url?.trim(); } - tempConfig.mainProperties = toJS(state.config.mainProperties); + tempConfig.mainPropertyValues = toJS(state.config.mainPropertyValues); if (tempConfig.configurationType === DriverConfigurationType.Manual && !driver.useCustomPage) { - tempConfig.mainProperties[MAIN_PROPERTY_DATABASE_KEY] = state.config.databaseName?.trim(); + tempConfig.mainPropertyValues[MAIN_PROPERTY_DATABASE_KEY] = state.config.databaseName?.trim(); if (!driver.embedded) { - tempConfig.mainProperties[MAIN_PROPERTY_HOST_KEY] = state.config.host?.trim(); - tempConfig.mainProperties[MAIN_PROPERTY_PORT_KEY] = state.config.port?.trim(); + tempConfig.mainPropertyValues[MAIN_PROPERTY_HOST_KEY] = state.config.host?.trim(); + tempConfig.mainPropertyValues[MAIN_PROPERTY_PORT_KEY] = state.config.port?.trim(); } if (driver.requiresServerName) { - tempConfig.mainProperties[MAIN_PROPERTY_SERVER_KEY] = state.config.serverName?.trim(); + tempConfig.mainPropertyValues[MAIN_PROPERTY_SERVER_KEY] = state.config.serverName?.trim(); } } @@ -338,7 +338,11 @@ export class ConnectionOptionsTabService extends Bootstrap { } if (driver.useCustomPage && driver.mainProperties.length > 0) { - tempConfig.mainProperties = this.prepareDynamicProperties(driver.mainProperties, tempConfig.mainProperties, tempConfig.configurationType); + tempConfig.mainPropertyValues = this.prepareDynamicProperties( + driver.mainProperties, + tempConfig.mainPropertyValues, + tempConfig.configurationType, + ); } runInAction(() => { @@ -427,8 +431,8 @@ export class ConnectionOptionsTabService extends Bootstrap { (config.sharedCredentials !== undefined && config.sharedCredentials !== data.info.sharedCredentials) || (config.providerProperties !== undefined && !isObjectPropertyInfoStateEqual(driver.providerProperties, config.providerProperties, data.info.providerProperties)) || - (config.mainProperties !== undefined && - !isObjectPropertyInfoStateEqual(driver.mainProperties, config.mainProperties, data.info.mainProperties)) || + (config.mainPropertyValues !== undefined && + !isObjectPropertyInfoStateEqual(driver.mainProperties, config.mainPropertyValues, data.info.mainPropertyValues)) || (config.keepAliveInterval !== undefined && !isValuesEqual(config.keepAliveInterval, data.info.keepAliveInterval)) ) { stateContext.markEdited(); diff --git a/webapp/packages/plugin-connections/src/ConnectionForm/Options/Options.tsx b/webapp/packages/plugin-connections/src/ConnectionForm/Options/Options.tsx index 0bbad04a87..f50955f7e4 100644 --- a/webapp/packages/plugin-connections/src/ConnectionForm/Options/Options.tsx +++ b/webapp/packages/plugin-connections/src/ConnectionForm/Options/Options.tsx @@ -226,7 +226,7 @@ export const Options: TabContainerPanelComponent = observe {config.configurationType === DriverConfigurationType.Manual && (driver?.useCustomPage ? (