-
Notifications
You must be signed in to change notification settings - Fork 51
🐛 Update Cloud Foundry discover applications filter #2718
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
Conversation
Resolves: https://issues.redhat.com/browse/MTA-6326 Resolves: konveyor#2709 CloudFoundry schema update: konveyor/operator#484 Update the discover application wizard CloudFoundry source platform filter input and review to support organizations, spaces, and names. Added the ability to validate that two JSON schemas are functionally equivalent. This is used to validate that the Cloud Foundry schema is functionally equivalent to the schema used to build the Cloud Foundry forms. If a source platform is kind of "cloudfoundry", and the filter schema pulled from hub is functionally equivalent to the schema the components are based on, then show the custom components. If the schema is not equivalent, then show the generic schema defined fields components. This will most likely give the user a code editor to input a json document to define the filter. Signed-off-by: Scott J Dickerson <[email protected]>
Signed-off-by: Scott J Dickerson <[email protected]>
WalkthroughAdds Cloud Foundry organization filtering to the Discover Applications wizard, introduces a Cloud Foundry schema validator and hook, moves JSON Schema utilities to a centralized module with tests, and updates imports, dependencies, and Jest handling for Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant FilterInput as FilterInput (filter-input.tsx)
participant CFCheck as useCloudFoundryCheck
participant CFValidator as validate-cloudfoundry-schema
participant CFFilter as FilterInputCloudFoundry
participant Generic as SchemaDefinedField
User->>FilterInput: Render filter component
FilterInput->>CFCheck: shouldUseCloudFoundryInput(platform, schema)
CFCheck->>CFValidator: validate schema against CF spec
CFValidator-->>CFCheck: valid / invalid
alt Cloud Foundry schema valid
CFCheck-->>FilterInput: true
FilterInput->>CFFilter: Render CF form (organizations → spaces → names)
CFFilter->>User: Show CF-specific inputs
else not CF or schema invalid
CFCheck-->>FilterInput: false
FilterInput->>Generic: Render generic SchemaDefinedField
Generic->>User: Show generic schema-based editor
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🧰 Additional context used🧠 Learnings (3)📓 Common learnings📚 Learning: 2025-08-13T08:52:51.365ZApplied to files:
📚 Learning: 2025-11-07T22:56:18.566ZApplied to files:
🧬 Code graph analysis (2)client/src/app/components/discover-import-wizard/filter-input.tsx (1)
client/src/app/components/discover-import-wizard/review.tsx (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
🔇 Additional comments (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
client/src/app/components/discover-import-wizard/filter-input-cloudfoundry.tsx (1)
92-178: Enforce the “one or more organizations” rule in the formRight now the resolver lets the organizations array stay empty, so users can advance with no organizations even though the Cloud Foundry discovery contract requires at least one. That will either make the schema comparison fail (after you add
minItems: 1) or produce an invalid payload. Please enforce the minimum in the Yup schema (and mark the group as required so the UI reflects it).const validationSchema = yup.object().shape({ - organizations: yup.array().of( - yup.object().shape({ - value: yup - .string() - .min(1, "Organization name must be at least 1 character") - .trim(), - }) - ), + organizations: yup + .array() + .min(1, "Add at least one organization") + .of( + yup.object().shape({ + value: yup + .string() + .min(1, "Organization name must be at least 1 character") + .trim(), + }) + ),<StringFieldsGroup control={form.control} groupTitle="Organizations" groupDescription="Enter organization name" fieldName="organizations" addLabel="Add an organization" removeLabel="Remove this organization" emptyMessage="No organizations specified" - isRequired={false} + isRequired />
🧹 Nitpick comments (3)
client/src/app/components/discover-import-wizard/filter-input.tsx (1)
110-113: Consider renaming the boolean variable.The variable
useCloudFoundryFilterInputhas auseprefix which conventionally indicates a React hook, but it's actually a boolean value computed fromuseCloudFoundryCheck(). Consider renaming it to something likeshouldUseCloudFoundryFilterInputorisCloudFoundryFilterInputfor clarity.Apply this diff to improve naming:
- const useCloudFoundryFilterInput = useCloudFoundryCheck( + const shouldUseCloudFoundryFilterInput = useCloudFoundryCheck( platform, filtersSchema );And update the usage on line 149:
- useCloudFoundryFilterInput ? ( + shouldUseCloudFoundryFilterInput ? (client/src/app/components/discover-import-wizard/review.tsx (1)
31-31: Consider renaming the boolean variable.Similar to the filter input component,
useCloudFoundryReviewhas auseprefix suggesting it's a hook, but it's actually a boolean. Consider renaming toshouldUseCloudFoundryRevieworisCloudFoundryReviewfor clarity.Apply this diff:
- const useCloudFoundryReview = useCloudFoundryCheck(platform, filters.schema); + const shouldUseCloudFoundryReview = useCloudFoundryCheck(platform, filters.schema);And update line 88:
- {useCloudFoundryReview ? ( + {shouldUseCloudFoundryReview ? (client/src/app/components/discover-import-wizard/review-input-cloudfoundry.tsx (1)
35-78: Consider extracting the repeated pattern into a helper component.All three sections (Organizations, Spaces, Names) follow an identical structure. Extracting this pattern would reduce duplication and improve maintainability.
Example refactor:
const FilterListGroup: React.FC<{ label: string; items: string[]; emptyMessage: string; }> = ({ label, items, emptyMessage }) => ( <DescriptionListGroup> <DescriptionListTerm>{label}</DescriptionListTerm> <DescriptionListDescription> {items.length === 0 ? ( <EmptyTextMessage message={emptyMessage} /> ) : ( <List isPlain> {items.map((item) => ( <ListItem key={item}>{item}</ListItem> ))} </List> )} </DescriptionListDescription> </DescriptionListGroup> );Then use it in the render:
return ( <DescriptionList isHorizontal isCompact id={id}> <FilterListGroup label="Organizations" items={organizations} emptyMessage="No organizations specified" /> <FilterListGroup label="Spaces" items={spaces} emptyMessage="No spaces specified" /> <FilterListGroup label="Names" items={names} emptyMessage="No names specified" /> </DescriptionList> );
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (13)
client/config/jest.config.ts(1 hunks)client/package.json(3 hunks)client/src/app/components/discover-import-wizard/filter-input-cloudfoundry.tsx(5 hunks)client/src/app/components/discover-import-wizard/filter-input.tsx(3 hunks)client/src/app/components/discover-import-wizard/review-input-cloudfoundry.tsx(2 hunks)client/src/app/components/discover-import-wizard/review.tsx(3 hunks)client/src/app/components/discover-import-wizard/validate-cloudfoundry-schema.tsx(1 hunks)client/src/app/components/schema-defined-fields/utils.test.tsx(1 hunks)client/src/app/components/schema-defined-fields/utils.tsx(0 hunks)client/src/app/pages/applications/generate-assets-wizard/step-capture-parameters.tsx(1 hunks)client/src/app/utils/json-schema.test.ts(1 hunks)client/src/app/utils/json-schema.ts(1 hunks)cspell.json(1 hunks)
💤 Files with no reviewable changes (1)
- client/src/app/components/schema-defined-fields/utils.tsx
🧰 Additional context used
🧠 Learnings (5)
📚 Learning: 2025-10-17T17:03:52.480Z
Learnt from: sjd78
Repo: konveyor/tackle2-ui PR: 2656
File: .prettierignore:9-18
Timestamp: 2025-10-17T17:03:52.480Z
Learning: The tackle2-ui project uses a specific formatting setup: ESLint (with eslint-plugin-prettier) handles all JavaScript/TypeScript code files, while standalone Prettier handles non-code files. The .prettierignore file intentionally excludes **/*.js, **/*.ts, etc. to prevent duplicate formatting runs, as ESLint internally applies Prettier to code files.
Applied to files:
client/config/jest.config.ts
📚 Learning: 2025-07-17T23:29:20.652Z
Learnt from: sjd78
Repo: konveyor/tackle2-ui PR: 2432
File: client/src/app/components/schema-defined-fields/utils.tsx:42-47
Timestamp: 2025-07-17T23:29:20.652Z
Learning: In the tackle2-ui codebase, when using yup.lazy for optional object validation, the correct TypeScript typing is `ReturnType<typeof yup.lazy<yup.AnySchema>>` instead of passing the generic type parameter directly to yup.lazy, due to the specific version of yup being used.
Applied to files:
client/src/app/components/schema-defined-fields/utils.test.tsxclient/src/app/pages/applications/generate-assets-wizard/step-capture-parameters.tsx
📚 Learning: 2025-10-09T06:42:54.063Z
Learnt from: sjd78
Repo: konveyor/tackle2-ui PR: 2660
File: client/src/app/components/repository-fields/schema.ts:72-99
Timestamp: 2025-10-09T06:42:54.063Z
Learning: In the tackle2-ui repository, prefer the `when, is, then` style for Yup schemas (e.g., `.when(["field"], { is: ..., then: ... })`). Ignore Biome's `noThenProperty` warning in these circumstances.
Applied to files:
client/src/app/components/schema-defined-fields/utils.test.tsx
📚 Learning: 2025-08-13T08:52:51.365Z
Learnt from: sjd78
Repo: konveyor/tackle2-ui PR: 2545
File: client/src/app/pages/source-platforms/discover-import-wizard/review.tsx:22-24
Timestamp: 2025-08-13T08:52:51.365Z
Learning: In the platform discovery import wizard, users can only provide filter documents when filterRequired is true. When filterRequired is false, no schema is available and the FilterInput component shows a "no filters available" message without rendering input fields. Therefore, filters.document will only exist when filters.filterRequired is true.
Applied to files:
client/src/app/components/discover-import-wizard/review.tsxclient/src/app/components/discover-import-wizard/filter-input.tsxclient/src/app/components/discover-import-wizard/filter-input-cloudfoundry.tsx
📚 Learning: 2025-08-15T22:35:55.912Z
Learnt from: sjd78
Repo: konveyor/tackle2-ui PR: 2558
File: client/src/app/pages/applications/generate-assets-wizard/generate-assets-wizard.tsx:0-0
Timestamp: 2025-08-15T22:35:55.912Z
Learning: The Generate Assets Wizard in client/src/app/pages/applications/generate-assets-wizard/generate-assets-wizard.tsx is designed to accommodate additional wizard steps in the future, so the current conditional rendering of the Results step is intentional and appropriate for the planned architecture.
Applied to files:
client/src/app/pages/applications/generate-assets-wizard/step-capture-parameters.tsx
🧬 Code graph analysis (6)
client/src/app/components/discover-import-wizard/review.tsx (1)
client/src/app/components/discover-import-wizard/validate-cloudfoundry-schema.tsx (1)
useCloudFoundryCheck(50-61)
client/src/app/utils/json-schema.test.ts (2)
client/src/app/utils/json-schema.ts (4)
stripAnnotations(80-103)combineSchemas(26-55)isEquivalentSchema(109-120)validatorGenerator(126-132)client/src/app/api/models.ts (1)
JsonSchemaObject(1008-1049)
client/src/app/components/discover-import-wizard/filter-input.tsx (1)
client/src/app/components/discover-import-wizard/validate-cloudfoundry-schema.tsx (1)
useCloudFoundryCheck(50-61)
client/src/app/components/discover-import-wizard/validate-cloudfoundry-schema.tsx (2)
client/src/app/api/models.ts (3)
JsonSchemaObject(1008-1049)SourcePlatform(984-993)TargetedSchema(1062-1065)client/src/app/utils/json-schema.ts (1)
validatorGenerator(126-132)
client/src/app/utils/json-schema.ts (1)
client/src/app/api/models.ts (1)
JsonSchemaObject(1008-1049)
client/src/app/components/discover-import-wizard/review-input-cloudfoundry.tsx (1)
client/src/app/components/EmptyTextMessage.tsx (1)
EmptyTextMessage(9-19)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: unit-test
- GitHub Check: test-image-build (amd64)
- GitHub Check: test-image-build (arm64)
- GitHub Check: build-and-upload-for-global-ci
🔇 Additional comments (8)
cspell.json (1)
5-5: LGTM - Spell-check dictionary updated.The addition of "cloudfoundry" to the dictionary aligns with the Cloud Foundry feature additions throughout the PR.
client/config/jest.config.ts (1)
47-49: LGTM - Jest configuration updated for lodash-es.The addition of
lodash-estotransformIgnorePatternscorrectly ensures the ESM module is processed by ts-jest, aligning with the new dependency added in package.json.client/package.json (1)
47-47: LGTM - Dependency management improvements.The changes correctly:
- Add
lodash-esas a runtime dependency with appropriate typing support- Move
jesttodevDependencieswhere it belongs (test-time only)Also applies to: 72-72, 85-85
client/src/app/components/schema-defined-fields/utils.test.tsx (1)
3-3: LGTM - Import updated to reflect refactored utilities.The import statement correctly reflects that
combineSchemaswas moved to@app/utils/json-schema, while the remaining functions stay in this module.client/src/app/pages/applications/generate-assets-wizard/step-capture-parameters.tsx (1)
20-22: LGTM - Imports reorganized to use centralized utilities.The import paths correctly reflect the refactoring:
combineSchemasandisSchemaEmptynow come from the centralized@app/utils/json-schemamodule, whilejsonSchemaToYupSchemaremains in its original location.client/src/app/components/discover-import-wizard/filter-input.tsx (1)
149-168: LGTM - Cloud Foundry conditional rendering implemented correctly.The logic correctly uses the Cloud Foundry validation check to render either the custom
FilterInputCloudFoundrycomponent or the genericSchemaDefinedField, providing graceful degradation when the schema doesn't match expectations.client/src/app/components/discover-import-wizard/review.tsx (1)
88-100: LGTM - Review rendering correctly gates on Cloud Foundry validation.The conditional rendering appropriately selects between the Cloud Foundry-specific review component and the generic schema field based on runtime validation, ensuring the UI adapts to schema compatibility.
client/src/app/components/discover-import-wizard/review-input-cloudfoundry.tsx (1)
29-31: LGTM!The variable declarations correctly extract the filter arrays with safe type assertions and appropriate fallbacks.
client/src/app/components/discover-import-wizard/validate-cloudfoundry-schema.tsx
Show resolved
Hide resolved
Signed-off-by: Scott J Dickerson <[email protected]>
Resolves: https://issues.redhat.com/browse/MTA-6326 Resolves: konveyor#2709 CloudFoundry schema update: konveyor/operator#484 Update the discover application wizard CloudFoundry source platform filter input and review to support organizations, spaces, and names. Added the ability to validate that two JSON schemas are functionally equivalent. This is used to validate that the Cloud Foundry schema is functionally equivalent to the schema used to build the Cloud Foundry forms. If a source platform is kind of "cloudfoundry", and the filter schema pulled from hub is functionally equivalent to the schema the components are based on, then show the custom components. If the schema is not equivalent, then show the generic schema defined fields components. This will most likely give the user a code editor to input a json document to define the filter. * **New Features** * Added Cloud Foundry discovery filters: separate Organizations, Spaces, and Names in import and review flows. * **Chores** * Updated dependency declarations and added lodash-es integration. * Moved and consolidated JSON Schema utilities for clearer schema handling and validation. * **Tests** * Expanded JSON Schema utility test coverage and removed tests for a deprecated combine helper. --------- Signed-off-by: Scott J Dickerson <[email protected]>
) (#2722) Resolves: https://issues.redhat.com/browse/MTA-6326 Resolves: #2709 Backport-Of: #2718 CloudFoundry schema update: konveyor/operator#484 ## Summary Update the discover application wizard CloudFoundry source platform filter input and review to support organizations, spaces, and names. Added the ability to validate that two JSON schemas are functionally equivalent. This is used to validate that the Cloud Foundry schema is functionally equivalent to the schema used to build the Cloud Foundry forms. If a source platform is kind of "cloudfoundry", and the filter schema pulled from hub is functionally equivalent to the schema the components are based on, then show the custom components. If the schema is not equivalent, then show the generic schema defined fields components. This will most likely give the user a code editor to input a json document to define the filter. ## Summary by CodeRabbit * **New Features** * Added Cloud Foundry discovery filters: separate Organizations, Spaces, and Names in import and review flows. * **Chores** * Updated dependency declarations and added lodash-es integration. * Moved and consolidated JSON Schema utilities for clearer schema handling and validation. * **Tests** * Expanded JSON Schema utility test coverage and removed tests for a deprecated combine helper. Signed-off-by: Scott J Dickerson <[email protected]>
Resolves: https://issues.redhat.com/browse/MTA-6326
Resolves: #2709
CloudFoundry schema update: konveyor/operator#484
Summary
Update the discover application wizard CloudFoundry source platform filter input and review to support organizations, spaces, and names.
Added the ability to validate that two JSON schemas are functionally equivalent. This is used to validate that the Cloud Foundry schema is functionally equivalent to the schema used to build the Cloud Foundry forms.
If a source platform is kind of "cloudfoundry", and the filter schema pulled from hub is functionally equivalent to the schema the components are based on, then show the custom components. If the schema is not equivalent, then show the generic schema defined fields components. This will most likely give the user a code editor to input a json document to define the filter.
Screenshots
No inputs required input and review:


Input for all fields in input and review:


Summary by CodeRabbit
New Features
Chores
Tests