Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Security solution] Guided onboarding unhappy path fixes #144178

Merged
merged 11 commits into from
Nov 1, 2022

Conversation

stephmilovic
Copy link
Contributor

@stephmilovic stephmilovic commented Oct 28, 2022

Summary

Follow up to #143598
Fixes unhappy path behavior on the SecurityStepId.alertsCases tour. Details on the fixes are in the code!

To test

Add to your dev yml: xpack.cloud.id: test (this is new since the original PR)
Follow instructions from original PR #143598

Known issues left unresolved

  1. If you have a flyout guide step open, close the flyout, open the Setup guide menu, and click "Continue", the user needs to manually open the flyout to get back to the step. Here is an issue to add a callback that will allow us to automate this click. FWIW, this only happens if the user is on the alerts page. If they go to an unrelated page (non-detections), open the Setup guide menu, and click "Continue", they are redirected to the Alerts page and reset to step 1.

const StyledTourStep = styled(EuiTourStep)<EuiTourStepProps & { stepId: SecurityStepId }>`
&.euiPopover__panel[data-popover-open] {
z-index: ${({ step, stepId }) =>
isStepExternallyMounted(stepId, step) ? '9000 !important' : '1000 !important'};
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I needed to lower the z-index to prevent bugs like this:
Screen Shot 2022-10-28 at 10 14 47 AM

But it needs to be high again for the cases step or else:
Screen Shot 2022-10-28 at 10 15 14 AM

export const SecurityTourStep = ({ children, step, stepId }: SecurityTourStep) => {
const { activeStep, incrementStep, isTourShown } = useTourContext();
const tourStep = useMemo(
() => securityTourConfig[stepId].find((config) => config.step === step),
[step, stepId]
);

const getTimeline = useMemo(() => timelineSelectors.getTimelineByIdSelector(), []);
const showTimeline = useShallowEqualSelector(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes this

Screen Shot 2022-10-28 at 10 17 01 AM

@@ -217,11 +217,12 @@ const ActionsComponent: React.FC<ActionProps> = ({
);

const onExpandEvent = useCallback(() => {
if (isTourAnchor) {
const isStep2Active = activeStep === 2 && isTourShown(SecurityStepId.alertsCases);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1
To prevent bugs like this, only allow incrementStep from this action if the alerts tour step is currently 2

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use the enum here instead of 2 and maybe isExpandEventStepActive ?

@@ -80,7 +80,9 @@ export const useAddToCaseActions = ({
onMenuItemClick();
createCaseFlyout.open({
attachments: caseAttachments,
...(isTourShown(SecurityStepId.alertsCases) && activeStep === 4
// activeStep will be 4 on first render because not yet incremented
// if the user closes the flyout without completing the form and comes back, we will be at step 5
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2a
Fixes this issue

@@ -19,7 +19,7 @@ import { securityTourConfig, SecurityStepId } from './tour_config';
export interface TourContextValue {
activeStep: number;
endTourStep: (stepId: SecurityStepId) => void;
incrementStep: (stepId: SecurityStepId, step?: number) => void;
incrementStep: (stepId: SecurityStepId) => void;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

never used/implemented

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it going to be used in the future or should we just remove it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh ignore me

@@ -9,6 +9,12 @@ import { render } from '@testing-library/react';
import { GuidedOnboardingTourStep, SecurityTourStep } from './tour_step';
import { SecurityStepId } from './tour_config';
import { useTourContext } from './tour';
import { mockGlobalState, SUB_PLUGINS_REDUCER, TestProviders } from '../../mock';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need this now since we have timeline state in the component

@stephmilovic stephmilovic added release_note:skip Skip the PR/issue when compiling release notes Team:Threat Hunting Security Solution Threat Hunting Team Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. Team:Threat Hunting:Explore v8.6.0 labels Oct 28, 2022
@stephmilovic stephmilovic changed the title Guided onboarding unhappy [Security solution] Guided onboarding unhappy path fixes Oct 28, 2022
@stephmilovic stephmilovic marked this pull request as ready for review October 28, 2022 19:26
@stephmilovic stephmilovic requested review from a team as code owners October 28, 2022 19:26
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-threat-hunting (Team:Threat Hunting)

@elasticmachine
Copy link
Contributor

Pinging @elastic/security-solution (Team: SecuritySolution)

@@ -89,11 +117,13 @@ export const SecurityTourStep = ({ children, step, stepId }: SecurityTourStep) =
// see type EuiTourStepAnchorProps
return anchor != null ? (
<>
<EuiTourStep {...commonProps} anchor={anchor} />
<StyledTourStep stepId={stepId} {...commonProps} anchor={anchor} />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: In this case where we have the anchor, do we need to render the TourStep if we don't have children?
I am asking because if we don't have to render anything if children is not passed, then we could create an exit case (if !children return null) much earlier in the component, and avoid checking it on every return, and this double ternary condition as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, step 5 is only the tour step, no children passed

Copy link
Contributor

@semd semd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally, All the problems mentioned are solved.
The only change I would do is to use constants in the components for the steps, instead of the sequence number, as discussed. But besides that, it LGTM.

@michaelolo24
Copy link
Contributor

A minor ux thing: just pulling down and testing it looks like the FlyoutHeader width is smaller when step 3 is visible? It takes up the full space once you move to the next step

image

Copy link
Contributor

@michaelolo24 michaelolo24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally, just one UX change for the flyout header, but everything else looks good...just some nits. Thanks for doing this work!

@stephmilovic
Copy link
Contributor Author

A minor ux thing: just pulling down and testing it looks like the FlyoutHeader width is smaller when step 3 is visible? It takes up the full space once you move to the next step

@michaelolo24 I have a PR with design fixes coming up next so I will clear this problem up there. thanks!

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
securitySolution 9.5MB 9.5MB +3.5KB
Unknown metric groups

ESLint disabled in files

id before after diff
osquery 1 2 +1

ESLint disabled line counts

id before after diff
enterpriseSearch 19 21 +2
fleet 57 63 +6
osquery 103 108 +5
securitySolution 439 443 +4
total +17

Total ESLint disabled count

id before after diff
enterpriseSearch 20 22 +2
fleet 65 71 +6
osquery 104 110 +6
securitySolution 516 520 +4
total +18

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@stephmilovic stephmilovic merged commit 8969009 into elastic:main Nov 1, 2022
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Nov 1, 2022
@stephmilovic stephmilovic deleted the guided_onboarding_unhappy branch November 1, 2022 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. Team:Threat Hunting:Explore Team:Threat Hunting Security Solution Threat Hunting Team v8.6.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants