From bd2ecfe1a834869a99962116e2d45512e6dfc54a Mon Sep 17 00:00:00 2001 From: Ankita Kinger Date: Sun, 10 Nov 2024 22:28:49 +0530 Subject: [PATCH] adding permission check for the view tab on datasource editor --- .../Editor/DatasourceInfo/DatasorceTabs.tsx | 54 ++++++++++++------- 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/app/client/src/pages/Editor/DatasourceInfo/DatasorceTabs.tsx b/app/client/src/pages/Editor/DatasourceInfo/DatasorceTabs.tsx index 3960d00402a..85f9d0ad59a 100644 --- a/app/client/src/pages/Editor/DatasourceInfo/DatasorceTabs.tsx +++ b/app/client/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 ? ( + + ) : ( + + )} + + )}