Commit 142a323e by Torkel Ödegaard

fix(save as): fixed issue with save as and overwriting a dashboard with the same name

parent ea198fea
...@@ -14,9 +14,8 @@ function (angular) { ...@@ -14,9 +14,8 @@ function (angular) {
$scope.clone.title = $scope.clone.title + " Copy"; $scope.clone.title = $scope.clone.title + " Copy";
}; };
$scope.saveClone = function() { function saveDashboard(options) {
backendSrv.saveDashboard($scope.clone) return backendSrv.saveDashboard($scope.clone, options).then(function(result) {
.then(function(result) {
$scope.appEvent('alert-success', ['Dashboard saved', 'Saved as ' + $scope.clone.title]); $scope.appEvent('alert-success', ['Dashboard saved', 'Saved as ' + $scope.clone.title]);
$location.url('/dashboard/db/' + result.slug); $location.url('/dashboard/db/' + result.slug);
...@@ -24,6 +23,24 @@ function (angular) { ...@@ -24,6 +23,24 @@ function (angular) {
$scope.appEvent('dashboard-saved', $scope.clone); $scope.appEvent('dashboard-saved', $scope.clone);
$scope.dismiss(); $scope.dismiss();
}); });
}
$scope.saveClone = function() {
saveDashboard({overwrite: false}).then(null, function(err) {
if (err.data && err.data.status === "name-exists") {
err.isHandled = true;
$scope.appEvent('confirm-modal', {
title: 'Another dashboard with the same name exists',
text: "Would you still like to save this dashboard?",
yesText: "Save & Overwrite",
icon: "fa-warning",
onConfirm: function() {
saveDashboard({overwrite: true});
}
});
}
});
}; };
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment