From 98a4f9ecdc53e7cdb0321f2290dd0741a78296b8 Mon Sep 17 00:00:00 2001 From: Lukas Olson Date: Fri, 12 Jun 2015 17:13:27 -0700 Subject: [PATCH 1/6] Fix issue with edit link on dashboard with broken objects (issues/4200) --- .../plugins/dashboard/components/panel/panel.js | 13 ++++++++++++- .../plugins/settings/sections/objects/_view.js | 3 +-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/kibana/plugins/dashboard/components/panel/panel.js b/src/kibana/plugins/dashboard/components/panel/panel.js index cb8f595f27834..aab894413dc3f 100644 --- a/src/kibana/plugins/dashboard/components/panel/panel.js +++ b/src/kibana/plugins/dashboard/components/panel/panel.js @@ -3,12 +3,20 @@ define(function (require) { var $ = require('jquery'); require('modules') .get('app/dashboard') - .directive('dashboardPanel', function (savedVisualizations, savedSearches, Notifier, Private, $compile) { + .directive('dashboardPanel', function (savedVisualizations, savedSearches, Notifier, Private, $injector) { var _ = require('lodash'); var loadPanel = Private(require('plugins/dashboard/components/panel/lib/load_panel')); var filterManager = Private(require('components/filter_manager/filter_manager')); var notify = new Notifier(); + var services = require('plugins/settings/saved_object_registry').all().map(function (serviceObj) { + var service = $injector.get(serviceObj.service); + return { + type: service.type, + name: serviceObj.service + }; + }); + require('components/visualize/visualize'); require('components/doc_table/doc_table'); @@ -38,6 +46,9 @@ define(function (require) { }; }).catch(function (e) { $scope.error = e.message; + + var service = _.find(services, {type: $scope.panel.type}); + $scope.edit = '#settings/objects/' + (service && service.name); }); }); diff --git a/src/kibana/plugins/settings/sections/objects/_view.js b/src/kibana/plugins/settings/sections/objects/_view.js index 80dcd6e469f19..cfed63c63d72b 100644 --- a/src/kibana/plugins/settings/sections/objects/_view.js +++ b/src/kibana/plugins/settings/sections/objects/_view.js @@ -1,7 +1,6 @@ define(function (require) { var _ = require('lodash'); var angular = require('angular'); - var inflection = require('inflection'); var rison = require('utils/rison'); var registry = require('plugins/settings/saved_object_registry'); var objectViewHTML = require('text!plugins/settings/sections/objects/_view.html'); @@ -101,7 +100,7 @@ define(function (require) { $scope.notFound = $routeParams.notFound; - $scope.title = inflection.singularize(serviceObj.title); + $scope.title = service.type; es.get({ index: config.file.kibana_index, From 2b064d7192d0e93f2b3c08b60168c8aeb34ccf28 Mon Sep 17 00:00:00 2001 From: Lukas Olson Date: Fri, 12 Jun 2015 17:14:22 -0700 Subject: [PATCH 2/6] Remove inflection as it is no longer used --- bower.json | 1 - src/kibana/require.config.js | 4 ---- 2 files changed, 5 deletions(-) diff --git a/bower.json b/bower.json index ae61559c12f7b..f899253c5409a 100644 --- a/bower.json +++ b/bower.json @@ -35,7 +35,6 @@ "FileSaver": "babc6d9d8f", "font-awesome": "4.2.0", "gridster": "0.5.6", - "inflection": "1.3.8", "jquery": "2.1.4", "leaflet": "0.7.3", "Leaflet.heat": "Leaflet/Leaflet.heat#627ede7c11bbe43", diff --git a/src/kibana/require.config.js b/src/kibana/require.config.js index 22eb9cce98abb..cff1fbaa17940 100644 --- a/src/kibana/require.config.js +++ b/src/kibana/require.config.js @@ -26,7 +26,6 @@ require.config({ file_saver: 'bower_components/FileSaver/FileSaver', gridster: 'bower_components/gridster/dist/jquery.gridster', 'leaflet-heat': 'bower_components/Leaflet.heat/dist/leaflet-heat', - inflection: 'bower_components/inflection/lib/inflection', jquery: 'bower_components/jquery/dist/jquery', leaflet: 'bower_components/leaflet/dist/leaflet', 'leaflet-draw': 'bower_components/leaflet-draw/dist/leaflet.draw', @@ -55,9 +54,6 @@ require.config({ 'leaflet-heat': { deps: ['leaflet'] }, - inflection: { - exports: 'inflection' - }, file_saver: { exports: 'saveAs' }, From 30cb7af7d82a073b6636fc70e99dac41f7f3c328 Mon Sep 17 00:00:00 2001 From: Lukas Olson Date: Sat, 13 Jun 2015 08:28:57 -0700 Subject: [PATCH 3/6] Remove edit link if the object has been deleted --- .../plugins/dashboard/components/panel/panel.html | 2 +- src/kibana/plugins/dashboard/components/panel/panel.js | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/kibana/plugins/dashboard/components/panel/panel.html b/src/kibana/plugins/dashboard/components/panel/panel.html index c16d6c9e3dec1..5abb8b64aca67 100644 --- a/src/kibana/plugins/dashboard/components/panel/panel.html +++ b/src/kibana/plugins/dashboard/components/panel/panel.html @@ -2,7 +2,7 @@
{{savedObj.title}}
- +
diff --git a/src/kibana/plugins/dashboard/components/panel/panel.js b/src/kibana/plugins/dashboard/components/panel/panel.js index aab894413dc3f..d663a8eaae591 100644 --- a/src/kibana/plugins/dashboard/components/panel/panel.js +++ b/src/kibana/plugins/dashboard/components/panel/panel.js @@ -47,8 +47,14 @@ define(function (require) { }).catch(function (e) { $scope.error = e.message; - var service = _.find(services, {type: $scope.panel.type}); - $scope.edit = '#settings/objects/' + (service && service.name); + // If the savedObjectType matches the panel type, this means the object itself has been deleted, + // so we shouldn't even have an edit link. If they don't match, it means something else is wrong + // with the object (but the object still exists), so we link to the object editor instead. + var objectHasBeenDeleted = e.savedObjectType === $scope.panel.type; + if (!objectHasBeenDeleted) { + var service = _.find(services, {type: $scope.panel.type}); + $scope.edit = '#settings/objects/' + (service && service.name); + } }); }); From 6f750f1b1e82dcb29e31b1f97448ff6f8e1f9995 Mon Sep 17 00:00:00 2001 From: Spencer Alger Date: Mon, 15 Jun 2015 13:32:51 -0700 Subject: [PATCH 4/6] [dashboard/panel] use service to make full editUrl --- src/kibana/plugins/dashboard/components/panel/lib/search.js | 2 +- .../plugins/dashboard/components/panel/lib/visualization.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/kibana/plugins/dashboard/components/panel/lib/search.js b/src/kibana/plugins/dashboard/components/panel/lib/search.js index d5a147c187e66..426e61e2fabaa 100644 --- a/src/kibana/plugins/dashboard/components/panel/lib/search.js +++ b/src/kibana/plugins/dashboard/components/panel/lib/search.js @@ -17,7 +17,7 @@ define(function (require) { return { savedObj: savedSearch, panel: panel, - edit: '#discover' + edit: savedSearches.urlFor(panel.id) }; }); }; diff --git a/src/kibana/plugins/dashboard/components/panel/lib/visualization.js b/src/kibana/plugins/dashboard/components/panel/lib/visualization.js index 38f18ef7af678..63d05ff8d12cf 100644 --- a/src/kibana/plugins/dashboard/components/panel/lib/visualization.js +++ b/src/kibana/plugins/dashboard/components/panel/lib/visualization.js @@ -13,7 +13,7 @@ define(function (require) { return { savedObj: savedVis, panel: panel, - edit: '#visualize/edit' + edit: savedVisualizations.urlFor(panel.id) }; }); }; From 86ac687a017ffad42ab752a661d0a91f56af5e61 Mon Sep 17 00:00:00 2001 From: Spencer Alger Date: Mon, 15 Jun 2015 13:34:48 -0700 Subject: [PATCH 5/6] [dashbaord/panel] fallback urls should have ?notFound=type query string --- .../dashboard/components/panel/lib/search.js | 2 +- .../components/panel/lib/visualization.js | 2 +- .../dashboard/components/panel/panel.html | 10 +++++++--- .../plugins/dashboard/components/panel/panel.js | 16 ++++++++++------ 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/kibana/plugins/dashboard/components/panel/lib/search.js b/src/kibana/plugins/dashboard/components/panel/lib/search.js index 426e61e2fabaa..cf7dc1a8647c5 100644 --- a/src/kibana/plugins/dashboard/components/panel/lib/search.js +++ b/src/kibana/plugins/dashboard/components/panel/lib/search.js @@ -17,7 +17,7 @@ define(function (require) { return { savedObj: savedSearch, panel: panel, - edit: savedSearches.urlFor(panel.id) + editUrl: savedSearches.urlFor(panel.id) }; }); }; diff --git a/src/kibana/plugins/dashboard/components/panel/lib/visualization.js b/src/kibana/plugins/dashboard/components/panel/lib/visualization.js index 63d05ff8d12cf..12bce66c1b50a 100644 --- a/src/kibana/plugins/dashboard/components/panel/lib/visualization.js +++ b/src/kibana/plugins/dashboard/components/panel/lib/visualization.js @@ -13,7 +13,7 @@ define(function (require) { return { savedObj: savedVis, panel: panel, - edit: savedVisualizations.urlFor(panel.id) + editUrl: savedVisualizations.urlFor(panel.id) }; }); }; diff --git a/src/kibana/plugins/dashboard/components/panel/panel.html b/src/kibana/plugins/dashboard/components/panel/panel.html index 5abb8b64aca67..9e2f1b4ad40f3 100644 --- a/src/kibana/plugins/dashboard/components/panel/panel.html +++ b/src/kibana/plugins/dashboard/components/panel/panel.html @@ -2,8 +2,12 @@
{{savedObj.title}}
- - + + + + + +
@@ -26,4 +30,4 @@ class="panel-content" filter="filter"> -
\ No newline at end of file + diff --git a/src/kibana/plugins/dashboard/components/panel/panel.js b/src/kibana/plugins/dashboard/components/panel/panel.js index d663a8eaae591..ae03ab2e090a4 100644 --- a/src/kibana/plugins/dashboard/components/panel/panel.js +++ b/src/kibana/plugins/dashboard/components/panel/panel.js @@ -37,7 +37,7 @@ define(function (require) { loadPanel($scope.panel, $scope).then(function (panelConfig) { // These could be done in loadPanel, putting them here to make them more explicit $scope.savedObj = panelConfig.savedObj; - $scope.edit = panelConfig.edit; + $scope.editUrl = panelConfig.editUrl; $scope.$on('$destroy', panelConfig.savedObj.destroy); $scope.filter = function (field, value, operator) { @@ -50,11 +50,15 @@ define(function (require) { // If the savedObjectType matches the panel type, this means the object itself has been deleted, // so we shouldn't even have an edit link. If they don't match, it means something else is wrong // with the object (but the object still exists), so we link to the object editor instead. - var objectHasBeenDeleted = e.savedObjectType === $scope.panel.type; - if (!objectHasBeenDeleted) { - var service = _.find(services, {type: $scope.panel.type}); - $scope.edit = '#settings/objects/' + (service && service.name); - } + var objectItselfDeleted = e.savedObjectType === $scope.panel.type; + if (objectItselfDeleted) return; + + var type = $scope.panel.type; + var id = $scope.panel.id; + var service = _.find(services, { type: type }); + if (!service) return; + + $scope.editUrl = '#settings/objects/' + service.name + '/' + id + '?notFound=' + e.savedObjectType; }); }); From f8b32555c775e10be9095b3dbaec81b4662bc2ca Mon Sep 17 00:00:00 2001 From: Lukas Olson Date: Mon, 15 Jun 2015 15:42:00 -0700 Subject: [PATCH 6/6] Add error message for object editor when a field is missing --- src/kibana/plugins/settings/sections/objects/_view.html | 1 + 1 file changed, 1 insertion(+) diff --git a/src/kibana/plugins/settings/sections/objects/_view.html b/src/kibana/plugins/settings/sections/objects/_view.html index 7c9202280c309..b8ce631383970 100644 --- a/src/kibana/plugins/settings/sections/objects/_view.html +++ b/src/kibana/plugins/settings/sections/objects/_view.html @@ -10,6 +10,7 @@

There is a problem with that saved object

The saved search associated with this object no longer exists.

The index pattern associated with this object no longer exists.

+

A field associated with this object no longer exists in the index pattern.

If you know what this error means, go ahead and fix it - otherwise click the delete button above.