Skip to content
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: Categories & Tags - Row is not grayed out entirely when disabled offline. #38443

Merged
merged 6 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/libs/actions/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -2692,6 +2693,7 @@ function setWorkspaceCategoryEnabled(policyID: string, categoriesToUpdate: Recor
pendingFields: {
enabled: null,
},
pendingAction: null,
};

return acc;
Expand All @@ -2712,6 +2714,7 @@ function setWorkspaceCategoryEnabled(policyID: string, categoriesToUpdate: Recor
pendingFields: {
enabled: null,
},
pendingAction: null,
};

return acc;
Expand Down Expand Up @@ -2922,6 +2925,7 @@ function setWorkspaceTagEnabled(policyID: string, tagsToUpdate: Record<string, {
pendingFields: {
enabled: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE,
},
pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE,
};

return acc;
Expand All @@ -2946,6 +2950,7 @@ function setWorkspaceTagEnabled(policyID: string, tagsToUpdate: Record<string, {
pendingFields: {
enabled: null,
},
pendingAction: null,
};

return acc;
Expand All @@ -2970,6 +2975,7 @@ function setWorkspaceTagEnabled(policyID: string, tagsToUpdate: Record<string, {
pendingFields: {
enabled: null,
},
pendingAction: null,
};

return acc;
Expand Down
44 changes: 24 additions & 20 deletions src/pages/workspace/tags/WorkspaceTagsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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: (
<View style={styles.flexRow}>
<Text style={[styles.textSupporting, styles.alignSelfCenter, styles.pl2, styles.label]}>
{value.enabled ? translate('workspace.common.enabled') : translate('workspace.common.disabled')}
</Text>
<View style={[styles.p1, styles.pl2]}>
<Icon
src={Expensicons.ArrowRight}
fill={theme.icon}
/>
Object.values(policyTagList.tags || []).map((value) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know we only update this function, but as we touch these lines, let's change the name value to tag or policyTag

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: (
<View style={styles.flexRow}>
<Text style={[styles.textSupporting, styles.alignSelfCenter, styles.pl2, styles.label]}>
{value.enabled ? translate('workspace.common.enabled') : translate('workspace.common.disabled')}
</Text>
<View style={[styles.p1, styles.pl2]}>
<Icon
src={Expensicons.ArrowRight}
fill={theme.icon}
/>
</View>
</View>
</View>
),
})),
),
};
}),
)
.flat(),
[policyTagLists, selectedTags, styles.alignSelfCenter, styles.flexRow, styles.label, styles.p1, styles.pl2, styles.textSupporting, theme.icon, translate],
Expand Down
Loading