Submit Requirements - show no votes
Change-Id: I003cf23d436e8b8ace4daad3063a3c4427f5c594
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 724d803..03fac07 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
@@ -28,6 +28,7 @@
import {unique} from '../../../utils/common-util';
import {
extractAssociatedLabels,
+ hasVotes,
iconForStatus,
} from '../../../utils/label-util';
import {fontStyles} from '../../../styles/gr-font-styles';
@@ -159,11 +160,23 @@
renderVotes(requirement: SubmitRequirementResultInfo) {
const requirementLabels = extractAssociatedLabels(requirement);
- const labels = this.change?.labels ?? {};
+ const allLabels = this.change?.labels ?? {};
+ const associatedLabels = Object.keys(allLabels).filter(label =>
+ requirementLabels.includes(label)
+ );
- return Object.keys(labels)
- .filter(label => requirementLabels.includes(label))
- .map(label => this.renderLabelVote(label, labels));
+ const everyAssociatedLabelsIsWithoutVotes = associatedLabels.every(
+ label => {
+ const labelInfo = allLabels[label];
+ if (!isDetailedLabelInfo(labelInfo)) return true;
+ return !hasVotes(labelInfo);
+ }
+ );
+ if (everyAssociatedLabelsIsWithoutVotes) return html`No votes`;
+
+ return associatedLabels.map(label =>
+ this.renderLabelVote(label, allLabels)
+ );
}
renderLabelVote(label: string, labels: LabelNameToInfoMap) {
diff --git a/polygerrit-ui/app/utils/label-util.ts b/polygerrit-ui/app/utils/label-util.ts
index 16e6803..066c7cd 100644
--- a/polygerrit-ui/app/utils/label-util.ts
+++ b/polygerrit-ui/app/utils/label-util.ts
@@ -121,6 +121,13 @@
return label.all?.filter(x => x._account_id === account._account_id)[0];
}
+export function hasVotes(labelInfo: DetailedLabelInfo) {
+ return (labelInfo.all ?? []).some(
+ approval =>
+ getLabelStatus(labelInfo, approval.value) !== LabelStatus.NEUTRAL
+ );
+}
+
export function labelCompare(labelName1: string, labelName2: string) {
if (labelName1 === CODE_REVIEW && labelName2 === CODE_REVIEW) return 0;
if (labelName1 === CODE_REVIEW) return -1;