From a008aa9428d0099cafe9f2965a0b9beecb78aecd Mon Sep 17 00:00:00 2001 From: Logan Hanks Date: Fri, 22 Jul 2016 10:31:12 -0700 Subject: [PATCH] Prompt to confirm to add large group as reviewer Depending on server configuration, a group with a certain number of members must be marked as explicitly confirmed by the user before it may be added as a reviewer. This change introduces an overlay on top of the reply dialog to prompt the user for this confirmation in advance of submission. Change-Id: I0a61819e785c9a80aaa12ebae347907e41b24aac --- .../change/gr-account-list/gr-account-list.js | 17 ++++ .../gr-account-list/gr-account-list_test.html | 33 +++++++ .../gr-reply-dialog/gr-reply-dialog.html | 37 ++++++++ .../change/gr-reply-dialog/gr-reply-dialog.js | 26 +++++- .../gr-reply-dialog/gr-reply-dialog_test.html | 87 +++++++++++++++++++ 5 files changed, 199 insertions(+), 1 deletion(-) diff --git a/polygerrit-ui/app/elements/change/gr-account-list/gr-account-list.js b/polygerrit-ui/app/elements/change/gr-account-list/gr-account-list.js index 828169d445..3b792e2a84 100644 --- a/polygerrit-ui/app/elements/change/gr-account-list/gr-account-list.js +++ b/polygerrit-ui/app/elements/change/gr-account-list/gr-account-list.js @@ -24,6 +24,11 @@ }, change: Object, placeholder: String, + pendingConfirmation: { + type: Object, + value: null, + notify: true, + }, readonly: Boolean, filter: { @@ -52,10 +57,22 @@ var account = Object.assign({}, reviewer.account, {_pendingAdd: true}); this.push('accounts', account); } else if (reviewer.group) { + if (reviewer.confirm) { + this.pendingConfirmation = reviewer; + return; + } var group = Object.assign({}, reviewer.group, {_pendingAdd: true, _group: true}); this.push('accounts', group); } + this.pendingConfirmation = null; + }, + + confirmGroup: function(group) { + group = Object.assign( + {}, group, {confirmed: true, _pendingAdd: true, _group: true}); + this.push('accounts', group); + this.pendingConfirmation = null; }, _computeChipClass: function(account) { diff --git a/polygerrit-ui/app/elements/change/gr-account-list/gr-account-list_test.html b/polygerrit-ui/app/elements/change/gr-account-list/gr-account-list_test.html index 79d5e5920f..bb55d0887d 100644 --- a/polygerrit-ui/app/elements/change/gr-account-list/gr-account-list_test.html +++ b/polygerrit-ui/app/elements/change/gr-account-list/gr-account-list_test.html @@ -199,5 +199,38 @@ limitations under the License. }, ]); }); + + test('large group confirmations', function() { + assert.isNull(element.pendingConfirmation); + assert.deepEqual(element.additions(), []); + + var group = makeGroup(); + var reviewer = { + group: group, + count: 10, + confirm: true, + }; + element._handleAdd({ + detail: { + value: reviewer, + }, + }); + + assert.deepEqual(element.pendingConfirmation, reviewer); + assert.deepEqual(element.additions(), []); + + element.confirmGroup(group); + assert.isNull(element.pendingConfirmation); + assert.deepEqual(element.additions(), [ + { + group: { + id: group.id, + _group: true, + _pendingAdd: true, + confirmed: true, + }, + }, + ]); + }); }); diff --git a/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog.html b/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog.html index 89cb4a2370..e923d48025 100644 --- a/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog.html +++ b/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog.html @@ -20,6 +20,7 @@ limitations under the License. + @@ -64,6 +65,19 @@ limitations under the License. gr-account-list { flex: 1; } + #reviewerConfirmationOverlay { + padding: 1em; + text-align: center; + } + .reviewerConfirmationButtons { + margin-top: 1em; + } + .groupName { + font-weight: bold; + } + .groupSize { + font-style: italic; + } .textareaContainer { position: relative; display: flex; @@ -135,9 +149,32 @@ limitations under the License. id="reviewers" accounts="[[_reviewers]]" change="[[change]]" + pending-confirmation="{{_reviewerPendingConfirmation}}" placeholder="Add reviewer..."> + +
+ Group + + {{_reviewerPendingConfirmation.group.name}} + + has + + {{_reviewerPendingConfirmation.count}} + + members. +
+ Are you sure you want to add them all? +
+
+ Yes + No +
+