Skip to content

Commit

Permalink
[RAM] Alert table all column fix 2 (#161054)
Browse files Browse the repository at this point in the history
#160455

---------

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
XavierM and kibanamachine authored Jul 7, 2023
1 parent 4fc4ded commit bed184b
Show file tree
Hide file tree
Showing 12 changed files with 256 additions and 169 deletions.
1 change: 1 addition & 0 deletions .buildkite/scripts/pipelines/pull_request/pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ const uploadPipeline = (pipelineContent: string | object) => {
/^x-pack\/plugins\/security_solution/,
/^x-pack\/plugins\/timelines/,
/^x-pack\/plugins\/triggers_actions_ui\/public\/application\/sections\/action_connector_form/,
/^x-pack\/plugins\/triggers_actions_ui\/public\/application\/sections\/alerts_table/,
/^x-pack\/plugins\/triggers_actions_ui\/public\/application\/context\/actions_connectors_context\.tsx/,
/^x-pack\/test\/defend_workflows_cypress/,
/^x-pack\/test\/security_solution_cypress/,
Expand Down
1 change: 1 addition & 0 deletions vars/tasks.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ def functionalXpack(Map params = [:]) {
'x-pack/test/security_solution_cypress/',
'x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/',
'x-pack/plugins/triggers_actions_ui/public/application/context/actions_connectors_context.tsx',
'x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_table/',
]) {
if (githubPr.isPr()) {
task(kibanaPipeline.functionalTestProcess('xpack-securitySolutionCypressChrome', './test/scripts/jenkins_security_solution_cypress_chrome.sh'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1261,66 +1261,17 @@ describe('SiemLocalStorage', () => {
],
sort: [{ '@timestamp': { order: 'desc' } }],
visibleColumns: [
{
columnHeaderType: 'not-filtered',
id: '@timestamp',
initialWidth: 180,
},
{
columnHeaderType: 'not-filtered',
displayAsText: 'Rule',
id: 'kibana.alert.rule.name',
initialWidth: 180,
linkField: 'kibana.alert.rule.uuid',
},
{
columnHeaderType: 'not-filtered',
displayAsText: 'Severity',
id: 'kibana.alert.severity',
initialWidth: 180,
},
{
columnHeaderType: 'not-filtered',
displayAsText: 'Risk Score',
id: 'kibana.alert.risk_score',
initialWidth: 180,
},
{
columnHeaderType: 'not-filtered',
displayAsText: 'Reason',
id: 'kibana.alert.reason',
initialWidth: 180,
},
{
columnHeaderType: 'not-filtered',
id: 'host.name',
initialWidth: 180,
},
{
columnHeaderType: 'not-filtered',
id: 'user.name',
initialWidth: 180,
},
{
columnHeaderType: 'not-filtered',
id: 'process.name',
initialWidth: 180,
},
{
columnHeaderType: 'not-filtered',
id: 'file.name',
initialWidth: 180,
},
{
columnHeaderType: 'not-filtered',
id: 'source.ip',
initialWidth: 180,
},
{
columnHeaderType: 'not-filtered',
id: 'destination.ip',
initialWidth: 180,
},
'@timestamp',
'kibana.alert.rule.name',
'kibana.alert.severity',
'kibana.alert.risk_score',
'kibana.alert.reason',
'host.name',
'user.name',
'process.name',
'file.name',
'source.ip',
'destination.ip',
],
},
},
Expand Down Expand Up @@ -1393,66 +1344,17 @@ describe('SiemLocalStorage', () => {
{ 'kibana.alert.rule.name': { order: 'desc' } },
],
visibleColumns: [
{
columnHeaderType: 'not-filtered',
id: '@timestamp',
initialWidth: 180,
},
{
columnHeaderType: 'not-filtered',
displayAsText: 'Rule',
id: 'kibana.alert.rule.name',
initialWidth: 180,
linkField: 'kibana.alert.rule.uuid',
},
{
columnHeaderType: 'not-filtered',
displayAsText: 'Severity',
id: 'kibana.alert.severity',
initialWidth: 180,
},
{
columnHeaderType: 'not-filtered',
displayAsText: 'Risk Score',
id: 'kibana.alert.risk_score',
initialWidth: 180,
},
{
columnHeaderType: 'not-filtered',
displayAsText: 'Reason',
id: 'kibana.alert.reason',
initialWidth: 180,
},
{
columnHeaderType: 'not-filtered',
id: 'host.name',
initialWidth: 180,
},
{
columnHeaderType: 'not-filtered',
id: 'user.name',
initialWidth: 180,
},
{
columnHeaderType: 'not-filtered',
id: 'process.name',
initialWidth: 180,
},
{
columnHeaderType: 'not-filtered',
id: 'file.name',
initialWidth: 180,
},
{
columnHeaderType: 'not-filtered',
id: 'source.ip',
initialWidth: 180,
},
{
columnHeaderType: 'not-filtered',
id: 'destination.ip',
initialWidth: 180,
},
'@timestamp',
'kibana.alert.rule.name',
'kibana.alert.severity',
'kibana.alert.risk_score',
'kibana.alert.reason',
'host.name',
'user.name',
'process.name',
'file.name',
'source.ip',
'destination.ip',
],
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export const migrateAlertTableStateToTriggerActionsState = (
sort: legacyDataTableState[tableKey].sort.map((sortCandidate) => ({
[sortCandidate.columnId]: { order: sortCandidate.sortDirection },
})),
visibleColumns: legacyDataTableState[tableKey].columns,
visibleColumns: legacyDataTableState[tableKey].columns.map((c) => c.id),
},
};
});
Expand All @@ -110,6 +110,7 @@ export const migrateAlertTableStateToTriggerActionsState = (
storage.set(key, stateObj[key]);
})
);
return Object.assign(legacyDataTableState, triggersActionsState);
};

/**
Expand Down Expand Up @@ -154,7 +155,7 @@ export const getDataTablesInStorageByIds = (storage: Storage, tableIds: TableIdL
}
}

migrateAlertTableStateToTriggerActionsState(storage, allDataTables);
allDataTables = migrateAlertTableStateToTriggerActionsState(storage, allDataTables);

return tableIds.reduce((acc, tableId) => {
const tableModel = allDataTables[tableId];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,6 @@ describe('AlertsTable', () => {
updatedAt: Date.now(),
onToggleColumn: () => {},
onResetColumns: () => {},
onColumnsChange: () => {},
onChangeVisibleColumns: () => {},
browserFields,
query: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ const AlertsTable: React.FunctionComponent<AlertsTableProps> = (props: AlertsTab
updatedAt,
browserFields,
onChangeVisibleColumns,
onColumnResize,
showAlertStatusWithFlapping = false,
showInspectButton = false,
} = props;
Expand Down Expand Up @@ -486,6 +487,7 @@ const AlertsTable: React.FunctionComponent<AlertsTableProps> = (props: AlertsTab
onChangePage: onChangePageIndex,
}}
rowHeightsOptions={props.rowHeightsOptions}
onColumnResize={onColumnResize}
ref={dataGridRef}
/>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -762,9 +762,15 @@ describe('AlertsTableState', () => {
storageMock.mockImplementation(() => ({
get: () => {
return {
columns: [{ displayAsText: 'Reason', id: 'kibana.alert.reason', schema: undefined }],
sort: [],
visibleColumns: ['kibana.alert.reason'],
columns: [{ displayAsText: 'Reason', id: AlertsField.reason, schema: undefined }],
sort: [
{
[AlertsField.reason]: {
order: 'asc',
},
},
],
visibleColumns: [AlertsField.reason],
};
},
set: jest.fn(),
Expand All @@ -780,11 +786,11 @@ describe('AlertsTableState', () => {

await waitFor(() => {
expect(queryByTestId(`dataGridHeaderCell-${AlertsField.name}`)).not.toBe(null);
expect(
getByTestId('dataGridHeader')
.querySelectorAll('.euiDataGridHeaderCell__content')[1]
.getAttribute('title')
).toBe('Name');
const titles: string[] = [];
getByTestId('dataGridHeader')
.querySelectorAll('.euiDataGridHeaderCell__content')
.forEach((n) => titles.push(n?.getAttribute('title') ?? ''));
expect(titles).toContain('Name');
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,13 @@ const AlertsTableStateWithQueryProvider = ({

const {
columns,
onColumnsChange,
browserFields,
isBrowserFieldDataLoading,
onToggleColumn,
onResetColumns,
visibleColumns,
onChangeVisibleColumns,
onColumnResize,
fields,
} = useColumns({
featureIds,
Expand Down Expand Up @@ -393,8 +393,8 @@ const AlertsTableStateWithQueryProvider = ({
browserFields,
onToggleColumn,
onResetColumns,
onColumnsChange,
onChangeVisibleColumns,
onColumnResize,
query,
rowHeightsOptions,
renderCellValue,
Expand All @@ -410,7 +410,7 @@ const AlertsTableStateWithQueryProvider = ({
memoizedMaintenanceWindows,
columns,
flyoutSize,
pagination,
pagination.pageSize,
id,
leadingControlColumns,
showExpandToDetails,
Expand All @@ -421,8 +421,8 @@ const AlertsTableStateWithQueryProvider = ({
browserFields,
onToggleColumn,
onResetColumns,
onColumnsChange,
onChangeVisibleColumns,
onColumnResize,
query,
rowHeightsOptions,
renderCellValue,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ describe('AlertsTable.BulkActions', () => {
updatedAt: Date.now(),
onToggleColumn: () => {},
onResetColumns: () => {},
onColumnsChange: () => {},
onChangeVisibleColumns: () => {},
browserFields: {},
query: {},
Expand Down
Loading

0 comments on commit bed184b

Please sign in to comment.