Skip to content

Commit

Permalink
Update doc and nav title with new name on rename
Browse files Browse the repository at this point in the history
don't hardcode Dashboard
  • Loading branch information
stacey-gammon committed Nov 30, 2016
1 parent cf04dde commit 9686b2a
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/core_plugins/kibana/public/dashboard/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
>
<span
ng-show="dash.id"
ng-bind="::dash.title"
ng-bind="dash.lastSavedTitle"
></span>
</div>

Expand Down
6 changes: 4 additions & 2 deletions src/core_plugins/kibana/public/dashboard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,11 @@ app.directive('dashboardApp', function (Notifier, courier, AppState, timefilter,

courier.setRootSearchSource(dash.searchSource);

const docTitle = Private(DocTitleProvider);

function init() {
updateQueryOnRootSource();

const docTitle = Private(DocTitleProvider);
if (dash.id) {
docTitle.change(dash.title);
}
Expand Down Expand Up @@ -228,7 +229,6 @@ app.directive('dashboardApp', function (Notifier, courier, AppState, timefilter,
};

$scope.save = function () {
$state.title = dash.title;
$state.save();

const timeRestoreObj = _.pick(timefilter.refreshInterval, ['display', 'pause', 'section', 'value']);
Expand All @@ -247,6 +247,8 @@ app.directive('dashboardApp', function (Notifier, courier, AppState, timefilter,
notify.info('Saved Dashboard as "' + dash.title + '"');
if (dash.id !== $routeParams.id) {
kbnUrl.change('/dashboard/{{id}}', {id: dash.id});
} else {
docTitle.change(dash.lastSavedTitle);
}
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ function discoverController($scope, config, courier, $route, $window, Notifier,
} else {
// Update defaults so that "reload saved query" functions correctly
$state.setDefaults(getStateDefaults());
docTitle.change(savedSearch.lastSavedTitle);
}
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/core_plugins/kibana/public/discover/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<div data-transclude-slot="topLeftCorner" class="localBreadcrumbs">
<div class="localBreadcrumb">
<span ng-show="opts.savedSearch.id" class="localBreadcrumb__emphasis">
<span data-test-subj="discoverCurrentQuery" ng-bind="::opts.savedSearch.title"></span>
<span data-test-subj="discoverCurrentQuery" ng-bind="opts.savedSearch.lastSavedTitle"></span>
<i aria-label="Reload Saved Search" tooltip="Reload Saved Search" ng-click="resetQuery();" class="fa fa-undo small"></i>&nbsp;
</span>
<span data-test-subj="discoverQueryHits" class="localBreadcrumb__emphasis">{{(hits || 0) | number:0}}</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
>
<span
ng-show="savedVis.id"
ng-bind="::savedVis.title"
ng-bind="savedVis.lastSavedTitle"
></span>
</div>

Expand Down
7 changes: 5 additions & 2 deletions src/core_plugins/kibana/public/visualize/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,11 @@ function VisEditor($scope, $route, timefilter, AppState, $location, kbnUrl, $tim

if (id) {
notify.info('Saved Visualization "' + savedVis.title + '"');
if (savedVis.id === $route.current.params.id) return;
kbnUrl.change('/visualize/edit/{{id}}', {id: savedVis.id});
if (savedVis.id === $route.current.params.id) {
docTitle.change(savedVis.lastSavedTitle);
} else {
kbnUrl.change('/visualize/edit/{{id}}', {id: savedVis.id});
}
}
}, notify.fatal);
};
Expand Down
2 changes: 1 addition & 1 deletion src/core_plugins/timelion/public/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ app.controller('timelion', function (
}
});

$scope.$watch(function () { return savedSheet.title; }, function (newTitle) {
$scope.$watch(function () { return savedSheet.lastSavedTitle; }, function (newTitle) {
docTitle.change(savedSheet.id ? newTitle : undefined);
});

Expand Down
2 changes: 1 addition & 1 deletion src/core_plugins/timelion/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<div data-transclude-slots>
<div data-transclude-slot="topLeftCorner">
<span class="localTitle" ng-show="opts.savedSheet.id">
{{opts.savedSheet.title}}
{{opts.savedSheet.lastSavedTitle}}
&nbsp;
<span class="fa fa-bolt" ng-click="showStats = !showStats"></span>
&nbsp;
Expand Down
2 changes: 2 additions & 0 deletions src/ui/public/courier/saved_object/saved_object.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ export default function SavedObjectFactory(es, kbnIndex, Promise, Private, Notif

// Give obj all of the values in _source.fields
_.assign(self, self._source);
self.lastSavedTitle = self.title;

return Promise.try(() => {
parseSearchSource(meta.searchSourceJSON);
Expand Down Expand Up @@ -284,6 +285,7 @@ export default function SavedObjectFactory(es, kbnIndex, Promise, Private, Notif
.then(self.refreshIndex)
.then(() => {
self.isSaving = false;
self.lastSavedTitle = self.title;
return self.id;
})
.catch(function (err) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div ng-hide="!savedObject.id || savedObject.isSaving">
<div ng-hide="!savedObject.isTitleChanged() || savedObject.copyOnSave" class="localDropdownWarning">
In previous versions of Kibana, changing the name of a Dashboard would make a copy with the new name. Use the 'Save as a new {{savedObject.getDisplayName()}}' checkbox to do this now.
In previous versions of Kibana, changing the name of a {{savedObject.getDisplayName()}} would make a copy with the new name. Use the 'Save as a new {{savedObject.getDisplayName()}}' checkbox to do this now.
</div>
<label>
<input type="checkbox" ng-model="savedObject.copyOnSave" ng-checked="savedObject.copyOnSave">
Expand Down

0 comments on commit 9686b2a

Please sign in to comment.