ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akovale...@apache.org
Subject [1/2] ambari git commit: AMBARI-11478. Configs saving popup is displayed if user navigates away before configs are loaded (akovalenko)
Date Thu, 28 May 2015 12:03:33 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk da826636c -> 283ec21ec


AMBARI-11478. Configs saving popup is displayed if user navigates away before configs are
loaded (akovalenko)


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

Branch: refs/heads/trunk
Commit: da02aeef78008ed82b67132c1e3c4843883acff7
Parents: da82663
Author: Aleksandr Kovalenko <akovalenko@hortonworks.com>
Authored: Thu May 28 13:58:53 2015 +0300
Committer: Aleksandr Kovalenko <akovalenko@hortonworks.com>
Committed: Thu May 28 13:58:53 2015 +0300

----------------------------------------------------------------------
 .../app/mixins/common/configs/configs_saver.js  |  2 +-
 .../main/service/info/config_test.js            | 31 +++++++++++++++-----
 2 files changed, 24 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/da02aeef/ambari-web/app/mixins/common/configs/configs_saver.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/common/configs/configs_saver.js b/ambari-web/app/mixins/common/configs/configs_saver.js
index 7b2af7a..4626c15 100644
--- a/ambari-web/app/mixins/common/configs/configs_saver.js
+++ b/ambari-web/app/mixins/common/configs/configs_saver.js
@@ -156,7 +156,7 @@ App.ConfigsSaverMixin = Em.Mixin.create({
    * @method hasUnsavedChanges
    */
   hasUnsavedChanges: function () {
-    return this.get('hash') != this.getHash();
+    return !Em.isNone(this.get('hash')) && this.get('hash') != this.getHash();
   },
 
   /*********************************** 1. PRE SAVE CHECKS ************************************/

http://git-wip-us.apache.org/repos/asf/ambari/blob/da02aeef/ambari-web/test/controllers/main/service/info/config_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/service/info/config_test.js b/ambari-web/test/controllers/main/service/info/config_test.js
index b895ed6..0fedc6d 100644
--- a/ambari-web/test/controllers/main/service/info/config_test.js
+++ b/ambari-web/test/controllers/main/service/info/config_test.js
@@ -148,6 +148,24 @@ describe("App.MainServiceInfoConfigsController", function () {
   });
 
   describe("#hasUnsavedChanges", function () {
+    var cases = [
+      {
+        hash: null,
+        hasUnsavedChanges: false,
+        title: 'configs not rendered'
+      },
+      {
+        hash: 'hash1',
+        hasUnsavedChanges: true,
+        title: 'with unsaved'
+      },
+      {
+        hash: 'hash',
+        hasUnsavedChanges: false,
+        title: 'without unsaved'
+      }
+    ];
+
     beforeEach(function () {
       sinon.stub(mainServiceInfoConfigsController, "getHash", function () {
         return "hash"
@@ -157,14 +175,11 @@ describe("App.MainServiceInfoConfigsController", function () {
       mainServiceInfoConfigsController.getHash.restore();
     });
 
-    it("with unsaved", function () {
-      mainServiceInfoConfigsController.set("hash", "hash1");
-      expect(mainServiceInfoConfigsController.hasUnsavedChanges()).to.equal(true);
-    });
-
-    it("without unsaved", function () {
-      mainServiceInfoConfigsController.set("hash", "hash");
-      expect(mainServiceInfoConfigsController.hasUnsavedChanges()).to.equal(false);
+    cases.forEach(function (item) {
+      it(item.title, function () {
+        mainServiceInfoConfigsController.set('hash', item.hash);
+        expect(mainServiceInfoConfigsController.hasUnsavedChanges()).to.equal(item.hasUnsavedChanges);
+      });
     });
   });
 


Mime
View raw message