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; } @@ -108,7 +108,7 @@ limitations under the License. -
+
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), ''); + }); });