Skip to content

Commit

Permalink
Put category and tag approvers behind a new beta
Browse files Browse the repository at this point in the history
  • Loading branch information
marcaaron committed Sep 26, 2024
1 parent 7743f38 commit cc2aca1
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 11 deletions.
1 change: 1 addition & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
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 @@ -81,4 +85,5 @@ export default {
canUseWorkspaceRules,
canUseCombinedTrackSubmit,
canUseNewSearchRouter,
canUseCategoryAndTagApprovers,
};
22 changes: 13 additions & 9 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 @@ -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);

Expand Down Expand Up @@ -253,15 +255,17 @@ 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}
/>
{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>{' '}
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 cc2aca1

Please sign in to comment.