PolyGerrit: Allow status editing when full name is not editable
LDAP installs would not allow editing the status when full name was not
editable.
Bug: Issue 6080
Change-Id: Ifd53448891607908af9600b3ab61df4771304da9
(cherry picked from commit fbe932e296)
This commit is contained in:
@@ -79,7 +79,7 @@
|
||||
},
|
||||
|
||||
save: function() {
|
||||
if (!this.mutable || !this.hasUnsavedChanges) {
|
||||
if (!this.hasUnsavedChanges) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
@@ -97,9 +97,9 @@
|
||||
},
|
||||
|
||||
_maybeSetName: function() {
|
||||
return this._hasNameChange ?
|
||||
this.$.restAPI.setAccountName(this._account.name) :
|
||||
Promise.resolve();
|
||||
return this._hasNameChange && this.mutable ?
|
||||
this.$.restAPI.setAccountName(this._account.name) :
|
||||
Promise.resolve();
|
||||
},
|
||||
|
||||
_maybeSetStatus: function() {
|
||||
|
||||
@@ -168,5 +168,92 @@ limitations under the License.
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
suite('edit name and status', function() {
|
||||
var nameChangedSpy;
|
||||
var statusChangedSpy;
|
||||
var nameStub;
|
||||
var statusStub;
|
||||
|
||||
setup(function() {
|
||||
nameChangedSpy = sandbox.spy(element, '_nameChanged');
|
||||
statusChangedSpy = sandbox.spy(element, '_statusChanged');
|
||||
element.set('_serverConfig',
|
||||
{auth: {editable_account_fields: ['FULL_NAME']}});
|
||||
|
||||
nameStub = sandbox.stub(element.$.restAPI, 'setAccountName',
|
||||
function(name) { return Promise.resolve(); });
|
||||
statusStub = sandbox.stub(element.$.restAPI, 'setAccountStatus',
|
||||
function(status) { return Promise.resolve(); });
|
||||
});
|
||||
|
||||
test('set name and status', function(done) {
|
||||
assert.isTrue(element.mutable);
|
||||
assert.isFalse(element.hasUnsavedChanges);
|
||||
|
||||
element.set('_account.name', 'new name');
|
||||
|
||||
assert.isTrue(nameChangedSpy.called);
|
||||
|
||||
element.set('_account.status', 'new status');
|
||||
|
||||
assert.isTrue(statusChangedSpy.called);
|
||||
|
||||
assert.isTrue(element.hasUnsavedChanges);
|
||||
|
||||
element.save().then(function() {
|
||||
assert.isTrue(statusStub.called);
|
||||
assert.isTrue(nameStub.called);
|
||||
|
||||
assert.equal(nameStub.lastCall.args[0], 'new name');
|
||||
|
||||
assert.equal(statusStub.lastCall.args[0], 'new status');
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
suite('set status but read name', function() {
|
||||
var statusChangedSpy;
|
||||
var statusStub;
|
||||
|
||||
setup(function() {
|
||||
statusChangedSpy = sandbox.spy(element, '_statusChanged');
|
||||
element.set('_serverConfig',
|
||||
{auth: {editable_account_fields: []}});
|
||||
|
||||
statusStub = sandbox.stub(element.$.restAPI, 'setAccountStatus',
|
||||
function(status) { return Promise.resolve(); });
|
||||
});
|
||||
|
||||
test('read full name but set status', function(done) {
|
||||
var section = element.$.nameSection;
|
||||
var displaySpan = section.querySelectorAll('.value')[0];
|
||||
var inputSpan = section.querySelectorAll('.value')[1];
|
||||
|
||||
assert.isFalse(element.mutable);
|
||||
|
||||
assert.isFalse(element.hasUnsavedChanges);
|
||||
|
||||
assert.isFalse(displaySpan.hasAttribute('hidden'));
|
||||
assert.equal(displaySpan.textContent, account.name);
|
||||
assert.isTrue(inputSpan.hasAttribute('hidden'));
|
||||
|
||||
element.set('_account.status', 'new status');
|
||||
|
||||
assert.isTrue(statusChangedSpy.called);
|
||||
|
||||
assert.isTrue(element.hasUnsavedChanges);
|
||||
|
||||
element.save().then(function() {
|
||||
assert.isTrue(statusStub.called);
|
||||
statusStub.lastCall.returnValue.then(function() {
|
||||
assert.equal(statusStub.lastCall.args[0], 'new status');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -118,11 +118,10 @@ limitations under the License.
|
||||
<fieldset id="profile">
|
||||
<gr-account-info
|
||||
id="accountInfo"
|
||||
mutable="{{_accountInfoMutable}}"
|
||||
mutable="{{_accountNameMutable}}"
|
||||
has-unsaved-changes="{{_accountInfoChanged}}"></gr-account-info>
|
||||
<gr-button
|
||||
on-tap="_handleSaveAccountInfo"
|
||||
hidden$="[[!_accountInfoMutable]]"
|
||||
disabled="[[!_accountInfoChanged]]">Save changes</gr-button>
|
||||
</fieldset>
|
||||
<h2
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
type: Object,
|
||||
value: function() { return {}; },
|
||||
},
|
||||
_accountInfoMutable: Boolean,
|
||||
_accountNameMutable: Boolean,
|
||||
_accountInfoChanged: Boolean,
|
||||
_diffPrefs: Object,
|
||||
_changeTableColumnsNotDisplayed: Array,
|
||||
|
||||
Reference in New Issue
Block a user