Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OS-81/project-permissions-render-on-tabhide #49

Merged
merged 3 commits into from Apr 1, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 17 additions & 1 deletion front/app/modules/commercial/granular_permissions/index.tsx
Expand Up @@ -9,6 +9,10 @@ type RenderOnFeatureFlagProps = {
children: ReactNode;
};

type RenderOnTabHideConditionProps = {
children: ReactNode;
};

const RenderOnFeatureFlag = ({ children }: RenderOnFeatureFlagProps) => {
const isGranularPermissionsEnabled = useFeatureFlag('granular_permissions');
if (isGranularPermissionsEnabled) {
Expand All @@ -17,6 +21,16 @@ const RenderOnFeatureFlag = ({ children }: RenderOnFeatureFlagProps) => {
return null;
};

const RenderOnTabHideCondition = ({ children }: RenderOnTabHideConditionProps) => {
// currently the same as RenderOnFeatureFlag, but wanted to make clear
// there's a difference and RenderOnTabHideCondition might diverge from RenderOnFeatureFlag
const isGranularPermissionsEnabled = useFeatureFlag('granular_permissions');
if (isGranularPermissionsEnabled) {
return <>{children}</>;
}
return null;
};

const configuration: ModuleConfiguration = {
routes: {
'admin.initiatives': [
Expand All @@ -40,7 +54,9 @@ const configuration: ModuleConfiguration = {
'app.containers.Admin.projects.edit': (props) => {
return (
<RenderOnFeatureFlag>
<ProjectSettingsTab {...props} />
<RenderOnTabHideCondition>
<ProjectSettingsTab {...props} />
</RenderOnTabHideCondition>
</RenderOnFeatureFlag>
);
},
Expand Down