fix: Adding permission check for the view tab on datasource editor (#37308)
## 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" ### 🔍 Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/11766974110> > Commit: bd2ecfe1a834869a99962116e2d45512e6dfc54a > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=11766974110&attempt=2" target="_blank">Cypress dashboard</a>. > Tags: `@tag.Sanity, @tag.Datasource` > Spec: > <hr>Sun, 10 Nov 2024 18:51:27 UTC <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ ] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## 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. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
parent
99841a34c6
commit
5c075e89de
|
|
@ -19,6 +19,9 @@ import {
|
||||||
} from "utils/editorContextUtils";
|
} from "utils/editorContextUtils";
|
||||||
import { getPlugin } from "ee/selectors/entitiesSelector";
|
import { getPlugin } from "ee/selectors/entitiesSelector";
|
||||||
import GoogleSheetSchema from "./GoogleSheetSchema";
|
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)`
|
const TabsContainer = styled(Tabs)`
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
|
@ -72,38 +75,49 @@ const DatasourceTabs = (props: DatasourceTabProps) => {
|
||||||
)
|
)
|
||||||
: false;
|
: false;
|
||||||
|
|
||||||
|
const isFeatureEnabled = useFeatureFlag(FEATURE_FLAG.license_gac_enabled);
|
||||||
|
|
||||||
|
const canCreateDatasourceActions = getHasCreateDatasourceActionPermission(
|
||||||
|
isFeatureEnabled,
|
||||||
|
props.datasource?.userPermissions ?? [],
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TabsContainer
|
<TabsContainer
|
||||||
defaultValue={
|
defaultValue={
|
||||||
isDatasourceValid || isPluginAuthorized
|
(isDatasourceValid || isPluginAuthorized) && canCreateDatasourceActions
|
||||||
? VIEW_MODE_TABS.VIEW_DATA
|
? VIEW_MODE_TABS.VIEW_DATA
|
||||||
: VIEW_MODE_TABS.CONFIGURATIONS
|
: VIEW_MODE_TABS.CONFIGURATIONS
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<TabListWrapper className="t--datasource-tab-list">
|
<TabListWrapper className="t--datasource-tab-list">
|
||||||
<Tab value={VIEW_MODE_TABS.VIEW_DATA}>
|
{canCreateDatasourceActions && (
|
||||||
{createMessage(DATASOURCE_VIEW_DATA_TAB)}
|
<Tab value={VIEW_MODE_TABS.VIEW_DATA}>
|
||||||
</Tab>
|
{createMessage(DATASOURCE_VIEW_DATA_TAB)}
|
||||||
|
</Tab>
|
||||||
|
)}
|
||||||
<Tab value={VIEW_MODE_TABS.CONFIGURATIONS}>
|
<Tab value={VIEW_MODE_TABS.CONFIGURATIONS}>
|
||||||
{createMessage(DATASOURCE_CONFIGURATIONS_TAB)}
|
{createMessage(DATASOURCE_CONFIGURATIONS_TAB)}
|
||||||
</Tab>
|
</Tab>
|
||||||
</TabListWrapper>
|
</TabListWrapper>
|
||||||
<TabPanelContainer
|
{canCreateDatasourceActions && (
|
||||||
className="t--datasource-tab-container"
|
<TabPanelContainer
|
||||||
value={VIEW_MODE_TABS.VIEW_DATA}
|
className="t--datasource-tab-container"
|
||||||
>
|
value={VIEW_MODE_TABS.VIEW_DATA}
|
||||||
{isGoogleSheetPlugin ? (
|
>
|
||||||
<GoogleSheetSchema
|
{isGoogleSheetPlugin ? (
|
||||||
datasourceId={props.datasource.id}
|
<GoogleSheetSchema
|
||||||
pluginId={props.datasource?.pluginId}
|
datasourceId={props.datasource.id}
|
||||||
/>
|
pluginId={props.datasource?.pluginId}
|
||||||
) : (
|
/>
|
||||||
<DatasourceViewModeSchema
|
) : (
|
||||||
datasource={props.datasource}
|
<DatasourceViewModeSchema
|
||||||
setDatasourceViewModeFlag={setDatasourceViewModeFlagClick}
|
datasource={props.datasource}
|
||||||
/>
|
setDatasourceViewModeFlag={setDatasourceViewModeFlagClick}
|
||||||
)}
|
/>
|
||||||
</TabPanelContainer>
|
)}
|
||||||
|
</TabPanelContainer>
|
||||||
|
)}
|
||||||
<ConfigurationsTabPanelContainer
|
<ConfigurationsTabPanelContainer
|
||||||
className="t--datasource-tab-container"
|
className="t--datasource-tab-container"
|
||||||
value={VIEW_MODE_TABS.CONFIGURATIONS}
|
value={VIEW_MODE_TABS.CONFIGURATIONS}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user