Skip to content

Commit

Permalink
finish write the default mode logic
Browse files Browse the repository at this point in the history
  • Loading branch information
shirael committed Dec 11, 2024
1 parent f4179ef commit 5d12dd6
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,22 @@ const determineMode = (
| "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,
Expand Down Expand Up @@ -173,7 +188,7 @@ export const AnalysisWizard: React.FC<IAnalysisWizard> = ({
const methods = useForm<AnalysisWizardFormValues>({
defaultValues: {
artifact: null,
mode: determineMode(applications),
mode: determineMode(applications) ?? "source-code-deps",
formLabels: [],
selectedTargets: [],
// defaults will be passed as initialFilterValues to the table hook
Expand Down

0 comments on commit 5d12dd6

Please sign in to comment.