Hide "private" check box if private changes are disabled

Bug: Issue 9776
Change-Id: Ide3b849a9dbe1c26b7787a514c503f97bce9ef31
This commit is contained in:
Paladox none 2018-11-05 16:55:30 +00:00 committed by Logan Hanks
parent 79d356a5d9
commit 71bc7f33d2
3 changed files with 35 additions and 7 deletions

@ -55,7 +55,7 @@ limitations under the License.
padding: 0 .15em;
}
}
.hideBranch {
.hide {
display: none;
}
</style>
@ -108,7 +108,7 @@ limitations under the License.
</iron-autogrow-textarea>
</span>
</section>
<section>
<section class$="[[_computePrivateSectionClass(_privateChangesEnabled)]]">
<label
class="title"
for="privateChangeCheckBox">Private change</label>

@ -44,6 +44,7 @@
notify: true,
value: false,
},
_privateChangesEnabled: Boolean,
},
behaviors: [
@ -52,10 +53,23 @@
],
attached() {
if (!this.repoName) { return; }
this.$.restAPI.getProjectConfig(this.repoName).then(config => {
this.privateByDefault = config.private_by_default;
});
if (!this.repoName) { return Promise.resolve(); }
const promises = [];
promises.push(this.$.restAPI.getProjectConfig(this.repoName)
.then(config => {
this.privateByDefault = config.private_by_default;
}));
promises.push(this.$.restAPI.getConfig().then(config => {
if (!config) { return; }
this._privateConfig = config && config.change &&
config.change.disable_private_changes;
}));
return Promise.all(promises);
},
observers: [
@ -63,7 +77,7 @@
],
_computeBranchClass(baseChange) {
return baseChange ? 'hideBranch' : '';
return baseChange ? 'hide' : '';
},
_allowCreate(branch, subject) {
@ -120,5 +134,9 @@
return false;
}
},
_computePrivateSectionClass(config) {
return config ? 'hide' : '';
},
});
})();

@ -158,5 +158,15 @@ limitations under the License.
done();
});
});
test('_computeBranchClass', () => {
assert.equal(element._computeBranchClass(true), 'hide');
assert.equal(element._computeBranchClass(false), '');
});
test('_computePrivateSectionClass', () => {
assert.equal(element._computePrivateSectionClass(true), 'hide');
assert.equal(element._computePrivateSectionClass(false), '');
});
});
</script>