From f508bc9c9e76b5f66d62bc1e0ac990e1d47dbf4c Mon Sep 17 00:00:00 2001 From: Krishna Gupta Date: Sun, 17 Mar 2024 01:46:34 +0530 Subject: [PATCH 1/3] fix: Categories & Tags - Row is not grayed out entirely when disabled offline. Signed-off-by: Krishna Gupta --- src/libs/actions/Policy.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/libs/actions/Policy.ts b/src/libs/actions/Policy.ts index 9df73f970195..72761342f04a 100644 --- a/src/libs/actions/Policy.ts +++ b/src/libs/actions/Policy.ts @@ -2672,6 +2672,7 @@ function setWorkspaceCategoryEnabled(policyID: string, categoriesToUpdate: Recor pendingFields: { enabled: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, }, + pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, }; return acc; @@ -2692,6 +2693,7 @@ function setWorkspaceCategoryEnabled(policyID: string, categoriesToUpdate: Recor pendingFields: { enabled: null, }, + pendingAction: null, }; return acc; @@ -2712,6 +2714,7 @@ function setWorkspaceCategoryEnabled(policyID: string, categoriesToUpdate: Recor pendingFields: { enabled: null, }, + pendingAction: null, }; return acc; @@ -2922,6 +2925,7 @@ function setWorkspaceTagEnabled(policyID: string, tagsToUpdate: Record Date: Tue, 19 Mar 2024 03:23:08 +0530 Subject: [PATCH 2/3] disable tag selection when pending action. Signed-off-by: Krishna Gupta --- .../workspace/tags/WorkspaceTagsPage.tsx | 44 ++++++++++--------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/src/pages/workspace/tags/WorkspaceTagsPage.tsx b/src/pages/workspace/tags/WorkspaceTagsPage.tsx index 7cf42b17fe5e..f9a3cc8cb164 100644 --- a/src/pages/workspace/tags/WorkspaceTagsPage.tsx +++ b/src/pages/workspace/tags/WorkspaceTagsPage.tsx @@ -74,27 +74,31 @@ function WorkspaceTagsPage({policyTags, route}: WorkspaceTagsPageProps) { () => policyTagLists .map((policyTagList) => - Object.values(policyTagList.tags || []).map((value) => ({ - value: value.name, - text: value.name, - keyForList: value.name, - isSelected: !!selectedTags[value.name], - pendingAction: value.pendingAction, - errors: value.errors ?? undefined, - rightElement: ( - - - {value.enabled ? translate('workspace.common.enabled') : translate('workspace.common.disabled')} - - - + Object.values(policyTagList.tags || []).map((value) => { + const isDisabled = value.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE || Object.values(value.pendingFields ?? {}).length > 0; + return { + value: value.name, + text: value.name, + keyForList: value.name, + isSelected: !!selectedTags[value.name], + pendingAction: value.pendingAction, + errors: value.errors ?? undefined, + isDisabled, + rightElement: ( + + + {value.enabled ? translate('workspace.common.enabled') : translate('workspace.common.disabled')} + + + + - - ), - })), + ), + }; + }), ) .flat(), [policyTagLists, selectedTags, styles.alignSelfCenter, styles.flexRow, styles.label, styles.p1, styles.pl2, styles.textSupporting, theme.icon, translate], From 8b31c5e3c2fe9e9463229ea77507ba71e7cd4474 Mon Sep 17 00:00:00 2001 From: Krishna Gupta Date: Wed, 20 Mar 2024 15:37:22 +0530 Subject: [PATCH 3/3] clear selected tag on navigating to tag settings. Signed-off-by: Krishna Gupta --- .../workspace/tags/WorkspaceTagsPage.tsx | 45 +++++++++---------- 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/src/pages/workspace/tags/WorkspaceTagsPage.tsx b/src/pages/workspace/tags/WorkspaceTagsPage.tsx index f9a3cc8cb164..02f8d57488d2 100644 --- a/src/pages/workspace/tags/WorkspaceTagsPage.tsx +++ b/src/pages/workspace/tags/WorkspaceTagsPage.tsx @@ -74,31 +74,27 @@ function WorkspaceTagsPage({policyTags, route}: WorkspaceTagsPageProps) { () => policyTagLists .map((policyTagList) => - Object.values(policyTagList.tags || []).map((value) => { - const isDisabled = value.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE || Object.values(value.pendingFields ?? {}).length > 0; - return { - value: value.name, - text: value.name, - keyForList: value.name, - isSelected: !!selectedTags[value.name], - pendingAction: value.pendingAction, - errors: value.errors ?? undefined, - isDisabled, - rightElement: ( - - - {value.enabled ? translate('workspace.common.enabled') : translate('workspace.common.disabled')} - - - - + Object.values(policyTagList.tags || []).map((value) => ({ + value: value.name, + text: value.name, + keyForList: value.name, + isSelected: !!selectedTags[value.name], + pendingAction: value.pendingAction, + errors: value.errors ?? undefined, + rightElement: ( + + + {value.enabled ? translate('workspace.common.enabled') : translate('workspace.common.disabled')} + + + - ), - }; - }), + + ), + })), ) .flat(), [policyTagLists, selectedTags, styles.alignSelfCenter, styles.flexRow, styles.label, styles.p1, styles.pl2, styles.textSupporting, theme.icon, translate], @@ -132,6 +128,7 @@ function WorkspaceTagsPage({policyTags, route}: WorkspaceTagsPageProps) { }; const navigateToTagSettings = (tag: PolicyOption) => { + setSelectedTags({}); Navigation.navigate(ROUTES.WORKSPACE_TAG_SETTINGS.getRoute(route.params.policyID, tag.keyForList)); };