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

Put category and tag approvers behind a new beta #49811

Merged
merged 6 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading