Skip to content

SRVKP-15190: Add shared synced resource editor - #1487

Merged
openshift-merge-bot[bot] merged 1 commit into
openshift-pipelines:masterfrom
ankrsinha:feat/SRVKP-15190-sync-editor
Nov 24, 2026
Merged

openshift-merge-bot[bot] merged 1 commit into
openshift-pipelines:masterfrom
ankrsinha:feat/SRVKP-15190-sync-editor

Conversation

@ankrsinha

@ankrsinha ankrsinha commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Type of Change

  • Bug fix
  • New feature
  • Refactoring
  • Migration
  • CVE Fix

Summary

Adds SyncedResourceEditor, a shared Form/YAML synchronization foundation for CRs.

It owns the common behavior:

  • Form/YAML mode toggle
  • Form-to-YAML and YAML-to-Form synchronization
  • Invalid YAML protection
  • Preservation of YAML-only fields after Form edits
  • Rendering resource-specific Form fields

Resource-specific code provides an adapter that converts between Form values and the complete Kubernetes resource.

Example Usage

ClusterQueueBuilderPage uses the SyncedResourceEditor for both Create and Edit routes. The route parameter decides the mode:

const { clusterQueueName } = useParams();
const isEdit = Boolean(clusterQueueName);
const [resource, loaded] = useK8sWatchResource();

<SyncedResourceEditor
  adapter={clusterQueueAdapter}
  initialResource={resource ?? initialClusterQueueResource}
  title={isEdit ? t('Edit ClusterQueue') : t('Create ClusterQueue')}
>
  <ClusterQueueFields isEdit={isEdit} />
</SyncedResourceEditor>

Note: The adapter handles resource-specific data conversion and basic validation. The shared editor does not contain ClusterQueue or LocalQueue-specific logic.

ClusterQueue example

This PR includes a minimal ClusterQueueBuilderPage to demonstrate how one page can support both Create and Edit routes with SyncedResourceEditor.

It is not the full ClusterQueue create / edit implementation.

Validation

  • Added focused unit tests for Form/YAML synchronization.
  • Verified Form children rendering, Form-to-YAML updates, YAML-to-Form updates, YAML-only field preservation, invalid YAML handling, and initialization from a page-supplied resource.
  • Ran linting and TypeScript checks.

Screen Recordings / Screenshot

SRVKP-15190-sync-updated.mp4

@openshift-ci-robot

openshift-ci-robot commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

@ankrsinha: This pull request references SRVKP-15190 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "5.1.0" version, but no target version was set.

Details

In response to this:

Type of Change

  • Bug fix
  • New feature
  • Refactoring
  • Migration
  • CVE Fix

Summary

Adds SyncedResourceEditor, a shared Form/YAML synchronization foundation for CRs.

It owns the common behavior:

  • Form/YAML mode toggle
  • Form-to-YAML and YAML-to-Form synchronization
  • Invalid YAML protection
  • Preservation of YAML-only fields after Form edits
  • Rendering resource-specific Form fields

Resource-specific code provides an adapter that converts between Form values and the complete Kubernetes resource.

Usage

Create pages can use this sync editor by providing the adaptor, form fields and initial resource:

<SyncedResourceEditor
 adapter={clusterQueueAdapter}
 initialResource={initialClusterQueueResource}
>
 <ClusterQueueFields />
</SyncedResourceEditor>

Future edit pages can use the same editor, adapter, and fields by passing the resource fetched from the API:

<SyncedResourceEditor
 adapter={clusterQueueAdapter}
 initialResource={loadedClusterQueue}
>
 <ClusterQueueFields />
</SyncedResourceEditor>

Note: The adapter handles resource-specific data conversion and basic validation. The shared editor does not contain ClusterQueue or LocalQueue-specific logic.

ClusterQueue example

This PR includes a minimal ClusterQueue create page only to demonstrate how a resource uses SyncedResourceEditor.
It is not the full ClusterQueue create implementation.

Validation

  • Added focused unit tests for Form/YAML synchronization.
  • Verified Form children rendering, Form-to-YAML updates, YAML-to-Form updates, YAML-only field preservation, invalid YAML handling, and initialization from a page-supplied resource.
  • Ran linting and TypeScript checks.

Screen Recordings / Screenshot

SRVKP-15190-sync-editor.mp4

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@qodo-code-review

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Warning

/review is deprecated. Use /agentic_review instead (removal date not yet scheduled).

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Incomplete Creation

The new create route renders the editor but provides no action to submit the resource. Users can edit a ClusterQueue but cannot create it from this page.

<SyncedResourceEditor
  adapter={clusterQueueAdapter}
  initialResource={initialClusterQueueResource}
>
  <ClusterQueueFields />
</SyncedResourceEditor>
Invalid Resource

yamlToResource accepts an empty metadata.name and a missing spec as valid, allowing onResourceChange to receive a resource that cannot be created. Validate required resource fields before accepting YAML.

if (
  !isRecord(resource) ||
  resource.apiVersion !== apiVersion ||
  resource.kind !== ClusterQueueModel.kind ||
  !isRecord(resource.metadata) ||
  typeof resource.metadata.name !== 'string' ||
  (resource.spec !== undefined && !isRecord(resource.spec)) ||
  (isRecord(resource.spec) &&
    resource.spec.cohortName !== undefined &&
    typeof resource.spec.cohortName !== 'string')
) {
  throw new Error('YAML must describe a valid ClusterQueue.');
}

@qodo-code-review

Copy link
Copy Markdown

Important

The /generate_labels command by Qodo was deprecated on the 1st of October 2026 and is no longer available. We recommend switching to the latest Qodo review capabilities. Learn more

@ankrsinha
ankrsinha force-pushed the feat/SRVKP-15190-sync-editor branch from 9a0f424 to 51cc2c9 Compare November 20, 2026 09:11
@ankrsinha
ankrsinha force-pushed the feat/SRVKP-15190-sync-editor branch 2 times, most recently from 8bd5727 to b18a863 Compare November 20, 2026 12:14

@anwesha-palit-redhat anwesha-palit-redhat left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Looks Good to Me Label label Nov 23, 2026
- Support reusable Form/YAML synchronization through resource adapters.
- Add a minimal ClusterQueue usage example and focused tests.

Signed-off-by: Ankur Sinha <anksinha@redhat.com>
@ankrsinha
ankrsinha force-pushed the feat/SRVKP-15190-sync-editor branch from b18a863 to c1cb2f5 Compare November 23, 2026 08:34
@openshift-ci openshift-ci Bot removed the lgtm Looks Good to Me Label label Nov 23, 2026
@anwesha-palit-redhat

Copy link
Copy Markdown
Contributor

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Looks Good to Me Label label Nov 23, 2026

@arvindk-softwaredev arvindk-softwaredev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci

openshift-ci Bot commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ankrsinha, arvindk-softwaredev

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:
  • OWNERS [arvindk-softwaredev]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci Bot added the approved Label for Approved PRs label Nov 24, 2026
@openshift-merge-bot
openshift-merge-bot Bot merged commit 0436db3 into openshift-pipelines:master Nov 24, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Label for Approved PRs jira/valid-reference lgtm Looks Good to Me Label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants