Skip to content

Commit

Permalink
Merge pull request #49811 from Expensify/marcaaron-categoryAndTagAppr…
Browse files Browse the repository at this point in the history
…oversBeta

Put category and tag approvers behind a new beta
  • Loading branch information
neil-marcellini authored Oct 8, 2024
2 parents 6d74fe7 + ac9116e commit 7e80021
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 22 deletions.
1 change: 1 addition & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,7 @@ const CONST = {
NEW_DOT_COPILOT: 'newDotCopilot',
WORKSPACE_RULES: 'workspaceRules',
COMBINED_TRACK_SUBMIT: 'combinedTrackSubmit',
CATEGORY_AND_TAG_APPROVERS: 'categoryAndTagApprovers',
NEW_DOT_QBD: 'quickbooksDesktopOnNewDot',
},
BUTTON_STATES: {
Expand Down
5 changes: 5 additions & 0 deletions src/libs/Permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ function canUseWorkspaceRules(betas: OnyxEntry<Beta[]>): boolean {
return !!betas?.includes(CONST.BETAS.WORKSPACE_RULES) || canUseAllBetas(betas);
}

function canUseCategoryAndTagApprovers(betas: OnyxEntry<Beta[]>): boolean {
return !!betas?.includes(CONST.BETAS.CATEGORY_AND_TAG_APPROVERS) || canUseAllBetas(betas);
}

function canUseCombinedTrackSubmit(betas: OnyxEntry<Beta[]>): 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);
Expand Down Expand Up @@ -85,5 +89,6 @@ export default {
canUseWorkspaceRules,
canUseCombinedTrackSubmit,
canUseNewSearchRouter,
canUseCategoryAndTagApprovers,
canUseNewDotQBD,
};
46 changes: 26 additions & 20 deletions src/pages/workspace/categories/CategorySettingsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -43,6 +44,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);

Expand Down Expand Up @@ -255,26 +257,30 @@ function CategorySettingsPage({
/>
</OfflineWithFeedback>
)}
<MenuItemWithTopDescription
title={approverText}
description={translate('workspace.rules.categoryRules.approver')}
onPress={() => {
Navigation.navigate(ROUTES.WORSKPACE_CATEGORY_APPROVER.getRoute(policyID, policyCategory.name));
}}
shouldShowRightIcon
disabled={approverDisabled}
/>
{approverDisabled && (
<Text style={[styles.flexRow, styles.alignItemsCenter, styles.mv2, styles.mh5]}>
<Text style={[styles.textLabel, styles.colorMuted]}>{translate('workspace.rules.categoryRules.goTo')}</Text>{' '}
<TextLink
style={[styles.link, styles.label]}
onPress={() => Navigation.navigate(ROUTES.WORKSPACE_MORE_FEATURES.getRoute(policyID))}
>
{translate('workspace.common.moreFeatures')}
</TextLink>{' '}
<Text style={[styles.textLabel, styles.colorMuted]}>{translate('workspace.rules.categoryRules.andEnableWorkflows')}</Text>
</Text>
{canUseCategoryAndTagApprovers && (
<>
<MenuItemWithTopDescription
title={approverText}
description={translate('workspace.rules.categoryRules.approver')}
onPress={() => {
Navigation.navigate(ROUTES.WORSKPACE_CATEGORY_APPROVER.getRoute(policyID, policyCategory.name));
}}
shouldShowRightIcon
disabled={approverDisabled}
/>
{approverDisabled && (
<Text style={[styles.flexRow, styles.alignItemsCenter, styles.mv2, styles.mh5]}>
<Text style={[styles.textLabel, styles.colorMuted]}>{translate('workspace.rules.categoryRules.goTo')}</Text>{' '}
<TextLink
style={[styles.link, styles.label]}
onPress={() => Navigation.navigate(ROUTES.WORKSPACE_MORE_FEATURES.getRoute(policyID))}
>
{translate('workspace.common.moreFeatures')}
</TextLink>{' '}
<Text style={[styles.textLabel, styles.colorMuted]}>{translate('workspace.rules.categoryRules.andEnableWorkflows')}</Text>
</Text>
)}
</>
)}
{policy?.tax?.trackingEnabled && (
<MenuItemWithTopDescription
Expand Down
5 changes: 3 additions & 2 deletions src/pages/workspace/tags/TagSettingsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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);
Expand Down Expand Up @@ -153,7 +154,7 @@ function TagSettingsPage({route, navigation}: TagSettingsPageProps) {
/>
</OfflineWithFeedback>

{policy?.areRulesEnabled && (
{policy?.areRulesEnabled && canUseCategoryAndTagApprovers && (
<>
<View style={[styles.mh5, styles.mv3, styles.pt3, styles.borderTop]}>
<Text style={[styles.textNormal, styles.textStrong, styles.mv3]}>{translate('workspace.tags.tagRules')}</Text>
Expand Down

0 comments on commit 7e80021

Please sign in to comment.