Commit 142a323e by Torkel Ödegaard

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

parent ea198fea
......@@ -14,16 +14,33 @@ function (angular) {
$scope.clone.title = $scope.clone.title + " Copy";
};
$scope.saveClone = function() {
backendSrv.saveDashboard($scope.clone)
.then(function(result) {
$scope.appEvent('alert-success', ['Dashboard saved', 'Saved as ' + $scope.clone.title]);
function saveDashboard(options) {
return backendSrv.saveDashboard($scope.clone, options).then(function(result) {
$scope.appEvent('alert-success', ['Dashboard saved', 'Saved as ' + $scope.clone.title]);
$location.url('/dashboard/db/' + result.slug);
$location.url('/dashboard/db/' + result.slug);
$scope.appEvent('dashboard-saved', $scope.clone);
$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('dashboard-saved', $scope.clone);
$scope.dismiss();
});
$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