[Discover] Removing SavedObject usage for savedSearch#112983
[Discover] Removing SavedObject usage for savedSearch#112983alexwizp merged 34 commits intoelastic:masterfrom
Conversation
7a5fe7f to
7000224
Compare
2af74a6 to
bb32a6a
Compare
|
@elasticmachine merge upstream |
|
@elasticmachine merge upstream |
ab44b21 to
61d82f7
Compare
269ae6b to
5a6e2f0
Compare
5a6e2f0 to
479c5a9
Compare
479c5a9 to
702607e
Compare
0aa4101 to
9ce16e6
Compare
| export const getSavedSearchUrlConflictMessage = async (savedSearch: SavedSearch) => | ||
| i18n.translate('discover.savedSearchEmbeddable.legacyURLConflict.errorMessage', { | ||
| defaultMessage: `This search has the same URL as a legacy alias. Disable the alias to resolve this error : {json}`, | ||
| values: { | ||
| json: savedSearch.sharingSavedObjectProps?.errorJSON, | ||
| }, | ||
| }); | ||
|
|
||
| export const throwErrorOnSavedSearchUrlConflict = async (savedSearch: SavedSearch) => { | ||
| if (savedSearch.sharingSavedObjectProps?.errorJSON) { | ||
| throw new Error(await getSavedSearchUrlConflictMessage(savedSearch)); | ||
| } | ||
| }; |
There was a problem hiding this comment.
The Spaces plugin now provides a component for this embeddable error. Whether you want to change it in this PR or leave it for a follow-on PR, I just wanted to leave a note and let you know about it.
You can load this component with spaces.ui.components.getEmbeddableLegacyUrlConflict; you can see how Lens consumes it here:
kibana/x-pack/plugins/lens/public/embeddable/embeddable.tsx
Lines 283 to 296 in 961fe75
The sourceId is the ID of the saved object.
|
@elasticmachine merge upstream |
flash1293
left a comment
There was a problem hiding this comment.
Found two minor issues while re-testing. The rest looks good to me.
- When trying to save a search "as new" (switch in the modal) and pick a name which exists already, the warning about duplicate names is shown, but pressing the button a second time doesn't save the search under this name
- When accessing discover with a conflicting index pattern, the error page is rendered. But when loading a saved search via deeplink, it's stuck at the loading spinner:
kertal
left a comment
There was a problem hiding this comment.
Code LGTM 👍 ... code review part 1, will continue later on testing
| const DiscoverError = ({ error }: { error: Error }) => ( | ||
| <EuiEmptyPrompt | ||
| iconType="alert" | ||
| iconColor="danger" | ||
| title={ | ||
| <h2> | ||
| {i18n.translate('discover.discoverError.title', { | ||
| defaultMessage: 'Error loading Discover', | ||
| })} | ||
| </h2> | ||
| } | ||
| body={<p>{error.message}</p>} | ||
| /> | ||
| ); | ||
|
|
walterra
left a comment
There was a problem hiding this comment.
Transform code LGTM, also did some local testing.
|
@elastic/kibana-reporting-services could we get a review on this? |
@flash1293 I think I fixed these issues. |
src/plugins/discover/public/saved_searches/saved_search_url_conflict_callout.ts
Outdated
Show resolved
Hide resolved
flash1293
left a comment
There was a problem hiding this comment.
Comments got addressed, works fine for me 👍
|
@elasticmachine merge upstream |
kertal
left a comment
There was a problem hiding this comment.
Is there a way we could improve showing a conflicting saved search? Because currently users need to navigate to a different application, return to Discover, to have it removed. This is confusing, because first you'll try to reload the page, but the last link of Discover is still in session, which means, still the conflict screen is displayed. So I think showing the default view with the default index pattern and showing an error message about the conflicting saved object would be a better experience in this case.
This should not be the case, a conflicted saved search loads just fine (and shows a warning callout above the app). I'm guessing you are talking about the case with a conflicted index pattern (if you follow Joe Portners script with an export containing both index pattern and saved search, it will actually put both into a conflicting state). We discussed this with Joe and the current guidance is to fail on conflicts on "secondary saved objects" (SOs managed by some other part of Kibana, but used in the current view) - this is also how dashboard behaves (even though it's just per panel there). I don't have a strong opinion on this - @jportner what do you think? |
yes, exactly that's what I did. fine with failing here, just to remove the failure in this special case could be improved |
|
We do the "show toast and go to default view of the app" in some other error cases (e.g. Visualize). Could be done here as well, but we would have to make sure to not enter a loop (what if the default index pattern is conflicted?) |
yes, this could be the case. Is there a way to remove or clean the last discover URL in the session in case there's an conflicting error? |
Yeah, for the most consistent user experience we should do this. FWIW, a more recent development is #113335, in which we will add validation before objects are created to prevent legacy URL alias conflict scenarios from happening in the first place. We hope no users will ever run into this in the real world, but we have this error handling out of an abundance of caution. I wouldn't worry too much about making sure this screen has a really nice workflow to help users fix the issue. If this does happen, users will need to disable the legacy URL alias using our API. With #114172 that was recently merged, the |
VladLasitsa
left a comment
There was a problem hiding this comment.
LGTM, tested locally.
…ct-loader # Conflicts: # src/plugins/discover/public/application/apps/context/services/context.ts
💚 Build Succeeded
Metrics [docs]Module Count
Public APIs missing comments
Async chunks
Public APIs missing exports
Page load bundle
Unknown metric groupsAPI count
References to deprecated APIs
History
To update your PR or re-run it, just comment with: cc @alexwizp |


Closes: #105810
Get rid of
savedSearchSavedObject inDiscover. This work is done because theSavedObjectclass has been deprecated and will be removed inKibana 8To avoid the PR affecting many files, I suggest breaking it down into several parts:
Step 1 (7.16 and 8.0):
The goal of this step is to get rid of legacy dependencies in all external plugins. What should be done:
savedSearchSavedObjectas deprecated and move intolegacyfolder.savedSearchand use it from all external plugins instead ofSavedObjectLoader;lastSavedTitlefromSavedSearchsavedObject.getshould be replaced tosavedObject.resolveStep 2 (7.16 and 8.0):
ISearchSource,SearchSourcetype should be replaced toISearchSourcegetSavedSearchByIdandgetSavedSearchUrlByIdfrom the DiscoverServices API;Discoverto work withsavedSearch'es withoutSavedObject.Step 3 (7.16 and 8.0):
Discoverto correctly handle cases onIndex Pattern conflicts.Step 4 (only for 8.0): 🏃
Testing notes:
This PR contains changes with replacing
get()toresolve()for support ofSharing Saved Objects. To test it follow the following guide #107099 (comment)Screens:
SavedSearchURLConflictCallout:Redirect:Conflict index pattern:Transform plugin: