Skip to content

Commit

Permalink
Merge pull request #38759 from Tony-MK/fix/37847
Browse files Browse the repository at this point in the history
Fix/37847 - Show the tags in the first policyTagLists
  • Loading branch information
luacmartins authored Apr 17, 2024
2 parents e95fd06 + 8ad872e commit 7a30485
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/pages/workspace/tags/EditTagPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function EditTagPage({route, policyTags}: EditTagPageProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();
const {inputCallbackRef} = useAutoFocusInput();
const currentTagName = route.params.tagName;
const currentTagName = PolicyUtils.getCleanedTagName(route.params.tagName);

const validate = useCallback(
(values: FormOnyxValues<typeof ONYXKEYS.FORMS.WORKSPACE_TAG_FORM>) => {
Expand Down
4 changes: 2 additions & 2 deletions src/pages/workspace/tags/TagSettingsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function TagSettingsPage({route, policyTags}: TagSettingsPageProps) {
testID={TagSettingsPage.displayName}
>
<HeaderWithBackButton
title={route.params.tagName}
title={PolicyUtils.getCleanedTagName(route.params.tagName)}
shouldShowThreeDotsButton
shouldSetModalVisibility={false}
threeDotsAnchorPosition={styles.threeDotsPopoverOffset(windowWidth)}
Expand Down Expand Up @@ -122,7 +122,7 @@ function TagSettingsPage({route, policyTags}: TagSettingsPageProps) {
</OfflineWithFeedback>
<OfflineWithFeedback pendingAction={currentPolicyTag.pendingFields?.name}>
<MenuItemWithTopDescription
title={currentPolicyTag.name}
title={PolicyUtils.getCleanedTagName(currentPolicyTag.name)}
description={translate(`workspace.tags.tagName`)}
onPress={navigateToEditTag}
shouldShowRightIcon
Expand Down
6 changes: 4 additions & 2 deletions src/pages/workspace/tags/WorkspaceEditTagsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ function WorkspaceEditTagsPage({route, policyTags}: WorkspaceEditTagsPageProps)

const updateTaglistName = useCallback(
(values: FormOnyxValues<typeof ONYXKEYS.FORMS.POLICY_TAG_NAME_FORM>) => {
Policy.renamePolicyTaglist(route.params.policyID, {oldName: taglistName, newName: values[INPUT_IDS.POLICY_TAGS_NAME]}, policyTags);
if (values[INPUT_IDS.POLICY_TAGS_NAME] !== taglistName) {
Policy.renamePolicyTaglist(route.params.policyID, {oldName: taglistName, newName: values[INPUT_IDS.POLICY_TAGS_NAME]}, policyTags);
}
Navigation.goBack();
},
[policyTags, route.params.policyID, taglistName],
Expand Down Expand Up @@ -81,7 +83,7 @@ function WorkspaceEditTagsPage({route, policyTags}: WorkspaceEditTagsPageProps)
inputID={INPUT_IDS.POLICY_TAGS_NAME}
label={translate(`workspace.tags.customTagName`)}
accessibilityLabel={translate(`workspace.tags.customTagName`)}
defaultValue={taglistName}
defaultValue={PolicyUtils.getCleanedTagName(taglistName)}
role={CONST.ROLE.PRESENTATION}
ref={inputCallbackRef}
/>
Expand Down
5 changes: 3 additions & 2 deletions src/pages/workspace/tags/WorkspaceTagsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ function WorkspaceTagsPage({policyTags, route}: WorkspaceTagsPageProps) {
setSelectedTags({});
}, [isFocused]);

const policyTagLists = useMemo(() => PolicyUtils.getTagLists(policyTags), [policyTags]);
// We currently don't support multi level tags, so let's only get the first level tags.
const policyTagLists = useMemo(() => PolicyUtils.getTagLists(policyTags).slice(0, 1), [policyTags]);
const tagList = useMemo<PolicyForList[]>(
() =>
policyTagLists
Expand All @@ -101,7 +102,7 @@ function WorkspaceTagsPage({policyTags, route}: WorkspaceTagsPageProps) {
const isDisabled = tag.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE;
return {
value: tag.name,
text: tag.name,
text: PolicyUtils.getCleanedTagName(tag.name),
keyForList: tag.name,
isSelected: !!selectedTags[tag.name],
pendingAction: tag.pendingAction,
Expand Down

0 comments on commit 7a30485

Please sign in to comment.