forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Security solution] Guided onboarding rules (#1)
- Loading branch information
1 parent
b76263b
commit 7fd258c
Showing
9 changed files
with
113 additions
and
216 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
50 changes: 50 additions & 0 deletions
50
...gins/security_solution/public/common/components/guided_onboarding_tour/use_rules_tour.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,50 @@ | ||
/* | ||
* 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 { useCallback, useEffect } from 'react'; | ||
import { useTourContext } from './tour'; | ||
import type { RulesQueryResponse } from '../../../detection_engine/rule_management/api/hooks/use_find_rules_query'; | ||
import { useFindRulesQuery } from '../../../detection_engine/rule_management/api/hooks/use_find_rules_query'; | ||
import { SecurityStepId } from './tour_config'; | ||
const GUIDED_ONBOARDING_RULES_FILTER = { | ||
filter: '', | ||
showCustomRules: false, | ||
showElasticRules: true, | ||
tags: ['Guided Onboarding'], | ||
}; | ||
export const useRulesTour = () => { | ||
const { isTourShown, endTourStep, incrementStep, activeStep, setActiveStep } = useTourContext(); | ||
const { data: onboardingRules } = useFindRulesQuery( | ||
{ filterOptions: GUIDED_ONBOARDING_RULES_FILTER }, | ||
{ retry: false, enabled: isTourShown(SecurityStepId.rules) } | ||
); | ||
|
||
const manageRulesTour = useCallback( | ||
({ rules }: RulesQueryResponse) => { | ||
if (rules && rules.length === 0 && isTourShown(SecurityStepId.rules) && activeStep === 2) { | ||
// reset to 1 if they are on step 2 but have no onboarding rules | ||
setActiveStep(SecurityStepId.rules, 1); | ||
} | ||
if (rules && rules.length > 0 && isTourShown(SecurityStepId.rules) && activeStep === 1) { | ||
// There are onboarding rules now, advance to step 2 if on step 1 | ||
incrementStep(SecurityStepId.rules); | ||
} | ||
if (rules.some((rule) => rule.enabled)) { | ||
// The onboarding rule is enabled, end the tour | ||
endTourStep(SecurityStepId.rules); | ||
} | ||
}, | ||
[activeStep, endTourStep, incrementStep, isTourShown, setActiveStep] | ||
); | ||
|
||
useEffect(() => { | ||
if (onboardingRules) { | ||
manageRulesTour(onboardingRules); | ||
} | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [onboardingRules]); | ||
}; |
118 changes: 0 additions & 118 deletions
118
...etection_engine/rule_management_ui/components/guided_onboarding/rules_management_tour.tsx
This file was deleted.
Oops, something went wrong.
36 changes: 0 additions & 36 deletions
36
...n/public/detection_engine/rule_management_ui/components/guided_onboarding/translations.ts
This file was deleted.
Oops, something went wrong.
35 changes: 0 additions & 35 deletions
35
...etection_engine/rule_management_ui/components/guided_onboarding/use_is_element_mounted.ts
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
Oops, something went wrong.