From 751fa52cf183a611710e6f8f3e8bf163434fd4e3 Mon Sep 17 00:00:00 2001 From: Ryan Liang Date: Mon, 1 Apr 2024 19:29:19 -0700 Subject: [PATCH] Add conditional rendering for data connection page for tabs Signed-off-by: Ryan Liang --- .../data_connection.test.tsx.snap | 127 ++++++------------ .../components/manage/data_connection.tsx | 81 ++++++----- 2 files changed, 87 insertions(+), 121 deletions(-) diff --git a/public/components/datasources/components/__tests__/__snapshots__/data_connection.test.tsx.snap b/public/components/datasources/components/__tests__/__snapshots__/data_connection.test.tsx.snap index a0cc385e53..6a56e9ac87 100644 --- a/public/components/datasources/components/__tests__/__snapshots__/data_connection.test.tsx.snap +++ b/public/components/datasources/components/__tests__/__snapshots__/data_connection.test.tsx.snap @@ -359,8 +359,8 @@ exports[`Data Connection Page test Renders S3 data connection page with data 1`] > - -
- @@ -558,31 +506,38 @@ exports[`Data Connection Page test Renders S3 data connection page with data 1`] class="euiHorizontalRule euiHorizontalRule--full euiHorizontalRule--marginLarge" />
-
-
-

- Loading - databases -

+
+
+ Query access +
+
+ Admin only +
+
-
+
+
{ // eslint-disable-next-line react-hooks/exhaustive-deps }, [chrome, http]); - const tabs = [ - { - id: 'associated_objects', - name: 'Associated Objects', - disabled: false, - content: ( - - ), - }, - { - id: 'acceleration_table', - name: 'Accelerations', - disabled: false, - content: ( - - ), - }, - { - id: 'installed_integrations', - name: 'Installed Integrations', - disabled: false, - content: ( - - ), - }, + const genericTabs = [ { id: 'access_control', name: 'Access control', @@ -260,6 +226,51 @@ export const DataConnection = (props: { dataSource: string }) => { }, ]; + const conditionalTabs = + datasourceDetails.connector !== 'PROMETHEUS' + ? [ + { + id: 'associated_objects', + name: 'Associated Objects', + disabled: false, + content: ( + + ), + }, + { + id: 'acceleration_table', + name: 'Accelerations', + disabled: false, + content: ( + + ), + }, + { + id: 'installed_integrations', + name: 'Installed Integrations', + disabled: false, + content: ( + + ), + }, + ] + : []; + + const tabs = [...conditionalTabs, ...genericTabs]; + const QueryOrAccelerateData = () => { switch (datasourceDetails.connector) { case 'S3GLUE':