Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ uiModules.get('apps/management')
const getData = function (filter) {
const services = savedObjectManagementRegistry.all().map(function (obj) {
const service = $injector.get(obj.service);
return service.find(filter).then(function (data) {
return service.findAll(filter).then(function (data) {
return {
service: service,
serviceName: obj.service,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,8 @@ savedObjectManagementRegistry.register({
title: 'visualizations'
});

app.service('savedVisualizations', function (Promise, kbnIndex, SavedVis, Private, Notifier, kbnUrl, $http) {
app.service('savedVisualizations', function (Promise, kbnIndex, SavedVis, Private, kbnUrl, $http) {
const visTypes = Private(VisTypesRegistryProvider);
const notify = new Notifier({
location: 'Saved Visualization Service'
});

const saveVisualizationLoader = new SavedObjectLoader(SavedVis, kbnIndex, kbnUrl, $http);

Expand All @@ -32,9 +29,8 @@ app.service('savedVisualizations', function (Promise, kbnIndex, SavedVis, Privat
}

if (!typeName || !visTypes.byName[typeName]) {
if (!typeName) notify.error('Visualization type is missing. Please add a type to this visualization.', source);
else notify.error('Visualization type of "' + typeName + '" is invalid. Please change to a valid type.', source);
return kbnUrl.redirect('/management/kibana/objects/savedVisualizations/{{id}}', { id: source.id });
source.error = 'Unknown visualization type';
return source;
}

source.type = visTypes.byName[typeName];
Expand Down
5 changes: 4 additions & 1 deletion src/ui/public/courier/_redirect_when_missing.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ export function RedirectWhenMissingProvider($location, kbnUrl, Notifier, Promise

return function (err) {
// if this error is not "404", rethrow
if (!(err instanceof SavedObjectNotFound)) throw err;
const savedObjectNotFound = err instanceof SavedObjectNotFound;
const unknownVisType = err.message.indexOf('Invalid type') === 0;
if (unknownVisType) err.savedObjectType = 'visualization';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor nit - adding { }'s would make this a bit easier to read.

else if (!savedObjectNotFound) throw err;

let url = mapping[err.savedObjectType] || mapping['*'];
if (!url) url = '/';
Expand Down
14 changes: 12 additions & 2 deletions src/ui/public/courier/saved_object/saved_object_loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export class SavedObjectLoader {
* @param size
* @returns {Promise}
*/
find(search = '', size = 100) {
findAll(search = '', size = 100) {
return this.savedObjectsClient.find(
{
type: this.lowercaseType,
Expand All @@ -99,8 +99,18 @@ export class SavedObjectLoader {
}).then((resp) => {
return {
total: resp.total,
hits: resp.savedObjects.map((savedObject) => this.mapSavedObjectApiHits(savedObject))
hits: resp.savedObjects
.map((savedObject) => this.mapSavedObjectApiHits(savedObject))
};
});
}

find(search = '', size = 100) {
return this.findAll(search, size).then(resp => {
return {
total: resp.total,
hits: resp.hits.filter(savedObject => !savedObject.error)
};
});
}
}