[Security Solution] [Platform] removes guided tour for data views in rules (#141501) (#141707)

* removes guided tour for data views in rules

* updates with comments - remove unused exported const and remove unused html id

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit 0d3917e45d)

Co-authored-by: Devin W. Hurley <devin.hurley@elastic.co>
This commit is contained in:
Kibana Machine 2022-09-23 14:55:12 -06:00 committed by GitHub
parent 47fe94206b
commit eefc5485b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 1 additions and 94 deletions

View file

@ -448,8 +448,6 @@ export const RULES_TABLE_PAGE_SIZE_OPTIONS = [5, 10, 20, 50, RULES_TABLE_MAX_PAG
*/
export const NEW_FEATURES_TOUR_STORAGE_KEYS = {
RULE_MANAGEMENT_PAGE: 'securitySolution.rulesManagementPage.newFeaturesTour.v8.4',
RULE_CREATION_PAGE_DEFINE_STEP:
'securitySolution.ruleCreationPage.defineStep.newFeaturesTour.v8.4',
};
export const RULES_MANAGEMENT_FEATURE_TOUR_STORAGE_KEY =

View file

@ -74,7 +74,6 @@ import { useFetchIndex } from '../../../../common/containers/source';
import { NewTermsFields } from '../new_terms_fields';
import { ScheduleItem } from '../schedule_item_form';
import { DocLink } from '../../../../common/components/links_to_docs/doc_link';
import { StepDefineRuleNewFeaturesTour } from './new_features_tour';
import { defaultCustomQuery } from '../../../pages/detection_engine/rules/utils';
import { getIsRulePreviewDisabled } from '../rule_preview/helpers';
@ -504,7 +503,7 @@ const StepDefineRuleComponent: FC<StepDefineRuleProps> = ({
const DataSource = useMemo(() => {
return (
<RuleTypeEuiFormRow id="dataSourceSelector" label={i18n.SOURCE} $isVisible={true} fullWidth>
<RuleTypeEuiFormRow label={i18n.SOURCE} $isVisible={true} fullWidth>
<EuiFlexGroup
direction="column"
gutterSize="s"
@ -679,7 +678,6 @@ const StepDefineRuleComponent: FC<StepDefineRuleProps> = ({
) : (
<>
<StepContentWrapper addPadding={!isUpdateView}>
<StepDefineRuleNewFeaturesTour />
<Form form={form} data-test-subj="stepDefineRule">
<StyledVisibleContainer isVisible={false}>
<UseField

View file

@ -1,89 +0,0 @@
/*
* 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 { noop } from 'lodash';
import type { FC } from 'react';
import React, { useEffect, useMemo, useState } from 'react';
import type { EuiTourState } from '@elastic/eui';
import { EuiSpacer, EuiTourStep, useEuiTour } from '@elastic/eui';
import { NEW_FEATURES_TOUR_STORAGE_KEYS } from '../../../../../common/constants';
import { useKibana } from '../../../../common/lib/kibana';
import * as i18n from './translations';
const TOUR_STORAGE_KEY = NEW_FEATURES_TOUR_STORAGE_KEYS.RULE_CREATION_PAGE_DEFINE_STEP;
const TOUR_POPOVER_WIDTH = 300;
const tourConfig: EuiTourState = {
currentTourStep: 1,
isTourActive: true,
tourPopoverWidth: TOUR_POPOVER_WIDTH,
tourSubtitle: '',
};
const stepsConfig = [
{
step: 1,
title: i18n.DATA_SOURCE_GUIDE_TITLE,
content: (
<span>
<p>{i18n.DATA_SOURCE_GUIDE_CONTENT}</p>
<EuiSpacer />
</span>
),
anchor: `#dataSourceSelector`,
anchorPosition: 'rightCenter' as const,
stepsTotal: 1,
onFinish: noop,
},
];
export const StepDefineRuleNewFeaturesTour: FC = () => {
const { storage } = useKibana().services;
const restoredState = useMemo<EuiTourState>(
() => ({
...tourConfig,
...storage.get(TOUR_STORAGE_KEY),
}),
[storage]
);
const [tourSteps, , tourState] = useEuiTour(stepsConfig, restoredState);
useEffect(() => {
const { isTourActive, currentTourStep } = tourState;
storage.set(TOUR_STORAGE_KEY, { isTourActive, currentTourStep });
}, [tourState, storage]);
const [shouldShowTour, setShouldShowTour] = useState(false);
useEffect(() => {
/**
* Wait until the tour target elements are visible on the page and mount
* EuiTourStep components only after that. Otherwise, the tours would never
* show up on the page.
*/
const observer = new MutationObserver(() => {
if (document.querySelector(stepsConfig[0].anchor)) {
setShouldShowTour(true);
observer.disconnect();
}
});
observer.observe(document.body, {
childList: true,
subtree: true,
});
return () => observer.disconnect();
}, []);
return shouldShowTour ? <EuiTourStep {...tourSteps[0]} /> : null;
};