From aeb891fd7cd5824be8aa807baf636ea9ed7f03b1 Mon Sep 17 00:00:00 2001 From: Ankita Kinger Date: Mon, 11 Nov 2024 14:28:18 +0530 Subject: [PATCH] fix: Adding permission check for the view tab on datasource editor (#37308) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description Adding permission check for the view tab on datasource editor Fixes [#37317](https://github.com/appsmithorg/appsmith/issues/37317) ## Automation /ok-to-test tags="@tag.Sanity, @tag.Datasource" ### :mag: Cypress test results > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: > Commit: bd2ecfe1a834869a99962116e2d45512e6dfc54a > Cypress dashboard. > Tags: `@tag.Sanity, @tag.Datasource` > Spec: >
Sun, 10 Nov 2024 18:51:27 UTC ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ ] No ## Summary by CodeRabbit - **New Features** - Introduced feature flag checks for tab rendering based on user permissions. - Conditional display of the "View Data" tab, ensuring only authorized users can access it. - **Bug Fixes** - Improved control flow for tab activation based on datasource validity and user permissions. --- .../Editor/DatasourceInfo/DatasorceTabs.tsx | 54 ++++++++++++------- 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/src/pages/Editor/DatasourceInfo/DatasorceTabs.tsx b/src/pages/Editor/DatasourceInfo/DatasorceTabs.tsx index 3960d00402a..85f9d0ad59a 100644 --- a/src/pages/Editor/DatasourceInfo/DatasorceTabs.tsx +++ b/src/pages/Editor/DatasourceInfo/DatasorceTabs.tsx @@ -19,6 +19,9 @@ import { } from "utils/editorContextUtils"; import { getPlugin } from "ee/selectors/entitiesSelector"; import GoogleSheetSchema from "./GoogleSheetSchema"; +import { useFeatureFlag } from "utils/hooks/useFeatureFlag"; +import { FEATURE_FLAG } from "ee/entities/FeatureFlag"; +import { getHasCreateDatasourceActionPermission } from "ee/utils/BusinessFeatures/permissionPageHelpers"; const TabsContainer = styled(Tabs)` height: 100%; @@ -72,38 +75,49 @@ const DatasourceTabs = (props: DatasourceTabProps) => { ) : false; + const isFeatureEnabled = useFeatureFlag(FEATURE_FLAG.license_gac_enabled); + + const canCreateDatasourceActions = getHasCreateDatasourceActionPermission( + isFeatureEnabled, + props.datasource?.userPermissions ?? [], + ); + return ( - - {createMessage(DATASOURCE_VIEW_DATA_TAB)} - + {canCreateDatasourceActions && ( + + {createMessage(DATASOURCE_VIEW_DATA_TAB)} + + )} {createMessage(DATASOURCE_CONFIGURATIONS_TAB)} - - {isGoogleSheetPlugin ? ( - - ) : ( - - )} - + {canCreateDatasourceActions && ( + + {isGoogleSheetPlugin ? ( + + ) : ( + + )} + + )}