Filter deleted workspace categories#54613
Conversation
|
@ZhenjaHorbach Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
Reviewer Checklist
Screenshots/VideosAndroid: Nativeandroid.movAndroid: mWeb Chromeandroid-web.moviOS: Nativeios.moviOS: mWeb Safariios-web.movMacOS: Chrome / Safariweb.movMacOS: Desktopdesktop.mov |
| (lodashSortBy(Object.values(policyCategories ?? {}), 'name', localeCompare) as PolicyCategory[]) | ||
| .filter((value) => (isOffline ? value : value.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE)) | ||
| .map((value) => { | ||
| const isDisabled = value.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE; | ||
| return { | ||
| text: value.name, | ||
| keyForList: value.name, | ||
| isSelected: !!selectedCategories[value.name] && canSelectMultiple, | ||
| isDisabled, | ||
| pendingAction: value.pendingAction, | ||
| errors: value.errors ?? undefined, | ||
| rightElement: <ListItemRightCaretWithLabel labelText={value.enabled ? translate('workspace.common.enabled') : translate('workspace.common.disabled')} />, | ||
| }; | ||
| }), | ||
| [policyCategories, isOffline, selectedCategories, canSelectMultiple, translate], |
There was a problem hiding this comment.
Minor comment
but maybe we should use reduce instead filter+map to decrease the number of operations and increase performance a bit?
const categoryList = useMemo<PolicyOption[]>(
() =>
(lodashSortBy(Object.values(policyCategories ?? {}), 'name', localeCompare) as PolicyCategory[]).reduce((acc, value) => {
const isDeleted = value.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE;
if (!isOffline && isDeleted) {
return acc;
}
acc.push({
text: value.name,
keyForList: value.name,
isSelected: !!selectedCategories[value.name] && canSelectMultiple,
isDisabled: isDeleted,
pendingAction: value.pendingAction,
errors: value.errors ?? undefined,
rightElement: <ListItemRightCaretWithLabel labelText={value.enabled ? translate('workspace.common.enabled') : translate('workspace.common.disabled')} />,
});
return acc;
}, [] as PolicyOption[]),
[policyCategories, isOffline, selectedCategories, canSelectMultiple, translate],
);
There was a problem hiding this comment.
@ZhenjaHorbach I've addressed both of your comments
|
And let's update QA Steps and make a mention that the remaining elements after removed appear immediately |
|
LGTM ! @mountiny |
|
Posted a question in Slack about adding a unit test to this here: https://expensify.slack.com/archives/C01GTK53T8Q/p1735322052721899 Otherwise looks good 👍 |
|
Tests look good ! |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/blimpich in version: 9.0.80-1 🚀
|
|
🚀 Deployed to production by https://github.com/puneetlath in version: 9.0.80-6 🚀
|
Explanation of Change
Problem:
Changes:
pendingAction: deleteFixed Issues
$ #53035
PROPOSAL: #53035 (comment)
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
Online:
Screen.Recording.2024-12-27.at.12.39.35.mp4
Offline:
Screen.Recording.2024-12-27.at.12.40.24.mp4
MacOS: Desktop