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, alerts & cases #143598

Merged
merged 55 commits into from
Oct 27, 2022
Merged
Show file tree
Hide file tree
Changes from 51 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
818dad9
define guided ob plugin
stephmilovic Oct 4, 2022
e0db543
Merge branch 'main' into guided_onboarding_define
stephmilovic Oct 5, 2022
503c23b
stepping along
stephmilovic Oct 5, 2022
2fbbf37
more wip
stephmilovic Oct 5, 2022
94abf31
cleanup
stephmilovic Oct 5, 2022
f527d31
Merge branch 'main' into guided_onboarding_define
stephmilovic Oct 6, 2022
3378b2c
fixies
stephmilovic Oct 6, 2022
cf5646a
Merge branch 'main' into guided_onboarding_define
stephmilovic Oct 18, 2022
3f8be4d
better
stephmilovic Oct 18, 2022
81a706a
fix merge
stephmilovic Oct 19, 2022
238a5af
hey, thats different now
stephmilovic Oct 19, 2022
caa0380
move code to helpers
stephmilovic Oct 20, 2022
5042d3f
yes
stephmilovic Oct 20, 2022
c7a3a16
Merge branch 'guided_onboarding_define' into guided_onboarding_whack
stephmilovic Oct 20, 2022
e76c1ea
fix it
stephmilovic Oct 20, 2022
68c6a74
Merge branch 'main' into guided_onboarding_define
stephmilovic Oct 24, 2022
7541494
rm some old code
stephmilovic Oct 24, 2022
6ebd473
testing
stephmilovic Oct 24, 2022
883a393
add some fancy tests
stephmilovic Oct 24, 2022
0fac6ff
fix
stephmilovic Oct 24, 2022
5c5ac86
revert
stephmilovic Oct 24, 2022
805d052
better?
stephmilovic Oct 24, 2022
7cc2a2f
more better
stephmilovic Oct 24, 2022
b38991b
more better again
stephmilovic Oct 24, 2022
c2158ee
fix alpha
stephmilovic Oct 24, 2022
f5dd0b8
eh?
stephmilovic Oct 24, 2022
fb5df0f
cleaning
stephmilovic Oct 24, 2022
61f3ccf
rename
stephmilovic Oct 24, 2022
8a1f426
rename
stephmilovic Oct 24, 2022
956e96a
type fix
stephmilovic Oct 25, 2022
c5d0e30
fix translations
stephmilovic Oct 25, 2022
1f77e7c
Merge branch 'main' into guided_onboarding_define
stephmilovic Oct 25, 2022
2f75590
fixies
stephmilovic Oct 25, 2022
9ce04cf
add readme
stephmilovic Oct 25, 2022
499f744
Merge branch 'main' into guided_onboarding_define
kibanamachine Oct 25, 2022
ead7344
Merge branch 'main' into guided_onboarding_define
kibanamachine Oct 25, 2022
ae88fc9
fix obs
stephmilovic Oct 26, 2022
93378e2
Merge branch 'guided_onboarding_define' of github.com:stephmilovic/ki…
stephmilovic Oct 26, 2022
a019401
remove tour from nav
stephmilovic Oct 26, 2022
7738e1f
Merge branch 'main' into guided_onboarding_define
stephmilovic Oct 26, 2022
9b8cc02
fix type
stephmilovic Oct 26, 2022
e718c72
johnnys pr feedback
stephmilovic Oct 26, 2022
4af82c5
rm guided onboarding test from nav
stephmilovic Oct 26, 2022
26b1337
fix
stephmilovic Oct 26, 2022
ba8b78c
only use context in detections paths
stephmilovic Oct 26, 2022
251a42e
fix tests
stephmilovic Oct 26, 2022
e09574a
fix possible side effect
stephmilovic Oct 26, 2022
aa676d5
remove step arg
stephmilovic Oct 26, 2022
9d5f20b
Merge branch 'main' into guided_onboarding_define
stephmilovic Oct 27, 2022
9717786
make better
stephmilovic Oct 27, 2022
d0c8a92
Merge branch 'main' into guided_onboarding_define
kibanamachine Oct 27, 2022
c0f35b9
fix for mr michael
stephmilovic Oct 27, 2022
1958a5a
add feature flag
stephmilovic Oct 27, 2022
c2c43d7
mock feature flag (duh)
stephmilovic Oct 27, 2022
aa53370
fix warning in tests
stephmilovic Oct 27, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,24 @@ describe('CreateCaseFlyout', () => {
});
expect(onClose).toBeCalled();
});

it('renders headerContent when passed', async () => {
const headerContent = <p data-test-subj="testing123" />;
const { getByTestId } = mockedContext.render(
<CreateCaseFlyout {...defaultProps} headerContent={headerContent} />
);

await act(async () => {
expect(getByTestId('testing123')).toBeTruthy();
expect(getByTestId('create-case-flyout-header').children.length).toEqual(2);
});
});

it('does not render headerContent when undefined', async () => {
const { getByTestId } = mockedContext.render(<CreateCaseFlyout {...defaultProps} />);

await act(async () => {
expect(getByTestId('create-case-flyout-header').children.length).toEqual(1);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export interface CreateCaseFlyoutProps {
onClose?: () => void;
onSuccess?: (theCase: Case) => Promise<void>;
attachments?: CaseAttachmentsWithoutOwner;
headerContent?: React.ReactNode;
}

const StyledFlyout = styled(EuiFlyout)`
Expand Down Expand Up @@ -71,9 +72,10 @@ const FormWrapper = styled.div`
`;

export const CreateCaseFlyout = React.memo<CreateCaseFlyoutProps>(
({ afterCaseCreated, onClose, onSuccess, attachments }) => {
({ afterCaseCreated, onClose, onSuccess, attachments, headerContent }) => {
const handleCancel = onClose || function () {};
const handleOnSuccess = onSuccess || async function () {};

return (
<QueryClientProvider client={casesQueryClient}>
<GlobalStyle />
Expand All @@ -83,10 +85,11 @@ export const CreateCaseFlyout = React.memo<CreateCaseFlyoutProps>(
// maskProps is needed in order to apply the z-index to the parent overlay element, not to the flyout only
maskProps={{ className: maskOverlayClassName }}
>
<EuiFlyoutHeader hasBorder>
<EuiFlyoutHeader data-test-subj="create-case-flyout-header" hasBorder>
<EuiTitle size="m">
<h2>{i18n.CREATE_CASE_TITLE}</h2>
</EuiTitle>
{headerContent && headerContent}
</EuiFlyoutHeader>
<StyledEuiFlyoutBody>
<FormWrapper>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* 2.0.
*/

import type React from 'react';
import { useCallback } from 'react';
import type { CaseAttachmentsWithoutOwner } from '../../../types';
import { useCasesToast } from '../../../common/use_cases_toast';
Expand All @@ -29,12 +30,16 @@ export const useCasesAddToNewCaseFlyout = (props: AddToNewCaseFlyoutProps = {})
}, [dispatch]);

const openFlyout = useCallback(
({ attachments }: { attachments?: CaseAttachmentsWithoutOwner } = {}) => {
({
attachments,
headerContent,
}: { attachments?: CaseAttachmentsWithoutOwner; headerContent?: React.ReactNode } = {}) => {
dispatch({
type: CasesContextStoreActionsList.OPEN_CREATE_CASE_FLYOUT,
payload: {
...props,
attachments,
headerContent,
onClose: () => {
closeFlyout();
if (props.onClose) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import { login, visit } from '../../tasks/login';
import { completeTour, goToNextStep, skipTour } from '../../tasks/guided_onboarding';
import { SECURITY_TOUR_ACTIVE_KEY } from '../../../public/common/components/guided_onboarding';
import { OVERVIEW_URL } from '../../urls/navigation';
import {
WELCOME_STEP,
Expand All @@ -21,11 +20,11 @@ before(() => {
login();
});

describe('Guided onboarding tour', () => {
// need to redo these tests for new implementation
describe.skip('Guided onboarding tour', () => {
describe('Tour is enabled', () => {
beforeEach(() => {
visit(OVERVIEW_URL);
window.localStorage.setItem(SECURITY_TOUR_ACTIVE_KEY, 'true');
});

it('can be completed', () => {
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/security_solution/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"embeddable",
"eventLog",
"features",
"guidedOnboarding",
"inspector",
"kubernetesSecurity",
"lens",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
EuiHeaderSection,
EuiHeaderSectionItem,
} from '@elastic/eui';
import React, { useCallback, useEffect, useMemo, useState } from 'react';
import React, { useEffect, useMemo, useState } from 'react';
import { useLocation } from 'react-router-dom';
import { createHtmlPortalNode, InPortal, OutPortal } from 'react-reverse-portal';
import { i18n } from '@kbn/i18n';
Expand All @@ -28,7 +28,6 @@ import { timelineDefaults } from '../../../timelines/store/timeline/defaults';
import { timelineSelectors } from '../../../timelines/store/timeline';
import { useShallowEqualSelector } from '../../../common/hooks/use_selector';
import { getScopeFromPath, showSourcererByPath } from '../../../common/containers/sourcerer';
import { useTourContext } from '../../../common/components/guided_onboarding';

const BUTTON_ADD_DATA = i18n.translate('xpack.securitySolution.globalHeader.buttonAddData', {
defaultMessage: 'Add integrations',
Expand Down Expand Up @@ -83,12 +82,6 @@ export const GlobalHeader = React.memo(
};
}, [portalNode, setHeaderActionMenu, theme.theme$]);

const { isTourShown, endTour } = useTourContext();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

not sure why this was here, but we are changing the tour entirely so i think safe to remove?

const closeOnboardingTourIfShown = useCallback(() => {
if (isTourShown) {
endTour();
}
}, [isTourShown, endTour]);
return (
<InPortal node={portalNode}>
<EuiHeaderSection side="right">
Expand All @@ -105,7 +98,6 @@ export const GlobalHeader = React.memo(
data-test-subj="add-data"
href={href}
iconType="indexOpen"
onClick={closeOnboardingTourIfShown}
>
{BUTTON_ADD_DATA}
</EuiHeaderLink>
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/security_solution/public/app/home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { useUpgradeSecurityPackages } from '../../common/hooks/use_upgrade_secur
import { GlobalHeader } from './global_header';
import { ConsoleManager } from '../../management/components/console/components/console_manager';

import { TourContextProvider } from '../../common/components/guided_onboarding';
import { TourContextProvider } from '../../common/components/guided_onboarding_tour';

import { useUrlState } from '../../common/hooks/use_url_state';
import { useUpdateBrowserTitle } from '../../common/hooks/use_update_browser_title';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,22 @@

import type { EuiTabbedContentTab } from '@elastic/eui';
import {
EuiHorizontalRule,
EuiTabbedContent,
EuiSpacer,
EuiLoadingContent,
EuiNotificationBadge,
EuiFlexGroup,
EuiFlexItem,
EuiHorizontalRule,
EuiLoadingContent,
EuiLoadingSpinner,
EuiNotificationBadge,
EuiSpacer,
EuiTabbedContent,
} from '@elastic/eui';
import React, { useCallback, useMemo, useState } from 'react';
import styled from 'styled-components';
import { isEmpty } from 'lodash';

import { GuidedOnboardingTourStep } from '../guided_onboarding_tour/tour_step';
import { isDetectionsAlertsTable } from '../top_n/helpers';
import { getTourAnchor, SecurityStepId } from '../guided_onboarding_tour/tour_config';
import type { AlertRawEventData } from './osquery_tab';
import { useOsqueryTab } from './osquery_tab';
import { EventFieldsBrowser } from './event_fields_browser';
Expand Down Expand Up @@ -179,6 +182,8 @@ const EventDetailsComponent: React.FC<Props> = ({
[detailsEcsData]
);

const isTourAnchor = useMemo(() => isDetectionsAlertsTable(scopeId), [scopeId]);

const showThreatSummary = useMemo(() => {
const hasEnrichments = enrichmentCount > 0;
const hasRiskInfoWithLicense = isLicenseValid && (hostRisk || userRisk);
Expand Down Expand Up @@ -402,13 +407,20 @@ const EventDetailsComponent: React.FC<Props> = ({
);

return (
<StyledEuiTabbedContent
data-test-subj="eventDetails"
tabs={tabs}
selectedTab={selectedTab}
onTabClick={handleTabClick}
key="event-summary-tabs"
/>
<GuidedOnboardingTourStep
isTourAnchor={isTourAnchor}
step={3}
stepId={SecurityStepId.alertsCases}
>
<StyledEuiTabbedContent
{...(isTourAnchor ? { 'tour-step': getTourAnchor(3, SecurityStepId.alertsCases) } : {})}
stephmilovic marked this conversation as resolved.
Show resolved Hide resolved
data-test-subj="eventDetails"
tabs={tabs}
selectedTab={selectedTab}
onTabClick={handleTabClick}
key="event-summary-tabs"
/>
</GuidedOnboardingTourStep>
);
};
EventDetailsComponent.displayName = 'EventDetailsComponent';
Expand Down

This file was deleted.

Loading