Skip to content

Commit

Permalink
addresses comments
Browse files Browse the repository at this point in the history
  • Loading branch information
dplumlee committed Feb 13, 2024
1 parent b401e9e commit be35f69
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ interface RuleDetailsFlyoutProps {
size?: EuiFlyoutProps['size'];
extraTabs?: EuiTabbedContentTab[];
dataTestSubj?: string;
id?: string;
closeFlyout: () => void;
}

Expand All @@ -118,6 +119,7 @@ export const RuleDetailsFlyout = ({
size = 'm',
extraTabs = [],
dataTestSubj,
id,
closeFlyout,
}: RuleDetailsFlyoutProps) => {
const { expandedOverviewSections, toggleOverviewSection } = useOverviewTabSections();
Expand Down Expand Up @@ -181,6 +183,7 @@ export const RuleDetailsFlyout = ({

return (
<EuiFlyout
id={id}
size={size}
onClose={closeFlyout}
ownFocus={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import { MlJobUpgradeModal } from '../../../../../detections/components/modals/m
import { useIsExperimentalFeatureEnabled } from '../../../../../common/hooks/use_experimental_features';
import * as ruleDetailsI18n from '../../../../rule_management/components/rule_details/translations';
import * as i18n from './translations';
import { PREBUILT_RULE_UPDATE_FLYOUT_ANCHOR } from './upgrade_prebuilt_rules_tour';

export interface UpgradePrebuiltRulesTableState {
/**
Expand Down Expand Up @@ -343,6 +344,7 @@ export const UpgradePrebuiltRulesTableContextProvider = ({
<RuleDetailsFlyout
rule={previewedRule}
size={isJsonPrebuiltRulesDiffingEnabled ? 'l' : 'm'}
id={PREBUILT_RULE_UPDATE_FLYOUT_ANCHOR}
dataTestSubj="updatePrebuiltRulePreview"
closeFlyout={closeRulePreview}
ruleActions={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,7 @@ import type {
EuiTourState,
EuiTourStepProps,
} from '@elastic/eui';
import {
EuiButtonIcon,
EuiFlexGroup,
EuiFlexItem,
EuiSpacer,
EuiText,
EuiTourStep,
useEuiTour,
} from '@elastic/eui';
import { EuiText, EuiTourStep, useEuiTour } from '@elastic/eui';
import { noop } from 'lodash';
import type { FC } from 'react';
import React, { useEffect, useMemo } from 'react';
Expand All @@ -34,6 +26,7 @@ export interface RulesFeatureTourContextType {
}

export const PER_FIELD_UPGRADE_TOUR_ANCHOR = 'perFieldUpgradeTour';
export const PREBUILT_RULE_UPDATE_FLYOUT_ANCHOR = 'updatePrebuiltRulePreview';

This comment has been minimized.

Copy link
@jpdjere

jpdjere Feb 13, 2024

Contributor

Let's export this one from the file where the component is, and import it here. We might delete the tour in the future.


const TOUR_STORAGE_KEY = NEW_FEATURES_TOUR_STORAGE_KEYS.RULE_MANAGEMENT_PAGE;
const TOUR_POPOVER_WIDTH = 400;
Expand Down Expand Up @@ -68,51 +61,24 @@ export const PrebuiltRulesUpgradeTour: FC = () => {
[storage]
);

const [tourSteps, tourActions, tourState] = useEuiTour(stepsConfig, restoredState);
const [tourSteps, , tourState] = useEuiTour(stepsConfig, restoredState);

useEffect(() => {
const { isTourActive, currentTourStep } = tourState;
storage.set(TOUR_STORAGE_KEY, { isTourActive, currentTourStep });
}, [tourState, storage]);

const shouldShowRuleUpgradeTour = useIsElementMounted(PER_FIELD_UPGRADE_TOUR_ANCHOR);
const isTourAnchorMounted = useIsElementMounted(PER_FIELD_UPGRADE_TOUR_ANCHOR);
const isFlyoutOpen = useIsElementMounted(PREBUILT_RULE_UPDATE_FLYOUT_ANCHOR);
const shouldShowRuleUpgradeTour = isTourAnchorMounted && !isFlyoutOpen;

const enhancedSteps = useMemo(
() =>
tourSteps.map((item, index) => ({
tourSteps.map((item) => ({
...item,
content: (
<>
{item.content}
{tourSteps.length > 1 && (
<>
<EuiSpacer size="s" />
<EuiFlexGroup responsive={false} gutterSize="s" alignItems="center">
<EuiFlexItem grow={false}>
<EuiButtonIcon
iconType="arrowLeft"
aria-label={'previous'}
display="empty"
disabled={index === 0}
onClick={tourActions.decrementStep}
/>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButtonIcon
iconType="arrowRight"
aria-label={'next'}
display="base"
disabled={index === tourSteps.length - 1}
onClick={tourActions.incrementStep}
/>
</EuiFlexItem>
</EuiFlexGroup>
</>
)}
</>
),
content: item.content,
})),
[tourSteps, tourActions]
[tourSteps]
);

return shouldShowRuleUpgradeTour ? (
Expand Down

0 comments on commit be35f69

Please sign in to comment.