-
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.
Fix performance issues affecting rules management (#135311)
- Loading branch information
Showing
40 changed files
with
735 additions
and
970 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
videos | ||
screenshots | ||
downloads |
1 change: 0 additions & 1 deletion
1
x-pack/plugins/security_solution/cypress/downloads/timelines_export.ndjson
This file was deleted.
Oops, something went wrong.
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
52 changes: 52 additions & 0 deletions
52
...ion/public/detections/containers/detection_engine/rules/use_install_pre_packaged_rules.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,52 @@ | ||
/* | ||
* 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 { useMutation } from 'react-query'; | ||
import { useAppToasts } from '../../../../common/hooks/use_app_toasts'; | ||
import { createPrepackagedRules } from './api'; | ||
import * as i18n from './translations'; | ||
import { useInvalidateRules } from './use_find_rules_query'; | ||
import { useInvalidatePrePackagedRulesStatus } from './use_pre_packaged_rules_status'; | ||
|
||
export const useInstallPrePackagedRules = () => { | ||
const { addError, addSuccess } = useAppToasts(); | ||
const invalidateRules = useInvalidateRules(); | ||
const invalidatePrePackagedRulesStatus = useInvalidatePrePackagedRulesStatus(); | ||
|
||
return useMutation(() => createPrepackagedRules(), { | ||
onError: (err) => { | ||
addError(err, { title: i18n.RULE_AND_TIMELINE_PREPACKAGED_FAILURE }); | ||
}, | ||
onSuccess: (result) => { | ||
addSuccess(getSuccessToastMessage(result)); | ||
// Always invalidate all rules and the prepackaged rules status cache as | ||
// the number of rules might change after the installation | ||
invalidatePrePackagedRulesStatus(); | ||
invalidateRules(); | ||
}, | ||
}); | ||
}; | ||
|
||
const getSuccessToastMessage = (result: { | ||
rules_installed: number; | ||
rules_updated: number; | ||
timelines_installed: number; | ||
timelines_updated: number; | ||
}) => { | ||
const { | ||
rules_installed: rulesInstalled, | ||
rules_updated: rulesUpdated, | ||
timelines_installed: timelinesInstalled, | ||
timelines_updated: timelinesUpdated, | ||
} = result; | ||
if (rulesInstalled === 0 && (timelinesInstalled > 0 || timelinesUpdated > 0)) { | ||
return i18n.TIMELINE_PREPACKAGED_SUCCESS; | ||
} else if ((rulesInstalled > 0 || rulesUpdated > 0) && timelinesInstalled === 0) { | ||
return i18n.RULE_PREPACKAGED_SUCCESS; | ||
} else { | ||
return i18n.RULE_AND_TIMELINE_PREPACKAGED_SUCCESS; | ||
} | ||
}; |
Oops, something went wrong.