-
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.
move rule snooze settings fetching functionality to a hook
- Loading branch information
Showing
10 changed files
with
65 additions
and
84 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
...k/plugins/security_solution/public/detection_engine/components/rule_snooze_badge/index.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,8 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export * from './rule_snooze_badge'; |
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
38 changes: 38 additions & 0 deletions
38
...solution/public/detection_engine/components/rule_snooze_badge/use_rule_snooze_settings.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,38 @@ | ||
/* | ||
* 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 { RuleSnoozeSettings } from '../../rule_management/logic'; | ||
import { useFetchRulesSnoozeSettings } from '../../rule_management/api/hooks/use_fetch_rules_snooze_settings'; | ||
import { useRulesTableContextOptional } from '../../rule_management_ui/components/rules_table/rules_table/rules_table_context'; | ||
import * as i18n from './translations'; | ||
|
||
interface UseRuleSnoozeSettingsResult { | ||
snoozeSettings?: RuleSnoozeSettings; | ||
error?: string; | ||
} | ||
|
||
export function useRuleSnoozeSettings(id: string): UseRuleSnoozeSettingsResult { | ||
const { | ||
state: { rulesSnoozeSettings: rulesTableSnoozeSettings }, | ||
} = useRulesTableContextOptional() ?? { state: {} }; | ||
const { | ||
data: rulesSnoozeSettings, | ||
isFetching: isSingleSnoozeSettingsFetching, | ||
isError: isSingleSnoozeSettingsError, | ||
} = useFetchRulesSnoozeSettings([id]); | ||
const snoozeSettings = rulesTableSnoozeSettings?.data[id] ?? rulesSnoozeSettings?.[0]; | ||
const isFetching = rulesTableSnoozeSettings?.isFetching || isSingleSnoozeSettingsFetching; | ||
const isError = rulesTableSnoozeSettings?.isError || isSingleSnoozeSettingsError; | ||
|
||
return { | ||
snoozeSettings, | ||
error: | ||
isError || (!snoozeSettings && !isFetching) | ||
? i18n.UNABLE_TO_FETCH_RULES_SNOOZE_SETTINGS | ||
: undefined, | ||
}; | ||
} |
35 changes: 0 additions & 35 deletions
35
...gine/rule_details_ui/pages/rule_details/components/rule_details_snooze_settings/index.tsx
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