Skip to content

Commit

Permalink
fix(server): only metrics get numeric diff view
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickhulce committed Oct 3, 2019
1 parent 2e9a282 commit 98b0ca2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Expand Up @@ -12,7 +12,7 @@ import clsx from 'clsx';
import {AuditDiff} from './audit-diff';

/**
* @param {{key?: string, group: {title: string}, selectedAuditId: string|null, setSelectedAuditId: (id: string|null) => void, pairs: Array<LHCI.AuditPair>, baseLhr?: LH.Result, variant?: 'standard'|'numeric'}} props
* @param {{key?: string, group: {id: string, title: string}, selectedAuditId: string|null, setSelectedAuditId: (id: string|null) => void, pairs: Array<LHCI.AuditPair>, baseLhr?: LH.Result, variant?: 'standard'|'numeric'}} props
*/
export const AuditGroup = props => {
const {group, pairs} = props;
Expand All @@ -24,6 +24,11 @@ export const AuditGroup = props => {
{pairs.map(pair => {
const {audit} = pair;

// Only metrics are allowed to display the numericValue diff in this view.
if (group.id !== 'metrics') {
pair = {...pair, diffs: pair.diffs.filter(diff => diff.type !== 'numericValue')};
}

return (
<div
key={audit.id}
Expand Down
6 changes: 3 additions & 3 deletions packages/server/src/ui/routes/build-view/build-view.jsx
Expand Up @@ -46,7 +46,7 @@ function computeAuditGroups(lhr, baseLhr) {
const audits = auditRefGroup
.map(ref => ({...lhr.audits[ref.id], id: ref.id}))
.sort((a, b) => (a.score || 0) - (b.score || 0));
return {id: groupId, group, audits};
return {id: groupId, group: {...group, id: groupId}, audits};
});
})
.reduce((a, b) => a.concat(b));
Expand Down Expand Up @@ -80,8 +80,8 @@ function computeAuditGroups(lhr, baseLhr) {
return auditGroups;
}

/** @typedef {{id: string, audits: Array<LH.AuditResult>, group: {title: string}}} IntermediateAuditGroupDef */
/** @typedef {{id: string, pairs: Array<LHCI.AuditPair>, group: {title: string}}} AuditGroupDef */
/** @typedef {{id: string, audits: Array<LH.AuditResult>, group: {id: string, title: string}}} IntermediateAuditGroupDef */
/** @typedef {{id: string, pairs: Array<LHCI.AuditPair>, group: {id: string, title: string}}} AuditGroupDef */

/** @param {{selectedUrl: string, setUrl(url: string): void, build: LHCI.ServerCommand.Build | null, lhr?: LH.Result, baseLhr?: LH.Result, urls: Array<string>}} props */
const BuildViewScoreAndUrl = props => {
Expand Down

0 comments on commit 98b0ca2

Please sign in to comment.