From cc2aca1fe09f504a7616b085fe8facf321f645c7 Mon Sep 17 00:00:00 2001 From: Marc Glasser Date: Thu, 26 Sep 2024 10:01:46 -1000 Subject: [PATCH 1/2] Put category and tag approvers behind a new beta --- src/CONST.ts | 1 + src/libs/Permissions.ts | 5 +++++ .../categories/CategorySettingsPage.tsx | 22 +++++++++++-------- src/pages/workspace/tags/TagSettingsPage.tsx | 5 +++-- 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index c7f6f12a0419..09aee309d7d9 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -474,6 +474,7 @@ const CONST = { NEW_DOT_COPILOT: 'newDotCopilot', WORKSPACE_RULES: 'workspaceRules', COMBINED_TRACK_SUBMIT: 'combinedTrackSubmit', + CATEGORY_AND_TAG_APPROVERS: 'categoryAndTagApprovers', }, BUTTON_STATES: { DEFAULT: 'default', diff --git a/src/libs/Permissions.ts b/src/libs/Permissions.ts index 7f7e89ad3585..18d2810fd2f6 100644 --- a/src/libs/Permissions.ts +++ b/src/libs/Permissions.ts @@ -45,6 +45,10 @@ function canUseWorkspaceRules(betas: OnyxEntry): boolean { return !!betas?.includes(CONST.BETAS.WORKSPACE_RULES) || canUseAllBetas(betas); } +function canUseCategoryAndTagApprovers(betas: OnyxEntry): boolean { + return !!betas?.includes(CONST.BETAS.CATEGORY_AND_TAG_APPROVERS) || canUseAllBetas(betas); +} + function canUseCombinedTrackSubmit(betas: OnyxEntry): boolean { // We don't need to show this to all betas since this will be used for developing a feature for A/B testing. return !!betas?.includes(CONST.BETAS.COMBINED_TRACK_SUBMIT); @@ -81,4 +85,5 @@ export default { canUseWorkspaceRules, canUseCombinedTrackSubmit, canUseNewSearchRouter, + canUseCategoryAndTagApprovers, }; diff --git a/src/pages/workspace/categories/CategorySettingsPage.tsx b/src/pages/workspace/categories/CategorySettingsPage.tsx index 05111864f61a..d0fbaadc1506 100644 --- a/src/pages/workspace/categories/CategorySettingsPage.tsx +++ b/src/pages/workspace/categories/CategorySettingsPage.tsx @@ -14,6 +14,7 @@ import Switch from '@components/Switch'; import Text from '@components/Text'; import TextLink from '@components/TextLink'; import useLocalize from '@hooks/useLocalize'; +import usePermissions from '@hooks/usePermissions'; import usePolicy from '@hooks/usePolicy'; import useThemeStyles from '@hooks/useThemeStyles'; import * as CategoryUtils from '@libs/CategoryUtils'; @@ -42,6 +43,7 @@ function CategorySettingsPage({ const [policyCategories] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${policyID}`); const styles = useThemeStyles(); const {translate} = useLocalize(); + const {canUseCategoryAndTagApprovers} = usePermissions(); const [deleteCategoryConfirmModalVisible, setDeleteCategoryConfirmModalVisible] = useState(false); const policy = usePolicy(policyID); @@ -253,15 +255,17 @@ function CategorySettingsPage({ /> )} - { - Navigation.navigate(ROUTES.WORSKPACE_CATEGORY_APPROVER.getRoute(policyID, policyCategory.name)); - }} - shouldShowRightIcon - disabled={approverDisabled} - /> + {canUseCategoryAndTagApprovers && ( + { + Navigation.navigate(ROUTES.WORSKPACE_CATEGORY_APPROVER.getRoute(policyID, policyCategory.name)); + }} + shouldShowRightIcon + disabled={approverDisabled} + /> + )} {approverDisabled && ( {translate('workspace.rules.categoryRules.goTo')}{' '} diff --git a/src/pages/workspace/tags/TagSettingsPage.tsx b/src/pages/workspace/tags/TagSettingsPage.tsx index f5599ed4c269..aedd7e36a274 100644 --- a/src/pages/workspace/tags/TagSettingsPage.tsx +++ b/src/pages/workspace/tags/TagSettingsPage.tsx @@ -13,6 +13,7 @@ import Switch from '@components/Switch'; import Text from '@components/Text'; import TextLink from '@components/TextLink'; import useLocalize from '@hooks/useLocalize'; +import usePermissions from '@hooks/usePermissions'; import usePolicy from '@hooks/usePolicy'; import useThemeStyles from '@hooks/useThemeStyles'; import * as ErrorUtils from '@libs/ErrorUtils'; @@ -38,7 +39,7 @@ function TagSettingsPage({route, navigation}: TagSettingsPageProps) { const policyTag = useMemo(() => PolicyUtils.getTagList(policyTags, orderWeight), [policyTags, orderWeight]); const policy = usePolicy(policyID); const hasAccountingConnections = PolicyUtils.hasAccountingConnections(policy); - + const {canUseCategoryAndTagApprovers} = usePermissions(); const [isDeleteTagModalOpen, setIsDeleteTagModalOpen] = React.useState(false); const currentPolicyTag = policyTag.tags[tagName] ?? Object.values(policyTag.tags ?? {}).find((tag) => tag.previousTagName === tagName); @@ -153,7 +154,7 @@ function TagSettingsPage({route, navigation}: TagSettingsPageProps) { /> - {policy?.areRulesEnabled && ( + {policy?.areRulesEnabled && canUseCategoryAndTagApprovers && ( <> {translate('workspace.tags.tagRules')} From 246fa81691fba6abb313e7e65e2434278ffec722 Mon Sep 17 00:00:00 2001 From: Marc Glasser Date: Thu, 26 Sep 2024 10:06:08 -1000 Subject: [PATCH 2/2] Hide the More Features cta text on CategorySettingsPage --- .../categories/CategorySettingsPage.tsx | 44 ++++++++++--------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/src/pages/workspace/categories/CategorySettingsPage.tsx b/src/pages/workspace/categories/CategorySettingsPage.tsx index d0fbaadc1506..afab606c76a4 100644 --- a/src/pages/workspace/categories/CategorySettingsPage.tsx +++ b/src/pages/workspace/categories/CategorySettingsPage.tsx @@ -256,27 +256,29 @@ function CategorySettingsPage({ )} {canUseCategoryAndTagApprovers && ( - { - Navigation.navigate(ROUTES.WORSKPACE_CATEGORY_APPROVER.getRoute(policyID, policyCategory.name)); - }} - shouldShowRightIcon - disabled={approverDisabled} - /> - )} - {approverDisabled && ( - - {translate('workspace.rules.categoryRules.goTo')}{' '} - Navigation.navigate(ROUTES.WORKSPACE_MORE_FEATURES.getRoute(policyID))} - > - {translate('workspace.common.moreFeatures')} - {' '} - {translate('workspace.rules.categoryRules.andEnableWorkflows')} - + <> + { + Navigation.navigate(ROUTES.WORSKPACE_CATEGORY_APPROVER.getRoute(policyID, policyCategory.name)); + }} + shouldShowRightIcon + disabled={approverDisabled} + /> + {approverDisabled && ( + + {translate('workspace.rules.categoryRules.goTo')}{' '} + Navigation.navigate(ROUTES.WORKSPACE_MORE_FEATURES.getRoute(policyID))} + > + {translate('workspace.common.moreFeatures')} + {' '} + {translate('workspace.rules.categoryRules.andEnableWorkflows')} + + )} + )} {policy?.tax?.trackingEnabled && (