diff --git a/src/core_plugins/timelion/public/app.js b/src/core_plugins/timelion/public/app.js index cd16759251b63..301176b197ec6 100644 --- a/src/core_plugins/timelion/public/app.js +++ b/src/core_plugins/timelion/public/app.js @@ -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')); @@ -61,7 +62,6 @@ app.controller('timelion', function ( var defaultExpression = '.es(*)'; var savedSheet = $route.current.locals.savedSheet; - var blankSheet = [defaultExpression]; $scope.topNavMenu = [{ key: 'new', @@ -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', @@ -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) {