-
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
[Cases] Add Severity bulk action & row action #142826
Conversation
Pinging @elastic/response-ops (Team:ResponseOps) |
Pinging @elastic/response-ops-cases (Feature:Cases) |
@@ -158,10 +158,6 @@ describe('AllCasesListGeneric', () => { | |||
.prop('value') | |||
).toBe(useGetCasesMockState.data.cases[0].createdAt); | |||
|
|||
expect( |
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.
Moved to its own test
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 good, left a few comments
i18n.translate('xpack.cases.actions.severity', { | ||
values: { caseTitle, totalCases, severity }, | ||
defaultMessage: | ||
'{totalCases, plural, =1 {Case "{caseTitle}" was} other {{totalCases} cases were}} set to {severity}', |
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.
if caseTitle
is undefined will it show Case "undefined" was
?
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.
The case is a mandatory field and it will never be undefined
. Types also protect us from that, right?
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 might be misunderstanding but I'm referring to caseTitle?: string;
, so it's optional and can be undefined
.
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.
Oh, sorry my mistake 🙂. It is a pattern we had before that I followed. The title will only show if you have one case. Indeed, it is possible to show "undefined" if totalCases === 1
and caseTitlte === undefined
. Do you want me to change the pattern to something else? Any ideas? I am not super fun of it for the reason you mentioned.
x-pack/plugins/cases/public/components/actions/severity/translations.ts
Outdated
Show resolved
Hide resolved
{ | ||
name: severities[CaseSeverity.LOW].label, | ||
icon: getSeverityIcon(CaseSeverity.LOW), | ||
onClick: () => handleUpdateCaseSeverity(selectedCases, CaseSeverity.LOW), |
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.
Should we pass handleUpdateCaseSeverity
directly? Instead of a function that calls it? I think passing a new function invalidates the memoization right?
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 need to get the selected cases somehow which are passed to getActions
. It invalidates memorization but I think it is fine for this case. I am open to suggestions 🙂.
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.
oh I see, yeah that's fine. Or we could use two useCallback
I think:
onClick: useCallback(() => handle..., [...])
Or does that not work?
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.
This will not work because the onClick
handler passes a MouseEvent
and not the selected cases. Somehow I need to get them from the getActions
function. I could
import { memoize } from 'lodash'
const onLowSeverityClick = memorize((selectedCases) => handleUpdateCaseSeverity(selectedCases, CaseSeverity.LOW))
//
onClick: () => onLowSeverityClick(selectedCases)
but I do not think it is worth the optimization until we have a strong indicator that it causes performance problems. The memorization cost in this scenario maybe be greater than the problem itself.
@elasticmachine merge upstream |
@elasticmachine merge upstream |
💚 Build Succeeded
Metrics [docs]Module Count
Async chunks
History
To update your PR or re-run it, just comment with: cc @cnasikas |
Summary
This PR adds the ability for users to be able to change the severity of a case through bulk actions or row actions
User flow
Screen.Recording.2022-10-06.at.1.04.09.PM.mov
Checklist
Delete any items that are not applicable to this PR.
For maintainers