-
Notifications
You must be signed in to change notification settings - Fork 0
[Security Solution][Alerts Table] support bulk selection for run workflow action #1
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,77 @@ | ||||||||||||||||||||||
| /* | ||||||||||||||||||||||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||||||||||||||||||||||
| * or more contributor license agreements. Licensed under the Elastic License | ||||||||||||||||||||||
| * 2.0; you may not use this file except in compliance with the Elastic License | ||||||||||||||||||||||
| * 2.0. | ||||||||||||||||||||||
| */ | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| import type { | ||||||||||||||||||||||
| BulkActionsConfig, | ||||||||||||||||||||||
| ContentPanelConfig, | ||||||||||||||||||||||
| RenderContentPanelProps, | ||||||||||||||||||||||
| } from '@kbn/response-ops-alerts-table/types'; | ||||||||||||||||||||||
| import { useKibana } from '@kbn/kibana-react-plugin/public'; | ||||||||||||||||||||||
| import type { ApplicationStart } from '@kbn/core-application-browser'; | ||||||||||||||||||||||
| import { WORKFLOWS_UI_SETTING_ID } from '@kbn/workflows'; | ||||||||||||||||||||||
| import React, { useCallback, useMemo } from 'react'; | ||||||||||||||||||||||
| import * as i18n from '../../components/alerts_table/translations'; | ||||||||||||||||||||||
| import { useAlertsPrivileges } from '../../containers/detection_engine/alerts/use_alerts_privileges'; | ||||||||||||||||||||||
| import { | ||||||||||||||||||||||
| AlertWorkflowsPanel, | ||||||||||||||||||||||
| RUN_WORKFLOW_BULK_PANEL_ID, | ||||||||||||||||||||||
| } from '../../components/alerts_table/timeline_actions/use_run_alert_workflow_panel'; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| export const useBulkRunAlertWorkflowPanel = (): { | ||||||||||||||||||||||
| runWorkflowItems: BulkActionsConfig[]; | ||||||||||||||||||||||
| runWorkflowPanels: ContentPanelConfig[]; | ||||||||||||||||||||||
| } => { | ||||||||||||||||||||||
| const { | ||||||||||||||||||||||
| services: { uiSettings, application }, | ||||||||||||||||||||||
| } = useKibana<{ application: ApplicationStart }>(); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const workflowUIEnabled = uiSettings?.get<boolean>(WORKFLOWS_UI_SETTING_ID, false) ?? false; | ||||||||||||||||||||||
| const canExecuteWorkflow = application.capabilities.workflowsManagement?.executeWorkflow ?? false; | ||||||||||||||||||||||
| const { hasIndexWrite } = useAlertsPrivileges(); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const renderContent = useCallback((props: RenderContentPanelProps) => { | ||||||||||||||||||||||
| const alertIds = props.alertItems.map((item) => ({ | ||||||||||||||||||||||
| _id: item._id, | ||||||||||||||||||||||
| _index: item._index ?? '', | ||||||||||||||||||||||
| })); | ||||||||||||||||||||||
|
Comment on lines
+37
to
+40
|
||||||||||||||||||||||
| const alertIds = props.alertItems.map((item) => ({ | |
| _id: item._id, | |
| _index: item._index ?? '', | |
| })); | |
| const alertIds = props.alertItems | |
| .filter((item) => Boolean(item._index)) | |
| .map((item) => ({ | |
| _id: item._id, | |
| _index: item._index!, | |
| })); |
Copilot
AI
Feb 10, 2026
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 enablement condition hasIndexWrite && workflowUIEnabled && canExecuteWorkflow is duplicated across both memos. Consider extracting a single isRunWorkflowEnabled boolean (memoized or derived) and using it in both places to reduce duplication and prevent future drift between item/panel gating logic.
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.
AlertWorkflowAlertIdrequires_index: string, but callers are currently constructing_indexvalues via?? ''(i.e., potentially passing an empty string). This weakens the contract and makes it unclear whether_indexis truly required. Consider either (a) making_indexoptional in the type and handling missing values before mutation, or (b) enforcing non-empty_indexat the call sites (e.g., filter/guard and surface a user-facing error).