Skip to content

Commit

Permalink
Flatten diagnostics to count (filters) (#459)
Browse files Browse the repository at this point in the history
  • Loading branch information
marc-mrt authored and GauthierPLM committed Dec 6, 2018
1 parent 853d9f5 commit a0a788b
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,17 @@ function DiagnosticsQuickSelector({
severities: Set<DiagnosticSeverity>,
onFilterClick: (severity: number) => void,
}) {
const flattenDiagnostics = (
severity: DiagnosticSeverity,
): List<MoleculeDiagnostic> =>
diagnostics
.filter(diagnosticGroup => diagnosticGroup.get(severity))
.reduce(
(acc, serverityMap) =>
serverityMap ? acc.concat(...serverityMap.values()) : acc,
List(),
);

return (
<DiagnosticsBox>
{[3, 5, 2, 1].map((severity: DiagnosticSeverity) => (
Expand All @@ -125,9 +136,7 @@ function DiagnosticsQuickSelector({
activated={severities.includes(severity)}
key={severity}
severity={severity}
count={diagnostics
.filter(diagnosticGroup => diagnosticGroup.get(severity))
.count()}
count={flattenDiagnostics(severity).count()}
/>
))}
</DiagnosticsBox>
Expand Down

0 comments on commit a0a788b

Please sign in to comment.