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 05541b89b..6e2040e56 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 a7542103c..e6b83f1e6 100644 --- a/client/src/app/pages/applications/applications-table/applications-table.tsx +++ b/client/src/app/pages/applications/applications-table/applications-table.tsx @@ -1082,6 +1082,7 @@ export const ApplicationsTable: React.FC = () => { name).join()} applications={selectedRows} isOpen={isAnalyzeModalOpen} onClose={() => {