-
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] Show Cases column on the alerts table #150963
Conversation
71edc38
to
ed8c32d
Compare
@@ -34,7 +34,8 @@ | |||
"esUiShared", | |||
"kibanaReact", | |||
"kibanaUtils", | |||
"actions" | |||
"actions", | |||
"cases" |
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.
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 see cases plugin has triggers_actions_ui as plugin dependency, could there be a cyclic dependency issue? Otherwise, it's ok for me
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 there is an issue with bundles. Only with required plugins. I will verify with operations to be sure. If there is a problem I will duplicate the code.
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.
@jcger You were right. CI was complaining about circular dependencies. I will create an issue to create a package so we can import the cases types from there. In this PR I duplicate the code.
* 2.0. | ||
*/ | ||
|
||
export const triggersActionsUiQueriesKeys = { |
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 followed the same pattern we do in Cases. Inspired by this article https://tkdodo.eu/blog/effective-react-query-keys#use-query-key-factories
import { act } from 'react-dom/test-utils'; | ||
import { AlertsFlyout } from './alerts_flyout'; | ||
import { AlertsField } from '../../../../types'; | ||
import { Alert, AlertsField } from '../../../../types'; |
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 created the following types
export type Alert = EcsFieldsResponse;
export type Alerts = Alert[];
and use them everywhere. I think is clearer.
data, | ||
}); | ||
|
||
if (isSystemCell(_props.columnId)) { |
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 created a factory for our internal cells. The factory will get the columnId
and all required props and render the corresponding cell component.
if (isSystemCell(_props.columnId)) { | ||
return ( | ||
<SystemCellFactory | ||
alert={alert} |
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.
Passing the alert
makes the code easier instead of passing the data
|
||
const AlertsTableState = (props: AlertsTableStateProps) => { | ||
return ( | ||
<QueryClientProvider client={alertsTableQueryClient}> |
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 alerts table is wrapped by the React Query provider.
@@ -240,6 +270,7 @@ const AlertsTableState = ({ | |||
const tableProps = useMemo( | |||
() => ({ | |||
alertsTableConfiguration, | |||
casesData: { cases: cases ?? new Map(), isLoading: isLoadingCases }, |
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 preferred to group all case props into one object. Let me know if you need me to do something else.
|
||
export const systemCells: SystemCellId[] = [ALERT_STATUS, ALERT_CASE_IDS]; | ||
|
||
const SystemCellFactoryComponent: React.FC<CellComponentProps> = (props) => { |
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 created a factory for our internal cells. The factory will get the columnId
and all required props and render the corresponding cell component.
|
||
const SystemCellFactoryComponent: React.FC<CellComponentProps> = (props) => { | ||
const { columnId } = props; | ||
const cellComponents: SystemCellComponentMap = useMemo( |
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.
Maybe it is better to put it outside of the component.
}, | ||
{ | ||
enabled: caseIds.length > 0, | ||
select: transformCases, |
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 backend returns an array of cases. We transform it into a Map to avoid looping the cases array each time we need to find the case information.
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, waiting for those tests!
@@ -34,7 +34,8 @@ | |||
"esUiShared", | |||
"kibanaReact", | |||
"kibanaUtils", | |||
"actions" | |||
"actions", | |||
"cases" |
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 see cases plugin has triggers_actions_ui as plugin dependency, could there be a cyclic dependency issue? Otherwise, it's ok for me
8442029
to
9631771
Compare
9631771
to
ba58d00
Compare
coreStart: TriggersAndActionsUiServices; | ||
} | ||
|
||
export const createAppMockRenderer = (): AppMockRenderer => { |
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 moved it one level up because I need it in the section
folder.
6e084e8
to
1d890ac
Compare
Pinging @elastic/response-ops (Team:ResponseOps) |
Pinging @elastic/response-ops-cases (Feature:Cases) |
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.
not done yet but I already wanted to let you know that I did some QA and saw that after adding an alert to a case, the table isn't updated and also even if clicking on refresh, it doesn't update. I have to hard reload to get the data
Screenshot.1.mov
.filter((theCase): theCase is Case => theCase != null); | ||
|
||
if (validCases.length === 0) { | ||
return null; |
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've seen that if there is no linked case, the cell is just empty. I guess it's happening because of this return and I'm wondering if we should render '--' or even call the DefaultRenderer to keep consistency with other empty cell values
See difference between empty values of other cells compared to case
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. I will call the DefaultRenderer
to be consistent.
wrapper: appMockRender.AppWrapper, | ||
}); | ||
|
||
act(() => { |
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.
do you really need to call act here? I tried without it I there is no warning or error message
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 examples in the documentation of the library use act
when you call a function. In react testing library it does not need it but it seems to be needed in the react testing hook library.
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!
💚 Build Succeeded
Metrics [docs]Module Count
Public APIs missing comments
Async chunks
Public APIs missing exports
Page load bundle
Unknown metric groupsAPI count
ESLint disabled in files
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: cc @cnasikas |
We decided offline that we will address it on another PR. |
Summary
This PR adds the cases column to the alerts table. Assumptions:
Issue: #146864
Checklist
Delete any items that are not applicable to this PR.
For maintainers
Release notes
Adds the Cases column to the alerts table. The column shows, for each alert, all cases the alert is attached to.