Repository: ambari
Updated Branches:
  refs/heads/branch-alerts-dev c13730a06 -> 7a0f50917


AMBARI-7081 Configs: save/cancel/discard flow not correct. (ababiichuk)


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

Branch: refs/heads/branch-alerts-dev
Commit: f04ba443c60b279f526dc908b21b19847e294f27
Parents: 866f5b2
Author: aBabiichuk <ababiic...@cybervisiontech.com>
Authored: Mon Sep 1 14:46:18 2014 +0300
Committer: aBabiichuk <ababiic...@cybervisiontech.com>
Committed: Mon Sep 1 14:46:18 2014 +0300

----------------------------------------------------------------------
 .../controllers/main/service/info/configs.js    | 24 +++++++++++++++-----
 ambari-web/app/models/service_config.js         |  6 ++++-
 .../common/configs/config_history_flow.hbs      |  4 ++--
 .../common/configs/save_configuration.hbs       |  6 ++++-
 .../views/common/configs/config_history_flow.js | 11 +++++++--
 5 files changed, 39 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/f04ba443/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 39f4997..10ed830 100644
--- a/ambari-web/app/controllers/main/service/info/configs.js
+++ b/ambari-web/app/controllers/main/service/info/configs.js
@@ -108,6 +108,10 @@ App.MainServiceInfoConfigsController = 
Em.Controller.extend(App.ServerValidatorM
     return (!(this.stepConfigs.everyProperty('errorCount', 0)) || 
this.get('isApplyingChanges'));
   }.property('stepConfigs.@each.errorCount', 'isApplyingChanges'),
 
+  isPropertiesChanged: function(){
+    return this.stepConfigs.someProperty('isPropertiesChanged', true)
+  }.property('stepConfigs.@each.isPropertiesChanged'),
+
   slaveComponentGroups: null,
 
   /**
@@ -2244,7 +2248,7 @@ App.MainServiceInfoConfigsController = 
Em.Controller.extend(App.ServerValidatorM
    * @method loadStep
    */
   doCancel: function () {
-    this.loadStep();
+    Em.run.once(this, 'onConfigGroupChange');
   },
 
   /**
@@ -2530,16 +2534,24 @@ App.MainServiceInfoConfigsController = 
Em.Controller.extend(App.ServerValidatorM
     var self = this;
     return App.ModalPopup.show({
       header: Em.I18n.t('common.warning'),
-      body: Em.I18n.t('services.service.config.exitPopup.body'),
+      bodyClass: Em.View.extend({
+        templateName: require('templates/common/configs/save_configuration'),
+        showSaveWarning: true,
+        notesArea: Em.TextArea.extend({
+          classNames: ['full-width'],
+          placeholder: 
Em.I18n.t('dashboard.configHistory.info-bar.save.popup.placeholder'),
+          onChangeValue: function() {
+            this.get('parentView.parentView').set('serviceConfigNote', 
this.get('value'));
+          }.observes('value')
+        })
+      }),
       footerClass: Ember.View.extend({
-        templateName: require('templates/main/service/info/save_popup_footer'),
-        isSaveDisabled: function () {
-          return self.get('isSubmitDisabled');
-        }.property()
+        templateName: require('templates/main/service/info/save_popup_footer')
       }),
       primary: Em.I18n.t('common.save'),
       secondary: Em.I18n.t('common.cancel'),
       onSave: function () {
+        self.set('serviceConfigVersionNote', this.get('serviceConfigNote'));
         self.restartServicePopup();
         this.hide();
       },

http://git-wip-us.apache.org/repos/asf/ambari/blob/f04ba443/ambari-web/app/models/service_config.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/service_config.js 
b/ambari-web/app/models/service_config.js
index 0200ac8..45e4f50 100644
--- a/ambari-web/app/models/service_config.js
+++ b/ambari-web/app/models/service_config.js
@@ -45,7 +45,11 @@ App.ServiceConfig = Ember.Object.extend({
       slaveErrors += _category.get('slaveErrorCount');
     }, this);
     return masterErrors + slaveErrors + overrideErrors;
-  }.property('configs.@each.isValid', 'configs.@each.isVisible', 
'configCategories.@each.slaveErrorCount', 'configs.@each.overrideErrorTrigger')
+  }.property('configs.@each.isValid', 'configs.@each.isVisible', 
'configCategories.@each.slaveErrorCount', 'configs.@each.overrideErrorTrigger'),
+
+  isPropertiesChanged: function() {
+    return this.get('configs').someProperty('isNotDefaultValue', true);
+  }.property('configs.@each.isNotDefaultValue')
 });
 
 App.ServiceConfigCategory = Ember.Object.extend({

http://git-wip-us.apache.org/repos/asf/ambari/blob/f04ba443/ambari-web/app/templates/common/configs/config_history_flow.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/common/configs/config_history_flow.hbs 
b/ambari-web/app/templates/common/configs/config_history_flow.hbs
index a900760..b18ca8c 100644
--- a/ambari-web/app/templates/common/configs/config_history_flow.hbs
+++ b/ambari-web/app/templates/common/configs/config_history_flow.hbs
@@ -76,7 +76,7 @@
               </div>
               <div class="pull-right operations-button">
                   <div {{bindAttr 
class="view.compareServiceVersion.isCurrent::hidden"}}>
-                      <button class="btn" {{action doCancel 
target="controller"}} {{bindAttr disabled="view.versionActionsDisabled"}}>{{t 
common.cancel}}</button>
+                      <button class="btn" {{action doCancel 
target="controller"}} {{bindAttr disabled="view.isDiscardDisabled"}}>{{t 
common.discard}}</button>
                       <button class="btn btn-success" {{action save 
target="view"}} {{bindAttr disabled="view.isSaveDisabled"}}>{{t 
common.save}}</button>
                   </div>
                   <button class="btn btn-success"  {{action revert 
target="view"}} {{bindAttr disabled="view.versionActionsDisabled" 
class="view.compareServiceVersion.isCurrent:hidden"}}>{{view.compareServiceVersion.makeCurrentButtonText}}</button>
@@ -131,7 +131,7 @@
               </div>
               <div class="pull-right operations-button">
                   <div {{bindAttr 
class="view.displayedServiceVersion.isCurrent::hidden"}}>
-                      <button class="btn" {{action doCancel 
target="controller"}} {{bindAttr disabled="view.versionActionsDisabled"}}>{{t 
common.cancel}}</button>
+                      <button class="btn" {{action doCancel 
target="controller"}} {{bindAttr disabled="view.isDiscardDisabled"}}>{{t 
common.discard}}</button>
                       <button class="btn btn-success" {{action save 
target="view"}} {{bindAttr disabled="view.isSaveDisabled"}}>{{t 
common.save}}</button>
                   </div>
                   <button class="btn btn-success"  {{action revert 
target="view"}} {{bindAttr disabled="view.versionActionsDisabled" 
class="view.displayedServiceVersion.isCurrent:hidden"}}>{{view.displayedServiceVersion.makeCurrentButtonText}}</button>

http://git-wip-us.apache.org/repos/asf/ambari/blob/f04ba443/ambari-web/app/templates/common/configs/save_configuration.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/common/configs/save_configuration.hbs 
b/ambari-web/app/templates/common/configs/save_configuration.hbs
index ef39884..8ef4efd 100644
--- a/ambari-web/app/templates/common/configs/save_configuration.hbs
+++ b/ambari-web/app/templates/common/configs/save_configuration.hbs
@@ -15,7 +15,11 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 }}
-
+{{#if view.showSaveWarning}}
+    <div class="row-fluid">
+        <div class="span12 alert alert-warning">{{t 
services.service.config.exitPopup.body}}</div>
+    </div>
+{{/if}}
 <div class="row-fluid">
     <div class="span1">{{t common.notes}}</div>
     <div class="span10">{{view view.notesArea}}</div>

http://git-wip-us.apache.org/repos/asf/ambari/blob/f04ba443/ambari-web/app/views/common/configs/config_history_flow.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/configs/config_history_flow.js 
b/ambari-web/app/views/common/configs/config_history_flow.js
index d2eb084..01fca17 100644
--- a/ambari-web/app/views/common/configs/config_history_flow.js
+++ b/ambari-web/app/views/common/configs/config_history_flow.js
@@ -40,8 +40,8 @@ App.ConfigHistoryFlowView = Em.View.extend({
   }.property('compareServiceVersion'),
 
   isSaveDisabled: function () {
-    return (this.get('controller.isSubmitDisabled') || 
!this.get('controller.versionLoaded'));
-  }.property('controller.isSubmitDisabled', 'controller.versionLoaded'),
+    return (this.get('controller.isSubmitDisabled') || 
!this.get('controller.versionLoaded') || 
!this.get('controller.isPropertiesChanged')) ;
+  }.property('controller.isSubmitDisabled', 'controller.versionLoaded', 
'controller.isPropertiesChanged'),
 
   serviceName: function () {
     return this.get('controller.selectedService.serviceName');
@@ -104,6 +104,12 @@ App.ConfigHistoryFlowView = Em.View.extend({
   }.property('controller.versionLoaded'),
 
   /**
+   * enable discard to manipulate version only after it's loaded and any 
property is changed
+   */
+  isDiscardDisabled: function () {
+    return !this.get('controller.versionLoaded') || 
!this.get('controller.isPropertiesChanged');
+  }.property('controller.versionLoaded','controller.isPropertiesChanged'),
+  /**
    * list of service versions
    * by default 6 is number of items in short list
    */
@@ -405,6 +411,7 @@ App.ConfigHistoryFlowView = Em.View.extend({
       },
       onDiscard: function () {
         this.hide();
+        self.get('controller').loadStep();
       },
       onCancel: function () {
         this.hide();

Reply via email to