Skip to content

Commit

Permalink
Add ability to delete timeline sheets (#9231)
Browse files Browse the repository at this point in the history
Backports PR #9191

**Commit 1:**
Add ability to delete timeline sheets

Note there is a bug that already exists in timeline where the
notify.info message disappears immediately.  Not fixing in this PR, but
the delete info message suffers the same bug as the save info message
does already.

* Original sha: f53a1a8
* Authored by Stacey Gammon <[email protected]> on 2016-11-22T21:12:14Z
  • Loading branch information
elastic-jasper authored and stacey-gammon committed Nov 28, 2016
1 parent 5120270 commit 1c37948
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/core_plugins/timelion/public/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ require('ui/routes')
});

app.controller('timelion', function (
$scope, $http, timefilter, AppState, courier, $route, $routeParams, kbnUrl, Notifier, config, $timeout, Private, savedVisualizations) {
$scope, $http, timefilter, AppState, courier, $route, $routeParams,
kbnUrl, Notifier, config, $timeout, Private, savedVisualizations, safeConfirm) {

// TODO: For some reason the Kibana core doesn't correctly do this for all apps.
moment.tz.setDefault(config.get('dateFormat:tz'));
Expand All @@ -61,7 +62,6 @@ app.controller('timelion', function (

var defaultExpression = '.es(*)';
var savedSheet = $route.current.locals.savedSheet;
var blankSheet = [defaultExpression];

$scope.topNavMenu = [{
key: 'new',
Expand All @@ -78,6 +78,21 @@ app.controller('timelion', function (
description: 'Save Sheet',
template: require('plugins/timelion/partials/save_sheet.html'),
testId: 'timelionSaveButton',
}, {
key: 'delete',
description: 'Delete current sheet',
disableButton: function () {
return !savedSheet.id;
},
run: function () {
var title = savedSheet.title;
safeConfirm('Are you sure you want to delete the sheet ' + title + ' ?').then(function () {
savedSheet.delete().then(() => {
notify.info('Deleted ' + title);
kbnUrl.change('/');
}).catch(notify.fatal);
});},
testId: 'timelionDeleteButton',
}, {
key: 'open',
description: 'Open Sheet',
Expand Down Expand Up @@ -213,7 +228,6 @@ app.controller('timelion', function (
savedSheet.timelion_columns = $scope.state.columns;
savedSheet.timelion_rows = $scope.state.rows;
savedSheet.save().then(function (id) {
//$scope.configTemplate.close('save');
if (id) {
notify.info('Saved sheet as "' + savedSheet.title + '"');
if (savedSheet.id !== $routeParams.id) {
Expand Down

0 comments on commit 1c37948

Please sign in to comment.