-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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][Sourcerer] Replace Sourcerer with Discover Data View Picker #210585
base: main
Are you sure you want to change the base?
Conversation
x-pack/solutions/security/plugins/security_solution/public/data_view_picker/redux/types.ts
Outdated
Show resolved
Hide resolved
browserFields, | ||
dataViewId, | ||
sourcererDataView, | ||
// important to get selectedPatterns from useSourcererDataView | ||
// in order to include the exclude filters in the search that are not stored in the timeline | ||
selectedPatterns, | ||
} = useSourcererDataView(scopeId); | ||
|
||
if (newDataViewPickerEnabled) { | ||
dataViewId = experimentalDataView.id ?? ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we default to an empty string if all the other parameters are provided in the reducer and not do these nullish checks everywhere the id is called?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eventually we will only pass the spec reference around, I imagine. Unfortunately this is how the DataViewSpec looks like 😭
const { dataView: experimentalDataView } = useDataView(DataViewPickerScopeName.timeline); | ||
const experimentalBrowserFields = useBrowserFields(DataViewPickerScopeName.timeline); | ||
|
||
if (newDataViewPickerEnabled) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for doing it this way. I understand it's not ideal, but it keeps us safe-guarded for the time being 👍🏾
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
safer to do something like
const { browserFields: sourcererBrowserFields, sourcererDataView } = useSourcererDataView(SourcererScopeName.timeline);
const { dataView: experimentalDataView } = useDataView(DataViewManagerScopeName.timeline);
const experimentalBrowserFields = useBrowserFields(DataViewManagerScopeName.timeline);
const finalBrowserFields = useMemo(() =>
newDataViewPickerEnabled ? experimentalBrowserFields : sourcererBrowserFields,
[newDataViewPickerEnabled, experimentalBrowserFields, sourcererBrowserFields]
);
const finalDataView = useMemo(() =>
newDataViewPickerEnabled ? experimentalDataView : sourcererDataView,
[newDataViewPickerEnabled, experimentalDataView, sourcererDataView]
);
let sometimes leads to non-obvious issues, and of all the props in kibana, browserFields is the one to be most defensive about
let [dataView, setDataView] = useState<DataViewSpec | undefined>(); | ||
|
||
if (newDataViewPickerEnabled) { | ||
dataView = experimentalDataView; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would just call setDataview(experimentalDataView)
- if you're trying to avoid rerenders, then I would just use useRef
instead.
.../security/plugins/security_solution/public/timelines/components/timeline/tabs/esql/index.tsx
Show resolved
Hide resolved
if (newDataViewPickerEnabled) { | ||
selectedPatterns = experimentalSelectedPatterns; | ||
sourcererDataView = experimentalDataView; | ||
dataViewId = experimentalDataView.id ?? ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same thing here re defaulting id to ''
in the experimentalDataView
initialization
const dataView = useGetScopedSourcererDataView({ | ||
const experimentalDataView = useFullDataView({ | ||
dataViewPickerScope: DataViewPickerScopeName.timeline, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
useFullDataView
view called here and then dataView
is getting replaced by experimentalDataView
later only when newDataViewPickerEnabled
is enabled.
It does look, that experimentalDataView is getting initiated every time, in disregard of feature flag.
Should it be avoided?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agree, avoiding use of let would achieve the same thing, and is imo a good rule of thumb to follow
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Module Count
Async chunks
Page load bundle
Unknown metric groupsESLint disabled line counts
References to deprecated APIs
Total ESLint disabled count
History
|
Unified Data View Picker: Phase 1 Implementation
Part of https://github.com/elastic/security-team/issues/11959
What This PR Does
This PR represents the first step in our transition from the current Sourcerer component to the new unified Data View Picker. Specifically, this implementation:
See the readme for more info:
x-pack/solutions/security/plugins/security_solution/public/data_view_manager/readme.md
What This PR Does NOT Cover
Implementation Notes
We've made several accommodations to support both Sourcerer and the new Data View Picker simultaneously during this transition period, including:
Testing Instructions
Todo:
dataViewPicker
todataViewManager
WORK IN PROGRESS But reviews are welcome