diff options
author | Kasper Nilsson <kaspern@google.com> | 2018-11-14 20:58:46 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2018-11-14 20:58:46 +0000 |
commit | fa28f1882a5589d1dd6bdeb7273024fc77990e05 (patch) | |
tree | 5904b288881470c23816a7fefe2873d05b5d74ae | |
parent | f7de361bcff92168fe2fd01aa441195c9e3f89ea (diff) | |
parent | bd9c390223cbe36aca2094407b3e065bbdf655b1 (diff) |
Merge "Hide "private" check box if private changes are disabled" into stable-2.16
3 files changed, 35 insertions, 7 deletions
diff --git a/polygerrit-ui/app/elements/admin/gr-create-change-dialog/gr-create-change-dialog.html b/polygerrit-ui/app/elements/admin/gr-create-change-dialog/gr-create-change-dialog.html index ad12a44316..987b63dab6 100644 --- a/polygerrit-ui/app/elements/admin/gr-create-change-dialog/gr-create-change-dialog.html +++ b/polygerrit-ui/app/elements/admin/gr-create-change-dialog/gr-create-change-dialog.html @@ -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> diff --git a/polygerrit-ui/app/elements/admin/gr-create-change-dialog/gr-create-change-dialog.js b/polygerrit-ui/app/elements/admin/gr-create-change-dialog/gr-create-change-dialog.js index 826a6dc524..8e15755e6b 100644 --- a/polygerrit-ui/app/elements/admin/gr-create-change-dialog/gr-create-change-dialog.js +++ b/polygerrit-ui/app/elements/admin/gr-create-change-dialog/gr-create-change-dialog.js @@ -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' : ''; + }, }); })(); diff --git a/polygerrit-ui/app/elements/admin/gr-create-change-dialog/gr-create-change-dialog_test.html b/polygerrit-ui/app/elements/admin/gr-create-change-dialog/gr-create-change-dialog_test.html index 08c569ca00..aa4da68937 100644 --- a/polygerrit-ui/app/elements/admin/gr-create-change-dialog/gr-create-change-dialog_test.html +++ b/polygerrit-ui/app/elements/admin/gr-create-change-dialog/gr-create-change-dialog_test.html @@ -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> |