mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
fix(plugin-connections): CB-1565 form defaults
This commit is contained in:
@@ -12,7 +12,6 @@ import styled, { css } from 'reshadow';
|
||||
|
||||
import { useAdministrationSettings } from '@cloudbeaver/core-administration';
|
||||
import { AUTH_PROVIDER_LOCAL_ID } from '@cloudbeaver/core-authentication';
|
||||
import type { TabContainerPanelComponent } from '@cloudbeaver/core-ui';
|
||||
import {
|
||||
InputField,
|
||||
SubmittingForm,
|
||||
@@ -32,6 +31,7 @@ import { DatabaseAuthModelsResource, DBDriverResource, isJDBCConnection, isLocal
|
||||
import { useService } from '@cloudbeaver/core-di';
|
||||
import { useTranslate } from '@cloudbeaver/core-localization';
|
||||
import { useStyles } from '@cloudbeaver/core-theming';
|
||||
import type { TabContainerPanelComponent } from '@cloudbeaver/core-ui';
|
||||
import { useAuthenticationAction } from '@cloudbeaver/core-ui';
|
||||
|
||||
import { ConnectionFormService } from '../ConnectionFormService';
|
||||
@@ -115,7 +115,7 @@ export const Options: TabContainerPanelComponent<IConnectionFormProps> = observe
|
||||
const originLocal = !info || isLocalConnection(info);
|
||||
|
||||
const drivers = driver.resource.values
|
||||
.filter(({ id }) => availableDrivers?.includes(id))
|
||||
.filter(({ id }) => availableDrivers.includes(id))
|
||||
.sort(driver.resource.compare);
|
||||
|
||||
let properties = authModel?.properties;
|
||||
@@ -125,8 +125,8 @@ export const Options: TabContainerPanelComponent<IConnectionFormProps> = observe
|
||||
}
|
||||
|
||||
// TODO we need to get these values other way
|
||||
const providerPropertiesWithoutBoolean = driver.data?.providerProperties?.slice().filter(property => property.dataType !== 'Boolean');
|
||||
const booleanProviderProperties = driver.data?.providerProperties?.slice().filter(property => property.dataType === 'Boolean');
|
||||
const providerPropertiesWithoutBoolean = driver.data?.providerProperties.slice().filter(property => property.dataType !== 'Boolean');
|
||||
const booleanProviderProperties = driver.data?.providerProperties.slice().filter(property => property.dataType === 'Boolean');
|
||||
|
||||
return styled(useStyles(styles, BASE_CONTAINERS_STYLES))(
|
||||
<SubmittingForm ref={formRef} onChange={handleFormChange}>
|
||||
@@ -139,7 +139,7 @@ export const Options: TabContainerPanelComponent<IConnectionFormProps> = observe
|
||||
state={config}
|
||||
items={drivers}
|
||||
keySelector={driver => driver.id}
|
||||
valueSelector={driver => driver?.name ?? ''}
|
||||
valueSelector={driver => driver.name ?? ''}
|
||||
titleSelector={driver => driver.description}
|
||||
iconSelector={driver => driver.icon}
|
||||
searchable={drivers.length > 10}
|
||||
@@ -194,7 +194,7 @@ export const Options: TabContainerPanelComponent<IConnectionFormProps> = observe
|
||||
state={config}
|
||||
disabled={edit || disabled}
|
||||
readOnly={readonly}
|
||||
// autoHide={} // maybe better to use autoHide
|
||||
// autoHide // maybe better to use autoHide
|
||||
>
|
||||
{translate('connections_connection_template')}
|
||||
</FieldCheckbox>
|
||||
|
||||
@@ -67,19 +67,19 @@ export function useOptions(state: IConnectionFormState) {
|
||||
},
|
||||
} = refObject;
|
||||
|
||||
if (config.host === prevDriver?.defaultServer) {
|
||||
if (!prevDriver || config.host === prevDriver.defaultServer) {
|
||||
config.host = driver?.defaultServer || 'localhost';
|
||||
}
|
||||
|
||||
if (config.port === prevDriver?.defaultPort) {
|
||||
if (!prevDriver || config.port === prevDriver.defaultPort) {
|
||||
config.port = driver?.defaultPort;
|
||||
}
|
||||
|
||||
if (config.databaseName === prevDriver?.defaultDatabase) {
|
||||
if (!prevDriver || config.databaseName === prevDriver.defaultDatabase) {
|
||||
config.databaseName = driver?.defaultDatabase;
|
||||
}
|
||||
|
||||
if (config.url === prevDriver?.sampleURL) {
|
||||
if (!prevDriver || config.url === prevDriver.sampleURL) {
|
||||
config.url = driver?.sampleURL;
|
||||
}
|
||||
|
||||
@@ -87,12 +87,10 @@ export function useOptions(state: IConnectionFormState) {
|
||||
|
||||
if (driver?.id !== prevDriver?.id && !info) {
|
||||
for (const property of Object.keys(config.credentials)) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
||||
delete config.credentials[property];
|
||||
}
|
||||
|
||||
for (const property of Object.keys(config.providerProperties)) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
||||
delete config.providerProperties[property];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user