Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Fix Divergent Branch Issue and Update Default Mode Logic #2106

Closed
Closed
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -163,7 +189,7 @@ export const AnalysisWizard: React.FC<IAnalysisWizard> = ({
const methods = useForm<AnalysisWizardFormValues>({
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
rszwajko marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1082,6 +1082,7 @@ export const ApplicationsTable: React.FC = () => {

<TaskGroupProvider>
<AnalysisWizard
key={selectedRows.map(({ name }) => name).join()}
applications={selectedRows}
isOpen={isAnalyzeModalOpen}
onClose={() => {
Expand Down
Loading