Skip to content

Commit

Permalink
Merge pull request #41552 from gijoe0295/gijoe/38683
Browse files Browse the repository at this point in the history
hide delete option for multilevel tags
  • Loading branch information
luacmartins authored May 10, 2024
2 parents 7535c89 + 9c12a5a commit c00ca12
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/libs/PolicyUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,13 @@ function getCountOfEnabledTagsOfList(policyTags: PolicyTags) {
return Object.values(policyTags).filter((policyTag) => policyTag.enabled).length;
}

/**
* Whether the policy has multi-level tags
*/
function isMultiLevelTags(policyTagList: OnyxEntry<PolicyTagList>): boolean {
return Object.keys(policyTagList ?? {}).length > 1;
}

function isPendingDeletePolicy(policy: OnyxEntry<Policy>): boolean {
return policy?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE;
}
Expand Down Expand Up @@ -432,6 +439,7 @@ export {
getTagList,
getCleanedTagName,
getCountOfEnabledTagsOfList,
isMultiLevelTags,
isPendingDeletePolicy,
isPolicyEmployee,
isPolicyOwner,
Expand Down
3 changes: 2 additions & 1 deletion src/pages/workspace/tags/TagSettingsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ function TagSettingsPage({route, policyTags}: TagSettingsPageProps) {
};

const isThereAnyAccountingConnection = Object.keys(policy?.connections ?? {}).length !== 0;
const isMultiLevelTags = PolicyUtils.isMultiLevelTags(policyTags);
const threeDotsMenuItems = [];
if (!isThereAnyAccountingConnection) {
if (!isThereAnyAccountingConnection && !isMultiLevelTags) {
threeDotsMenuItems.push({
icon: Trashcan,
text: translate('workspace.tags.deleteTag'),
Expand Down
3 changes: 2 additions & 1 deletion src/pages/workspace/tags/WorkspaceTagsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,10 @@ function WorkspaceTagsPage({route}: WorkspaceTagsPageProps) {
const getHeaderButtons = () => {
const options: Array<DropdownOption<DeepValueOf<typeof CONST.POLICY.TAGS_BULK_ACTION_TYPES>>> = [];
const isThereAnyAccountingConnection = Object.keys(policy?.connections ?? {}).length !== 0;
const isMultiLevelTags = PolicyUtils.isMultiLevelTags(policyTags);

if (selectedTagsArray.length > 0) {
if (!isThereAnyAccountingConnection) {
if (!isThereAnyAccountingConnection && !isMultiLevelTags) {
options.push({
icon: Expensicons.Trashcan,
text: translate(selectedTagsArray.length === 1 ? 'workspace.tags.deleteTag' : 'workspace.tags.deleteTags'),
Expand Down

0 comments on commit c00ca12

Please sign in to comment.