Skip to content

Conversation

@Sobyt483
Copy link
Collaborator

@Sobyt483 Sobyt483 commented Oct 28, 2025

Cleanup resource.ts import from openmfp
Add readyCondition to resourceDefintion

Summary by CodeRabbit

  • New Features

    • Configurable resource readiness via optional readyCondition (JSONPath + property) to declare when an item is considered ready.
  • Improvements

    • List view now computes item readiness from readyCondition, updating field generation and readiness flags accordingly.
  • Tests

    • Added/expanded readiness tests covering mixed statuses, missing conditions, async scenarios, single- and multi-item lists.
  • Documentation

    • Docs and examples updated to show readyCondition configuration and usage.

@Sobyt483 Sobyt483 self-assigned this Oct 28, 2025
@Sobyt483 Sobyt483 requested review from a team as code owners October 28, 2025 13:39
@Sobyt483 Sobyt483 added the bug Something isn't working label Oct 28, 2025
@Sobyt483 Sobyt483 linked an issue Oct 28, 2025 that may be closed by this pull request
@coderabbitai
Copy link

coderabbitai bot commented Oct 28, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Adds an optional readyCondition to ResourceDefinition, exposes resourceDefinition and entity in node contexts, migrates several type/service imports to @platform-mesh/portal-ui-lib, implements ready-condition-aware readiness computation and GraphQL field generation in the list view, and expands related tests and docs.

Changes

Cohort / File(s) Summary
Resource Definition
projects/lib/models/models/resource.ts
Added optional readyCondition?: { jsonPathExpression: string; property: string | string[] } to ResourceDefinition.
Node Contexts & Luigi Context
projects/lib/services/resource/resource-node-context.ts, projects/lib/portal-options/models/luigi-context.ts
Added resourceDefinition?: ResourceDefinition to ResourceNodeContext; added entity?: Resource to PortalNodeContext; updated imports to @platform-mesh/portal-ui-lib/*.
List View (logic & tests)
projects/wc/src/app/components/generic-ui/list-view/list-view.component.ts, projects/wc/src/app/components/generic-ui/list-view/list-view.component.spec.ts
Added readyCondition accessor; replaced status-based field generator with generateGqlFieldsWithReadyConditions(); added getResourceReadyStatus(resource); mapping now computes per-resource ready flags; tests expanded to cover ready-condition scenarios (single, list, async, mixed).
Type Import Migration (FieldDefinition, Resource)
projects/lib/utils/utils/columns-to-gql-fields.ts, projects/lib/utils/utils/columns-to-gql-fields.spec.ts, projects/lib/utils/utils/get-value-by-path.ts, projects/lib/utils/utils/resource-field-by-path.spec.ts, projects/wc/src/app/components/dynamic-select/dynamic-select.component.ts, projects/wc/src/app/components/generic-ui/list-view/create-resource-modal/create-resource-modal.component.ts, projects/wc/src/app/components/generic-ui/list-view/create-resource-modal/create-resource-modal.component.spec.ts, projects/wc/src/app/components/generic-ui/list-view/delete-resource-confirmation-modal/delete-resource-modal.component.ts
Updated imports for FieldDefinition and/or Resource from @openmfp/portal-ui-lib@platform-mesh/portal-ui-lib/models (type/module path changes only).
Renderer & Test Import Reorg
projects/lib/portal-options/services/header-bar-renderers/namespace-selection-renderer.service.ts, projects/lib/portal-options/services/node-context-processing.service.spec.ts
Reorganized/updated imports: FieldDefinition/Resource from @platform-mesh/portal-ui-lib/models; ResourceNodeContext/ResourceService from @platform-mesh/portal-ui-lib/services (no logic changes).
Import Reordering / Formatting
projects/wc/src/app/components/organization-management/organization-management.component.ts
Reorganized and reformatted import blocks (no behavioral changes).
Dependency bump
package.json
Dev dependency @openmfp/portal-ui-lib bumped from 0.181.80.182.0.
Docs
docs/readme-generic-ui.md
Documented new optional readyCondition on resource definitions with example usage.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Files needing focused review:
    • projects/wc/src/app/components/generic-ui/list-view/list-view.component.ts — verify readyCondition wiring, ready-status computation, and GraphQL field concatenation.
    • projects/wc/src/app/components/generic-ui/list-view/list-view.component.spec.ts — ensure tests correctly assert async/mixed readiness and align with new logic.
    • projects/lib/models/models/resource.ts and projects/lib/services/resource/resource-node-context.ts — confirm typings for readyCondition and resourceDefinition.
  • Quick checks:
    • Confirm all migrated imports consistently reference @platform-mesh/portal-ui-lib/* and no old @openmfp/portal-ui-lib remain.
    • Validate that type-only import path changes do not affect runtime bundles or typings.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "Resource ready conditions" directly and clearly summarizes the main functional change in this pull request. The primary objective is to add the readyCondition field to the ResourceDefinition interface, enabling resource readiness evaluation through JSONPath expressions and property checks. While the PR also includes secondary refactoring (import path migrations from @openmfp/portal-ui-lib to @platform-mesh/portal-ui-lib), the title correctly emphasizes the core feature addition. The title is concise, specific, and a teammate reviewing the history would immediately understand that this PR introduces resource readiness condition functionality.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2be3630 and e3471d2.

📒 Files selected for processing (1)
  • docs/readme-generic-ui.md (2 hunks)

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

"namespace": null,
"readyCondition": {
"jsonPathExpression": "status.conditions[?(@.type=='Ready')].status",
"property": ["status.conditions.status", "status.conditions.type"],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't understand this configuration.

the jsonPathExpression ends up in a concrete value - a particular conditions stats.
What does the property then do?

Copy link
Collaborator Author

@Sobyt483 Sobyt483 Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's needed for graphQL. So they can be fetch from it

@Sobyt483 Sobyt483 requested a review from nexus49 October 29, 2025 11:48
Copy link

@coderabbitai coderabbitai bot left a 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

🧹 Nitpick comments (6)
projects/lib/utils/utils/get-value-by-path.ts (1)

4-12: Consider constraining the generic type for better type safety.

The function accepts any object type T but immediately casts it to Resource without validation. Consider either removing the generic parameter or constraining T to extend Resource to make the type contract more explicit.

Example refactor:

-export const getValueByPath = <T extends object, R = unknown>(
-  obj: T,
+export const getValueByPath = <R = unknown>(
+  obj: Resource,
   path: string,
 ): R | undefined => {
-  return getResourceValueByJsonPath(obj as Resource, {
+  return getResourceValueByJsonPath(obj, {
     jsonPathExpression: path,
     property: '',
   });
 };
docs/readme-generic-ui.md (2)

27-35: Clarify the purpose of both jsonPathExpression and property fields.

The documentation explains what each field contains but doesn't clarify why both are needed. This has already been flagged in a past review comment. Consider adding an explanation that:

  • jsonPathExpression is used at runtime to evaluate whether a resource is ready (JSONPath query evaluation)
  • property is used for GraphQL field generation to ensure the necessary data is fetched

This would help address the confusion raised in the previous review.

Example addition:

 - Also `"resourceDefinition"` have optional field `readyCondition` that describing when resource treated as ready
-It's an object that contain two fields. `jsonPathExpression` that contain JSONPath expression for complex data access and ready status matching and `property` JSON path to the resource property that contain info about resource ready state
+It's an object that contains two fields:
+  - `jsonPathExpression`: JSONPath expression used to evaluate whether the resource is ready at runtime
+  - `property`: JSON path(s) used to generate GraphQL fields to fetch the necessary data for readiness evaluation

27-28: Fix markdown list indentation.

Markdownlint reports incorrect indentation (4 spaces instead of 2).

Apply this diff:

-    - in the `"resourceDefinition"` the given fields need to be specified: `group, plural, singular, kind, scope, namespace` describing properties of the resource.
-    - Also `"resourceDefinition"` have optional field `readyCondition` that describing when resource treated as ready
+  - in the `"resourceDefinition"` the given fields need to be specified: `group, plural, singular, kind, scope, namespace` describing properties of the resource.
+  - Also `"resourceDefinition"` have optional field `readyCondition` that describing when resource treated as ready
projects/wc/src/app/components/generic-ui/list-view/list-view.component.spec.ts (2)

430-470: Clarify test name to avoid confusion.

The test name says "when Ready condition is missing" but the resource actually has a Ready condition (with status: 'False'). What's missing is the readyCondition configuration in the resourceDefinition.

Consider renaming to: "should mark resource as ready when readyCondition configuration is missing" to more accurately reflect what's being tested (the default behavior when no readyCondition is configured).


472-520: Clarify test name for precision.

The test name says "when status condition is missing" but the resource does have a status condition (type: 'Other'). What's missing is the specific Ready condition that the readyCondition JSONPath is looking for.

Consider renaming to: "should mark resource as not ready when matching Ready status condition is not found" for clarity.

projects/wc/src/app/components/generic-ui/list-view/list-view.component.ts (1)

240-249: Consider removing or changing console.log to console.debug.

The readiness logic is correct, but line 247 contains console.log('readyStatus', readyStatus) which should likely be console.debug or removed for production code to reduce console noise.

Apply this diff:

-    console.log('readyStatus', readyStatus);
+    console.debug('readyStatus', readyStatus);

Or remove it entirely if the logging is no longer needed.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cee8b36 and b3f8faf.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (18)
  • docs/readme-generic-ui.md (2 hunks)
  • package.json (2 hunks)
  • projects/lib/models/models/resource.ts (2 hunks)
  • projects/lib/portal-options/models/luigi-context.ts (1 hunks)
  • projects/lib/portal-options/services/header-bar-renderers/namespace-selection-renderer.service.ts (2 hunks)
  • projects/lib/portal-options/services/node-context-processing.service.spec.ts (2 hunks)
  • projects/lib/services/resource/resource-node-context.ts (2 hunks)
  • projects/lib/utils/utils/columns-to-gql-fields.spec.ts (1 hunks)
  • projects/lib/utils/utils/columns-to-gql-fields.ts (1 hunks)
  • projects/lib/utils/utils/get-value-by-path.ts (1 hunks)
  • projects/lib/utils/utils/resource-field-by-path.spec.ts (1 hunks)
  • projects/wc/src/app/components/dynamic-select/dynamic-select.component.ts (1 hunks)
  • projects/wc/src/app/components/generic-ui/list-view/create-resource-modal/create-resource-modal.component.spec.ts (1 hunks)
  • projects/wc/src/app/components/generic-ui/list-view/create-resource-modal/create-resource-modal.component.ts (1 hunks)
  • projects/wc/src/app/components/generic-ui/list-view/delete-resource-confirmation-modal/delete-resource-modal.component.ts (1 hunks)
  • projects/wc/src/app/components/generic-ui/list-view/list-view.component.spec.ts (3 hunks)
  • projects/wc/src/app/components/generic-ui/list-view/list-view.component.ts (4 hunks)
  • projects/wc/src/app/components/organization-management/organization-management.component.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
projects/lib/services/resource/resource-node-context.ts (1)
projects/lib/models/models/resource.ts (1)
  • ResourceDefinition (61-73)
projects/wc/src/app/components/generic-ui/list-view/list-view.component.ts (3)
projects/lib/utils/utils/columns-to-gql-fields.ts (1)
  • generateGraphQLFields (3-13)
projects/lib/models/models/resource.ts (1)
  • Resource (53-59)
projects/lib/utils/utils/resource-field-by-path.ts (1)
  • getResourceValueByJsonPath (4-22)
🪛 markdownlint-cli2 (0.18.1)
docs/readme-generic-ui.md

27-27: Unordered list indentation
Expected: 2; Actual: 4

(MD007, ul-indent)


28-28: Unordered list indentation
Expected: 2; Actual: 4

(MD007, ul-indent)

⏰ 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). (1)
  • GitHub Check: pipe / build / build
🔇 Additional comments (24)
projects/wc/src/app/components/generic-ui/list-view/delete-resource-confirmation-modal/delete-resource-modal.component.ts (1)

18-18: Import path updated to align with PR objectives.

The Resource import has been correctly migrated from the openmfp package to @platform-mesh/portal-ui-lib/models, aligning with the PR's cleanup goals. All usages of the Resource type throughout the component remain unchanged and functional.

projects/lib/utils/utils/get-value-by-path.ts (1)

2-2: LGTM! Import migration aligns with PR objectives.

The import source update from @openmfp/portal-ui-lib to @platform-mesh/portal-ui-lib/models correctly addresses the stated objective to clean up resource imports from openmfp.

projects/wc/src/app/components/generic-ui/list-view/create-resource-modal/create-resource-modal.component.spec.ts (1)

5-5: Import path update is verified and consistent with codebase standards.

The import path change from @openmfp/portal-ui-lib to @platform-mesh/portal-ui-lib/models is confirmed valid. This package is declared as a dependency in package.json, and the same import pattern is already used in 22 other files across the codebase, indicating FieldDefinition is properly exported from this module path.

projects/wc/src/app/components/organization-management/organization-management.component.ts (3)

3-13: LGTM - Import formatting improvement

The multi-line formatting with trailing commas improves readability and makes diffs cleaner for future changes.


15-20: LGTM - Consistent formatting

Consistent with the Angular core imports formatting.


35-42: LGTM - Consistent formatting

UI5 webcomponents imports follow the same multi-line formatting pattern.

projects/lib/utils/utils/columns-to-gql-fields.spec.ts (1)

2-2: LGTM! Clean import path migration.

The import path update for FieldDefinition aligns with the package migration from @openmfp/portal-ui-lib to @platform-mesh/portal-ui-lib/models. No functional changes to tests.

projects/lib/utils/utils/resource-field-by-path.spec.ts (1)

2-2: LGTM! Import path migration consistent with codebase changes.

The updated import path for FieldDefinition and Resource aligns with the broader migration effort. No test behavior changes.

package.json (1)

32-32: LGTM! Version bump supports module path migration.

The minor version update of @openmfp/portal-ui-lib to 0.182.0 enables the new module paths (@platform-mesh/portal-ui-lib/models) used throughout this PR.

projects/lib/utils/utils/columns-to-gql-fields.ts (1)

1-1: LGTM! Import path updated correctly.

The FieldDefinition import has been migrated to @platform-mesh/portal-ui-lib/models with no changes to the function logic.

projects/lib/portal-options/models/luigi-context.ts (2)

2-2: LGTM! New import supports interface extension.

The Resource import from @platform-mesh/portal-ui-lib/models enables the new entity property on PortalNodeContext.


19-19: LGTM! Backward-compatible interface extension.

Adding the optional entity?: Resource property to PortalNodeContext extends the context capabilities without breaking existing implementations.

projects/lib/portal-options/services/node-context-processing.service.spec.ts (1)

5-8: LGTM! Import paths updated consistently.

The imports have been migrated to the new package paths:

  • Resource from @platform-mesh/portal-ui-lib/models
  • ResourceService from @platform-mesh/portal-ui-lib/services

No test logic changes, maintaining existing test coverage.

projects/lib/services/resource/resource-node-context.ts (2)

2-2: LGTM! Import enables resourceDefinition context.

The ResourceDefinition import from @platform-mesh/portal-ui-lib/models supports the new context property, which includes the readyCondition field added in this PR.


5-5: LGTM! Backward-compatible interface extension.

Adding the optional resourceDefinition?: ResourceDefinition property enables resource definition context (including readyCondition) to be passed through the node context without breaking existing implementations.

projects/wc/src/app/components/generic-ui/list-view/create-resource-modal/create-resource-modal.component.ts (1)

23-23: LGTM! Import path migration complete.

The FieldDefinition and Resource types have been migrated to @platform-mesh/portal-ui-lib/models, aligning with the package restructuring. No component logic changes.

projects/wc/src/app/components/dynamic-select/dynamic-select.component.ts (1)

3-7: LGTM! Import path migration is clean.

The import path updates from @openmfp/portal-ui-lib to @platform-mesh/portal-ui-lib are consistent with the PR objectives.

projects/lib/models/models/resource.ts (1)

68-71: LGTM! readyCondition field is well-structured.

The optional readyCondition field follows the established pattern of combining jsonPathExpression for complex data access with property for fallback/GraphQL field generation, consistent with FieldDefinition.

projects/lib/portal-options/services/header-bar-renderers/namespace-selection-renderer.service.ts (1)

9-13: LGTM! Import migration is consistent.

The import path updates align with the broader refactoring to use @platform-mesh/portal-ui-lib.

projects/wc/src/app/components/generic-ui/list-view/list-view.component.spec.ts (2)

382-428: LGTM! Test correctly validates readiness with False status.

The test properly verifies that a resource with Ready condition status of False is marked as not ready when readyCondition is configured.


522-634: LGTM! Comprehensive test coverage for edge cases.

The tests for empty conditions and mixed ready statuses provide good coverage of various readiness scenarios.

projects/wc/src/app/components/generic-ui/list-view/list-view.component.ts (3)

104-104: LGTM! Clean computed property.

The readyCondition computed property properly derives from resourceDefinition()?.readyCondition.


120-139: LGTM! Core readyCondition integration is well-implemented.

The changes properly integrate readyCondition by:

  • Using generateGqlFieldsWithReadyConditions() to include readyCondition fields in GraphQL queries (line 120)
  • Dynamically determining readiness with getResourceReadyStatus(resource) instead of hardcoded true (line 133)

231-238: LGTM! GraphQL field generation handles readyCondition correctly.

The method appropriately concatenates readyCondition with columns when present, treating it as a FieldDefinition-like object for GraphQL field generation.

@Sobyt483 Sobyt483 enabled auto-merge (squash) October 29, 2025 11:55
@Sobyt483 Sobyt483 merged commit 3fa20c3 into main Oct 29, 2025
6 of 7 checks passed
@Sobyt483 Sobyt483 deleted the resource-ready-conditions branch October 29, 2025 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ready condition check in generic UI

4 participants