@@ -27,7 +27,6 @@ import {
2727 PluginConfig ,
2828 PluginOptionType ,
2929 PreconfiguredPluginDescriptor ,
30- ReporterJobConfiguration ,
3130} from '@/api/requests' ;
3231import { PackageManagerId , packageManagers } from '@/lib/types' ;
3332
@@ -106,14 +105,21 @@ const createPluginConfigSchema = (plugin: PreconfiguredPluginDescriptor) => {
106105} ;
107106
108107export const createRunFormSchema = (
109- advisorPlugins : PreconfiguredPluginDescriptor [ ]
108+ advisorPlugins : PreconfiguredPluginDescriptor [ ] ,
109+ reporterPlugins : PreconfiguredPluginDescriptor [ ]
110110) => {
111111 const advisorConfigSchema : Record < string , z . ZodTypeAny > = { } ;
112112
113113 advisorPlugins . forEach ( ( plugin ) => {
114114 advisorConfigSchema [ plugin . id ] = createPluginConfigSchema ( plugin ) ;
115115 } ) ;
116116
117+ const reporterConfigSchema : Record < string , z . ZodTypeAny > = { } ;
118+
119+ reporterPlugins . forEach ( ( plugin ) => {
120+ reporterConfigSchema [ plugin . id ] = createPluginConfigSchema ( plugin ) ;
121+ } ) ;
122+
117123 return z . object ( {
118124 revision : z . string ( ) ,
119125 path : z . string ( ) ,
@@ -178,7 +184,7 @@ export const createRunFormSchema = (
178184 reporter : z . object ( {
179185 enabled : z . boolean ( ) ,
180186 formats : z . array ( z . string ( ) ) ,
181- deduplicateDependencyTree : z . boolean ( ) . optional ( ) ,
187+ config : z . object ( reporterConfigSchema ) . optional ( ) ,
182188 } ) ,
183189 notifier : z . object ( {
184190 enabled : z . boolean ( ) ,
@@ -342,7 +348,8 @@ function getPluginDefaultValues(plugins: PreconfiguredPluginDescriptor[]) {
342348 */
343349export function defaultValues (
344350 ortRun : OrtRun | null ,
345- advisorPlugins : PreconfiguredPluginDescriptor [ ]
351+ advisorPlugins : PreconfiguredPluginDescriptor [ ] ,
352+ reporterPlugins : PreconfiguredPluginDescriptor [ ]
346353) : z . infer < ReturnType < typeof createRunFormSchema > > {
347354 /**
348355 * Constructs the default options for a package manager, either as a blank set of options
@@ -380,17 +387,8 @@ export function defaultValues(
380387 } ;
381388 } ;
382389
383- // Find out if any of the reporters had their options.deduplicateDependencyTree set to true in the previous run.
384- // This is used to set the default value for the deduplicateDependencyTree toggle in the UI.
385- const deduplicateDependencyTreeEnabled = ortRun
386- ? ortRun . jobConfigs . reporter ?. config &&
387- Object . keys ( ortRun . jobConfigs . reporter . config ?? { } ) . some ( ( key ) => {
388- const config = ortRun . jobConfigs . reporter ?. config ?. [ key ] ;
389- return config ?. options ?. deduplicateDependencyTree === 'true' ;
390- } )
391- : false ;
392-
393390 const advisorPluginDefaultValues = getPluginDefaultValues ( advisorPlugins ) ;
391+ const reporterPluginDefaultValues = getPluginDefaultValues ( reporterPlugins ) ;
394392
395393 // Default values for the form: edit only these, not the defaultValues object.
396394 const baseDefaults = {
@@ -452,6 +450,7 @@ export function defaultValues(
452450 enabled : true ,
453451 formats : [ 'CycloneDX' , 'SpdxDocument' , 'WebApp' ] ,
454452 deduplicateDependencyTree : false ,
453+ config : reporterPluginDefaultValues ,
455454 } ,
456455 notifier : {
457456 enabled : false ,
@@ -530,8 +529,10 @@ export function defaultValues(
530529 ortRun . jobConfigs . reporter ?. formats ?. map ( ( format ) =>
531530 format === 'CycloneDx' ? 'CycloneDX' : format
532531 ) || baseDefaults . jobConfigs . reporter . formats ,
533- deduplicateDependencyTree :
534- deduplicateDependencyTreeEnabled || undefined ,
532+ config : mergePluginConfigs (
533+ ortRun ?. jobConfigs ?. reporter ?. config ,
534+ reporterPluginDefaultValues
535+ ) ,
535536 } ,
536537 notifier : {
537538 enabled :
@@ -752,61 +753,13 @@ export function formValuesToPayload(
752753 // Reporter configuration
753754 //
754755
755- // Check if CycloneDX, SPDX, and/or NOTICE file reports are enabled in the form,
756- // and configure them to use all output formats, accordingly.
757-
758- const cycloneDxEnabled =
759- values . jobConfigs . reporter . formats . includes ( 'CycloneDX' ) ;
760- const spdxDocumentEnabled =
761- values . jobConfigs . reporter . formats . includes ( 'SpdxDocument' ) ;
762- const noticeFileEnabled =
763- values . jobConfigs . reporter . formats . includes ( 'PlainTextTemplate' ) ;
764-
765- const config : ReporterJobConfiguration [ 'config' ] = { } ;
766-
767- if ( spdxDocumentEnabled ) {
768- config . SpdxDocument = {
769- options : {
770- outputFileFormats : 'YAML,JSON' ,
771- } ,
772- secrets : { } ,
773- } ;
774- }
775-
776- if ( cycloneDxEnabled ) {
777- config . CycloneDX = {
778- options : {
779- outputFileFormats : 'XML,JSON' ,
780- } ,
781- secrets : { } ,
782- } ;
783- }
784-
785- if ( noticeFileEnabled ) {
786- config . PlainTextTemplate = {
787- options : {
788- templateIds : 'NOTICE_DEFAULT,NOTICE_SUMMARY' ,
789- } ,
790- secrets : { } ,
791- } ;
792- }
793-
794- // If WebApp and the deduplicateDependencyTree option are enabled, add the configuration.
795-
796- const webAppEnabled = values . jobConfigs . reporter . formats . includes ( 'WebApp' ) ;
797- if ( webAppEnabled && values . jobConfigs . reporter . deduplicateDependencyTree ) {
798- config . WebApp = {
799- options : {
800- deduplicateDependencyTree : 'true' ,
801- } ,
802- secrets : { } ,
803- } ;
804- }
805-
806756 const reporterConfig = values . jobConfigs . reporter . enabled
807757 ? {
808758 formats : values . jobConfigs . reporter . formats ,
809- config : Object . keys ( config ) . length > 0 ? config : undefined ,
759+ config : createPluginPayload (
760+ values . jobConfigs . reporter . config ,
761+ values . jobConfigs . reporter . formats
762+ ) ,
810763 }
811764 : undefined ;
812765
0 commit comments