From 71bc7f33d24b58ead2d2c3dac043b8c1fa3e4dd9 Mon Sep 17 00:00:00 2001 From: Paladox none Date: Mon, 5 Nov 2018 16:55:30 +0000 Subject: [PATCH] Hide "private" check box if private changes are disabled Bug: Issue 9776 Change-Id: Ide3b849a9dbe1c26b7787a514c503f97bce9ef31 --- .../gr-create-change-dialog.html | 4 +-- .../gr-create-change-dialog.js | 28 +++++++++++++++---- .../gr-create-change-dialog_test.html | 10 +++++++ 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; } @@ -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), ''); + }); });