diff --git a/client/src/app/pages/applications/analysis-wizard/analysis-wizard.tsx b/client/src/app/pages/applications/analysis-wizard/analysis-wizard.tsx index 05541b89b1..6e2040e566 100644 --- a/client/src/app/pages/applications/analysis-wizard/analysis-wizard.tsx +++ b/client/src/app/pages/applications/analysis-wizard/analysis-wizard.tsx @@ -51,6 +51,32 @@ interface IAnalysisWizard { isOpen: boolean; } +const determineMode = ( + applications: Application[] +): + | "binary" + | "source-code-deps" + | "source-code" + | "binary-upload" + | undefined => { + if (applications.length === 0) return undefined; + + const modes = Array.from( + new Set( + applications.map((app) => { + const { repository, binary } = app; + return repository || (repository && binary) + ? "source-code-deps" + : binary && binary !== "" + ? "binary" + : undefined; + }) + ) + ); + + return modes.length === 1 ? modes[0] : undefined; +}; + const defaultTaskData: TaskData = { tagger: { enabled: true, @@ -163,7 +189,7 @@ export const AnalysisWizard: React.FC = ({ const methods = useForm({ defaultValues: { artifact: null, - mode: "source-code-deps", + mode: determineMode(applications) ?? "source-code-deps", formLabels: [], selectedTargets: [], // defaults will be passed as initialFilterValues to the table hook diff --git a/client/src/app/pages/applications/applications-table/applications-table.tsx b/client/src/app/pages/applications/applications-table/applications-table.tsx index d102d69a2a..d4affbb41c 100644 --- a/client/src/app/pages/applications/applications-table/applications-table.tsx +++ b/client/src/app/pages/applications/applications-table/applications-table.tsx @@ -1060,6 +1060,7 @@ export const ApplicationsTable: React.FC = () => { name).join()} applications={selectedRows} isOpen={isAnalyzeModalOpen} onClose={() => {