@@ -5,6 +5,7 @@ import {getJson} from "../../utils/requests";
55import {STATUS_DATA_NEW_URL } from " ../../urls" ;
66import {withLoading } from " ../../utils/loading" ;
77import {formatSecondsAsDuration } from " ../../utils/formatting" ;
8+ import {useExpandedStore } from " ../../utils/expansion" ;
89import {
910 BenchmarkRequest ,
1011 BenchmarkRequestStatus ,
@@ -97,11 +98,19 @@ function formatStatus(status: BenchmarkRequestStatus): string {
9798 }
9899}
99100
100- function formatErrors(errors : Dict <string >) {
101- return Object .entries (errors ).reduce (
102- (acc , e ) => (acc += ` ${e [0 ]}: ${e [1 ]}\n ` ),
103- " "
104- );
101+ function hasErrors(errors : Dict <string >) {
102+ // This is a bit odd but if the error object has values the loop will be
103+ // hit and thus return true.
104+ for (const key in errors ) {
105+ console .log (key );
106+ return true ;
107+ }
108+ return false ;
109+ }
110+
111+ function getErrorsLength(errors : Dict <string >) {
112+ const errorsLen = Object .keys (errors ).length ;
113+ return ` ${errorsLen } ${errorsLen > 1 ? " s" : " " } ` ;
105114}
106115
107116function PullRequestLink({request }: {request: BenchmarkRequest }) {
@@ -115,6 +124,9 @@ function PullRequestLink({request}: {request: BenchmarkRequest}) {
115124 );
116125}
117126
127+ const {toggleExpanded : toggleExpandedErrors, isExpanded : hasExpandedErrors} =
128+ useExpandedStore ();
129+
118130loadStatusData (loading );
119131 </script >
120132
@@ -154,8 +166,26 @@ loadStatusData(loading);
154166 </td >
155167 <td v-html =" req.completedAt" ></td >
156168 <td v-html =" getDuration(req)" ></td >
157- <td >
158- <pre >{{ formatErrors(req.errors) }}</pre >
169+
170+ <td v-if =" hasErrors(req.errors)" >
171+ <button @click =" toggleExpandedErrors(req.tag)" >
172+ {{ hasExpandedErrors(req.tag) ? "Hide" : "Show" }}
173+ {{ getErrorsLength(req.errors) }}
174+ </button >
175+ </td >
176+ <td v-else ></td >
177+ </tr >
178+
179+ <tr v-if =" hasExpandedErrors(req.tag)" >
180+ <td colspan =" 7" style =" padding : 10px 0 " >
181+ <div v-for =" benchmark in Object.entries(req.errors)" >
182+ <div >
183+ <details open >
184+ <summary >{{ benchmark[0] }}</summary >
185+ <pre class =" error" >{{ benchmark[1] }}</pre >
186+ </details >
187+ </div >
188+ </div >
159189 </td >
160190 </tr >
161191 </template >
0 commit comments