commit d6a47665b81b0177be849b690601e9b726bf44c4 Author: Ben Rohlfs Date: Thu Oct 1 14:42:47 2020 +0200 Fix "Do not update attention set" message If we are just removing users from the attention set, then we should not show "do not update", but "do not add" instead. Change-Id: I17f199a998f82d36a011147eda77a11c4f5919b4 diff --git a/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog.ts b/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog.ts index 95d76d8..d774607 100644 --- a/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog.ts +++ b/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog.ts @@ -97,7 +97,11 @@ import { PolymerSplice, PolymerSpliceChange, } from '@polymer/polymer/interfaces'; -import {assertNever} from '../../../utils/common-util'; +import { + areSetsEqual, + assertNever, + containsAll, +} from '../../../utils/common-util'; import {CommentThread, isDraft} from '../../diff/gr-comment-api/gr-comment-api'; import {GrTextarea} from '../../shared/gr-textarea/gr-textarea'; import {GrAccountChip} from '../../shared/gr-account-chip/gr-account-chip'; @@ -1065,6 +1069,23 @@ export class GrReplyDialog extends KeyboardShortcutMixin( ); } + _computeDoNotUpdateMessage( + currentAttentionSet?: Set, + newAttentionSet?: Set + ) { + if (!currentAttentionSet || !newAttentionSet) return ''; + if (areSetsEqual(currentAttentionSet, newAttentionSet)) { + return 'No changes to the attention set.'; + } + if (containsAll(currentAttentionSet, newAttentionSet)) { + return 'No additions to the attention set.'; + } + console.error( + '_computeDoNotUpdateMessage() should not be called when users were added to the attention set.' + ); + return ''; + } + _computeNewAttentionAccounts( _?: ServerInfo, currentAttentionSet?: Set, diff --git a/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog_html.ts b/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog_html.ts index 247e891..f076981 100644 --- a/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog_html.ts +++ b/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog_html.ts @@ -371,7 +371,10 @@ export const htmlTemplate = html` is="dom-if" if="[[_isNewAttentionEmpty(serverConfig, _currentAttentionSet, _newAttentionSet)]]" > - Do not update the attention set. + [[_computeDoNotUpdateMessage(_currentAttentionSet, + _newAttentionSet)]]