mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
fix(plugin-connection-custom): CB-481 remove URL/Params switch from connection-custom
This commit is contained in:
+32
-34
@@ -57,18 +57,6 @@ export const Options = observer(function Options({
|
||||
<SubmittingForm onChange={controller.onFormChange} onSubmit={formController.save}>
|
||||
<FormBox>
|
||||
<FormBoxElement>
|
||||
{isOriginLocal && (
|
||||
<FormGroup>
|
||||
<FieldCheckbox
|
||||
name="template"
|
||||
value={model.connection.id}
|
||||
state={model.connection}
|
||||
checkboxLabel={translate('connections_connection_template')}
|
||||
disabled={model.editing || disabled}
|
||||
mod='surface'
|
||||
/>
|
||||
</FormGroup>
|
||||
)}
|
||||
<FormGroup>
|
||||
<Combobox
|
||||
name='driverId'
|
||||
@@ -106,31 +94,41 @@ export const Options = observer(function Options({
|
||||
{translate('connections_connection_description')}
|
||||
</Textarea>
|
||||
</FormGroup>
|
||||
{isOriginLocal && (
|
||||
<FormGroup>
|
||||
<FieldCheckbox
|
||||
name="template"
|
||||
value={model.connection.id}
|
||||
state={model.connection}
|
||||
checkboxLabel={translate('connections_connection_template')}
|
||||
disabled={model.editing || disabled}
|
||||
mod='surface'
|
||||
/>
|
||||
</FormGroup>
|
||||
)}
|
||||
</FormBoxElement>
|
||||
<FormBoxElement>
|
||||
{formController.isUrlConnection
|
||||
? (
|
||||
<FormGroup>
|
||||
<InputField
|
||||
type="text"
|
||||
name="url"
|
||||
state={model.connection}
|
||||
disabled={disabled}
|
||||
autoComplete={`section-${controller.driver?.id || 'driver'} section-jdbc`}
|
||||
mod='surface'
|
||||
>
|
||||
{translate('customConnection_url_JDBC')}
|
||||
</InputField>
|
||||
</FormGroup>
|
||||
)
|
||||
: (
|
||||
<ParametersForm
|
||||
connection={model.connection}
|
||||
embedded={controller.driver?.embedded}
|
||||
{formController.isUrlConnection ? (
|
||||
<FormGroup>
|
||||
<InputField
|
||||
type="text"
|
||||
name="url"
|
||||
state={model.connection}
|
||||
disabled={disabled}
|
||||
readOnly={!isOriginLocal}
|
||||
/>
|
||||
)}
|
||||
autoComplete={`section-${controller.driver?.id || 'driver'} section-jdbc`}
|
||||
mod='surface'
|
||||
>
|
||||
{translate('customConnection_url_JDBC')}
|
||||
</InputField>
|
||||
</FormGroup>
|
||||
) : (
|
||||
<ParametersForm
|
||||
connection={model.connection}
|
||||
embedded={controller.driver?.embedded}
|
||||
disabled={disabled}
|
||||
readOnly={!isOriginLocal}
|
||||
/>
|
||||
)}
|
||||
|
||||
{(controller.authModel && !controller.driver?.anonymousAccess) && (
|
||||
<>
|
||||
|
||||
+4
-36
@@ -10,7 +10,6 @@ import { observer } from 'mobx-react';
|
||||
import styled, { css } from 'reshadow';
|
||||
|
||||
import {
|
||||
Radio,
|
||||
InputField,
|
||||
useFocus,
|
||||
ObjectPropertyInfoForm,
|
||||
@@ -20,13 +19,11 @@ import {
|
||||
FormBox,
|
||||
FormBoxElement,
|
||||
FormGroup,
|
||||
RadioGroup
|
||||
} from '@cloudbeaver/core-blocks';
|
||||
import { DBDriver } from '@cloudbeaver/core-connections';
|
||||
import { useTranslate } from '@cloudbeaver/core-localization';
|
||||
import { useStyles } from '@cloudbeaver/core-theming';
|
||||
|
||||
import { ConnectionType } from '../ConnectionFormDialogController';
|
||||
import { IFormController } from './IFormController';
|
||||
import { ParametersForm } from './ParametersForm';
|
||||
|
||||
@@ -43,16 +40,7 @@ const connectionFormStyles = css`
|
||||
flex: 1;
|
||||
}
|
||||
FormBox {
|
||||
padding: 4px 24px 18px;
|
||||
}
|
||||
connection-type {
|
||||
padding: 12px;
|
||||
margin-left: 160px;
|
||||
}
|
||||
Radio {
|
||||
composes: theme-typography--body2 from global;
|
||||
font-weight: 500;
|
||||
padding: 0 12px;
|
||||
padding: 24px 4px 24px;
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -67,29 +55,7 @@ export const ConnectionForm = observer(function ConnectionForm({
|
||||
<SubmittingForm ref={focusedRef}>
|
||||
<FormBox>
|
||||
<FormBoxElement>
|
||||
<FormGroup>
|
||||
<connection-type as="div">
|
||||
<RadioGroup name='type' value={controller.connectionType} onChange={controller.onChangeType}>
|
||||
<Radio
|
||||
value={ConnectionType.Attributes}
|
||||
disabled={controller.isConnecting}
|
||||
mod={['primary']}
|
||||
>
|
||||
{translate('customConnection_connectionType_custom')}
|
||||
</Radio>
|
||||
<Radio
|
||||
value={ConnectionType.URL}
|
||||
disabled={controller.isConnecting}
|
||||
mod={['primary']}
|
||||
>
|
||||
{translate('customConnection_connectionType_url')}
|
||||
</Radio>
|
||||
</RadioGroup>
|
||||
</connection-type>
|
||||
</FormGroup>
|
||||
{controller.connectionType === ConnectionType.Attributes ? (
|
||||
<ParametersForm controller={controller} embedded={driver?.embedded} />
|
||||
) : (
|
||||
{controller.isUrlConnection ? (
|
||||
<FormGroup>
|
||||
<InputField
|
||||
type="text"
|
||||
@@ -102,6 +68,8 @@ export const ConnectionForm = observer(function ConnectionForm({
|
||||
{translate('customConnection_url_JDBC')}
|
||||
</InputField>
|
||||
</FormGroup>
|
||||
) : (
|
||||
<ParametersForm controller={controller} embedded={driver?.embedded} />
|
||||
)}
|
||||
{controller.authModel && (
|
||||
<>
|
||||
|
||||
+1
-4
@@ -8,13 +8,10 @@
|
||||
|
||||
import { ConnectionConfig, DatabaseAuthModel } from '@cloudbeaver/core-sdk';
|
||||
|
||||
import { ConnectionType } from '../ConnectionFormDialogController';
|
||||
|
||||
export interface IFormController {
|
||||
authModel?: DatabaseAuthModel;
|
||||
config: ConnectionConfig;
|
||||
connectionType: ConnectionType;
|
||||
isUrlConnection: boolean;
|
||||
isConnecting: boolean;
|
||||
onChangeType: (type: ConnectionType) => void;
|
||||
onChange: <T extends keyof ConnectionConfig>(property: T, value: ConnectionConfig[T]) => void;
|
||||
}
|
||||
|
||||
+5
-12
@@ -16,16 +16,9 @@ import { ErrorDetailsDialog } from '@cloudbeaver/core-notifications';
|
||||
import { ConnectionConfig, GQLErrorCatcher, DatabaseAuthModel } from '@cloudbeaver/core-sdk';
|
||||
|
||||
import { CustomConnectionService } from '../../CustomConnectionService';
|
||||
|
||||
export enum ConnectionType {
|
||||
Attributes,
|
||||
URL
|
||||
}
|
||||
|
||||
@injectable()
|
||||
export class ConnectionFormDialogController
|
||||
implements IInitializableController, IDestructibleController {
|
||||
@observable connectionType = ConnectionType.Attributes;
|
||||
@observable isLoading = true;
|
||||
@observable isConnecting = false;
|
||||
@observable driver!: DBDriver;
|
||||
@@ -42,6 +35,10 @@ implements IInitializableController, IDestructibleController {
|
||||
saveCredentials: false,
|
||||
};
|
||||
|
||||
get isUrlConnection() {
|
||||
return !this.driver.sampleURL;
|
||||
}
|
||||
|
||||
readonly error = new GQLErrorCatcher();
|
||||
private onClose!: () => void;
|
||||
private isDistructed = false;
|
||||
@@ -64,10 +61,6 @@ implements IInitializableController, IDestructibleController {
|
||||
this.isDistructed = true;
|
||||
}
|
||||
|
||||
onChangeType = (type: ConnectionType) => {
|
||||
this.connectionType = type;
|
||||
};
|
||||
|
||||
onChange = (property: keyof ConnectionConfig, value: any) => {
|
||||
this.config[property] = value;
|
||||
};
|
||||
@@ -112,7 +105,7 @@ implements IInitializableController, IDestructibleController {
|
||||
config.name = this.config.name;
|
||||
config.driverId = this.config.driverId;
|
||||
|
||||
if (this.connectionType === ConnectionType.Attributes) {
|
||||
if (!this.isUrlConnection) {
|
||||
config.name = this.config.databaseName;
|
||||
if (!this.driver?.embedded) {
|
||||
config.host = this.config.host;
|
||||
|
||||
Reference in New Issue
Block a user