From 49bd009c9abf21e91359ac8982a0947cf82a7753 Mon Sep 17 00:00:00 2001 From: Antonio Rivero Date: Mon, 6 Feb 2023 19:58:19 -0300 Subject: [PATCH 1/2] SSH Tunnel UI: - Fix bug on DB edition for dbs with ssh tunnels: If the feature flag is OFF the toggle wouldn't show but the rest of the form fields would - Add test that check that if no toggle is in the document, then the rest of fields must not be in the document as well --- .../database/DatabaseModal/index.test.tsx | 21 +++++++++++++++++++ .../data/database/DatabaseModal/index.tsx | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) 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 d644b2f3e173f..c957258e91ff1 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 418b14f113537..3d52cdcaf61ce 100644 --- a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx +++ b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx @@ -1154,7 +1154,7 @@ const DatabaseModal: FunctionComponent = ({ }, [passwordsNeeded]); useEffect(() => { - if (db) { + if (db && isSSHTunneling) { setUseSSHTunneling(!isEmpty(db?.ssh_tunnel)); } }, [db]); From 5f6da7fac1aec857d9bd517dfd4873178cbb5aac Mon Sep 17 00:00:00 2001 From: Antonio Rivero Martinez <38889534+Antonio-RiveroMartnez@users.noreply.github.com> Date: Mon, 6 Feb 2023 21:02:02 -0300 Subject: [PATCH 2/2] Update superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx Co-authored-by: Lyndsi Kay Williams <55605634+lyndsiWilliams@users.noreply.github.com> --- .../src/views/CRUD/data/database/DatabaseModal/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 3d52cdcaf61ce..35151598e08d3 100644 --- a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx +++ b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx @@ -1157,7 +1157,7 @@ const DatabaseModal: FunctionComponent = ({ if (db && isSSHTunneling) { setUseSSHTunneling(!isEmpty(db?.ssh_tunnel)); } - }, [db]); + }, [db, isSSHTunneling]); const onDbImport = async (info: UploadChangeParam) => { setImportingErrorMessage('');