Преглед изворни кода

feat(apps): more polish on app dashboard save warning, #5529

Torkel Ödegaard пре 9 година
родитељ
комит
b2acac3a41

+ 2 - 2
pkg/api/dashboard.go

@@ -139,10 +139,10 @@ func PostDashboard(c *middleware.Context, cmd m.SaveDashboardCommand) Response {
 			return Json(412, util.DynMap{"status": "version-mismatch", "message": err.Error()})
 		}
 		if pluginErr, ok := err.(m.UpdatePluginDashboardError); ok {
-			message := "Dashboard is belongs to plugin " + pluginErr.PluginId + "."
+			message := "The dashboard belongs to plugin " + pluginErr.PluginId + "."
 			// look up plugin name
 			if pluginDef, exist := plugins.Plugins[pluginErr.PluginId]; exist {
-				message = "Dashboard is belongs to plugin " + pluginDef.Name + "."
+				message = "The dashboard belongs to plugin " + pluginDef.Name + "."
 			}
 			return Json(412, util.DynMap{"status": "plugin-dashboard", "message": message})
 		}

+ 2 - 0
public/app/core/services/alert_srv.ts

@@ -73,6 +73,8 @@ export class AlertSrv {
     scope.text = payload.text;
     scope.text2 = payload.text2;
     scope.onConfirm = payload.onConfirm;
+    scope.onAltAction = payload.onAltAction;
+    scope.altActionText = payload.altActionText;
     scope.icon = payload.icon || "fa-check";
     scope.yesText = payload.yesText || "Yes";
     scope.noText = payload.noText || "Cancel";

+ 6 - 2
public/app/features/dashboard/dashnav/dashnav.ts

@@ -141,9 +141,13 @@ export class DashNavCtrl {
         $scope.appEvent('confirm-modal', {
           title: 'Plugin Dashboard',
           text: err.data.message,
-          text2: 'Your changes will be overwritten next time you update the plugin. Use Save As to create custom version.',
-          yesText: "Save & Overwrite",
+          text2: 'Your changes will be lost when you update the plugin. Use Save As to create custom version.',
+          yesText: "Overwrite",
           icon: "fa-warning",
+          altActionText: "Save As",
+          onAltAction: function() {
+            $scope.saveDashboardAs();
+          },
           onConfirm: function() {
             $scope.saveDashboard({overwrite: true});
           }

+ 2 - 1
public/app/partials/confirm_modal.html

@@ -1,4 +1,4 @@
-<div class="modal-body">
+<div class="modal-body" ng-cloak>
 	<div class="modal-header">
 		<h2 class="modal-header-title">
 			<i class="fa {{icon}}"></i>
@@ -24,6 +24,7 @@
 		<div class="confirm-modal-buttons">
 			<button type="button" class="btn btn-inverse" ng-click="dismiss()">{{noText}}</button>
 			<button type="button" class="btn btn-danger" ng-click="onConfirm();dismiss();">{{yesText}}</button>
+			<button ng-show="onAltAction" type="button" class="btn btn-success" ng-click="dismiss();onAltAction();">{{altActionText}}</button>
 		</div>
 	</div>