From c2096ec17bdc8224bd49a08fb5280810cafc67b2 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Wed, 26 Feb 2020 10:56:32 -0800 Subject: [PATCH] Custom columns when grouping by Age. --- components/RunCard.renderCell.tsx | 6 ++++ components/RunStore.ts | 53 +++++++++++++++++++++---------- 2 files changed, 42 insertions(+), 17 deletions(-) diff --git a/components/RunCard.renderCell.tsx b/components/RunCard.renderCell.tsx index e039d68..a3f29cc 100644 --- a/components/RunCard.renderCell.tsx +++ b/components/RunCard.renderCell.tsx @@ -153,6 +153,7 @@ export function renderCell( }) : TableCell({ // Don't want SimpleTableCell as it has flex row. children: (() => { + const rule = result._rule switch (treeColumn.id) { case 'Details': return <> @@ -161,6 +162,11 @@ export function renderCell( : {renderMessageWithEmbeddedLinks(result)} || ''} {tryOr(() => )} + case 'Rule': + return <> + {tryLink(() => rule.helpUri, {rule.id || rule.guid})} + {tryOr(() => rule.name && <>: {rule.name})} + case 'Baseline': return {result.baselineState && capitalize(result.baselineState) || 'New'} case 'Bug': diff --git a/components/RunStore.ts b/components/RunStore.ts index cffce92..3ad0c19 100644 --- a/components/RunStore.ts +++ b/components/RunStore.ts @@ -209,24 +209,40 @@ export class RunStore { ), width: -3, }, - { - id: 'Details', - filterString: (result: Result) => { - const message = tryOr( - () => result.message.markdown, - () => result.message.text, // Can be a constant? - '') - const snippet = tryOr( - () => result.locations[0].physicalLocation.contextRegion.snippet.text, - () => result.locations[0].physicalLocation.region.snippet.text, - '') - return `${message} ${snippet}` - }, - sortString: (result: Result) => result.message.text as string || '', - width: -5, - }, ] + if (this.showAge && this.groupByAge.get()) { + columns.push({ + id: 'Rule', + filterString: (result: Result) => { + const rule = result._rule + return `${rule.id || rule.guid} ${rule.name ?? ''}` + }, + sortString: (result: Result) => { + const rule = result._rule + return `${rule.id || rule.guid} ${rule.name ?? ''}` + }, + width: -2, + }) + } + + columns.push({ + id: 'Details', + filterString: (result: Result) => { + const message = tryOr( + () => result.message.markdown, + () => result.message.text, // Can be a constant? + '') + const snippet = tryOr( + () => result.locations[0].physicalLocation.contextRegion.snippet.text, + () => result.locations[0].physicalLocation.region.snippet.text, + '') + return `${message} ${snippet}` + }, + sortString: (result: Result) => result.message.text as string || '', + width: -5, + }) + if (!this.hideBaseline) { columns.push({ id: 'Baseline', @@ -246,13 +262,16 @@ export class RunStore { }) } - if (this.showAge) { + if (this.showAge && !this.groupByAge.get()) { columns.push({ id: 'Age', filterString: (result: Result) => result.sla, sortString: (result: Result) => result.sla, width: -1, }) + } + + if (this.showAge) { columns.push({ id: 'First Observed', // Consider using name instead of id filterString: (result: Result) => result.firstDetection.toLocaleDateString(),