-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Filter deleted workspace categories #54613
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ZhenjaHorbach I've addressed both of your comments
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.
Nice
Thanks !
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 ! |
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.
Looks great! Nice job!
✋ 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 🚀
|
Explanation of Change
Problem:
Changes:
pendingAction: delete
Fixed Issues
$ #53035
PROPOSAL: #53035 (comment)
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.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