ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akovale...@apache.org
Subject git commit: AMBARI-4136. Unsaved Config Changes prompt should say Save, Discard, Cancel. (akovalenko)
Date Fri, 20 Dec 2013 15:27:06 GMT
Updated Branches:
  refs/heads/trunk b24a797b0 -> 21d083092


AMBARI-4136. Unsaved Config Changes prompt should say Save, Discard, Cancel. (akovalenko)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/21d08309
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/21d08309
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/21d08309

Branch: refs/heads/trunk
Commit: 21d0830929f3f14c4a031acb717e5bd89a8b1b3d
Parents: b24a797
Author: Aleksandr Kovalenko <akovalenko@hortonworks.com>
Authored: Fri Dec 20 17:24:16 2013 +0200
Committer: Aleksandr Kovalenko <akovalenko@hortonworks.com>
Committed: Fri Dec 20 17:24:16 2013 +0200

----------------------------------------------------------------------
 .../controllers/main/service/info/configs.js    | 30 ++++++++++++++------
 ambari-web/app/messages.js                      |  1 +
 ambari-web/app/routes/main.js                   | 13 +++++++--
 .../main/service/info/save_popup_footer.hbs     | 23 +++++++++++++++
 4 files changed, 55 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/21d08309/ambari-web/app/controllers/main/service/info/configs.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/info/configs.js b/ambari-web/app/controllers/main/service/info/configs.js
index c54f542..62a33c2 100644
--- a/ambari-web/app/controllers/main/service/info/configs.js
+++ b/ambari-web/app/controllers/main/service/info/configs.js
@@ -22,6 +22,7 @@ require('controllers/wizard/slave_component_groups_controller');
 App.MainServiceInfoConfigsController = Em.Controller.extend({
   name: 'mainServiceInfoConfigsController',
   isHostsConfigsPage: false,
+  forceTransition: false,
   dataIsLoaded: false,
   stepConfigs: [], //contains all field properties that are viewed in this service
   selectedService: null,
@@ -147,6 +148,7 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
   clearStep: function () {
     this.set('isInit', true);
     this.set('hash', null);
+    this.set('forceTransition', false);
     this.set('dataIsLoaded', false);
     this.set('filter', '');
     this.get('filterColumns').setEach('selected', false);
@@ -2014,7 +2016,7 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
   selectConfigGroup: function (event) {
     if (!this.get('isInit')) {
       if (this.hasUnsavedChanges()) {
-        this.showSavePopup(event);
+        this.showSavePopup(null, event);
         return;
       }
     }
@@ -2033,26 +2035,36 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
    * If some configs are changed and user navigates away or select another config-group,
show this popup with propose to save changes
    * @param {object} event - triggered event for seleting another config-group
    */
-  showSavePopup: function(event) {
-    if (!event) event = null;
+  showSavePopup: function (path, event) {
     var _this = this;
     App.ModalPopup.show({
       header: Em.I18n.t('common.warning'),
       body: Em.I18n.t('services.service.config.exitPopup.body'),
+      footerClass: Ember.View.extend({
+        templateName: require('templates/main/service/info/save_popup_footer'),
+        isSaveDisabled: function() {
+          return _this.get('isSubmitDisabled');
+        }.property()
+      }),
       primary: Em.I18n.t('common.save'),
       secondary: Em.I18n.t('common.cancel'),
-      onPrimary: function() {
+      onSave: function () {
         _this.restartServicePopup();
-        this._super();
+        this.hide();
       },
-      onSecondary: function() {
-        if (event) {
+      onDiscard: function () {
+        if (path) {
+          _this.set('forceTransition', true);
+          App.router.route(path);
+        } else if (event) {
           // Prevent multiple popups
           _this.set('hash', _this.getHash());
-
           _this.selectConfigGroup(event);
         }
-        this._super();
+        this.hide();
+      },
+      onCancel: function () {
+        this.hide();
       }
     });
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/21d08309/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 679ee8d..92a0096 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -162,6 +162,7 @@ Em.I18n.translations = {
   'common.conf.group': 'Configuration Group',
   'common.ignore': 'Ignore',
   'common.restart': 'Restart',
+  'common.discard': 'Discard',
 
   'requestInfo.installComponents':'Install Components',
   'requestInfo.installServices':'Install Services',

http://git-wip-us.apache.org/repos/asf/ambari/blob/21d08309/ambari-web/app/routes/main.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/routes/main.js b/ambari-web/app/routes/main.js
index 0a2d711..85674dc 100644
--- a/ambari-web/app/routes/main.js
+++ b/ambari-web/app/routes/main.js
@@ -869,10 +869,12 @@ module.exports = Em.Route.extend({
           var item = router.get('mainServiceItemController.content');
           router.get('mainServiceItemController').connectOutlet('mainServiceInfoConfigs',
item);
         },
-        exit: function(router, context) {
+        unroutePath: function (router, context) {
           var controller = router.get('mainServiceInfoConfigsController');
-          if (controller.hasUnsavedChanges()) {
-            controller.showSavePopup();
+          if (!controller.get('forceTransition') && controller.hasUnsavedChanges())
{
+            controller.showSavePopup(context);
+          } else {
+            this._super(router, context);
           }
         }
       }),
@@ -884,6 +886,11 @@ module.exports = Em.Route.extend({
         }
       }),
       showInfo: function (router, event) {
+        var mainServiceInfoConfigsController = App.router.get('mainServiceInfoConfigsController');
+        if (event.context === 'summary' && mainServiceInfoConfigsController.hasUnsavedChanges())
{
+          mainServiceInfoConfigsController.showSavePopup(router.get('location.lastSetURL').replace('configs',
'summary'));
+          return false;
+        }
         var parent = event.view._parentView;
         parent.deactivateChildViews();
         event.view.set('active', "active");

http://git-wip-us.apache.org/repos/asf/ambari/blob/21d08309/ambari-web/app/templates/main/service/info/save_popup_footer.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/service/info/save_popup_footer.hbs b/ambari-web/app/templates/main/service/info/save_popup_footer.hbs
new file mode 100644
index 0000000..e7c155c
--- /dev/null
+++ b/ambari-web/app/templates/main/service/info/save_popup_footer.hbs
@@ -0,0 +1,23 @@
+{{!
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+}}
+
+<div class="modal-footer">
+  <button type="button" class="btn btn" {{action onCancel target="view.parentView"}}>{{t
common.cancel}}</button>
+  <button type="button" class="btn btn" {{action onDiscard target="view.parentView"}}>{{t
common.discard}}</button>
+  <button type="button" class="btn btn-success" {{bindAttr disabled="view.isSaveDisabled"}}
{{action onSave target="view.parentView"}}>{{t common.save}}</button>
+</div>


Mime
View raw message