-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Tags violations #80448
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
Tags violations #80448
Changes from all commits
3858085
3cb35ea
b826cff
1df66d0
29d7bba
ae6e08e
ee75418
4ea22d5
951a3e8
968e697
2098e48
120fec9
097c66f
c9b5f52
5b7668d
42fdbb6
2234982
fb0e1d4
1d62dea
3046d50
0d2656a
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 |
|---|---|---|
|
|
@@ -121,33 +121,35 @@ function updateImportSpreadsheetData(tagsLength: number): OnyxData<typeof ONYXKE | |
| } | ||
|
|
||
| function createPolicyTag( | ||
| policyID: string, | ||
| policyData: PolicyData, | ||
| tagName: string, | ||
| policyTags: PolicyTagLists = {}, | ||
| setupTagsTaskReport?: OnyxEntry<Report>, | ||
| setupCategoriesAndTagsTaskReport?: OnyxEntry<Report>, | ||
| policyHasCustomCategories?: boolean, | ||
| ) { | ||
| const {policy, tags: policyTags} = policyData; | ||
| const policyID = policy?.id; | ||
| const policyTag = PolicyUtils.getTagLists(policyTags)?.at(0) ?? ({} as PolicyTagList); | ||
| const newTagName = PolicyUtils.escapeTagName(tagName); | ||
| const tagListsOptimisticData = { | ||
| [policyTag.name]: { | ||
| tags: { | ||
| [newTagName]: { | ||
| name: newTagName, | ||
| enabled: true, | ||
| errors: null, | ||
| pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD, | ||
| }, | ||
| }, | ||
| }, | ||
| }; | ||
|
|
||
| const onyxData: OnyxData<typeof ONYXKEYS.COLLECTION.POLICY_TAGS> = { | ||
| optimisticData: [ | ||
| { | ||
| onyxMethod: Onyx.METHOD.MERGE, | ||
| key: `${ONYXKEYS.COLLECTION.POLICY_TAGS}${policyID}`, | ||
| value: { | ||
| [policyTag.name]: { | ||
| tags: { | ||
| [newTagName]: { | ||
| name: newTagName, | ||
| enabled: true, | ||
| errors: null, | ||
| pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| value: tagListsOptimisticData, | ||
| }, | ||
| ], | ||
| successData: [ | ||
|
|
@@ -183,6 +185,8 @@ function createPolicyTag( | |
| ], | ||
| }; | ||
|
|
||
| pushTransactionViolationsOnyxData(onyxData, policyData, {}, {}, tagListsOptimisticData); | ||
|
|
||
| const parameters = { | ||
| policyID, | ||
| tags: JSON.stringify([{name: newTagName}]), | ||
|
|
@@ -202,10 +206,12 @@ function createPolicyTag( | |
| function importPolicyTags(policyID: string, tags: PolicyTag[]) { | ||
| const onyxData = updateImportSpreadsheetData(tags.length); | ||
|
|
||
| // eslint-disable-next-line @typescript-eslint/naming-convention | ||
|
Contributor
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. ❌ CONSISTENCY-5 (docs)ESLint rule disables must be accompanied by a clear comment explaining why the rule needs to be disabled. This helps team members understand the exception and promotes better maintainability. Suggested fix: // The backend API expects 'GL Code' as a property name, which violates TypeScript naming conventions
// eslint-disable-next-line @typescript-eslint/naming-convention
const optimisticTags = tags.map((tag) => ({name: tag.name, enabled: tag.enabled, 'GL Code': tag['GL Code']}));Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency. |
||
| const optimisticTags = tags.map((tag) => ({name: tag.name, enabled: tag.enabled, 'GL Code': tag['GL Code']})); | ||
|
|
||
| const parameters = { | ||
| policyID, | ||
| // eslint-disable-next-line @typescript-eslint/naming-convention | ||
| tags: JSON.stringify(tags.map((tag) => ({name: tag.name, enabled: tag.enabled, 'GL Code': tag['GL Code']}))), | ||
| tags: JSON.stringify(optimisticTags), | ||
|
Tony-MK marked this conversation as resolved.
|
||
| }; | ||
|
|
||
| API.write(WRITE_COMMANDS.IMPORT_TAGS_SPREADSHEET, parameters, onyxData); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.