-
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
[FilterEditor] Load DataView in case it's not provided by the consuming plugin #173017
Conversation
/ci |
/ci |
@elasticmachine merge upstream |
/ci |
…er-editor-changes # Conflicts: # src/plugins/unified_search/tsconfig.json
/ci |
/ci |
Pinging @elastic/kibana-data-discovery (Team:DataDiscovery) |
src/plugins/unified_search/public/filter_bar/filter_editor/filter_editor.tsx
Outdated
Show resolved
Hide resolved
@elasticmachine merge upstream |
@elasticmachine merge upstream |
@@ -84,6 +84,7 @@ const FilterItemsUI = React.memo(function FilterItemsUI(props: FilterItemsProps) | |||
readOnly={readOnly} | |||
suggestionsAbstraction={props.suggestionsAbstraction} | |||
filtersCount={props.filters.length} | |||
dataViews={data?.dataViews} |
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.
depending on the context relying on the data service cause functional test errors, same issue I encountered using the dataViews service directly.
@elasticmachine merge upstream |
@elasticmachine merge upstream |
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.
Exploratory view changes look good. 👍🏻
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.
This definitely resolves this issue. I initially expected you to load all the data views and pass them to the component as is done in Lens.
However, I read your comment and I see where you're coming from.
I'm wondering if giving these mostly-presentational components a reference to the entire data views service is overkill. Have you considered passing a simple callback instead (e.g. getDataViewById
), or at least constraining the call signature to just the get
method using Pick
?
Another thought—have we considered making the interface either/or?
Right now it looks like the components will accept both an array of already-loaded data views and a way to load new ones on-demand. Will consumers of these components understand what the function of the two are? Does it make sense to choose one or the other to support?
cc @stratoula
I am so sorry for coming late in the party. I am trying to understand why this behavior has impact high 🤔 The solution is nice but is any customer unhappy with how it worked? @kertal @drewdaemon
I see your point but is it possible? The consumer (Discover, Lens ...) has knowledge of the current dataview, doesnt have knowledge of the filters dataview. So this would add a lot of complexity in the consumers' code. Only on-demand on the other hand I cant think of how it would work. A dashboard can have many charts with different indices but no filters. The consumers communicate their indices to the dashboard and the dashboard to the unified search. I am not sure how else the component can know the dataviews of these charts 🤔 But maybe you have something else in mind. Can you elaborate more? Last but not least, I think this behavior happens only for the applications which have enabled the dataview picker (a unified search component, so it makes sense to solve this inside the unified search component) |
I originally thought it's an easy fix, we need to load and provide more data views in Discover. But it turned out, we would need to load all data views, which we shouldn't do, and on top of that, we would just fix the problem in Discover, not in Lens & Dashboards. That's why I closed this approach, but then I had another idea ...
This would be doable, however, I think we could need more of the data view service in this area, and maybe it's time to refactor this component, to have a better split between presentation and business logic. Why I think the whole service could be useful in the future? Mainly because of this discussion, #168131. If we e.g. would support DataViews and deduplicated Indexpatterns provided by ES|QL in an advanced filter editor, we would need to DataView service to create Ad-Hoc data views to provide the field list. Maybe it's not the time to think so far ahead, and to optimize for the given problem. I'd be fine with moving the a simple callback solution.
The current solution is providing a fallback in case the given filter id is not part of the provided data views list. It's additional functionality, making sure it works. Just so support this fallback functionality, would mean, this list of selectable data views would no be provided, so it's complementary functionality. We could add this context in Component type description. If the data views service is not provided, this fallback doesn't work. There's some usage of this UnifiedSearch component, where the data service is not provided, although using just the dataView service of |
Late party guest shouldn't be sorry, they are always welcome, and the buffet + fridge still has plenty of opportunies!
Maybe medium would be more accurate. This issue landed on the @elastic/kibana-data-discovery table, we thought it's very simple to run into it, it leads to bad UX when running into it and high likely simple to fix (change our consumption of the component), but that wasn't the case.
As I mentioned, it's a fallback solution for these cases, it mainly fixes UX in Discover, where it's pretty easy to run into that. But opposed to my first attempt focusing on Discover, it's now fixed for all consumers (given they provide the data service) |
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'm not as familiar with the unified search components as I should be. I now understand that the filter_editor_wrapper
is not used on its own, but only as part of unified search. This makes my architecture suggestions mostly irrelevant.
This PR fixes the issue, so no problem from my end.
FWIW, I believe this is exactly what we do in Lens |
@elasticmachine merge upstream |
Thx for the review @drewdaemon! I don't think you're loading really all data views, but missing ones, which I assume is a subset
if you would load all, the given issue wouldn't surface in Lens, but it does/did. However, it might be the case, that you won't need to load the missingIds, if they are just being used in the FilterEditor. Then this PR takes care of loading them on demand. |
💚 Build Succeeded
Metrics [docs]Async chunks
History
To update your PR or re-run it, just comment with: cc @kertal |
@kertal that method is called with an empty I can see why this approach would be untenable for Discover, where you are displaying a comprehensive list. |
…ng plugin (elastic#173017) Fix issue with missing data view by loading it, allowing users to edit the filter in the FilterEditor.
This is unfortunately still not fixed in 8.14.1. |
Summary
Resolves #154785
In Discover you can create filters for the current selected data view, switch data view, create another filter.
When you try to edit the first filter being created with the previous data view, it can no longer be edited, since the data view is no longer available in this context. Here is a screen cap by @drewdaemon showing this situation:
Screen.Recording.2023-04-11.at.4.38.34.PM.mov
With this PR this is resolved by actually loading the missing data view, so users can edit this Filter. Note that it doesn't resolve this issue when the filter was created by an ad-hoc data view, and it was not persisted, and the browser window was refreshed. This case we can't fix, unless we start to add e.g. the index pattern to the created filter. But this is out of scope of this PR
Checklist