Submit requirements - do not render neutral gr-vote-chip Change-Id: Icefeaa5e8dfe8cc4a0f3d630545a67bc864f2edf
diff --git a/polygerrit-ui/app/elements/change/gr-submit-requirements/gr-submit-requirements.ts b/polygerrit-ui/app/elements/change/gr-submit-requirements/gr-submit-requirements.ts index 11dc9d9..c2b54a6 100644 --- a/polygerrit-ui/app/elements/change/gr-submit-requirements/gr-submit-requirements.ts +++ b/polygerrit-ui/app/elements/change/gr-submit-requirements/gr-submit-requirements.ts
@@ -31,6 +31,7 @@ import { extractAssociatedLabels, getAllUniqueApprovals, + hasNeutralStatus, hasVotes, iconForStatus, } from '../../../utils/label-util'; @@ -227,7 +228,9 @@ renderLabelVote(label: string, labels: LabelNameToInfoMap) { const labelInfo = labels[label]; if (isDetailedLabelInfo(labelInfo)) { - const uniqueApprovals = getAllUniqueApprovals(labelInfo); + const uniqueApprovals = getAllUniqueApprovals(labelInfo).filter( + approval => !hasNeutralStatus(labelInfo, approval) + ); return uniqueApprovals.map( approvalInfo => html`<gr-vote-chip @@ -380,15 +383,19 @@ } private renderVotes() { - if (!this.labelInfo) return; - if (isDetailedLabelInfo(this.labelInfo)) { - return getAllUniqueApprovals(this.labelInfo).map( + const {labelInfo} = this; + if (!labelInfo) return; + if (isDetailedLabelInfo(labelInfo)) { + const approvals = getAllUniqueApprovals(labelInfo).filter( + approval => !hasNeutralStatus(labelInfo, approval) + ); + return approvals.map( approvalInfo => html`<gr-vote-chip .vote="${approvalInfo}" - .label="${this.labelInfo}" + .label="${labelInfo}" ></gr-vote-chip>` ); - } else if (isQuickLabelInfo(this.labelInfo)) { + } else if (isQuickLabelInfo(labelInfo)) { return [html`<gr-vote-chip .label="${this.labelInfo}"></gr-vote-chip>`]; } else { return html``;
diff --git a/polygerrit-ui/app/utils/label-util.ts b/polygerrit-ui/app/utils/label-util.ts index 7c94892..78c4132 100644 --- a/polygerrit-ui/app/utils/label-util.ts +++ b/polygerrit-ui/app/utils/label-util.ts
@@ -83,14 +83,20 @@ ? LabelStatus.APPROVED : LabelStatus.RECOMMENDED; } - } - if (isQuickLabelInfo(label)) { + } else if (isQuickLabelInfo(label)) { if (label.approved) return LabelStatus.RECOMMENDED; if (label.rejected) return LabelStatus.DISLIKED; } return LabelStatus.NEUTRAL; } +export function hasNeutralStatus( + label: DetailedLabelInfo, + approvalInfo: ApprovalInfo +) { + return getLabelStatus(label, approvalInfo.value) === LabelStatus.NEUTRAL; +} + export function classForLabelStatus(status: LabelStatus) { switch (status) { case LabelStatus.APPROVED:
diff --git a/polygerrit-ui/app/utils/label-util_test.ts b/polygerrit-ui/app/utils/label-util_test.ts index ec27758..1004aac 100644 --- a/polygerrit-ui/app/utils/label-util_test.ts +++ b/polygerrit-ui/app/utils/label-util_test.ts
@@ -32,6 +32,7 @@ AccountInfo, ApprovalInfo, DetailedLabelInfo, + LabelInfo, QuickLabelInfo, } from '../types/common'; import { @@ -182,6 +183,16 @@ assert.equal(getLabelStatus(labelInfo), LabelStatus.DISLIKED); }); + test('getLabelStatus - detailed and quick info', () => { + let labelInfo: LabelInfo = {all: [], values: VALUES_2}; + labelInfo = { + all: [{value: 0}], + values: VALUES_0, + rejected: createAccountWithEmail(), + }; + assert.equal(getLabelStatus(labelInfo), LabelStatus.NEUTRAL); + }); + test('getRepresentativeValue', () => { let labelInfo: DetailedLabelInfo = {all: []}; assert.equal(getRepresentativeValue(labelInfo), 0);