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 8de3b66adc..2b6d129681 100644 --- a/client/src/app/pages/applications/analysis-wizard/analysis-wizard.tsx +++ b/client/src/app/pages/applications/analysis-wizard/analysis-wizard.tsx @@ -41,6 +41,7 @@ import { useAsyncYupValidation } from "@app/hooks/useAsyncYupValidation"; import { CustomRules } from "./custom-rules"; import { useFetchIdentities } from "@app/queries/identities"; import { useTaskGroup } from "./components/TaskGroupContext"; +import { getParsedLabel } from "@app/utils/rules-utils"; interface IAnalysisWizard { applications: Application[]; @@ -164,6 +165,7 @@ export const AnalysisWizard: React.FC = ({ mode: "binary", formLabels: [], selectedTargets: [], + selectedSourceLabels: [], withKnownLibs: "app", includedPackages: [], excludedPackages: [], @@ -251,7 +253,16 @@ export const AnalysisWizard: React.FC = ({ labels: { included: Array.from( new Set([ - ...fieldValues.formLabels.map((label) => label.label), + ...fieldValues.formLabels + .filter( + (label) => + getParsedLabel(label.label).labelType !== "source" + ) + .map((label) => label.label) + .filter(Boolean), + ...fieldValues.selectedSourceLabels + .map((label) => label.label) + .filter(Boolean), ]) ), excluded: [], diff --git a/client/src/app/pages/applications/analysis-wizard/review.tsx b/client/src/app/pages/applications/analysis-wizard/review.tsx index 6054b6f142..61202775d2 100644 --- a/client/src/app/pages/applications/analysis-wizard/review.tsx +++ b/client/src/app/pages/applications/analysis-wizard/review.tsx @@ -43,6 +43,7 @@ export const Review: React.FC = ({ applications, mode }) => { const { watch } = useFormContext(); const { formLabels, + selectedSourceLabels, withKnownLibs, includedPackages, hasExcludedPackages, @@ -101,13 +102,13 @@ export const Review: React.FC = ({ applications, mode }) => { - {formLabels.length > 1 + {selectedSourceLabels.length > 1 ? t("wizard.terms.sources") : t("wizard.terms.source")} - {formLabels.map((label, index) => { + {selectedSourceLabels.map((label, index) => { const parsedLabel = getParsedLabel(label?.label); if (parsedLabel.labelType === "source") { return ( diff --git a/client/src/app/pages/applications/analysis-wizard/schema.ts b/client/src/app/pages/applications/analysis-wizard/schema.ts index 8498eb9224..8ce5a54094 100644 --- a/client/src/app/pages/applications/analysis-wizard/schema.ts +++ b/client/src/app/pages/applications/analysis-wizard/schema.ts @@ -158,6 +158,7 @@ export interface OptionsStepValues { diva: boolean; excludedRulesTags: string[]; autoTaggingEnabled: boolean; + selectedSourceLabels: TargetLabel[]; } const useOptionsStepSchema = (): yup.SchemaOf => { @@ -166,6 +167,12 @@ const useOptionsStepSchema = (): yup.SchemaOf => { diva: yup.bool().defined(), excludedRulesTags: yup.array().of(yup.string().defined()), autoTaggingEnabled: yup.bool().defined(), + selectedSourceLabels: yup.array().of( + yup.object().shape({ + name: yup.string().defined(), + label: yup.string().defined(), + }) + ), }); }; diff --git a/client/src/app/pages/applications/analysis-wizard/set-options.tsx b/client/src/app/pages/applications/analysis-wizard/set-options.tsx index 9db62fb7f0..c0a216570f 100644 --- a/client/src/app/pages/applications/analysis-wizard/set-options.tsx +++ b/client/src/app/pages/applications/analysis-wizard/set-options.tsx @@ -158,14 +158,14 @@ export const SetOptions: React.FC = () => { /> { - const sourceSelections = formLabels + const sourceSelections = value .map((formLabel) => { const parsedLabel = getParsedLabel(formLabel?.label); if (parsedLabel.labelType === "source") { @@ -190,17 +190,17 @@ export const SetOptions: React.FC = () => { (label) => label.label === selectionWithLabelSelector ) || ""; - const formLabelLabels = formLabels.map( + const formLabelLabels = value.map( (formLabel) => formLabel.label ); if ( matchingLabel && !formLabelLabels.includes(matchingLabel.label) ) { - onChange([...formLabels, matchingLabel]); + onChange([...value, matchingLabel]); } else { onChange( - formLabels.filter( + value.filter( (formLabel) => formLabel.label !== selectionWithLabelSelector )