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

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,28 @@ 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 = applications.map((app) => {
const { repository, binary } = app;
return repository || (repository && binary)
? "source-code-deps"
: binary && binary !== ""
? "binary"
: undefined;
});
const firstMode = modes[0];
rszwajko marked this conversation as resolved.
Show resolved Hide resolved
const allSame = modes.every((mode) => mode === firstMode);
return allSame ? firstMode : undefined;
};

const defaultTaskData: TaskData = {
tagger: {
enabled: true,
Expand Down Expand Up @@ -163,7 +185,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 @@ -1060,6 +1060,7 @@ export const ApplicationsTable: React.FC = () => {

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