@@ -167,14 +167,38 @@ export const ProblemsTable = ({
167167
168168 const processedReports = [ ] ;
169169 for ( const topLevel of Object . keys ( expandableReports ) ) {
170- let processedReport : ExpandableFileReport = {
171- [ expandableColumn as keyof Report ] : `${ topLevel } (${ expandableReports [ topLevel ] . length } )` ,
172- subRows : expandableReports [ topLevel ] ,
173- } ;
170+ const groupRows = expandableReports [ topLevel ] ;
171+
174172 if ( isFileTable ) {
175- processedReport = { ...processedReport , ...fileDataHash [ topLevel ] } ;
173+ const fileId = topLevel ;
174+ const fileInfo = fileDataHash [ fileId ] ;
175+ const fileName = fileInfo ?. fileName ?? getFileNameFromId ( fileId ) ?? fileId ;
176+
177+ // Compute highest severity among file issues as file can have Error, Warning and Info.
178+ const severityOrder : Report [ 'level' ] [ ] = [ 'Fatal' , 'Error' , 'Critical' , 'Warning' , 'Info' ] ;
179+ const highestSeverityLevel = groupRows . reduce < Report [ 'level' ] | undefined > ( ( currentSeverityLevel , row ) => {
180+ if ( ! row . level ) return currentSeverityLevel ;
181+ if ( ! currentSeverityLevel ) return row . level ;
182+ const currentIndex = severityOrder . indexOf ( currentSeverityLevel ) ;
183+ const newIndex = severityOrder . indexOf ( row . level ) ;
184+ return newIndex !== - 1 && ( currentIndex === - 1 || newIndex < currentIndex )
185+ ? row . level
186+ : currentSeverityLevel ;
187+ } , undefined ) ;
188+
189+ processedReports . push ( {
190+ ...( fileInfo ?? ( { } as SourceFile ) ) ,
191+ fileId,
192+ fileName,
193+ level : highestSeverityLevel ,
194+ subRows : groupRows ,
195+ } ) ;
196+ } else {
197+ processedReports . push ( {
198+ [ expandableColumn as keyof Report ] : `${ topLevel } (${ groupRows . length } )` ,
199+ subRows : groupRows ,
200+ } as ExpandableFileReport ) ;
176201 }
177- processedReports . push ( processedReport ) ;
178202 }
179203
180204 if ( isFileTable ) {
@@ -444,29 +468,28 @@ export const ProblemsTable = ({
444468 status ?: Status ;
445469 className ?: string ;
446470 } => {
447- if ( context ?. currentTable === TableTypeNames . Problems ) {
448- const isActiveRow = id === context ?. activeRow ;
449- let statusConverted = undefined ;
450-
471+ const getStatusFromLevel = ( level ?: Report [ 'level' ] ) : Status | undefined => {
451472 switch ( level ) {
452473 case 'Critical' :
453474 case 'Error' :
454475 case 'Fatal' :
455- statusConverted = 'negative' ;
456- break ;
476+ return 'negative' ;
457477 case 'Warning' :
458- statusConverted = 'warning' ;
459- break ;
478+ return 'warning' ;
460479 default :
461480 break ;
462481 }
463-
482+ } ;
483+ if ( context ?. currentTable === TableTypeNames . Problems ) {
484+ const isActiveRow = id === context ?. activeRow ;
464485 return {
465- status : statusConverted as Status ,
486+ status : getStatusFromLevel ( level ) ,
466487 className : `isr-table-row table-row__${ isActiveRow ? 'active' : 'inactive' } ` ,
467488 } ;
468489 } else if ( context ?. currentTable === TableTypeNames . Files ) {
469- return ! fileExists ? { status : 'negative' } : { } ;
490+ return {
491+ status : getStatusFromLevel ( level ) ,
492+ } ;
470493 }
471494
472495 return { status : undefined } ;
0 commit comments