mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
Migrate dashboard save error from old toast message to new EUI toast (#19956)
* Migrate dashboard save error from old toast message to new EUI toast * save function does not need to exist on anymore * account for error in onSave * update clone * lint errors
This commit is contained in:
parent
0945154302
commit
e40e64126b
3 changed files with 20 additions and 17 deletions
|
@ -58,7 +58,6 @@ const app = uiModules.get('app/dashboard', [
|
|||
'react',
|
||||
'kibana/courier',
|
||||
'kibana/config',
|
||||
'kibana/notify',
|
||||
'kibana/typeahead',
|
||||
]);
|
||||
|
||||
|
@ -67,7 +66,6 @@ app.directive('dashboardViewportProvider', function (reactDirective) {
|
|||
});
|
||||
|
||||
app.directive('dashboardApp', function ($injector) {
|
||||
const Notifier = $injector.get('Notifier');
|
||||
const courier = $injector.get('courier');
|
||||
const AppState = $injector.get('AppState');
|
||||
const timefilter = $injector.get('timefilter');
|
||||
|
@ -83,7 +81,6 @@ app.directive('dashboardApp', function ($injector) {
|
|||
const filterManager = Private(FilterManagerProvider);
|
||||
const filterBar = Private(FilterBarQueryFilterProvider);
|
||||
const docTitle = Private(DocTitleProvider);
|
||||
const notify = new Notifier({ location: 'Dashboard' });
|
||||
const embeddableFactories = Private(EmbeddableFactoriesRegistryProvider);
|
||||
const panelActionsRegistry = Private(DashboardPanelActionsRegistryProvider);
|
||||
|
||||
|
@ -288,7 +285,7 @@ app.directive('dashboardApp', function ($injector) {
|
|||
* @return {Promise}
|
||||
* @resolved {String} - The id of the doc
|
||||
*/
|
||||
$scope.save = function (saveOptions) {
|
||||
function save(saveOptions) {
|
||||
return saveDashboard(angular.toJson, timefilter, dashboardStateManager, saveOptions)
|
||||
.then(function (id) {
|
||||
$scope.kbnTopNav.close('save');
|
||||
|
@ -305,9 +302,15 @@ app.directive('dashboardApp', function ($injector) {
|
|||
updateViewMode(DashboardViewMode.VIEW);
|
||||
}
|
||||
}
|
||||
return id;
|
||||
}).catch(notify.error);
|
||||
};
|
||||
return { id };
|
||||
}).catch((error) => {
|
||||
toastNotifications.addDanger({
|
||||
title: `Dashboard '${dash.title}' was not saved. Error: ${error.message}`,
|
||||
'data-test-subj': 'saveDashboardFailure',
|
||||
});
|
||||
return { error };
|
||||
});
|
||||
}
|
||||
|
||||
$scope.showFilterBar = () => filterBar.getFilters().length > 0 || !dashboardStateManager.getFullScreenMode();
|
||||
|
||||
|
@ -338,14 +341,14 @@ app.directive('dashboardApp', function ($injector) {
|
|||
isTitleDuplicateConfirmed,
|
||||
onTitleDuplicate,
|
||||
};
|
||||
return $scope.save(saveOptions).then(id => {
|
||||
return save(saveOptions).then(({ id, error }) => {
|
||||
// If the save wasn't successful, put the original values back.
|
||||
if (!id) {
|
||||
if (!id || error) {
|
||||
dashboardStateManager.setTitle(currentTitle);
|
||||
dashboardStateManager.setDescription(currentDescription);
|
||||
dashboardStateManager.setTimeRestore(currentTimeRestore);
|
||||
}
|
||||
return id;
|
||||
return { id, error };
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -367,12 +370,12 @@ app.directive('dashboardApp', function ($injector) {
|
|||
isTitleDuplicateConfirmed,
|
||||
onTitleDuplicate,
|
||||
};
|
||||
return $scope.save(saveOptions).then(id => {
|
||||
return save(saveOptions).then(({ id, error }) => {
|
||||
// If the save wasn't successful, put the original title back.
|
||||
if (!id) {
|
||||
if (!id || error) {
|
||||
dashboardStateManager.setTitle(currentTitle);
|
||||
}
|
||||
return id;
|
||||
return { id, error };
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -29,8 +29,8 @@ export function showCloneModal(onClone, title) {
|
|||
};
|
||||
|
||||
const onCloneConfirmed = (newTitle, isTitleDuplicateConfirmed, onTitleDuplicate) => {
|
||||
onClone(newTitle, isTitleDuplicateConfirmed, onTitleDuplicate).then(id => {
|
||||
if (id) {
|
||||
onClone(newTitle, isTitleDuplicateConfirmed, onTitleDuplicate).then(({ id, error }) => {
|
||||
if (id || error) {
|
||||
closeModal();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -29,8 +29,8 @@ export function showSaveModal({ onSave, title, description, timeRestore, showCop
|
|||
};
|
||||
|
||||
const onSaveConfirmed = (...args) => {
|
||||
onSave(...args).then(id => {
|
||||
if (id) {
|
||||
onSave(...args).then(({ id, error }) => {
|
||||
if (id || error) {
|
||||
closeModal();
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue