-
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.
[SIEM] Detection engine cleanup for rule details/creation/edit page (#…
…55069) (#55269) * update extra action on rule detail to match design * remove experimental label * allow pre-package to be deleted + do not allow wrong user to create pre-packages rules * Additional look back minimum value to 1 * fix flow with edit rule * add success toaster when rule is created or updated * Fix Timeline selector loading * review ben doc + change detectin engine to detection even in url * Succeeded text size consistency in rule details page * fix description of threats * fix test * fix type * fix internatinalization * Update x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/create/translations.ts Co-Authored-By: Garrett Spong <spong@users.noreply.github.com> * Update x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/edit/translations.ts Co-Authored-By: Garrett Spong <spong@users.noreply.github.com> * Update x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/components/step_schedule_rule/schema.tsx Co-Authored-By: Garrett Spong <spong@users.noreply.github.com> * review I * fix type Co-authored-by: Garrett Spong <spong@users.noreply.github.com> Co-authored-by: Garrett Spong <spong@users.noreply.github.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
- Loading branch information
1 parent
666eda0
commit be1c35f
Showing
42 changed files
with
301 additions
and
195 deletions.
There are no files selected for viewing
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
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
81 changes: 81 additions & 0 deletions
81
...egacy/plugins/siem/public/containers/detection_engine/rules/use_create_packaged_rules.tsx
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,81 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { useEffect, useState } from 'react'; | ||
|
||
import { createPrepackagedRules } from './api'; | ||
|
||
type Return = [boolean, boolean | null]; | ||
|
||
interface UseCreatePackagedRules { | ||
canUserCRUD: boolean | null; | ||
hasIndexManage: boolean | null; | ||
hasManageApiKey: boolean | null; | ||
isAuthenticated: boolean | null; | ||
isSignalIndexExists: boolean | null; | ||
} | ||
|
||
/** | ||
* Hook for creating the packages rules | ||
* | ||
* @param canUserCRUD boolean | ||
* @param hasIndexManage boolean | ||
* @param hasManageApiKey boolean | ||
* @param isAuthenticated boolean | ||
* @param isSignalIndexExists boolean | ||
* | ||
* @returns [loading, hasCreatedPackageRules] | ||
*/ | ||
export const useCreatePackagedRules = ({ | ||
canUserCRUD, | ||
hasIndexManage, | ||
hasManageApiKey, | ||
isAuthenticated, | ||
isSignalIndexExists, | ||
}: UseCreatePackagedRules): Return => { | ||
const [hasCreatedPackageRules, setHasCreatedPackageRules] = useState<boolean | null>(null); | ||
const [loading, setLoading] = useState(true); | ||
|
||
useEffect(() => { | ||
let isSubscribed = true; | ||
const abortCtrl = new AbortController(); | ||
setLoading(true); | ||
|
||
async function createRules() { | ||
try { | ||
await createPrepackagedRules({ | ||
signal: abortCtrl.signal, | ||
}); | ||
|
||
if (isSubscribed) { | ||
setHasCreatedPackageRules(true); | ||
} | ||
} catch (error) { | ||
if (isSubscribed) { | ||
setHasCreatedPackageRules(false); | ||
} | ||
} | ||
if (isSubscribed) { | ||
setLoading(false); | ||
} | ||
} | ||
if ( | ||
canUserCRUD && | ||
hasIndexManage && | ||
hasManageApiKey && | ||
isAuthenticated && | ||
isSignalIndexExists | ||
) { | ||
createRules(); | ||
} | ||
return () => { | ||
isSubscribed = false; | ||
abortCtrl.abort(); | ||
}; | ||
}, [canUserCRUD, hasIndexManage, hasManageApiKey, isAuthenticated, isSignalIndexExists]); | ||
|
||
return [loading, hasCreatedPackageRules]; | ||
}; |
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.