-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RAC][Observability] Add status update actions in row menu (#108698)
* use rac alerts bulk_update * cleanup * adds replace ALERT_STATUS with ALERT_WORKFLOW_STATUS and updates tests and adds logic for switching between signal.status and workflow status when updating alerts in .siem-signals * allow object and string types in query param, fixed single update api to use WORKFLOW_STATUS instead of ALERT_STATUS * adds additional integration test for when query is a DSL object in addtion to KQL string * optionally use fields api in requests if _source does not contain authz properties * integrate bulk update to all hook calls * adds fields support, fixes bug where we were writing to 'signals.status' and not { signals: {status }} in alerts client * clean up and fixes * fix a bug where we were not waiting for updates to complete when using ids param in alerts bulk update. Adds integration tests for detection engine testing update alerts with new alerts as data client routes * take index name from ecsData props * pr suggestions * some more type fixes * refactor and type fixes * snapshot updated * add status update actions to row context menu * refactor to use dispatch function in o11y actions * comment removed * bring alertConsumer back * bring indexNames back * check capabilities to show status update items Co-authored-by: Devin Hurley <devin.hurley@elastic.co>
- Loading branch information
1 parent
e518b1a
commit 93d55dc
Showing
25 changed files
with
386 additions
and
177 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
x-pack/plugins/observability/public/hooks/use_alert_permission.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* 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 { useEffect, useState } from 'react'; | ||
import { RecursiveReadonly } from '@kbn/utility-types'; | ||
|
||
export interface UseGetUserAlertsPermissionsProps { | ||
crud: boolean; | ||
read: boolean; | ||
loading: boolean; | ||
featureId: string | null; | ||
} | ||
|
||
export const useGetUserAlertsPermissions = ( | ||
uiCapabilities: RecursiveReadonly<Record<string, any>>, | ||
featureId?: string | ||
): UseGetUserAlertsPermissionsProps => { | ||
const [alertsPermissions, setAlertsPermissions] = useState<UseGetUserAlertsPermissionsProps>({ | ||
crud: false, | ||
read: false, | ||
loading: true, | ||
featureId: null, | ||
}); | ||
|
||
useEffect(() => { | ||
if (!featureId || !uiCapabilities[featureId]) { | ||
setAlertsPermissions({ | ||
crud: false, | ||
read: false, | ||
loading: false, | ||
featureId: null, | ||
}); | ||
} else { | ||
setAlertsPermissions((currentAlertPermissions) => { | ||
if (currentAlertPermissions.featureId === featureId) { | ||
return currentAlertPermissions; | ||
} | ||
const capabilitiesCanUserCRUD: boolean = | ||
typeof uiCapabilities[featureId].save === 'boolean' | ||
? uiCapabilities[featureId].save | ||
: false; | ||
const capabilitiesCanUserRead: boolean = | ||
typeof uiCapabilities[featureId].show === 'boolean' | ||
? uiCapabilities[featureId].show | ||
: false; | ||
return { | ||
crud: capabilitiesCanUserCRUD, | ||
read: capabilitiesCanUserRead, | ||
loading: false, | ||
featureId, | ||
}; | ||
}); | ||
} | ||
}, [alertsPermissions.featureId, featureId, uiCapabilities]); | ||
|
||
return alertsPermissions; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.