-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Fix opening tag with colon shows not found page while opening for the first time #42381
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -3405,6 +3405,7 @@ function renamePolicyCategory(policyID: string, policyCategory: {oldName: string | |||||||
|
||||||||
function createPolicyTag(policyID: string, tagName: string) { | ||||||||
const policyTag = PolicyUtils.getTagLists(allPolicyTags?.[`${ONYXKEYS.COLLECTION.POLICY_TAGS}${policyID}`] ?? {})?.[0] ?? {}; | ||||||||
const newTagName = PolicyUtils.escapeTagName(tagName); | ||||||||
|
||||||||
const onyxData: OnyxData = { | ||||||||
optimisticData: [ | ||||||||
|
@@ -3414,8 +3415,8 @@ function createPolicyTag(policyID: string, tagName: string) { | |||||||
value: { | ||||||||
[policyTag.name]: { | ||||||||
tags: { | ||||||||
[tagName]: { | ||||||||
name: tagName, | ||||||||
[newTagName]: { | ||||||||
name: newTagName, | ||||||||
enabled: true, | ||||||||
errors: null, | ||||||||
pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD, | ||||||||
|
@@ -3432,7 +3433,7 @@ function createPolicyTag(policyID: string, tagName: string) { | |||||||
value: { | ||||||||
[policyTag.name]: { | ||||||||
tags: { | ||||||||
[tagName]: { | ||||||||
[newTagName]: { | ||||||||
errors: null, | ||||||||
pendingAction: null, | ||||||||
}, | ||||||||
|
@@ -3448,7 +3449,7 @@ function createPolicyTag(policyID: string, tagName: string) { | |||||||
value: { | ||||||||
[policyTag.name]: { | ||||||||
tags: { | ||||||||
[tagName]: { | ||||||||
[newTagName]: { | ||||||||
errors: ErrorUtils.getMicroSecondOnyxError('workspace.tags.genericFailureMessage'), | ||||||||
}, | ||||||||
}, | ||||||||
|
@@ -3460,7 +3461,7 @@ function createPolicyTag(policyID: string, tagName: string) { | |||||||
|
||||||||
const parameters = { | ||||||||
policyID, | ||||||||
tags: JSON.stringify([{name: tagName}]), | ||||||||
tags: JSON.stringify([{name: newTagName}]), | ||||||||
}; | ||||||||
|
||||||||
API.write(WRITE_COMMANDS.CREATE_POLICY_TAG, parameters, onyxData); | ||||||||
|
@@ -3649,7 +3650,9 @@ function clearPolicyTagErrors(policyID: string, tagName: string) { | |||||||
|
||||||||
function renamePolicyTag(policyID: string, policyTag: {oldName: string; newName: string}) { | ||||||||
const tagListName = Object.keys(allPolicyTags?.[`${ONYXKEYS.COLLECTION.POLICY_TAGS}${policyID}`] ?? {})[0]; | ||||||||
const oldTag = allPolicyTags?.[`${ONYXKEYS.COLLECTION.POLICY_TAGS}${policyID}`]?.[tagListName]?.tags?.[policyTag.oldName] ?? {}; | ||||||||
const oldTagName = PolicyUtils.escapeTagName(policyTag.oldName); | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @bernhardoj Why do we need to escape the old tag? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. because we escaped the tag name when creating, It means that the old tag is escaped. Unless you want to cover tags created before this PR was merged, in this case, I think it isn't a good way There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The tag name that we pass to the old name is the "cleaned" tag name.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @bernhardoj Should we pass route.params.tagName instead of currentTagName
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would prefer to keep it as it is. Having 2 different sources of the tag name, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But we shouldn't make a redundant logic. Currently, we clean tag name and escape again There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO, we only need to escape new tag There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I have updated it. |
||||||||
const newTagName = PolicyUtils.escapeTagName(policyTag.newName); | ||||||||
const oldTag = allPolicyTags?.[`${ONYXKEYS.COLLECTION.POLICY_TAGS}${policyID}`]?.[tagListName]?.tags?.[oldTagName] ?? {}; | ||||||||
const onyxData: OnyxData = { | ||||||||
optimisticData: [ | ||||||||
{ | ||||||||
|
@@ -3658,15 +3661,15 @@ function renamePolicyTag(policyID: string, policyTag: {oldName: string; newName: | |||||||
value: { | ||||||||
[tagListName]: { | ||||||||
tags: { | ||||||||
[policyTag.oldName]: null, | ||||||||
[policyTag.newName]: { | ||||||||
[oldTagName]: null, | ||||||||
[newTagName]: { | ||||||||
...oldTag, | ||||||||
name: policyTag.newName, | ||||||||
name: newTagName, | ||||||||
pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, | ||||||||
pendingFields: { | ||||||||
name: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, | ||||||||
}, | ||||||||
previousTagName: policyTag.oldName, | ||||||||
previousTagName: oldTagName, | ||||||||
}, | ||||||||
}, | ||||||||
}, | ||||||||
|
@@ -3680,7 +3683,7 @@ function renamePolicyTag(policyID: string, policyTag: {oldName: string; newName: | |||||||
value: { | ||||||||
[tagListName]: { | ||||||||
tags: { | ||||||||
[policyTag.newName]: { | ||||||||
[newTagName]: { | ||||||||
errors: null, | ||||||||
pendingAction: null, | ||||||||
pendingFields: { | ||||||||
|
@@ -3699,8 +3702,8 @@ function renamePolicyTag(policyID: string, policyTag: {oldName: string; newName: | |||||||
value: { | ||||||||
[tagListName]: { | ||||||||
tags: { | ||||||||
[policyTag.newName]: null, | ||||||||
[policyTag.oldName]: { | ||||||||
[newTagName]: null, | ||||||||
[oldTagName]: { | ||||||||
...oldTag, | ||||||||
errors: ErrorUtils.getMicroSecondOnyxError('workspace.tags.genericFailureMessage'), | ||||||||
}, | ||||||||
|
@@ -3713,8 +3716,8 @@ function renamePolicyTag(policyID: string, policyTag: {oldName: string; newName: | |||||||
|
||||||||
const parameters = { | ||||||||
policyID, | ||||||||
oldName: policyTag.oldName, | ||||||||
newName: policyTag.newName, | ||||||||
oldName: oldTagName, | ||||||||
newName: newTagName, | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A bit hesitant when changing the param but everything seems to still work well |
||||||||
}; | ||||||||
|
||||||||
API.write(WRITE_COMMANDS.RENAME_POLICY_TAG, parameters, onyxData); | ||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bernhardoj I see there are many cases the BE replace
:
by\:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you clarify what you are trying to request?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You assume that the BE will replace
:
with\\:
and I see there are some exceptionalThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bernhardoj If you enter the tag name is a:b the BE will return
a\:b
and the optimistic data in your change will returna\\:b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you see any pattern in how the BE replaces the colon?
cc @amyevans
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, we need double

\\
to escape the\
. You can expand the object and see the name contains 2\
.If you do
'a:b'.replaceAll(':', '\:')
, nothing is changed.