Skip to content

Commit

Permalink
🐛 Allow wizard to proceed with an empty custom target (#1649)
Browse files Browse the repository at this point in the history
- Update custom rules step validation to allow custom targets with no
labels when using rules from a repo.

Signed-off-by: ibolton336 <ibolton@redhat.com>
  • Loading branch information
ibolton336 authored Jan 3, 2024
1 parent d5c186a commit b21de21
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ export const CustomRules: React.FC = () => {
</Title>
<Text> {t("wizard.label.customRules")}</Text>
</TextContent>
{values.formLabels.length === 0 &&
{values.selectedTargets.length === 0 &&
values.customRulesFiles.length === 0 &&
!values.sourceRepository && (
<Alert
Expand Down
12 changes: 8 additions & 4 deletions client/src/app/pages/applications/analysis-wizard/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,14 @@ const useCustomRulesStepSchema = (): yup.SchemaOf<CustomRulesStepValues> => {
then: yup.array().of(customRulesFilesSchema),
otherwise: (schema) => schema,
})
.when(["formLabels", "rulesKind"], {
is: (labels: TargetLabel[], rulesKind: string) =>
labels.length === 0 && rulesKind === "manual",
then: (schema) => schema.min(1, "At least 1 Rule File is required"), // TODO translation here
.when(["formLabels", "rulesKind", "selectedTargets"], {
is: (
labels: TargetLabel[],
rulesKind: string,
selectedTargets: number
) =>
labels.length === 0 && rulesKind === "manual" && selectedTargets <= 0,
then: (schema) => schema.min(1, "At least 1 Rule File is required"),
}),
repositoryType: yup.mixed<string>().when("rulesKind", {
is: "repository",
Expand Down

0 comments on commit b21de21

Please sign in to comment.