Skip to content
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

[RAC] [TGrid] Migrate the TGrid's rendering to EuiDataGrid #106199

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import { DefaultCellRenderer } from '../../../timelines/components/timeline/cell
import * as i18n from './translations';
import { useKibana } from '../../lib/kibana';
import { SourcererScopeName } from '../../store/sourcerer/model';
import { useIsExperimentalFeatureEnabled } from '../../hooks/use_experimental_features';
import { DEFAULT_COLUMN_MIN_WIDTH } from '../../../timelines/components/timeline/body/constants';

export interface OwnProps {
end: string;
Expand Down Expand Up @@ -74,20 +76,29 @@ const AlertsTableComponent: React.FC<Props> = ({
const alertsFilter = useMemo(() => [...defaultAlertsFilters, ...pageFilters], [pageFilters]);
const { filterManager } = useKibana().services.data.query;

const tGridEnabled = useIsExperimentalFeatureEnabled('tGridEnabled');

useEffect(() => {
dispatch(
timelineActions.initializeTGridSettings({
id: timelineId,
documentType: i18n.ALERTS_DOCUMENT_TYPE,
filterManager,
defaultColumns: alertsDefaultModel.columns,
defaultColumns: alertsDefaultModel.columns.map((c) =>
!tGridEnabled && c.initialWidth == null
? {
...c,
initialWidth: DEFAULT_COLUMN_MIN_WIDTH,
}
: c
),
excludedRowRendererIds: alertsDefaultModel.excludedRowRendererIds,
footerText: i18n.TOTAL_COUNT_OF_ALERTS,
title: i18n.ALERTS_TABLE_TITLE,
// TODO: avoid passing this through the store
})
);
}, [dispatch, filterManager, timelineId]);
}, [dispatch, filterManager, tGridEnabled, timelineId]);

return (
<StatefulEventsViewer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@

import { ColumnHeaderOptions, RowRendererId } from '../../../../common/types/timeline';
import { defaultColumnHeaderType } from '../../../timelines/components/timeline/body/column_headers/default_headers';
import {
DEFAULT_COLUMN_MIN_WIDTH,
DEFAULT_DATE_COLUMN_MIN_WIDTH,
} from '../../../timelines/components/timeline/body/constants';
import { DEFAULT_DATE_COLUMN_MIN_WIDTH } from '../../../timelines/components/timeline/body/constants';
import { SubsetTimelineModel } from '../../../timelines/store/timeline/model';
import { timelineDefaults } from '../../../timelines/store/timeline/defaults';

Expand All @@ -23,48 +20,39 @@ export const alertsHeaders: ColumnHeaderOptions[] = [
{
columnHeaderType: defaultColumnHeaderType,
id: 'event.module',
initialWidth: DEFAULT_COLUMN_MIN_WIDTH,
linkField: 'rule.reference',
},
{
columnHeaderType: defaultColumnHeaderType,
id: 'event.dataset',
initialWidth: DEFAULT_COLUMN_MIN_WIDTH,
},
{
columnHeaderType: defaultColumnHeaderType,
id: 'event.category',
initialWidth: DEFAULT_COLUMN_MIN_WIDTH,
},
{
columnHeaderType: defaultColumnHeaderType,
id: 'event.severity',
initialWidth: DEFAULT_COLUMN_MIN_WIDTH,
},
{
columnHeaderType: defaultColumnHeaderType,
id: 'observer.name',
initialWidth: DEFAULT_COLUMN_MIN_WIDTH,
},
{
columnHeaderType: defaultColumnHeaderType,
id: 'host.name',
initialWidth: DEFAULT_COLUMN_MIN_WIDTH,
},
{
columnHeaderType: defaultColumnHeaderType,
id: 'message',
initialWidth: DEFAULT_COLUMN_MIN_WIDTH,
},
{
columnHeaderType: defaultColumnHeaderType,
id: 'agent.id',
initialWidth: DEFAULT_COLUMN_MIN_WIDTH,
},
{
columnHeaderType: defaultColumnHeaderType,
id: 'agent.type',
initialWidth: DEFAULT_COLUMN_MIN_WIDTH,
},
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@

import { ColumnHeaderOptions } from '../../../../common';
import { defaultColumnHeaderType } from '../../../timelines/components/timeline/body/column_headers/default_headers';
import {
DEFAULT_COLUMN_MIN_WIDTH,
DEFAULT_DATE_COLUMN_MIN_WIDTH,
} from '../../../timelines/components/timeline/body/constants';
import { DEFAULT_DATE_COLUMN_MIN_WIDTH } from '../../../timelines/components/timeline/body/constants';

export const defaultHeaders: ColumnHeaderOptions[] = [
{
Expand All @@ -21,41 +18,33 @@ export const defaultHeaders: ColumnHeaderOptions[] = [
{
columnHeaderType: defaultColumnHeaderType,
id: 'message',
initialWidth: DEFAULT_COLUMN_MIN_WIDTH,
},
{
columnHeaderType: defaultColumnHeaderType,
id: 'host.name',
initialWidth: DEFAULT_COLUMN_MIN_WIDTH,
},
{
columnHeaderType: defaultColumnHeaderType,
id: 'event.module',
initialWidth: DEFAULT_COLUMN_MIN_WIDTH,
},
{
columnHeaderType: defaultColumnHeaderType,
id: 'event.dataset',
initialWidth: DEFAULT_COLUMN_MIN_WIDTH,
},
{
columnHeaderType: defaultColumnHeaderType,
id: 'event.action',
initialWidth: DEFAULT_COLUMN_MIN_WIDTH,
},
{
columnHeaderType: defaultColumnHeaderType,
id: 'user.name',
initialWidth: DEFAULT_COLUMN_MIN_WIDTH,
},
{
columnHeaderType: defaultColumnHeaderType,
id: 'source.ip',
initialWidth: DEFAULT_COLUMN_MIN_WIDTH,
},
{
columnHeaderType: defaultColumnHeaderType,
id: 'destination.ip',
initialWidth: DEFAULT_COLUMN_MIN_WIDTH,
},
];
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ import { CellValueElementProps } from '../../../timelines/components/timeline/ce
import { useKibana } from '../../lib/kibana';
import { defaultControlColumn } from '../../../timelines/components/timeline/body/control_columns';
import { EventsViewer } from './events_viewer';
import * as i18n from './translations';

const EMPTY_CONTROL_COLUMNS: ControlColumnProps[] = [];
const leadingControlColumns: ControlColumnProps[] = [
{
...defaultControlColumn,
// eslint-disable-next-line react/display-name
headerCellRender: () => <>{i18n.ACTIONS}</>,
},
];

const FullScreenContainer = styled.div<{ $isFullScreen: boolean }>`
height: ${({ $isFullScreen }) => ($isFullScreen ? '100%' : undefined)};
Expand Down Expand Up @@ -115,8 +125,7 @@ const StatefulEventsViewerComponent: React.FC<Props> = ({
}, []);

const globalFilters = useMemo(() => [...filters, ...(pageFilters ?? [])], [filters, pageFilters]);
const leadingControlColumns: ControlColumnProps[] = [defaultControlColumn];
const trailingControlColumns: ControlColumnProps[] = [];
const trailingControlColumns: ControlColumnProps[] = EMPTY_CONTROL_COLUMNS;

return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@ export const UNIT = (totalCount: number) =>
values: { totalCount },
defaultMessage: `{totalCount, plural, =1 {event} other {events}}`,
});

export const ACTIONS = i18n.translate('xpack.securitySolution.eventsViewer.actionsColumnLabel', {
defaultMessage: 'Actions',
});
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import { buildTimeRangeFilter } from './helpers';
import { defaultRowRenderers } from '../../../timelines/components/timeline/body/renderers';
import { columns, RenderCellValue } from '../../configurations/security_solution_detections';
import { useInvalidFilterQuery } from '../../../common/hooks/use_invalid_filter_query';
import { DEFAULT_COLUMN_MIN_WIDTH } from '../../../timelines/components/timeline/body/constants';

interface OwnProps {
defaultFilters?: Filter[];
Expand Down Expand Up @@ -343,10 +344,19 @@ export const AlertsTableComponent: React.FC<AlertsTableComponentProps> = ({
? alertsDefaultModelRuleRegistry
: alertsDefaultModel;

const tGridEnabled = useIsExperimentalFeatureEnabled('tGridEnabled');

useEffect(() => {
dispatch(
timelineActions.initializeTGridSettings({
defaultColumns: columns,
defaultColumns: columns.map((c) =>
!tGridEnabled && c.initialWidth == null
? {
...c,
initialWidth: DEFAULT_COLUMN_MIN_WIDTH,
}
: c
),
documentType: i18n.ALERTS_DOCUMENT_TYPE,
excludedRowRendererIds: defaultTimelineModel.excludedRowRendererIds as RowRendererId[],
filterManager,
Expand All @@ -359,7 +369,7 @@ export const AlertsTableComponent: React.FC<AlertsTableComponentProps> = ({
showCheckboxes: true,
})
);
}, [dispatch, defaultTimelineModel, filterManager, timelineId]);
}, [dispatch, defaultTimelineModel, filterManager, tGridEnabled, timelineId]);

const headerFilterGroup = useMemo(
() => <AlertsTableFilterGroup onFilterGroupChanged={onFilterGroupChangedCallback} />,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ export const ALERTS_DOCUMENT_TYPE = i18n.translate(
}
);

export const ALERTS_UNIT = (totalCount: number) =>
i18n.translate('xpack.securitySolution.detectionEngine.alerts.alertsUnit', {
values: { totalCount },
defaultMessage: `{totalCount, plural, =1 {alert} other {alerts}}`,
});

export const OPEN_ALERTS = i18n.translate(
'xpack.securitySolution.detectionEngine.alerts.openAlertsTitle',
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,5 @@ export const columns: Array<
columnHeaderType: defaultColumnHeaderType,
displayAsText: i18n.ALERTS_HEADERS_REASON,
id: 'signal.reason',
initialWidth: 644,
},
];
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ describe('RenderCellValue', () => {
eventId,
header,
isDetails: false,
isDraggable: true,
isExpandable: false,
isExpanded: false,
linkValues,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export const RenderCellValue: React.FC<
eventId,
header,
isDetails,
isDraggable,
isExpandable,
isExpanded,
linkValues,
Expand Down Expand Up @@ -71,6 +72,7 @@ export const RenderCellValue: React.FC<
eventId={eventId}
header={header}
isDetails={isDetails}
isDraggable={isDraggable}
isExpandable={isExpandable}
isExpanded={isExpanded}
linkValues={linkValues}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,5 @@ export const columns: Array<
columnHeaderType: defaultColumnHeaderType,
id: 'signal.reason',
displayAsText: i18n.ALERTS_HEADERS_REASON,
initialWidth: 644,
},
];
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ describe('RenderCellValue', () => {
eventId,
header,
isDetails: false,
isDraggable: false,
isExpandable: false,
isExpanded: false,
linkValues,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export const RenderCellValue: React.FC<
eventId={eventId}
header={header}
isDetails={isDetails}
isDraggable={false}
isExpandable={isExpandable}
isExpanded={isExpanded}
linkValues={linkValues}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,40 +62,33 @@ export const columns: Array<
{
columnHeaderType: defaultColumnHeaderType,
id: 'event.module',
initialWidth: DEFAULT_COLUMN_MIN_WIDTH,
linkField: 'rule.reference',
},
{
aggregatable: true,
category: 'event',
columnHeaderType: defaultColumnHeaderType,
id: 'event.action',
initialWidth: 140,
type: 'string',
},
{
columnHeaderType: defaultColumnHeaderType,
id: 'event.category',
initialWidth: 150,
},
{
columnHeaderType: defaultColumnHeaderType,
id: 'host.name',
initialWidth: 120,
},
{
columnHeaderType: defaultColumnHeaderType,
id: 'user.name',
initialWidth: 120,
},
{
columnHeaderType: defaultColumnHeaderType,
id: 'source.ip',
initialWidth: 120,
},
{
columnHeaderType: defaultColumnHeaderType,
id: 'destination.ip',
initialWidth: 140,
},
];
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ describe('RenderCellValue', () => {
eventId,
header,
isDetails: false,
isDraggable: false,
isExpandable: false,
isExpanded: false,
linkValues,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const RenderCellValue: React.FC<
columnId,
data,
eventId,
isDraggable,
header,
isDetails,
isExpandable,
Expand All @@ -35,6 +36,7 @@ export const RenderCellValue: React.FC<
columnId={columnId}
data={data}
eventId={eventId}
isDraggable={isDraggable}
header={header}
isDetails={isDetails}
isExpandable={isExpandable}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import { MatrixHistogramType } from '../../../../common/search_strategy/security
import { defaultRowRenderers } from '../../../timelines/components/timeline/body/renderers';
import { DefaultCellRenderer } from '../../../timelines/components/timeline/cell_rendering/default_cell_renderer';
import { SourcererScopeName } from '../../../common/store/sourcerer/model';
import { useIsExperimentalFeatureEnabled } from '../../../common/hooks/use_experimental_features';
import { DEFAULT_COLUMN_MIN_WIDTH } from '../../../timelines/components/timeline/body/constants';

const EVENTS_HISTOGRAM_ID = 'eventsHistogramQuery';

Expand Down Expand Up @@ -66,14 +68,23 @@ const EventsQueryTabBodyComponent: React.FC<HostsComponentsQueryProps> = ({
const dispatch = useDispatch();
const { globalFullScreen } = useGlobalFullScreen();

const tGridEnabled = useIsExperimentalFeatureEnabled('tGridEnabled');

useEffect(() => {
dispatch(
timelineActions.initializeTGridSettings({
id: TimelineId.hostsPageEvents,
defaultColumns: eventsDefaultModel.columns,
defaultColumns: eventsDefaultModel.columns.map((c) =>
!tGridEnabled && c.initialWidth == null
? {
...c,
initialWidth: DEFAULT_COLUMN_MIN_WIDTH,
}
: c
),
})
);
}, [dispatch]);
}, [dispatch, tGridEnabled]);

useEffect(() => {
return () => {
Expand Down
Loading