@@ -251,11 +251,13 @@ export class ReportViewerProvider implements vscode.TreeDataProvider<LogItem>, v
251
251
}
252
252
} else if ( fs . lstatSync ( filePath ) . isFile ( ) ) {
253
253
const title = this . parseReportTitle ( filePath ) ;
254
- items . push ( new LogItem ( title , vscode . TreeItemCollapsibleState . None , {
254
+ const logFile = new LogItem ( title , vscode . TreeItemCollapsibleState . None , {
255
255
command : 'magento-log-viewer.openFile' ,
256
256
title : 'Open Log File' ,
257
257
arguments : [ filePath ]
258
- } ) ) ;
258
+ } ) ;
259
+ logFile . iconPath = this . getIconForReport ( filePath ) ;
260
+ items . push ( logFile ) ;
259
261
}
260
262
} ) ;
261
263
@@ -268,7 +270,9 @@ export class ReportViewerProvider implements vscode.TreeDataProvider<LogItem>, v
268
270
const report = JSON . parse ( fileContent ) ;
269
271
270
272
if ( filePath . includes ( '/api/' ) ) {
271
- return report ;
273
+ const folderName = path . basename ( path . dirname ( filePath ) ) ;
274
+ const capitalizedFolderName = folderName . charAt ( 0 ) . toUpperCase ( ) + folderName . slice ( 1 ) ;
275
+ return `${ capitalizedFolderName } : ${ report } ` ;
272
276
}
273
277
274
278
return report [ '0' ] || path . basename ( filePath ) ;
@@ -277,6 +281,25 @@ export class ReportViewerProvider implements vscode.TreeDataProvider<LogItem>, v
277
281
}
278
282
}
279
283
284
+ private getIconForReport ( filePath : string ) : vscode . ThemeIcon {
285
+ try {
286
+ const fileContent = fs . readFileSync ( filePath , 'utf-8' ) ;
287
+ const report = JSON . parse ( fileContent ) ;
288
+
289
+ if ( filePath . includes ( '/api/' ) ) {
290
+ return new vscode . ThemeIcon ( 'warning' ) ;
291
+ }
292
+
293
+ if ( report [ '0' ] && report [ '0' ] . toLowerCase ( ) . includes ( 'error' ) ) {
294
+ return new vscode . ThemeIcon ( 'error' ) ;
295
+ }
296
+
297
+ return new vscode . ThemeIcon ( 'file' ) ;
298
+ } catch ( error ) {
299
+ return new vscode . ThemeIcon ( 'file' ) ;
300
+ }
301
+ }
302
+
280
303
getLogFilesWithoutUpdatingBadge ( dir : string ) : LogItem [ ] {
281
304
if ( pathExists ( dir ) ) {
282
305
const files = fs . readdirSync ( dir ) ;
@@ -307,15 +330,14 @@ export class LogItem extends vscode.TreeItem {
307
330
public readonly label : string ,
308
331
public readonly collapsibleState : vscode . TreeItemCollapsibleState ,
309
332
public readonly command ?: vscode . Command ,
310
- public children ?: LogItem [ ]
333
+ public children ?: LogItem [ ] ,
334
+ public iconPath ?: vscode . ThemeIcon
311
335
) {
312
336
super ( label , collapsibleState as vscode . TreeItemCollapsibleState ) ;
313
337
this . description = this . label . match ( / \( \d + \) / ) ?. [ 0 ] || '' ;
314
338
this . label = this . label . replace ( / \( \d + \) / , '' ) . trim ( ) ;
315
339
}
316
340
317
- iconPath = new vscode . ThemeIcon ( 'list' ) ;
318
-
319
341
contextValue = 'logItem' ;
320
342
description = '' ;
321
343
}
0 commit comments