Skip to content

Commit

Permalink
integrate getCountOfEnabledTagsOfList
Browse files Browse the repository at this point in the history
  • Loading branch information
rezkiy37 committed Jan 29, 2024
1 parent 67f05d8 commit cf53298
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/components/TagPicker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function TagPicker({selectedTag, tag, tagIndex, policyTags, policyRecentlyUsedTa

const policyRecentlyUsedTagsList = lodashGet(policyRecentlyUsedTags, tag, []);
const policyTagList = PolicyUtils.getTagList(policyTags, tagIndex);
const policyTagsCount = _.size(_.filter(policyTagList.tags, (policyTag) => policyTag.enabled));
const policyTagsCount = PolicyUtils.getCountOfEnabledTagsOfList(policyTagList);
const isTagsCountBelowThreshold = policyTagsCount < CONST.TAG_LIST_THRESHOLD;

const shouldShowTextInput = !isTagsCountBelowThreshold;
Expand Down
8 changes: 8 additions & 0 deletions src/libs/PolicyUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,13 @@ function getCleanedTagName(tag: string) {
return tag?.replace(/\\{1,2}:/g, ':');
}

/**
* Gets a count of enabled tags of a policy
*/
function getCountOfEnabledTagsOfList(policyTagList: PolicyTagList) {
return Object.values(policyTagList.tags).filter((policyTag) => policyTag.enabled).length;
}

function isPendingDeletePolicy(policy: OnyxEntry<Policy>): boolean {
return policy?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE;
}
Expand Down Expand Up @@ -230,6 +237,7 @@ export {
getTagListName,
getTagList,
getCleanedTagName,
getCountOfEnabledTagsOfList,
isPendingDeletePolicy,
isPolicyMember,
isPaidGroupPolicy,
Expand Down

0 comments on commit cf53298

Please sign in to comment.