Skip to content

Commit 3fa20c3

Browse files
authored
Resource ready conditions (#100)
* feat: remove resource.ts from openmfp * feat: implement readyCondition * fix: fix tests * feat: update openmfp deps * fix: fix column retrieval * feat: update docs * feat: change ready condition equality check logic * fix: fix import path * feat: change docs
1 parent cee8b36 commit 3fa20c3

File tree

19 files changed

+369
-248
lines changed

19 files changed

+369
-248
lines changed

docs/readme-generic-ui.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,17 @@ In order to use the generic list view, you need to adjust the node’s `conten
2424

2525
- context resource definition `"context"`
2626

27-
- in the `"resourceDefinition"` the given fields need to be specified: `group, plural, singular, kind, scope, namespace` describing
28-
properties of the resource.
27+
- in the `"resourceDefinition"` the given fields need to be specified: `group, plural, singular, kind, scope, namespace` describing properties of the resource.
28+
- Also `"resourceDefinition"` have optional field `readyCondition` that describing when resource treated as ready
29+
It's an object that contains two fields:
30+
- `jsonPathExpression`: JSONPath expression used to evaluate whether the resource is ready at runtime
31+
- `property`: JSON path(s) used to generate GraphQL fields to fetch the necessary data for readiness evaluation
32+
```json
33+
"readyCondition": {
34+
"jsonPathExpression": "status.conditions[?(@.type=='Ready' && @.status=='True')]",
35+
"property": ["status.conditions.status", "status.conditions.type"],
36+
},
37+
```
2938
- in the `"ui"` part of the `"resourceDefinition"` we can specify `"logoUrl"` for the resource as well as the definitions of the
3039
corresponding views
3140

@@ -95,6 +104,10 @@ Below is an example content-configuration for an accounts node using the generic
95104
"kind": "Account",
96105
"scope": "Cluster",
97106
"namespace": null,
107+
"readyCondition": {
108+
"jsonPathExpression": "status.conditions[?(@.type=='Ready' && @.status=='True')]",
109+
"property": ["status.conditions.status", "status.conditions.type"],
110+
},
98111
"ui": {
99112
"logoUrl": "https://www.kcp.io/icons/logo.svg",
100113
"listView": {

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"@angular/compiler-cli": "^20.2.1",
3030
"@angular/localize": "^20.2.1",
3131
"@briebug/jest-schematic": "6.0.0",
32-
"@openmfp/portal-ui-lib": "0.181.8",
32+
"@openmfp/portal-ui-lib": "0.182.0",
3333
"@openmfp/config-prettier": "0.8.1",
3434
"@types/jest": "^30.0.0",
3535
"@types/jmespath": "0.15.2",
@@ -51,4 +51,4 @@
5151
"ts-jest": "29.3.2",
5252
"typescript": "~5.8.0"
5353
}
54-
}
54+
}

projects/lib/models/models/resource.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ export interface ResourceDefinition {
6565
kind: string;
6666
scope?: KubernetesScope;
6767
namespace?: string;
68+
readyCondition?: {
69+
jsonPathExpression: string;
70+
property: string | string[];
71+
};
6872
ui?: UIDefinition;
6973
}
7074

@@ -79,4 +83,4 @@ export interface UIDefinition {
7983
detailView?: UiView;
8084
}
8185

82-
export type KubernetesScope = 'Cluster' | 'Namespaced';
86+
export type KubernetesScope = 'Cluster' | 'Namespaced';

projects/lib/portal-options/models/luigi-context.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { NodeContext, Resource } from '@openmfp/portal-ui-lib';
1+
import { NodeContext } from '@openmfp/portal-ui-lib';
2+
import { Resource } from '@platform-mesh/portal-ui-lib/models';
23

34
export interface PortalContext extends Record<string, any> {
45
crdGatewayApiUrl: string;

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,21 @@ import { DestroyRef, Injectable, inject } from '@angular/core';
22
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
33
import {
44
AuthService,
5-
FieldDefinition,
65
LuigiCoreService,
76
LuigiNode,
87
PortalConfig,
9-
Resource,
108
} from '@openmfp/portal-ui-lib';
11-
import { ResourceNodeContext, ResourceService } from '@platform-mesh/portal-ui-lib/services';
9+
import { FieldDefinition, Resource } from '@platform-mesh/portal-ui-lib/models';
10+
import {
11+
ResourceNodeContext,
12+
ResourceService,
13+
} from '@platform-mesh/portal-ui-lib/services';
1214
import { generateGraphQLFields } from '@platform-mesh/portal-ui-lib/utils';
1315
import '@ui5/webcomponents/dist/ComboBox.js';
1416
import { Observable, of } from 'rxjs';
1517
import { shareReplay } from 'rxjs/operators';
1618

19+
1720
const defaultColumns: FieldDefinition[] = [
1821
{
1922
label: 'Name',
@@ -148,4 +151,4 @@ export class NamespaceSelectionRendererService {
148151
console.warn(`Segment "${name}" not found in path.`);
149152
}
150153
}
151-
}
154+
}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { TestBed } from '@angular/core/testing';
2-
import { Resource } from '@openmfp/portal-ui-lib';
3-
import { ResourceService } from '@platform-mesh/portal-ui-lib/services';
4-
import { of, throwError } from 'rxjs';
51
import { PortalNodeContext } from '../models/luigi-context';
62
import { PortalLuigiNode } from '../models/luigi-node';
73
import { CrdGatewayKcpPatchResolver } from './crd-gateway-kcp-patch-resolver.service';
84
import { NodeContextProcessingServiceImpl } from './node-context-processing.service';
5+
import { TestBed } from '@angular/core/testing';
6+
import { Resource } from '@platform-mesh/portal-ui-lib/models';
7+
import { ResourceService } from '@platform-mesh/portal-ui-lib/services';
8+
import { of, throwError } from 'rxjs';
99

1010
describe('NodeContextProcessingServiceImpl', () => {
1111
let service: NodeContextProcessingServiceImpl;
@@ -431,4 +431,4 @@ describe('NodeContextProcessingServiceImpl', () => {
431431
);
432432
});
433433
});
434-
});
434+
});

projects/lib/services/resource/resource-node-context.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { NodeContext } from '@openmfp/portal-ui-lib';
2+
import { ResourceDefinition } from '@platform-mesh/portal-ui-lib/models';
23

34
export interface ResourceNodeContext extends Partial<NodeContext> {
5+
resourceDefinition?: ResourceDefinition;
46
organization?: string;
57
accountId?: string;
68
kcpCA?: string;
@@ -15,4 +17,4 @@ export interface ResourceNodeContext extends Partial<NodeContext> {
1517
crdGatewayApiUrl: string;
1618
kcpWorkspaceUrl?: string;
1719
};
18-
}
20+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { FieldDefinition } from '@openmfp/portal-ui-lib';
21
import { generateGraphQLFields } from './columns-to-gql-fields';
2+
import { FieldDefinition } from '@platform-mesh/portal-ui-lib/models';
33

44
describe('columns-to-gql-fields', () => {
55
describe('generateGraphQLFields', () => {

projects/lib/utils/utils/columns-to-gql-fields.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { FieldDefinition } from '@openmfp/portal-ui-lib';
1+
import { FieldDefinition } from '@platform-mesh/portal-ui-lib/models';
22

33
export const generateGraphQLFields = (uiFields: FieldDefinition[]): any[] => {
44
const graphQLFields = [];

0 commit comments

Comments
 (0)