fix: fix warning in ssh tunnel (#22912)
This commit is contained in:
parent
88119a9930
commit
16800cc14c
|
|
@ -63,6 +63,7 @@ import {
|
|||
ExtraJson,
|
||||
} from 'src/views/CRUD/data/database/types';
|
||||
import Loading from 'src/components/Loading';
|
||||
import { pick } from 'lodash';
|
||||
import ExtraOptions from './ExtraOptions';
|
||||
import SqlAlchemyForm from './SqlAlchemyForm';
|
||||
import DatabaseConnectionForm from './DatabaseConnectionForm';
|
||||
|
|
@ -372,29 +373,41 @@ export function dbReducer(
|
|||
[action.payload.name]: action.payload.value,
|
||||
},
|
||||
};
|
||||
case ActionType.setSSHTunnelLoginMethod:
|
||||
case ActionType.setSSHTunnelLoginMethod: {
|
||||
let ssh_tunnel = {};
|
||||
if (trimmedState?.ssh_tunnel) {
|
||||
// remove any attributes that are considered sensitive
|
||||
ssh_tunnel = pick(trimmedState.ssh_tunnel, [
|
||||
'id',
|
||||
'server_address',
|
||||
'server_port',
|
||||
'username',
|
||||
]);
|
||||
}
|
||||
if (action.payload.login_method === AuthType.privateKey) {
|
||||
const { password, ...rest } = trimmedState?.ssh_tunnel ?? {};
|
||||
return {
|
||||
...trimmedState,
|
||||
ssh_tunnel: {
|
||||
...rest,
|
||||
private_key: trimmedState?.ssh_tunnel?.private_key,
|
||||
private_key_password:
|
||||
trimmedState?.ssh_tunnel?.private_key_password,
|
||||
...ssh_tunnel,
|
||||
},
|
||||
};
|
||||
}
|
||||
if (action.payload.login_method === AuthType.password) {
|
||||
const { private_key, private_key_password, ...rest } =
|
||||
trimmedState?.ssh_tunnel ?? {};
|
||||
return {
|
||||
...trimmedState,
|
||||
ssh_tunnel: {
|
||||
...rest,
|
||||
password: trimmedState?.ssh_tunnel?.password,
|
||||
...ssh_tunnel,
|
||||
},
|
||||
};
|
||||
}
|
||||
return {
|
||||
...trimmedState,
|
||||
};
|
||||
}
|
||||
case ActionType.removeSSHTunnelConfig:
|
||||
return {
|
||||
...trimmedState,
|
||||
|
|
|
|||
Loading…
Reference in New Issue