-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Merged
techievivek
merged 5 commits into
Expensify:main
from
bernhardoj:fix/41083-escape-colon-from-tag-name
May 29, 2024
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = policyTag.oldName; | ||
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); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.