-
Notifications
You must be signed in to change notification settings - Fork 8.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
Ram 145739 use bulk enable disable in UI #145928
Ram 145739 use bulk enable disable in UI #145928
Conversation
024f05b
to
222d8e0
Compare
Pinging @elastic/response-ops (Team:ResponseOps) |
@elasticmachine merge upstream |
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.
Just doing an initial review, looks pretty good! I have a few comments.
Also, I know we're currently skipping the rules_list unit tests, but I think we should still try to keep them up to date with new features 🙂
const actionToToastMapping = { | ||
DELETE: { | ||
getSuccessfulNotificationText: getSuccessfulDeletionNotificationText, | ||
getFailedNotificationText: getFailedDeletionNotificationText, | ||
getPartialSuccessNotificationText: getPartialSuccessDeletionNotificationText, | ||
}, | ||
ENABLE: { | ||
getSuccessfulNotificationText: getSuccessfulEnablingNotificationText, | ||
getFailedNotificationText: getFailedEnablingNotificationText, | ||
getPartialSuccessNotificationText: getPartialSuccessEnablingNotificationText, | ||
}, | ||
DISABLE: { | ||
getSuccessfulNotificationText: getSuccessfulDisablingNotificationText, | ||
getFailedNotificationText: getFailedDisablingNotificationText, | ||
getPartialSuccessNotificationText: getPartialSuccessDisablingNotificationText, | ||
}, | ||
}; |
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.
nitpick: let's move this outside of the component, incase it gets reused
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.
You are right. It's more clean. b44c57a
I did not move it in another file, just decided better to do it when we need it.
setIsEnablingRules(false); | ||
showToast({ action: 'ENABLE', errors, total }); | ||
await refreshRules(); | ||
}, [http, selectedIds, filter, setIsEnablingRules, toasts]); |
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.
I don't think memoizing this function is worth exposing filter
, I think we should just call getFilter
lazily because that function could be fairly expensive.
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.
After your message I've realised that filter and getFilter is almost the same and rewrite this part with getFilter:
e250d9f
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.
@JiaweiWu I did not get how to call getFilter lazily. Can you, please, write more details?
c264a5c
to
e250d9f
Compare
I pulled this locally and did some testing, everything seems to be working as intended. Just to be consistent with the other bulk actions, I think we should unselect the items and close the dropdown when we bulk enable/disable them: 2022-11-24.12-00-44.mp4Otherwise, it looks great! |
setIsEnablingRules(false); | ||
showToast({ action: 'ENABLE', errors, total }); | ||
await refreshRules(); | ||
}, [http, selectedIds, getFilter, setIsEnablingRules, toasts]); |
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.
I think toasts
is not being use in the function, so we can probably remove it from the dependency array.
Maybe you meant to have showToast?
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.
LGTM, there are 2 comments remaining but they should be easy changes. Feel free to merge after you've made those changes.
@elasticmachine merge upstream |
💚 Build Succeeded
Metrics [docs]Module Count
Async chunks
Page load bundle
Unknown metric groupsasync chunk count
ESLint disabled in files
ESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: cc @guskovaue |
Resolves: #145739
Summary
In this PR I am enabling Enable and Disable in menu when Select all is chosen. And trigger new bulk enable/disable API when Enable/Disable option will be chosen.
Checklist