mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
This commit is contained in:
parent
b62148c35e
commit
a772aa8c8a
3 changed files with 19 additions and 13 deletions
|
@ -211,7 +211,9 @@ export function SavedObjectProvider(Promise, Private, Notifier, confirmModalProm
|
|||
this.applyESResp = (resp) => {
|
||||
this._source = _.cloneDeep(resp._source);
|
||||
|
||||
if (resp.found != null && !resp.found) throw new SavedObjectNotFound(esType, this.id);
|
||||
if (resp.found != null && !resp.found) {
|
||||
throw new SavedObjectNotFound(esType, this.id);
|
||||
}
|
||||
|
||||
const meta = resp._source.kibanaSavedObjectMeta || {};
|
||||
delete resp._source.kibanaSavedObjectMeta;
|
||||
|
|
|
@ -95,12 +95,10 @@ export function IndexPatternProvider(Private, config, Promise, confirmModalPromi
|
|||
|
||||
function updateFromElasticSearch(indexPattern, response, forceFieldRefresh = false) {
|
||||
if (!response.found) {
|
||||
const markdownSaveId = indexPattern.id.replace('*', '%2A');
|
||||
|
||||
throw new SavedObjectNotFound(
|
||||
type,
|
||||
indexPattern.id,
|
||||
kbnUrl.eval('#/management/kibana/index?id={{id}}&name=', { id: markdownSaveId })
|
||||
'#/management/kibana/index',
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -18,9 +18,11 @@
|
|||
*/
|
||||
|
||||
|
||||
import React from 'react';
|
||||
import { MarkdownSimple } from 'ui/markdown';
|
||||
import { toastNotifications } from 'ui/notify';
|
||||
import { SavedObjectNotFound } from '../errors';
|
||||
import { uiModules } from '../modules';
|
||||
import { toastNotifications } from 'ui/notify';
|
||||
|
||||
uiModules.get('kibana/url')
|
||||
.service('redirectWhenMissing', function (Private) { return Private(RedirectWhenMissingProvider); });
|
||||
|
@ -39,22 +41,26 @@ export function RedirectWhenMissingProvider($location, kbnUrl, Promise) {
|
|||
mapping = { '*': mapping };
|
||||
}
|
||||
|
||||
return function (err) {
|
||||
return function (error) {
|
||||
// if this error is not "404", rethrow
|
||||
const savedObjectNotFound = err instanceof SavedObjectNotFound;
|
||||
const unknownVisType = err.message.indexOf('Invalid type') === 0;
|
||||
const savedObjectNotFound = error instanceof SavedObjectNotFound;
|
||||
const unknownVisType = error.message.indexOf('Invalid type') === 0;
|
||||
if (unknownVisType) {
|
||||
err.savedObjectType = 'visualization';
|
||||
error.savedObjectType = 'visualization';
|
||||
} else if (!savedObjectNotFound) {
|
||||
throw err;
|
||||
throw error;
|
||||
}
|
||||
|
||||
let url = mapping[err.savedObjectType] || mapping['*'];
|
||||
let url = mapping[error.savedObjectType] || mapping['*'];
|
||||
if (!url) url = '/';
|
||||
|
||||
url += (url.indexOf('?') >= 0 ? '&' : '?') + `notFound=${err.savedObjectType}`;
|
||||
url += (url.indexOf('?') >= 0 ? '&' : '?') + `notFound=${error.savedObjectType}`;
|
||||
|
||||
toastNotifications.addWarning({
|
||||
title: 'Saved object is missing',
|
||||
text: <MarkdownSimple>{error.message}</MarkdownSimple>,
|
||||
});
|
||||
|
||||
toastNotifications.addWarning(err.message);
|
||||
kbnUrl.redirect(url);
|
||||
return Promise.halt();
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue