-
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
[Saved Searches] Add support for saved searches by value #146849
[Saved Searches] Add support for saved searches by value #146849
Conversation
fbb86ec
to
dacae99
Compare
1a57e78
to
b3f27a3
Compare
6dd7bfc
to
1614130
Compare
): EmbeddableStateWithType => { | ||
if (hasAttributes(state)) { | ||
// Filter out references that are not in the state | ||
// https://github.com/elastic/kibana/pull/119079 |
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.
@ThomThomson It seems like we have to use the same approach to filtering references as the Lens inject
function due to the same issue outlined in #119079. When we have a by value saved search using a temporary data view, the saved search has no references which seems to result in the Dashboard inject
code passing in all dashboard references instead:
Lines 41 to 45 in 0d8a2da
const filteredReferences = references | |
.filter((reference) => reference.name.indexOf(prefix) === 0) | |
.map((reference) => ({ ...reference, name: reference.name.replace(prefix, '') })); | |
const panelReferences = filteredReferences.length === 0 ? references : filteredReferences; |
Let me know if this makes sense to you or if I'm missing something here.
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.
Ah of course, that makes a lot of sense!
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.
Since I had to make so many changes to this anyway, I also did some general cleanup to the embeddable to improve the organization a bit.
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.
Since the SavedSearchAttributeService
requires a serializable model and SavedSearch
isn't serializable due to SearchSource
, I'm using a similar approach as Lens and Visualizations by introducing a serializable model called SavedSearchByValueAttributes
that is essentially the raw SO attributes with the references
tucked in.
} | ||
|
||
export type SavedSearchByValueAttributes = Omit<SavedSearchAttributes, 'description'> & { | ||
description?: string; |
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.
description
must be optional to conform to the expected by value input interface.
Pinging @elastic/kibana-data-discovery (Team:DataDiscovery) |
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.
Looked through the code and ran through the test cases locally on chrome.
Everything looks inline with the other implementations of Time to Visualize, and the local testing went well. Nice jest test additions also!
…-ref HEAD~1..HEAD --fix'
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.
Had a quick incomplete look at it, and wanted to share 2 minor things I've found while testing
- It seems when editing a unlinked saved search, the sorting is lost: https://github.com/elastic/kibana/assets/463851/5322bb26-4b47-45bd-9983-e0e0726a30dc
- Secondly, when unlinking a saved search from it's library item, there's a toast telling the user that it was unlinked of the visualize library ... guess this wording should be more generic, even it's an honor to be mentioned by a such great library
Kapture.2023-07-28.at.20.15.42.mp4
@kertal Thanks for the initial feedback!
I think this may be how it should work. Currently the behaviour is the same for by reference saved searches too because the edit button takes the user to the last persisted state of the saved search, not the current dashboard state. For by value saved searches this might not matter currently since we don't have the "Save and return" functionality yet, but I think once we do it would make sense to use the last persisted state when editing to prevent implicitly modifying the saved search state when navigating to Discover. WDYT?
This makes sense to me and I started making the change, but I noticed Dashboard seems to refer to the entire library as the "Visualize Library" in multiple places in its copy: It seems like this may be intentional, but maybe @ThomThomson can help clarify this? |
I think this naming was just something that happened naturally more-or-less resulting from a confusion about IMO we should do a quick once-over to rename everything from |
private prevTimeRange?: TimeRange; | ||
private prevFilters?: Filter[]; | ||
private prevQuery?: Query; | ||
private prevSort?: SortOrder[]; | ||
private prevSearchSessionId?: string; | ||
private searchProps?: SearchProps; | ||
|
||
private isInitialized?: boolean; | ||
private isDestroyed?: boolean; |
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.
QQ, why not re-using destroyed
, which is contains the same functionality and is inherited?
protected destroyed: boolean = false; |
And in case this is a good idea, to align naming isInitialized
could be initialized
here ... just for alignment, ... I personally prefer the is...
naming
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.
No good reason 🙂 I used isDestroyed
initially because the Lens embeddable I based this work on uses it's own isDestroyed
property, but it seems like destroyed
works just as well. Updated and switched to initialized
as well here: f9ee121.
Thx, makes sense 👍 |
…troyed, also update isInitialized to initialized
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.
@ThomThomson I did a pass at replacing all instances of "Visualization Library" with "library" in Dashboard here: 52160a6. Would you mind doing another quick review of this PR for these changes? Or I can split that commit into a separate PR if you'd prefer not to have it lumped in with these changes.
private prevTimeRange?: TimeRange; | ||
private prevFilters?: Filter[]; | ||
private prevQuery?: Query; | ||
private prevSort?: SortOrder[]; | ||
private prevSearchSessionId?: string; | ||
private searchProps?: SearchProps; | ||
|
||
private isInitialized?: boolean; | ||
private isDestroyed?: boolean; |
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.
No good reason 🙂 I used isDestroyed
initially because the Lens embeddable I based this work on uses it's own isDestroyed
property, but it seems like destroyed
works just as well. Updated and switched to initialized
as well here: f9ee121.
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.
Code LGTM 👍 All looking pretty good from my side, just one last thing:
opening the link in a new tab (which will use query params to pass state).
Thx for this guide, else I wouldn't have thought to do this, it seems there's problem in my local dev mode, because the link I get is:
...http://localhost:5601/**xnf/xnf/**app/...
With Lens it seems to work
src/plugins/saved_search/public/services/saved_searches/create_get_saved_search_deps.ts
Show resolved
Hide resolved
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.
Dashboard copy changes LGTM!
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.
Thx for this guide, else I wouldn't have thought to do this, it seems there's problem in my local dev mode, because the link I get is:
...http://localhost:5601/**xnf/xnf/**app/...
With Lens it seems to work
@kertal Great catch! That'll teach me not to run with --no-base-path
🙂 Looks like I had things a bit backwards and was double prepending the base path. Fixed here: 13cf1fa.
src/plugins/saved_search/public/services/saved_searches/create_get_saved_search_deps.ts
Show resolved
Hide resolved
💚 Build Succeeded
Metrics [docs]Module Count
Public APIs missing comments
Async chunks
Page load bundle
Unknown metric groupsAPI count
References to deprecated APIs
History
To update your PR or re-run it, just comment with: cc @davismcphee |
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.
Thx for the last fix, works as expected now ... LGTM, thx for taking care of this and exciting about next steps, which are now possible
@kertal Great catch! That'll teach me not to run with
--no-base-path
🙂 Looks like I had things a bit backwards and was double prepending the base path.
How do you work without having the little pleasure of a random base path like wtf
, omg
or ice
being added to your URL? Or if you're lucky like me recently spalger
? 😄
… deleted saved search can't be removed (#169896) ## Summary This PR fixes an issue where an undefined reference error makes it so that Dashboard panels targeting deleted saved searches cannot be removed. The bug was likely introduced in 8.10 with embeddable changes in #146849. Fixes #169829. ### Checklist - [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [ ] Any UI touched in this PR is usable by keyboard only (learn more about [keyboard accessibility](https://webaim.org/techniques/keyboard/)) - [ ] Any UI touched in this PR does not create any new axe failures (run axe in browser: [FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/), [Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US)) - [ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - [ ] This renders correctly on smaller devices using a responsive layout. (You can test this [in your browser](https://www.browserstack.com/guide/responsive-testing-on-local-server)) - [ ] This was checked for [cross-browser compatibility](https://www.elastic.co/support/matrix#matrix_browsers) ### For maintainers - [ ] This was checked for breaking API changes and was [labeled appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
… deleted saved search can't be removed (elastic#169896) ## Summary This PR fixes an issue where an undefined reference error makes it so that Dashboard panels targeting deleted saved searches cannot be removed. The bug was likely introduced in 8.10 with embeddable changes in elastic#146849. Fixes elastic#169829. ### Checklist - [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [ ] Any UI touched in this PR is usable by keyboard only (learn more about [keyboard accessibility](https://webaim.org/techniques/keyboard/)) - [ ] Any UI touched in this PR does not create any new axe failures (run axe in browser: [FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/), [Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US)) - [ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - [ ] This renders correctly on smaller devices using a responsive layout. (You can test this [in your browser](https://www.browserstack.com/guide/responsive-testing-on-local-server)) - [ ] This was checked for [cross-browser compatibility](https://www.elastic.co/support/matrix#matrix_browsers) ### For maintainers - [ ] This was checked for breaking API changes and was [labeled appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) (cherry picked from commit 8c93e5c)
Summary
This PR adds support for saved searches by value. Functionality-wise this means that similar to other Dashboard panels, saved search panels now allow unlinking from the library as well as cloning by value instead of by reference.
Testing guide:
/app/discover#/view/{savedSearchId}
route._a
) query param./app/r?l=DISCOVER_APP_LOCATOR...
) in order to support encoding their temporary data view in the URL state.The following features are not included in this PR and comprise the remaining work for implementing Time to Visualize for saved searches (to be done at a later date; issue here: #141629):
Resolves #148995.
Unblocks #158632.
Checklist
Any text added follows EUI's writing guidelines, uses sentence case text and includes i18n supportDocumentation was added for features that require explanation or tutorialsAny UI touched in this PR is usable by keyboard only (learn more about keyboard accessibility)Any UI touched in this PR does not create any new axe failures (run axe in browser: FF, Chrome)If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the docker listThis renders correctly on smaller devices using a responsive layout. (You can test this in your browser)This was checked for cross-browser compatibilityFor maintainers