[Security Solution] remove unnecessary showExpandToDetails property (#168048)

This commit is contained in:
Philippe Oberti 2023-10-24 16:49:25 -05:00 committed by GitHub
parent 6f30fa3285
commit 5230db4865
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
28 changed files with 111 additions and 276 deletions

View file

@ -30,7 +30,6 @@ export const AlertsTableSandbox = ({ triggersActionsUi }: SandboxProps) => {
filter: [],
},
},
showExpandToDetails: true,
};
return <AlertsTable {...alertStateProps} />;

View file

@ -113,7 +113,6 @@ export function AlertsOverview() {
featureIds={[AlertConsumers.APM]}
query={esQuery}
showAlertStatusWithFlapping
showExpandToDetails={false}
/>
)}
</EuiFlexItem>

View file

@ -53,7 +53,6 @@ describe('CaseUI View Page activity tab', () => {
values: ['alert-id-1'],
},
},
showExpandToDetails: true,
showAlertStatusWithFlapping: false,
});
});
@ -82,7 +81,6 @@ describe('CaseUI View Page activity tab', () => {
values: ['alert-id-1'],
},
},
showExpandToDetails: false,
showAlertStatusWithFlapping: true,
});
});

View file

@ -48,7 +48,6 @@ export const CaseViewAlerts = ({ caseData }: CaseViewAlertsProps) => {
id: `case-details-alerts-${caseData.owner}`,
featureIds: alertFeatureIds ?? [],
query: alertIdsQuery,
showExpandToDetails: Boolean(alertFeatureIds?.includes('siem')),
showAlertStatusWithFlapping: caseData.owner !== SECURITY_SOLUTION_OWNER,
};

View file

@ -55,7 +55,6 @@ export const AlertsTabContent = () => {
pageSize={ALERTS_PER_PAGE}
query={alertsEsQueryByStatus}
showAlertStatusWithFlapping
showExpandToDetails={false}
/>
</EuiFlexItem>
)}

View file

@ -226,7 +226,6 @@ function InternalAlertsPage() {
id={ALERTS_TABLE_ID}
featureIds={observabilityAlertFeatureIds}
query={esQuery}
showExpandToDetails={false}
showAlertStatusWithFlapping
pageSize={ALERTS_PER_PAGE}
/>

View file

@ -193,7 +193,6 @@ export function OverviewPage() {
id={ALERTS_TABLE_ID}
pageSize={ALERTS_PER_PAGE}
query={esQuery}
showExpandToDetails={false}
showAlertStatusWithFlapping
/>
</SectionContainer>

View file

@ -110,7 +110,6 @@ export function RuleDetailsTabs({
featureIds={featureIds}
query={esQuery}
showAlertStatusWithFlapping
showExpandToDetails={false}
/>
)}
</EuiFlexItem>

View file

@ -41,7 +41,6 @@ export function SloDetailsAlerts({ slo }: Props) {
],
},
}}
showExpandToDetails={false}
showAlertStatusWithFlapping
pageSize={100}
/>

View file

@ -9,6 +9,9 @@ import React, { useCallback, useEffect, useMemo, useRef } from 'react';
import { useDispatch } from 'react-redux';
import type { CaseViewRefreshPropInterface } from '@kbn/cases-plugin/common';
import { CaseMetricsFeature } from '@kbn/cases-plugin/common';
import { useUiSetting$ } from '@kbn/kibana-react-plugin/public';
import { useExpandableFlyoutContext } from '@kbn/expandable-flyout';
import { RightPanelKey } from '../../flyout/document_details/right';
import { useTourContext } from '../../common/components/guided_onboarding_tour';
import {
AlertsCasesTourSteps,
@ -19,7 +22,12 @@ import { TimelineId } from '../../../common/types/timeline';
import { getRuleDetailsUrl, useFormatUrl } from '../../common/components/link_to';
import { useGetUserCasesPermissions, useKibana, useNavigation } from '../../common/lib/kibana';
import { APP_ID, CASES_PATH, SecurityPageName } from '../../../common/constants';
import {
APP_ID,
CASES_PATH,
ENABLE_EXPANDABLE_FLYOUT_SETTING,
SecurityPageName,
} from '../../../common/constants';
import { timelineActions } from '../../timelines/store/timeline';
import { useSourcererDataView } from '../../common/containers/sourcerer';
import { SourcererScopeName } from '../../common/store/sourcerer/model';
@ -53,6 +61,8 @@ const CaseContainerComponent: React.FC = () => {
const { formatUrl: detectionsFormatUrl, search: detectionsUrlSearch } = useFormatUrl(
SecurityPageName.rules
);
const { openFlyout } = useExpandableFlyoutContext();
const [isSecurityFlyoutEnabled] = useUiSetting$<boolean>(ENABLE_EXPANDABLE_FLYOUT_SETTING);
const getDetectionsRuleDetailsHref = useCallback(
(ruleId) => detectionsFormatUrl(getRuleDetailsUrl(ruleId ?? '', detectionsUrlSearch)),
@ -61,18 +71,34 @@ const CaseContainerComponent: React.FC = () => {
const showAlertDetails = useCallback(
(alertId: string, index: string) => {
dispatch(
timelineActions.toggleDetailPanel({
panelView: 'eventDetail',
id: TimelineId.casePage,
params: {
eventId: alertId,
indexName: index,
if (isSecurityFlyoutEnabled) {
openFlyout({
right: {
id: RightPanelKey,
params: {
id: alertId,
indexName: index,
scopeId: TimelineId.casePage,
},
},
})
);
});
}
// TODO remove when https://github.com/elastic/security-team/issues/7462 is merged
// support of old flyout in cases page
else {
dispatch(
timelineActions.toggleDetailPanel({
panelView: 'eventDetail',
id: TimelineId.casePage,
params: {
eventId: alertId,
indexName: index,
},
})
);
}
},
[dispatch]
[dispatch, isSecurityFlyoutEnabled, openFlyout]
);
const endpointDetailsHref = (endpointId: string) =>

View file

@ -11,6 +11,7 @@ import { useDispatch } from 'react-redux';
import { useExpandableFlyoutContext } from '@kbn/expandable-flyout';
import { dataTableActions, TableId } from '@kbn/securitysolution-data-table';
import { useUiSetting$ } from '@kbn/kibana-react-plugin/public';
import { timelineActions } from '../../../../timelines/store/timeline';
import { ENABLE_EXPANDABLE_FLYOUT_SETTING } from '../../../../../common/constants';
import { RightPanelKey } from '../../../../flyout/document_details/right';
import type {
@ -20,9 +21,9 @@ import type {
ExpandedDetailType,
} from '../../../../../common/types';
import { getMappedNonEcsValue } from '../../../../timelines/components/timeline/body/data_driven_columns';
import type { TimelineItem, TimelineNonEcsData } from '../../../../../common/search_strategy';
import type { ColumnHeaderOptions, OnRowSelected } from '../../../../../common/types/timeline';
import { TimelineId } from '../../../../../common/types';
type Props = EuiDataGridCellValueElementProps & {
columnHeaders: ColumnHeaderOptions[];
@ -97,6 +98,7 @@ const RowActionComponent = ({
},
};
// TODO remove when https://github.com/elastic/security-team/issues/7760 is merged
// excluding rule preview page as some sections in new flyout are not applicable when user is creating a new rule
if (isSecurityFlyoutEnabled && tableId !== TableId.rulePreview) {
openFlyout({
@ -109,7 +111,20 @@ const RowActionComponent = ({
},
},
});
} else {
}
// TODO remove when https://github.com/elastic/security-team/issues/7462 is merged
// support of old flyout in cases page
else if (tableId === TableId.alertsOnCasePage) {
dispatch(
timelineActions.toggleDetailPanel({
...updatedExpandedDetail,
id: TimelineId.casePage,
})
);
}
// TODO remove when https://github.com/elastic/security-team/issues/7462 is merged
// support of old flyout
else {
dispatch(
dataTableActions.toggleDetailPanel({
...updatedExpandedDetail,

View file

@ -23,7 +23,6 @@ import {
import { getDataTablesInStorageByIds } from '../../../timelines/containers/local_storage';
import { getColumns } from '../../../detections/configurations/security_solution_detections';
import { getRenderCellValueHook } from '../../../detections/configurations/security_solution_detections/render_cell_value';
import { useToGetInternalFlyout } from '../../../timelines/components/side_panel/event_details/flyout';
import { SourcererScopeName } from '../../store/sourcerer/model';
const registerAlertsTableConfiguration = (
@ -34,11 +33,6 @@ const registerAlertsTableConfiguration = (
const columnsFormStorage = dataTableStorage?.[TableId.alertsOnAlertsPage]?.columns ?? [];
const alertColumns = columnsFormStorage.length ? columnsFormStorage : getColumns();
const useInternalFlyout = () => {
const { header, body, footer } = useToGetInternalFlyout();
return { header, body, footer };
};
const renderCellValueHookAlertPage = getRenderCellValueHook({
scopeId: SourcererScopeName.detections,
tableId: TableId.alertsOnAlertsPage,
@ -64,7 +58,6 @@ const registerAlertsTableConfiguration = (
columns: alertColumns,
getRenderCellValue: renderCellValueHookAlertPage,
useActionsColumn: getUseActionColumnHook(TableId.alertsOnAlertsPage),
useInternalFlyout,
useBulkActions: getBulkActionHook(TableId.alertsOnAlertsPage),
useCellActions: getUseCellActionsHook(TableId.alertsOnAlertsPage),
usePersistentControls: getPersistentControlsHook(TableId.alertsOnAlertsPage),
@ -80,7 +73,6 @@ const registerAlertsTableConfiguration = (
columns: alertColumns,
getRenderCellValue: renderCellValueHookAlertPage,
useActionsColumn: getUseActionColumnHook(TableId.alertsOnRuleDetailsPage),
useInternalFlyout,
useBulkActions: getBulkActionHook(TableId.alertsOnRuleDetailsPage),
useCellActions: getUseCellActionsHook(TableId.alertsOnRuleDetailsPage),
usePersistentControls: getPersistentControlsHook(TableId.alertsOnRuleDetailsPage),
@ -93,9 +85,8 @@ const registerAlertsTableConfiguration = (
id: ALERTS_TABLE_REGISTRY_CONFIG_IDS.CASE,
cases: { featureId: CASES_FEATURE_ID, owner: [APP_ID], syncAlerts: true },
columns: alertColumns,
getRenderCellValue: renderCellValueHookCasePage,
useInternalFlyout,
useActionsColumn: getUseActionColumnHook(TableId.alertsOnCasePage),
useBulkActions: getBulkActionHook(TableId.alertsOnCasePage),
useCellActions: getUseCellActionsHook(TableId.alertsOnCasePage),
sort,
@ -108,7 +99,6 @@ const registerAlertsTableConfiguration = (
columns: alertColumns,
getRenderCellValue: renderCellValueHookAlertPage,
useActionsColumn: getUseActionColumnHook(TableId.alertsRiskInputs),
useInternalFlyout,
useBulkActions: getBulkActionHook(TableId.alertsRiskInputs),
useCellActions: getUseCellActionsHook(TableId.alertsRiskInputs),
usePersistentControls: getPersistentControlsHook(TableId.alertsRiskInputs),

View file

@ -258,7 +258,6 @@ export const AlertsTableComponent: FC<DetectionEngineAlertTableProps> = ({
id: `detection-engine-alert-table-${configId}-${tableView}`,
featureIds: ['siem'],
query: finalBoolQuery,
showExpandToDetails: false,
gridStyle,
shouldHighlightRow,
rowHeightsOptions,

View file

@ -9,7 +9,7 @@ import type { EcsSecurityExtension as Ecs } from '@kbn/securitysolution-ecs';
import React, { useCallback, useContext, useMemo } from 'react';
import { useSelector } from 'react-redux';
import type { AlertsTableConfigurationRegistry } from '@kbn/triggers-actions-ui-plugin/public/types';
import type { TableId } from '@kbn/securitysolution-data-table';
import { TableId } from '@kbn/securitysolution-data-table';
import { StatefulEventContext } from '../../../common/components/events_viewer/stateful_event_context';
import { eventsViewerSelector } from '../../../common/components/events_viewer/selectors';
import { getDefaultControlColumn } from '../../../timelines/components/timeline/body/control_columns';
@ -24,7 +24,7 @@ export const getUseActionColumnHook =
() => {
const license = useLicense();
const isEnterprisePlus = license.isEnterprise();
const ACTION_BUTTON_COUNT = isEnterprisePlus ? 5 : 4;
const ACTION_BUTTON_COUNT = tableId === TableId.alertsOnCasePage ? 3 : isEnterprisePlus ? 5 : 4;
const eventContext = useContext(StatefulEventContext);
@ -35,15 +35,13 @@ export const getUseActionColumnHook =
const {
dataTable: {
columns,
columns: columnHeaders,
showCheckboxes,
selectedEventIds,
loadingEventIds,
} = getAlertsDefaultModel(license),
} = useSelector((state: State) => eventsViewerSelector(state, tableId));
const columnHeaders = columns;
const renderCustomActionsRow = useCallback(
({
rowIndex,

View file

@ -211,6 +211,7 @@ describe('Isolate command', { tags: ['@ess', '@serverless', '@brokenInServerless
let hostname: string;
before(() => {
disableExpandableFlyoutAdvancedSettings();
indexNewCase().then((indexCase) => {
caseData = indexCase;
caseUrlPath = `${APP_CASES_PATH}/${indexCase.data.id}`;

View file

@ -4,164 +4,7 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import type { AlertsTableFlyoutBaseProps } from '@kbn/triggers-actions-ui-plugin/public';
import { EntityType } from '@kbn/timelines-plugin/common';
import { noop } from 'lodash/fp';
import React, { useCallback, useMemo, useState } from 'react';
import { TimelineId } from '../../../../../../common/types';
import { useHostIsolationTools } from '../use_host_isolation_tools';
import { FlyoutHeaderContent } from './header';
import { FlyoutBody } from './body';
import { FlyoutFooter } from './footer';
import { useTimelineEventsDetails } from '../../../../containers/details';
import { useSourcererDataView } from '../../../../../common/containers/sourcerer';
import { SourcererScopeName } from '../../../../../common/store/sourcerer/model';
import { useBasicDataFromDetailsData } from '../helpers';
export { FlyoutBody } from './body';
export { FlyoutHeader } from './header';
export { FlyoutFooter } from './footer';
export const useToGetInternalFlyout = () => {
const { browserFields, runtimeMappings } = useSourcererDataView(SourcererScopeName.detections);
const [alert, setAlert] = useState<{ id?: string; indexName?: string }>({
id: undefined,
indexName: undefined,
});
const [loading, detailsData, rawEventData, ecsData, refetchFlyoutData] = useTimelineEventsDetails(
{
entityType: EntityType.EVENTS,
indexName: alert.indexName ?? '',
eventId: alert.id ?? '',
runtimeMappings,
skip: !alert.id,
}
);
const { alertId, isAlert, hostName, ruleName, timestamp } =
useBasicDataFromDetailsData(detailsData);
const {
isolateAction,
isHostIsolationPanelOpen,
isIsolateActionSuccessBannerVisible,
handleIsolationActionSuccess,
showAlertDetails,
showHostIsolationPanel,
} = useHostIsolationTools();
const body = useCallback(
({ isLoading, alert: localAlert }: AlertsTableFlyoutBaseProps) => {
setAlert((prevAlert) => {
if (prevAlert.id !== localAlert._id) {
return { id: localAlert._id, indexName: localAlert._index };
}
return prevAlert;
});
return (
<FlyoutBody
alertId={alertId}
browserFields={browserFields}
detailsData={detailsData}
detailsEcsData={ecsData}
event={{ eventId: localAlert._id, indexName: localAlert._index }}
hostName={hostName ?? ''}
handleIsolationActionSuccess={handleIsolationActionSuccess}
handleOnEventClosed={noop}
isAlert={isAlert}
isDraggable={false}
isolateAction={isolateAction}
isIsolateActionSuccessBannerVisible={isIsolateActionSuccessBannerVisible}
isHostIsolationPanelOpen={isHostIsolationPanelOpen}
loading={isLoading || loading}
rawEventData={rawEventData}
showAlertDetails={showAlertDetails}
scopeId={TimelineId.casePage}
isReadOnly={false}
/>
);
},
[
alertId,
browserFields,
detailsData,
ecsData,
handleIsolationActionSuccess,
hostName,
isAlert,
isHostIsolationPanelOpen,
isIsolateActionSuccessBannerVisible,
isolateAction,
loading,
rawEventData,
showAlertDetails,
]
);
const header = useCallback(
({ isLoading }: AlertsTableFlyoutBaseProps) => {
return (
<FlyoutHeaderContent
isHostIsolationPanelOpen={isHostIsolationPanelOpen}
isAlert={isAlert}
eventIndex={alert.indexName ?? ''}
eventId={alertId}
isolateAction={isolateAction}
loading={isLoading || loading}
ruleName={ruleName}
showAlertDetails={showAlertDetails}
timestamp={timestamp}
/>
);
},
[
alert.indexName,
isAlert,
alertId,
isHostIsolationPanelOpen,
isolateAction,
loading,
ruleName,
showAlertDetails,
timestamp,
]
);
const footer = useCallback(
({ isLoading, alert: localAlert }: AlertsTableFlyoutBaseProps) => {
return (
<FlyoutFooter
detailsData={detailsData}
detailsEcsData={ecsData}
refetchFlyoutData={refetchFlyoutData}
handleOnEventClosed={noop}
isHostIsolationPanelOpen={isHostIsolationPanelOpen}
isReadOnly={false}
loadingEventDetails={isLoading || loading}
onAddIsolationStatusClick={showHostIsolationPanel}
scopeId={TimelineId.casePage}
/>
);
},
[
detailsData,
ecsData,
isHostIsolationPanelOpen,
loading,
refetchFlyoutData,
showHostIsolationPanel,
]
);
return useMemo(
() => ({
body,
header,
footer,
}),
[body, header, footer]
);
};

View file

@ -37777,7 +37777,6 @@
"xpack.triggersActionsUI.sections.alertsTable.alertsFlyout.paginationLabel": "Navigation dans les alertes",
"xpack.triggersActionsUI.sections.alertsTable.alertsFlyout.reason": "Raison",
"xpack.triggersActionsUI.sections.alertsTable.column.actions": "Actions",
"xpack.triggersActionsUI.sections.alertsTable.leadingControl.viewDetails": "Afficher les détails",
"xpack.triggersActionsUI.sections.alertsTable.title": "Tableau dalertes",
"xpack.triggersActionsUI.sections.confirmConnectorEditClose.cancelButtonLabel": "Annuler",
"xpack.triggersActionsUI.sections.confirmConnectorEditClose.confirmConnectorCloseMessage": "Vous ne pouvez pas récupérer de modifications non enregistrées.",

View file

@ -37768,7 +37768,6 @@
"xpack.triggersActionsUI.sections.alertsTable.alertsFlyout.paginationLabel": "アラートナビゲーション",
"xpack.triggersActionsUI.sections.alertsTable.alertsFlyout.reason": "理由",
"xpack.triggersActionsUI.sections.alertsTable.column.actions": "アクション",
"xpack.triggersActionsUI.sections.alertsTable.leadingControl.viewDetails": "詳細を表示",
"xpack.triggersActionsUI.sections.alertsTable.title": "アラートテーブル",
"xpack.triggersActionsUI.sections.confirmConnectorEditClose.cancelButtonLabel": "キャンセル",
"xpack.triggersActionsUI.sections.confirmConnectorEditClose.confirmConnectorCloseMessage": "保存されていない変更は回復できません。",

View file

@ -37762,7 +37762,6 @@
"xpack.triggersActionsUI.sections.alertsTable.alertsFlyout.paginationLabel": "告警导航",
"xpack.triggersActionsUI.sections.alertsTable.alertsFlyout.reason": "原因",
"xpack.triggersActionsUI.sections.alertsTable.column.actions": "操作",
"xpack.triggersActionsUI.sections.alertsTable.leadingControl.viewDetails": "查看详情",
"xpack.triggersActionsUI.sections.alertsTable.title": "告警表",
"xpack.triggersActionsUI.sections.confirmConnectorEditClose.cancelButtonLabel": "取消",
"xpack.triggersActionsUI.sections.confirmConnectorEditClose.confirmConnectorCloseMessage": "您无法恢复未保存更改。",

View file

@ -28,7 +28,6 @@ const AlertsPage: React.FunctionComponent = () => {
id: `internal-alerts-page`,
featureIds: consumers,
query: { bool: { must: [] } },
showExpandToDetails: true,
};
return (

View file

@ -300,7 +300,6 @@ describe('AlertsTable', () => {
pageSize: 1,
pageSizeOptions: [1, 10, 20, 50, 100],
leadingControlColumns: [],
showExpandToDetails: true,
trailingControlColumns: [],
useFetchAlertsData,
visibleColumns: columns.map((c) => c.id),
@ -416,11 +415,6 @@ describe('AlertsTable', () => {
});
describe('leading control columns', () => {
it('should return at least the flyout action control', async () => {
const wrapper = render(<AlertsTableWithProviders {...tableProps} />);
expect(wrapper.getByTestId('expandColumnHeaderLabel').textContent).toBe('Actions');
});
it('should render other leading controls', () => {
const customTableProps = {
...tableProps,
@ -481,13 +475,11 @@ describe('AlertsTable', () => {
const { queryByTestId } = render(<AlertsTableWithProviders {...customTableProps} />);
expect(queryByTestId('testActionColumn')).not.toBe(null);
expect(queryByTestId('testActionColumn2')).not.toBe(null);
expect(queryByTestId('expandColumnCellOpenFlyoutButton-0')).not.toBe(null);
});
it('should not add expansion action when not set', () => {
const customTableProps = {
...tableProps,
showExpandToDetails: false,
alertsTableConfiguration: {
...alertsTableConfiguration,
useActionsColumn: () => {
@ -532,7 +524,6 @@ describe('AlertsTable', () => {
it('should render no action column if there is neither the action nor the expand action config is set', () => {
const customTableProps = {
...tableProps,
showExpandToDetails: false,
};
const { queryByTestId } = render(<AlertsTableWithProviders {...customTableProps} />);

View file

@ -10,21 +10,15 @@ import React, { useState, Suspense, lazy, useCallback, useMemo, useEffect, useRe
import {
EuiDataGrid,
EuiDataGridCellValueElementProps,
EuiFlexGroup,
EuiFlexItem,
EuiToolTip,
EuiButtonIcon,
EuiDataGridStyle,
EuiSkeletonText,
EuiDataGridRefProps,
EuiFlexGroup,
} from '@elastic/eui';
import { useQueryClient } from '@tanstack/react-query';
import { useSorting, usePagination, useBulkActions, useActionsColumn } from './hooks';
import { AlertsTableProps, FetchAlertData } from '../../../types';
import {
ALERTS_TABLE_CONTROL_COLUMNS_ACTIONS_LABEL,
ALERTS_TABLE_CONTROL_COLUMNS_VIEW_DETAILS_LABEL,
} from './translations';
import { ALERTS_TABLE_CONTROL_COLUMNS_ACTIONS_LABEL } from './translations';
import './alerts_table.scss';
import { getToolbarVisibility } from './toolbar';
@ -209,12 +203,9 @@ const AlertsTable: React.FunctionComponent<AlertsTableProps> = (props: AlertsTab
])();
const leadingControlColumns = useMemo(() => {
const isActionButtonsColumnActive =
props.showExpandToDetails || Boolean(renderCustomActionsRow);
let controlColumns = [...props.leadingControlColumns];
if (isActionButtonsColumnActive) {
if (renderCustomActionsRow) {
controlColumns = [
{
id: 'expandColumn',
@ -231,38 +222,24 @@ const AlertsTable: React.FunctionComponent<AlertsTableProps> = (props: AlertsTab
visibleRowIndex: number;
};
if (!ecsAlertsData[visibleRowIndex]) {
return null;
}
return (
<EuiFlexGroup gutterSize="none" responsive={false}>
{props.showExpandToDetails && (
<EuiFlexItem grow={false}>
<EuiToolTip content={ALERTS_TABLE_CONTROL_COLUMNS_VIEW_DETAILS_LABEL}>
<EuiButtonIcon
size="s"
iconType="expand"
color="primary"
onClick={() => {
setFlyoutAlertIndex(visibleRowIndex);
}}
data-test-subj={`expandColumnCellOpenFlyoutButton-${visibleRowIndex}`}
aria-label={ALERTS_TABLE_CONTROL_COLUMNS_VIEW_DETAILS_LABEL}
/>
</EuiToolTip>
</EuiFlexItem>
)}
{renderCustomActionsRow &&
ecsAlertsData[visibleRowIndex] &&
renderCustomActionsRow({
alert: alerts[visibleRowIndex],
ecsAlert: ecsAlertsData[visibleRowIndex],
nonEcsData: oldAlertsData[visibleRowIndex],
rowIndex: visibleRowIndex,
setFlyoutAlert: handleFlyoutAlert,
id: props.id,
cveProps,
setIsActionLoading: getSetIsActionLoadingCallback(visibleRowIndex),
refresh,
clearSelection,
})}
{renderCustomActionsRow({
alert: alerts[visibleRowIndex],
ecsAlert: ecsAlertsData[visibleRowIndex],
nonEcsData: oldAlertsData[visibleRowIndex],
rowIndex: visibleRowIndex,
setFlyoutAlert: handleFlyoutAlert,
id: props.id,
cveProps,
setIsActionLoading: getSetIsActionLoadingCallback(visibleRowIndex),
refresh,
clearSelection,
})}
</EuiFlexGroup>
);
},
@ -286,9 +263,7 @@ const AlertsTable: React.FunctionComponent<AlertsTableProps> = (props: AlertsTab
isBulkActionsColumnActive,
props.id,
props.leadingControlColumns,
props.showExpandToDetails,
renderCustomActionsRow,
setFlyoutAlertIndex,
getSetIsActionLoadingCallback,
refresh,
clearSelection,

View file

@ -9,7 +9,12 @@ import { BehaviorSubject } from 'rxjs';
import userEvent from '@testing-library/user-event';
import { get } from 'lodash';
import { fireEvent, render, waitFor, screen } from '@testing-library/react';
import { AlertConsumers, ALERT_CASE_IDS, ALERT_MAINTENANCE_WINDOW_IDS } from '@kbn/rule-data-utils';
import {
AlertConsumers,
ALERT_CASE_IDS,
ALERT_MAINTENANCE_WINDOW_IDS,
ALERT_UUID,
} from '@kbn/rule-data-utils';
import { Storage } from '@kbn/kibana-utils-plugin/public';
import {
@ -18,6 +23,7 @@ import {
AlertsTableConfigurationRegistry,
AlertsTableFlyoutBaseProps,
FetchAlertData,
RenderCustomActionsRowArgs,
} from '../../../types';
import { PLUGIN_ID } from '../../../common/constants';
import AlertsTableState, { AlertsTableStateProps } from './alerts_table_state';
@ -130,6 +136,7 @@ const alerts = [
[AlertsField.name]: ['one'],
[AlertsField.reason]: ['two'],
[AlertsField.uuid]: ['1047d115-670d-469e-af7a-86fdd2b2f814'],
[ALERT_UUID]: ['alert-id-1'],
[ALERT_CASE_IDS]: ['test-id'],
[ALERT_MAINTENANCE_WINDOW_IDS]: ['test-mw-id-1'],
},
@ -257,6 +264,22 @@ const getMock = jest.fn().mockImplementation((plugin: string) => {
jest.fn().mockImplementation((props) => {
return `${props.colIndex}:${props.rowIndex}`;
}),
useActionsColumn: () => ({
renderCustomActionsRow: ({ setFlyoutAlert }: RenderCustomActionsRowArgs) => {
return (
<button
data-test-subj="expandColumnCellOpenFlyoutButton-0"
onClick={() => {
setFlyoutAlert({
fields: {
[ALERT_UUID]: 'alert-id-1',
},
});
}}
/>
);
},
}),
};
}
return {};
@ -313,7 +336,6 @@ describe('AlertsTableState', () => {
id: `test-alerts`,
featureIds: [AlertConsumers.LOGS],
query: {},
showExpandToDetails: true,
};
const mockCustomProps = (customProps: Partial<AlertsTableConfigurationRegistry>) => {
@ -656,7 +678,7 @@ describe('AlertsTableState', () => {
describe('flyout', () => {
it('should show a flyout when selecting an alert', async () => {
const wrapper = render(<AlertsTableWithLocale {...tableProps} />);
userEvent.click(wrapper.queryByTestId('expandColumnCellOpenFlyoutButton-0')!);
userEvent.click(wrapper.queryAllByTestId('expandColumnCellOpenFlyoutButton-0')[0]!);
const result = await wrapper.findAllByTestId('alertsFlyout');
expect(result.length).toBe(1);
@ -684,7 +706,7 @@ describe('AlertsTableState', () => {
/>
);
userEvent.click(wrapper.queryByTestId('expandColumnCellOpenFlyoutButton-0')!);
userEvent.click(wrapper.queryAllByTestId('expandColumnCellOpenFlyoutButton-0')[0]!);
const result = await wrapper.findAllByTestId('alertsFlyout');
expect(result.length).toBe(1);
@ -722,7 +744,7 @@ describe('AlertsTableState', () => {
/>
);
userEvent.click(wrapper.queryByTestId('expandColumnCellOpenFlyoutButton-0')!);
userEvent.click(wrapper.queryAllByTestId('expandColumnCellOpenFlyoutButton-0')[0]!);
const result = await wrapper.findAllByTestId('alertsFlyout');
expect(result.length).toBe(1);

View file

@ -65,7 +65,6 @@ export type AlertsTableStateProps = {
featureIds: ValidFeatureId[];
query: Pick<QueryDslQueryContainer, 'bool' | 'ids'>;
pageSize?: number;
showExpandToDetails: boolean;
browserFields?: BrowserFields;
onUpdate?: (args: TableUpdateHandlerArgs) => void;
runtimeMappings?: MappingRuntimeFields;
@ -148,7 +147,6 @@ const AlertsTableStateWithQueryProvider = ({
featureIds,
query,
pageSize,
showExpandToDetails,
leadingControlColumns,
rowHeightsOptions,
renderCellValue,
@ -387,7 +385,6 @@ const AlertsTableStateWithQueryProvider = ({
pageSizeOptions: [10, 20, 50, 100],
id,
leadingControlColumns: leadingControlColumns ?? [],
showExpandToDetails,
showAlertStatusWithFlapping,
trailingControlColumns: [],
useFetchAlertsData,
@ -417,7 +414,6 @@ const AlertsTableStateWithQueryProvider = ({
pagination.pageSize,
id,
leadingControlColumns,
showExpandToDetails,
showAlertStatusWithFlapping,
useFetchAlertsData,
visibleColumns,

View file

@ -169,7 +169,6 @@ describe('AlertsTable.BulkActions', () => {
pageSize: 2,
pageSizeOptions: [2, 4],
leadingControlColumns: [],
showExpandToDetails: true,
trailingControlColumns: [],
useFetchAlertsData: () => alertsData,
visibleColumns: columns.map((c) => c.id),
@ -706,8 +705,8 @@ describe('AlertsTable.BulkActions', () => {
expect(within(selectedOptions[0]).getByRole('checkbox')).toBeDefined();
// second row, first column
expect(within(selectedOptions[4]).getByLabelText('Loading')).toBeDefined();
expect(within(selectedOptions[4]).queryByRole('checkbox')).not.toBeInTheDocument();
expect(within(selectedOptions[3]).getByLabelText('Loading')).toBeDefined();
expect(within(selectedOptions[3]).queryByRole('checkbox')).not.toBeInTheDocument();
});
it('should hide the loading state on each selected row', async () => {

View file

@ -29,13 +29,6 @@ export const ALERTS_TABLE_CONTROL_COLUMNS_ACTIONS_LABEL = i18n.translate(
}
);
export const ALERTS_TABLE_CONTROL_COLUMNS_VIEW_DETAILS_LABEL = i18n.translate(
'xpack.triggersActionsUI.sections.alertsTable.leadingControl.viewDetails',
{
defaultMessage: 'View details',
}
);
export const ALERTS_TABLE_TITLE = i18n.translate(
'xpack.triggersActionsUI.sections.alertsTable.title',
{

View file

@ -547,7 +547,6 @@ export type AlertsTableProps = {
pageSizeOptions: number[];
id?: string;
leadingControlColumns: EuiDataGridControlColumn[];
showExpandToDetails: boolean;
showAlertStatusWithFlapping?: boolean;
trailingControlColumns: EuiDataGridControlColumn[];
useFetchAlertsData: () => FetchAlertData;

View file

@ -54,7 +54,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
await waitAndClickByTestId('close');
const headers = await find.allByCssSelector('.euiDataGridHeaderCell');
expect(headers.length).to.be(7);
expect(headers.length).to.be(6);
});
it('should take into account the column type when sorting', async () => {
@ -107,7 +107,9 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
);
});
it('should open a flyout and paginate through the flyout', async () => {
// TODO unskip once Security Solution uses the correct useInternalFlyout hook
// see https://github.com/elastic/security-team/issues/7872
it.skip('should open a flyout and paginate through the flyout', async () => {
await testSubjects.click('expandColumnCellOpenFlyoutButton-0');
await waitFlyoutOpen();
await waitFlyoutIsLoaded();