Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions workspaces/dcm/.changeset/multi-resource-catalog-items.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
'@red-hat-developer-hub/backstage-plugin-dcm-common': major
'@red-hat-developer-hub/backstage-plugin-dcm': major
---

Add multi-resource support for Catalog Items and Catalog Item Instances.

**API type changes (`dcm-common`)**

- `CatalogItemSpec` now holds a `resources?: CatalogResource[]` array instead of a single `service_type` + `fields`.
- New `CatalogResource` interface: `{ name, service_type, requires_resources?, fields? }`.
- `UserValue` gains a required `resource` field that identifies which resource the value targets.
- `CatalogItemInstanceSpec` gains `resource_ids?: string[]` (replaces the top-level `resource_id`).

**UI changes (`dcm`)**

- Catalog Item create/edit now uses a vertical-tabbed wizard dialog (`CatalogItemWizardDialog`) with tabs: Overview, API, Resources, and one tab per resource for field configurations.
- Catalog Item Instance create now uses a vertical-tabbed wizard dialog (`InstanceWizardDialog`) with an Overview tab and one tab per resource that has editable fields.
- Shared components extracted: `VerticalTabDialog`, `SchemaButton`, `ResourceFieldsPanel`, `UserValueFields`.
- Shared utility `validateJsonObject` de-duplicates JSON-object validation across `SchemaButton` and `catalogItemFormTypes`.
- Table columns updated: "Service type" replaced by "Resources" (chips per service_type); field count sums across all resources.
14 changes: 10 additions & 4 deletions workspaces/dcm/plugins/dcm-common/report.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ export interface CatalogItemInstance {
display_name: string;
// (undocumented)
path?: string;
resource_id?: string;
// (undocumented)
spec: CatalogItemInstanceSpec;
// (undocumented)
Expand All @@ -142,6 +141,7 @@ export interface CatalogItemInstanceList {
export interface CatalogItemInstanceSpec {
// (undocumented)
catalog_item_id: string;
resource_ids?: string[];
// (undocumented)
user_values: UserValue[];
}
Expand All @@ -156,10 +156,15 @@ export interface CatalogItemList {

// @public
export interface CatalogItemSpec {
// (undocumented)
resources?: CatalogResource[];
}

// @public
export interface CatalogResource {
fields?: FieldConfiguration[];
// (undocumented)
service_type?: string;
name: string;
requires_resources?: string[];
service_type: string;
}

// @public
Expand Down Expand Up @@ -529,6 +534,7 @@ export interface ServiceTypeList {
export interface UserValue {
// (undocumented)
path: string;
resource: string;
// (undocumented)
value: unknown;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ const MOCK_INSTANCE: CatalogItemInstance = {
spec: {
catalog_item_id: 'ci-1',
user_values: [],
resource_ids: ['res-new'],
},
resource_id: 'res-new',
};

function makeClient(fetchFn: jest.Mock) {
Expand Down
25 changes: 21 additions & 4 deletions workspaces/dcm/plugins/dcm-common/src/types/catalog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,26 @@ export interface CatalogItem {

/** Spec section of a {@link CatalogItem}. */
export interface CatalogItemSpec {
service_type?: string;
/** One or more named resources — each declares a service type and field configs. */
resources?: CatalogResource[];
}

/**
* A named resource within a {@link CatalogItemSpec}.
* `name` and `service_type` are immutable after creation.
*/
export interface CatalogResource {
/** Unique identifier within the catalog item (e.g. "app", "ordersDb"). */
name: string;
/** The service type for this resource (e.g. "vm", "three-tier-app-demo"). */
service_type: string;
/** Names of other resources that must be ready before this one is provisioned. */
requires_resources?: string[];
/** Field configurations for this resource. */
fields?: FieldConfiguration[];
}

/** A single field within a {@link CatalogItemSpec}. */
/** A single field within a {@link CatalogResource}. */
export interface FieldConfiguration {
path: string;
display_name?: string;
Expand All @@ -77,8 +92,6 @@ export interface CatalogItemInstance {
api_version: string;
display_name: string;
spec: CatalogItemInstanceSpec;
/** External resource identifier (readOnly). */
resource_id?: string;
path?: string;
create_time?: string;
update_time?: string;
Expand All @@ -88,10 +101,14 @@ export interface CatalogItemInstance {
export interface CatalogItemInstanceSpec {
catalog_item_id: string;
user_values: UserValue[];
/** External resource identifiers assigned by the Placement Manager (readOnly). */
resource_ids?: string[];
}

/** A user-supplied value for a field in a {@link CatalogItemInstanceSpec}. */
export interface UserValue {
/** The resource name within the catalog item this value targets. */
resource: string;
path: string;
value: unknown;
}
Expand Down
Loading
Loading