mirror of
https://github.com/apache/superset.git
synced 2026-05-31 05:09:20 +00:00
fix: SSH Tunnel creation with dynamic form (#24196)
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
* under the License.
|
||||
*/
|
||||
import React from 'react';
|
||||
import { isEmpty } from 'lodash';
|
||||
import { SupersetTheme, t } from '@superset-ui/core';
|
||||
import { AntdSwitch } from 'src/components';
|
||||
import InfoTooltip from 'src/components/InfoTooltip';
|
||||
@@ -250,3 +251,33 @@ export const forceSSLField = ({
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
||||
export const SSHTunnelSwitch = ({
|
||||
isEditMode,
|
||||
changeMethods,
|
||||
db,
|
||||
}: FieldPropTypes) => (
|
||||
<div css={(theme: SupersetTheme) => infoTooltip(theme)}>
|
||||
<AntdSwitch
|
||||
disabled={isEditMode && !isEmpty(db?.ssh_tunnel)}
|
||||
checked={db?.parameters?.ssh}
|
||||
onChange={changed => {
|
||||
changeMethods.onParametersChange({
|
||||
target: {
|
||||
type: 'toggle',
|
||||
name: 'ssh',
|
||||
checked: true,
|
||||
value: changed,
|
||||
},
|
||||
});
|
||||
}}
|
||||
data-test="ssh-tunnel-switch"
|
||||
/>
|
||||
<span css={toggleStyle}>{t('SSH Tunnel')}</span>
|
||||
<InfoTooltip
|
||||
tooltip={t('SSH Tunnel configuration parameters')}
|
||||
placement="right"
|
||||
viewBox="0 -5 24 24"
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -31,6 +31,7 @@ import {
|
||||
portField,
|
||||
queryField,
|
||||
usernameField,
|
||||
SSHTunnelSwitch,
|
||||
} from './CommonParameters';
|
||||
import { validatedInputField } from './ValidatedInputField';
|
||||
import { EncryptedField } from './EncryptedField';
|
||||
@@ -55,6 +56,7 @@ export const FormFieldOrder = [
|
||||
'account',
|
||||
'warehouse',
|
||||
'role',
|
||||
'ssh',
|
||||
];
|
||||
|
||||
export interface FieldPropTypes {
|
||||
@@ -102,6 +104,7 @@ const FORM_FIELD_MAP = {
|
||||
warehouse: validatedInputField,
|
||||
role: validatedInputField,
|
||||
account: validatedInputField,
|
||||
ssh: SSHTunnelSwitch,
|
||||
};
|
||||
|
||||
interface DatabaseConnectionFormProps {
|
||||
|
||||
Reference in New Issue
Block a user