-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[Security Solution][Sourcerer] Fix data view flash #225366
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
Closed
Closed
Changes from 2 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
26ea7e8
[Security Solution][Sourcerer] Fix data view flash
lgestc 4c8f48d
redo init
lgestc 6259c7e
cleanups
lgestc c64c6d4
fix broken tests and types
lgestc bde1735
flag based safeguards
lgestc 431c3ae
fix type error
lgestc 4b3a80f
fix type error
lgestc 96a2d8b
fix tests
lgestc 7b40858
fallback data view
lgestc f2b1c60
Merge branch 'main' into default_data_view_always_populated
lgestc f60ed4f
change to detection scope
lgestc a331c37
change default data views
lgestc 3afcf06
default data view should vary depending on the scope
lgestc 23d345a
type error
lgestc ed3e99d
unit tests
lgestc 7bdd587
fix tests
lgestc d83a75e
docs
lgestc c23c4e7
types
lgestc e1003ce
types
lgestc 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
52 changes: 52 additions & 0 deletions
52
...rity/plugins/security_solution/public/data_view_manager/containers/data_view_provider.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,52 @@ | ||
| /* | ||
| * 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 type { DataView } from '@kbn/data-views-plugin/public'; | ||
| import type { FC, PropsWithChildren } from 'react'; | ||
| import React, { createContext, useContext, useEffect, useState } from 'react'; | ||
| import { useKibana } from '../../common/lib/kibana'; | ||
| import { createDefaultDataView } from '../utils/create_default_data_view'; | ||
|
|
||
| const DefaultDataViewContext = createContext<DataView | undefined>(undefined); | ||
|
|
||
| export const useDefaultDataView = () => { | ||
| const defaultDataView = useContext(DefaultDataViewContext); | ||
|
|
||
| if (!defaultDataView) { | ||
| throw new Error('Could not fetch default data view'); | ||
| } | ||
|
|
||
| return defaultDataView; | ||
| }; | ||
|
|
||
| export const DefaultDataViewProvider: FC<PropsWithChildren> = ({ children }) => { | ||
| const { dataViews, uiSettings, spaces, application, http } = useKibana().services; | ||
|
|
||
| const [defaultDataView, setDefaultDataView] = useState<DataView>(); | ||
|
|
||
| useEffect(() => { | ||
| (async () => { | ||
| const { defaultDataView: dv } = await createDefaultDataView({ | ||
| dataViewService: dataViews, | ||
| uiSettings, | ||
| spaces, | ||
| application, | ||
| http, | ||
| }); | ||
|
|
||
| const dataView = await dataViews?.get(dv.id); | ||
|
lgestc marked this conversation as resolved.
Outdated
|
||
|
|
||
| setDefaultDataView(dataView); | ||
| })(); | ||
| }, [application, dataViews, http, spaces, uiSettings]); | ||
|
|
||
| return ( | ||
| <DefaultDataViewContext.Provider value={defaultDataView}> | ||
| {defaultDataView ? children : null} | ||
| </DefaultDataViewContext.Provider> | ||
| ); | ||
| }; | ||
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
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.