From ddd8d17aa4785918afc5395312678d206a2f100a Mon Sep 17 00:00:00 2001 From: Antonio Rivero Martinez <38889534+Antonio-RiveroMartnez@users.noreply.github.com> Date: Wed, 8 Feb 2023 17:58:42 -0300 Subject: [PATCH] fix(ssh_tunnel): Fix bug on database edition for databases with ssh tunnels (#23006) Co-authored-by: Lyndsi Kay Williams <55605634+lyndsiWilliams@users.noreply.github.com> --- .../database/DatabaseModal/index.test.tsx | 21 +++++++++++++++++++ .../data/database/DatabaseModal/index.tsx | 4 ++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.test.tsx b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.test.tsx index d644b2f3e1..c957258e91 100644 --- a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.test.tsx +++ b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.test.tsx @@ -1510,6 +1510,27 @@ describe('DatabaseModal', () => { expect(allowFileUploadText).not.toBeInTheDocument(); expect(schemasForFileUploadText).not.toBeInTheDocument(); }); + + it('if the SSH Tunneling toggle is not displayed, nothing should get displayed', async () => { + const SSHTunnelingToggle = screen.queryByTestId('ssh-tunnel-switch'); + expect(SSHTunnelingToggle).not.toBeInTheDocument(); + const SSHTunnelServerAddressInput = screen.queryByTestId( + 'ssh-tunnel-server_address-input', + ); + expect(SSHTunnelServerAddressInput).not.toBeInTheDocument(); + const SSHTunnelServerPortInput = screen.queryByTestId( + 'ssh-tunnel-server_port-input', + ); + expect(SSHTunnelServerPortInput).not.toBeInTheDocument(); + const SSHTunnelUsernameInput = screen.queryByTestId( + 'ssh-tunnel-username-input', + ); + expect(SSHTunnelUsernameInput).not.toBeInTheDocument(); + const SSHTunnelPasswordInput = screen.queryByTestId( + 'ssh-tunnel-password-input', + ); + expect(SSHTunnelPasswordInput).not.toBeInTheDocument(); + }); }); describe('DatabaseModal w errors as objects', () => { diff --git a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx index 418b14f113..35151598e0 100644 --- a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx +++ b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx @@ -1154,10 +1154,10 @@ const DatabaseModal: FunctionComponent = ({ }, [passwordsNeeded]); useEffect(() => { - if (db) { + if (db && isSSHTunneling) { setUseSSHTunneling(!isEmpty(db?.ssh_tunnel)); } - }, [db]); + }, [db, isSSHTunneling]); const onDbImport = async (info: UploadChangeParam) => { setImportingErrorMessage('');