-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[SecuritySolution] Retrieve onboarding steps #181442
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
Merged
Merged
Changes from all commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
6d4b37e
Retrieve onboarding steps
angorayc 7366052
compatible with legacy flyout
angorayc f2afbaa
Merge branch 'main' of github.com:elastic/kibana into issues/181190
angorayc 6e15bde
hide onboarding steps when cases opened
angorayc 91e636a
remove debugger
angorayc 5675be7
hide all tours when irrelevant flyout open
angorayc 2d503bf
open correlation tab after case submission
angorayc 818ffa2
fix types
angorayc da45950
Merge branch 'main' of github.com:elastic/kibana into issues/181190
angorayc 2b1ad24
unit tests
angorayc 31d997b
unit tests
angorayc c6c8a8d
fix unit tests
angorayc e0b59eb
unit tests
angorayc 3162e3e
Merge branch 'main' into issues/181190
angorayc d910941
use state observable
semd 205ab83
cleaning
semd b74b20e
set behavior subject default value
semd 30a5fa3
get context state util
semd 2ed8fdb
unit tests
angorayc 6ef8cae
fix UI error
angorayc c75c144
Merge branch 'main' into issues/181190
angorayc 2c5063c
unit tests
angorayc 7b91f9e
Merge branch 'main' into issues/181190
angorayc 4a9b90c
unit tests
angorayc edfc5d3
code review
angorayc 3273700
unit tests
angorayc a6cd062
unit tests
angorayc 7a40a60
Merge branch 'main' into issues/181190
angorayc 0c2b7ba
unit tests
angorayc caa3121
Merge branch 'main' into issues/181190
angorayc f7b2411
Merge branch 'main' into issues/181190
angorayc 05784f5
memo SecurityTourStep
semd 2933d68
Merge remote-tracking branch 'upstream/main' into issues/181190
semd 2534c07
prevent cells without anchor to update
semd 690f59b
type failure
angorayc 39e1468
Merge branch 'main' into issues/181190
angorayc 96f5924
use separate cases state context
semd e3433d9
remove type not used
semd a5e9085
clean tests
semd 5337e47
improve test
semd c80bdc8
Merge remote-tracking branch 'upstream/main' into issues/181190
semd 1e6f738
Merge branch 'main' into issues/181190
kibanamachine fc02346
Merge branch 'main' into issues/181190
kibanamachine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
21 changes: 21 additions & 0 deletions
21
x-pack/plugins/cases/public/components/cases_context/state/cases_state_context.ts
This file contains hidden or 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,21 @@ | ||
| /* | ||
| * 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 React, { useContext } from 'react'; | ||
| import type { CasesContextState } from './cases_context_reducer'; | ||
|
|
||
| export const CasesStateContext = React.createContext<CasesContextState | undefined>(undefined); | ||
|
|
||
| export const useCasesStateContext = () => { | ||
| const casesStateContext = useContext(CasesStateContext); | ||
| if (!casesStateContext) { | ||
| throw new Error( | ||
| 'useCasesStateContext must be used within a CasesProvider and have a defined value. See https://github.com/elastic/kibana/blob/main/x-pack/plugins/cases/README.md#cases-ui' | ||
| ); | ||
| } | ||
| return casesStateContext; | ||
| }; |
77 changes: 77 additions & 0 deletions
77
x-pack/plugins/cases/public/components/cases_context/state/use_is_add_to_case_open.test.tsx
This file contains hidden or 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,77 @@ | ||
| /* | ||
| * 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 { act, renderHook } from '@testing-library/react-hooks'; | ||
| import { useCasesAddToExistingCaseModal } from '../../all_cases/selector_modal/use_cases_add_to_existing_case_modal'; | ||
| import { createAppMockRenderer } from '../../../common/mock'; | ||
| import { useIsAddToCaseOpen } from './use_is_add_to_case_open'; | ||
| import { useCasesToast } from '../../../common/use_cases_toast'; | ||
| import { useCasesAddToNewCaseFlyout } from '../../create/flyout/use_cases_add_to_new_case_flyout'; | ||
|
|
||
| jest.mock('../../../common/use_cases_toast'); | ||
| const useCasesToastMock = useCasesToast as jest.Mock; | ||
| useCasesToastMock.mockReturnValue({ | ||
| showInfoToast: jest.fn(), | ||
| }); | ||
|
|
||
| const { AppWrapper } = createAppMockRenderer(); | ||
|
|
||
| describe('use is add to existing case modal open hook', () => { | ||
| beforeEach(() => { | ||
| jest.clearAllMocks(); | ||
| }); | ||
|
|
||
| it('should throw if called outside of a cases context', () => { | ||
| const { result } = renderHook(useIsAddToCaseOpen); | ||
| expect(result.error?.message).toContain( | ||
| 'useCasesStateContext must be used within a CasesProvider and have a defined value' | ||
| ); | ||
| }); | ||
|
|
||
| it('should return false when the add to case modal and flyout are not open', async () => { | ||
| const { result } = renderHook(useIsAddToCaseOpen, { wrapper: AppWrapper }); | ||
| expect(result.current).toEqual(false); | ||
| }); | ||
|
|
||
| it('should return true when the add to existing case modal opens', async () => { | ||
| const { result, rerender } = renderHook( | ||
| () => { | ||
| return { | ||
| modal: useCasesAddToExistingCaseModal(), | ||
| isOpen: useIsAddToCaseOpen(), | ||
| }; | ||
| }, | ||
| { wrapper: AppWrapper } | ||
| ); | ||
|
|
||
| expect(result.current.isOpen).toEqual(false); | ||
| act(() => { | ||
| result.current.modal.open(); | ||
| }); | ||
| rerender(); | ||
| expect(result.current.isOpen).toEqual(true); | ||
| }); | ||
|
|
||
| it('should return true when the add to new case flyout opens', async () => { | ||
| const { result, rerender } = renderHook( | ||
| () => { | ||
| return { | ||
| flyout: useCasesAddToNewCaseFlyout(), | ||
| isOpen: useIsAddToCaseOpen(), | ||
| }; | ||
| }, | ||
| { wrapper: AppWrapper } | ||
| ); | ||
|
|
||
| expect(result.current.isOpen).toEqual(false); | ||
| act(() => { | ||
| result.current.flyout.open(); | ||
| }); | ||
| rerender(); | ||
| expect(result.current.isOpen).toEqual(true); | ||
| }); | ||
| }); |
18 changes: 18 additions & 0 deletions
18
x-pack/plugins/cases/public/components/cases_context/state/use_is_add_to_case_open.ts
This file contains hidden or 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,18 @@ | ||
| /* | ||
| * 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 { useCasesStateContext } from './cases_state_context'; | ||
|
|
||
| export type UseIsAddToCaseOpen = () => boolean; | ||
|
|
||
| /** | ||
| * This hook is to check if the "add to case" is open, either the modal or the flyout | ||
| */ | ||
| export const useIsAddToCaseOpen: UseIsAddToCaseOpen = () => { | ||
| const { selectCaseModal, createCaseFlyout } = useCasesStateContext(); | ||
| return selectCaseModal.isModalOpen || createCaseFlyout.isFlyoutOpen; | ||
| }; | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.