Repository: ambari Updated Branches: refs/heads/trunk 5796e12de -> 35b96f728
AMBARI-10084. There is no revert indicator for repositories on stack and versions tab (onechiporenko) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/35b96f72 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/35b96f72 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/35b96f72 Branch: refs/heads/trunk Commit: 35b96f7283be0469594c3fda7cb3b6a8b5aeec91 Parents: 5796e12 Author: Oleg Nechiporenko <[email protected]> Authored: Mon Mar 16 18:03:05 2015 +0200 Committer: Oleg Nechiporenko <[email protected]> Committed: Mon Mar 16 18:40:09 2015 +0200 ---------------------------------------------------------------------- ambari-web/app/styles/stack_versions.less | 2 +- .../admin/stack_upgrade/edit_repositories.hbs | 12 ++--- ambari-web/app/views/common/controls_view.js | 50 +++++++++++++++++++- .../test/views/common/controls_view_test.js | 42 ++++++++++++++++ 4 files changed, 97 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/35b96f72/ambari-web/app/styles/stack_versions.less ---------------------------------------------------------------------- diff --git a/ambari-web/app/styles/stack_versions.less b/ambari-web/app/styles/stack_versions.less index 5416aac..a54953b 100644 --- a/ambari-web/app/styles/stack_versions.less +++ b/ambari-web/app/styles/stack_versions.less @@ -276,7 +276,7 @@ padding-top: 10px; } input[type="text"] { - width: 97%; + width: 80%; } } http://git-wip-us.apache.org/repos/asf/ambari/blob/35b96f72/ambari-web/app/templates/main/admin/stack_upgrade/edit_repositories.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/main/admin/stack_upgrade/edit_repositories.hbs b/ambari-web/app/templates/main/admin/stack_upgrade/edit_repositories.hbs index af861b3..053f7dc 100644 --- a/ambari-web/app/templates/main/admin/stack_upgrade/edit_repositories.hbs +++ b/ambari-web/app/templates/main/admin/stack_upgrade/edit_repositories.hbs @@ -34,11 +34,11 @@ <div class="span2"> {{os.osType}} </div> - <div class="span10"> - {{#each repository in os.repositories}} - <div class="row-fluid"> - <div class="span3">{{repository.repoName}}</div> - <div {{bindAttr class="repository.hasError:error :control-group :span9"}}>{{view App.BaseUrlTextField repositoryBinding="repository"}}</div> + <div class="span10"> + {{#each repository in os.repositories}} + <div class="row-fluid"> + <div class="span3">{{repository.repoName}}</div> + <div {{bindAttr class="repository.hasError:error :control-group :span9"}}>{{view App.BaseUrlTextField repositoryBinding="repository"}}</div> </div> {{/each}} </div> @@ -48,5 +48,5 @@ <div> <label>{{view view.skipCheckBox checkedBinding="view.parentView.skipValidation"}}{{t installer.step1.advancedRepo.skipValidation.message}} <i class="icon-question-sign" rel="skip-validation-tooltip" - data-toggle="tooltip" {{translateAttr title="installer.step1.advancedRepo.skipValidation.tooltip"}}></i></label> + data-toggle="tooltip" {{translateAttr title="installer.step1.advancedRepo.skipValidation.tooltip"}}></i></label> </div> http://git-wip-us.apache.org/repos/asf/ambari/blob/35b96f72/ambari-web/app/views/common/controls_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/controls_view.js b/ambari-web/app/views/common/controls_view.js index 5a0d007..118534e 100644 --- a/ambari-web/app/views/common/controls_view.js +++ b/ambari-web/app/views/common/controls_view.js @@ -1352,14 +1352,60 @@ App.CheckDBConnectionView = Ember.View.extend({ }); /** - * + * View with input field used to repo-version URLs * @type {*} */ App.BaseUrlTextField = Ember.TextField.extend({ + layout: Ember.Handlebars.compile('<div class="pull-left">{{yield}}</div> {{#if view.valueWasChanged}}<div class="pull-right"><a class="btn btn-small" {{action "restoreValue" target="view"}}><i class="icon-undo"></i></a></div>{{/if}}'), + + /** + * Binding in the template + * @type {App.RepositoryVersion} + */ + repository: null, + + /** + * @type {string} + */ valueBinding: 'repository.baseUrl', - keyUp: function (event) { + /** + * @type {string} + */ + defaultValue: '', + + /** + * Determines if user have put some new value + * @type {boolean} + */ + valueWasChanged: false, + + didInsertElement: function () { + this.set('defaultValue', this.get('value')); + this.addObserver('value', this, this.valueWasChangedObs); + }, + + valueWasChangedObs: function () { + var value = this.get('value'), + defaultValue = this.get('defaultValue'); + this.set('valueWasChanged', value !== defaultValue); + }, + + /** + * Restore value and unset error-flag + * @method restoreValue + */ + restoreValue: function () { + this.set('value', this.get('defaultValue')); + this.keyUp(); + }, + + /** + * Remove error-highlight after user puts some new value + * @method keyUp + */ + keyUp: function () { if (Em.get(this, 'repository.hasError')) { Em.set(this, 'repository.hasError', false); } http://git-wip-us.apache.org/repos/asf/ambari/blob/35b96f72/ambari-web/test/views/common/controls_view_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/common/controls_view_test.js b/ambari-web/test/views/common/controls_view_test.js index f995941..00b641e 100644 --- a/ambari-web/test/views/common/controls_view_test.js +++ b/ambari-web/test/views/common/controls_view_test.js @@ -654,4 +654,46 @@ describe('App.CheckDBConnectionView', function () { }); +}); + +describe('App.BaseUrlTextField', function () { + + var view; + + beforeEach(function () { + view = App.BaseUrlTextField.create({ + repository: Em.Object.create({ + baseUrl: 'val' + }) + }); + view.didInsertElement(); + }); + + describe('#valueWasChanged', function () { + + it('should be recalculated after value is changed', function () { + view.setProperties({ + value: 'val', + defaultValue: 'val' + }); + expect(view.get('valueWasChanged')).to.be.false; + view.set('value', 'newVal'); + expect(view.get('valueWasChanged')).to.be.true; + }); + + }); + + describe('#restoreValue', function () { + + it('should unset value', function () { + view.setProperties({ + value: 'valNew', + defaultValue: 'val' + }); + view.restoreValue(); + expect(view.get('value')).to.equal('val'); + }); + + }); + }); \ No newline at end of file
