mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[Triggers Actions UI] hideBulkActions for AlertsTable (#184877)
I would like to be able to disable the bulk actions entirely for a new Observability page. Maybe there's an existing or easier way but I couldn't figure it out :) I also added the possibility to set the `emptyStateHeight`. --------- Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
ac1b9d0625
commit
1b8236375a
5 changed files with 50 additions and 1 deletions
|
@ -343,6 +343,7 @@ const AlertsTable: React.FunctionComponent<AlertsTableProps> = memo((props: Aler
|
|||
useBulkActionsConfig: alertsTableConfiguration.useBulkActions,
|
||||
refresh: alertsRefresh,
|
||||
featureIds,
|
||||
hideBulkActions: Boolean(alertsTableConfiguration.hideBulkActions),
|
||||
};
|
||||
}, [alerts, alertsTableConfiguration, query, alertsRefresh, featureIds]);
|
||||
|
||||
|
|
|
@ -92,6 +92,7 @@ export type AlertsTableStateProps = {
|
|||
dynamicRowHeight?: boolean;
|
||||
lastReloadRequestTime?: number;
|
||||
renderCellPopover?: AlertsTableProps['renderCellPopover'];
|
||||
emptyStateHeight?: 'tall' | 'short';
|
||||
} & Omit<Partial<EuiDataGridProps>, 'renderCellPopover'>;
|
||||
|
||||
export interface AlertsTableStorage {
|
||||
|
@ -214,6 +215,7 @@ const AlertsTableStateWithQueryProvider = memo(
|
|||
shouldHighlightRow,
|
||||
dynamicRowHeight,
|
||||
lastReloadRequestTime,
|
||||
emptyStateHeight,
|
||||
}: AlertsTableStateProps) => {
|
||||
const { cases: casesService, fieldFormats } = useKibana<{
|
||||
cases?: CasesService;
|
||||
|
@ -530,6 +532,7 @@ const AlertsTableStateWithQueryProvider = memo(
|
|||
controls={persistentControls}
|
||||
getInspectQuery={getInspectQuery}
|
||||
showInpectButton={showInspectButton}
|
||||
height={emptyStateHeight}
|
||||
/>
|
||||
</InspectButtonContainer>
|
||||
)}
|
||||
|
|
|
@ -463,5 +463,42 @@ describe('bulk action hooks', () => {
|
|||
const newBulkActions = result.current.bulkActions[0].items;
|
||||
expect(initialBulkActions).toEqual(newBulkActions);
|
||||
});
|
||||
|
||||
it('hides bulk actions if hideBulkActions == true', () => {
|
||||
// make sure by default some actions are returned for this
|
||||
// config
|
||||
const { result: resultWithoutHideBulkActions } = renderHook(
|
||||
() =>
|
||||
useBulkActions({
|
||||
alerts: [],
|
||||
query: {},
|
||||
casesConfig,
|
||||
refresh,
|
||||
featureIds: ['observability'],
|
||||
}),
|
||||
{
|
||||
wrapper: appMockRender.AppWrapper,
|
||||
}
|
||||
);
|
||||
|
||||
expect(resultWithoutHideBulkActions.current.bulkActions.length).toBeGreaterThan(0);
|
||||
|
||||
const { result: resultWithHideBulkActions } = renderHook(
|
||||
() =>
|
||||
useBulkActions({
|
||||
alerts: [],
|
||||
query: {},
|
||||
casesConfig,
|
||||
refresh,
|
||||
featureIds: ['observability'],
|
||||
hideBulkActions: true,
|
||||
}),
|
||||
{
|
||||
wrapper: appMockRender.AppWrapper,
|
||||
}
|
||||
);
|
||||
|
||||
expect(resultWithHideBulkActions.current.bulkActions.length).toBe(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -42,6 +42,7 @@ interface BulkActionsProps {
|
|||
useBulkActionsConfig?: UseBulkActionsRegistry;
|
||||
refresh: () => void;
|
||||
featureIds?: ValidFeatureId[];
|
||||
hideBulkActions?: boolean;
|
||||
}
|
||||
|
||||
export interface UseBulkActions {
|
||||
|
@ -278,6 +279,7 @@ export function useBulkActions({
|
|||
refresh,
|
||||
useBulkActionsConfig = () => [],
|
||||
featureIds,
|
||||
hideBulkActions,
|
||||
}: BulkActionsProps): UseBulkActions {
|
||||
const {
|
||||
bulkActions: [bulkActionsState, updateBulkActionsState],
|
||||
|
@ -302,17 +304,22 @@ export function useBulkActions({
|
|||
featureIds,
|
||||
isAllSelected: bulkActionsState.isAllSelected,
|
||||
});
|
||||
|
||||
const initialItems = useMemo(() => {
|
||||
return [...caseBulkActions, ...(featureIds?.includes('siem') ? [] : untrackBulkActions)];
|
||||
}, [caseBulkActions, featureIds, untrackBulkActions]);
|
||||
const bulkActions = useMemo(() => {
|
||||
if (hideBulkActions) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return initialItems.length
|
||||
? addItemsToInitialPanel({
|
||||
panels: configBulkActionPanels,
|
||||
items: initialItems,
|
||||
})
|
||||
: configBulkActionPanels;
|
||||
}, [configBulkActionPanels, initialItems]);
|
||||
}, [configBulkActionPanels, initialItems, hideBulkActions]);
|
||||
|
||||
const isBulkActionsColumnActive = bulkActions.length !== 0;
|
||||
|
||||
|
|
|
@ -763,6 +763,7 @@ export interface AlertsTableConfigurationRegistry {
|
|||
};
|
||||
useFieldBrowserOptions?: UseFieldBrowserOptions;
|
||||
showInspectButton?: boolean;
|
||||
hideBulkActions?: boolean;
|
||||
ruleTypeIds?: string[];
|
||||
useFetchPageContext?: PreFetchPageContext;
|
||||
actions?: {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue