@@ -26,7 +26,7 @@ export class OSAssessmentReporter {
2626 org : getOrgDetailsForReport ( omnistudioOrgDetails ) ,
2727 assessmentDate : new Date ( ) . toString ( ) ,
2828 total : OSAssessmentInfos ?. length || 0 ,
29- filterGroups : this . getFilterGroupsForReport ( ) ,
29+ filterGroups : this . getFilterGroupsForReport ( OSAssessmentInfos ) ,
3030 headerGroups : this . getHeaderGroupsForReport ( ) ,
3131 rows : this . getRowsForReport ( OSAssessmentInfos , instanceUrl ) ,
3232 rollbackFlags : ( omnistudioOrgDetails . rollbackFlags || [ ] ) . includes ( 'RollbackOSChanges' )
@@ -67,11 +67,31 @@ export class OSAssessmentReporter {
6767 return OSAssessmentInfos . map ( ( info ) => ( {
6868 rowId : `${ this . rowIdPrefix } ${ this . rowId ++ } ` ,
6969 data : [
70- createRowDataParam ( 'name' , info . oldName , true , 1 , 1 , false ) ,
70+ createRowDataParam (
71+ 'name' ,
72+ info . oldName ,
73+ true ,
74+ 1 ,
75+ 1 ,
76+ false ,
77+ undefined ,
78+ undefined ,
79+ info . migrationStatus !== 'Can be Automated' ? 'invalid-icon' : ''
80+ ) ,
7181 createRowDataParam ( 'recordId' , info . id , false , 1 , 1 , true , `${ instanceUrl } /${ info . id } ` ) ,
7282 createRowDataParam ( 'newName' , info . name || '' , false , 1 , 1 , false ) ,
7383 createRowDataParam ( 'type' , info . type , false , 1 , 1 , false ) ,
74- createRowDataParam ( 'status' , info . migrationStatus , false , 1 , 1 , false ) ,
84+ createRowDataParam (
85+ 'status' ,
86+ info . migrationStatus ,
87+ false ,
88+ 1 ,
89+ 1 ,
90+ false ,
91+ undefined ,
92+ undefined ,
93+ info . migrationStatus === 'Can be Automated' ? 'text-success' : 'text-error'
94+ ) ,
7595 createRowDataParam (
7696 'summary' ,
7797 info . warnings ? info . warnings . join ( ', ' ) : '' ,
@@ -216,10 +236,23 @@ export class OSAssessmentReporter {
216236 ] ;
217237 }
218238
219- private static getFilterGroupsForReport ( ) : FilterGroupParam [ ] {
220- return [
221- createFilterGroupParam ( 'Filter By Type' , 'type' , [ 'LWC' , 'Angular' ] ) ,
222- createFilterGroupParam ( 'Filter By Assessment Status' , 'status' , [ 'Can be Automated' , 'Need Manual Intervention' ] ) ,
223- ] ;
239+ private static getFilterGroupsForReport ( OSAssessmentInfos : OSAssessmentInfo [ ] ) : FilterGroupParam [ ] {
240+ if ( ! OSAssessmentInfos || OSAssessmentInfos . length === 0 ) {
241+ return [ ] ;
242+ }
243+
244+ // Get distinct types from OSAssessmentInfos
245+ const distinctTypes = [ ...new Set ( OSAssessmentInfos . map ( ( info ) => info . type ) ) ] ;
246+ const typeFilterGroupParam : FilterGroupParam [ ] =
247+ distinctTypes . length > 0 && distinctTypes . filter ( ( type ) => type ) . length > 0
248+ ? [ createFilterGroupParam ( 'Filter By Type' , 'type' , distinctTypes ) ]
249+ : [ ] ;
250+ const distinctStatuses = [ ...new Set ( OSAssessmentInfos . map ( ( info ) => info . migrationStatus ) ) ] ;
251+ const statusFilterGroupParam : FilterGroupParam [ ] =
252+ distinctStatuses . length > 0 && distinctStatuses . filter ( ( status ) => status ) . length > 0
253+ ? [ createFilterGroupParam ( 'Filter By Assessment Status' , 'status' , distinctStatuses ) ]
254+ : [ ] ;
255+
256+ return [ ...typeFilterGroupParam , ...statusFilterGroupParam ] ;
224257 }
225258}
0 commit comments