diff --git a/frontend/packages/console-dynamic-plugin-sdk/CHANGELOG-core.md b/frontend/packages/console-dynamic-plugin-sdk/CHANGELOG-core.md index 9da19154c09..b4529de7a2a 100644 --- a/frontend/packages/console-dynamic-plugin-sdk/CHANGELOG-core.md +++ b/frontend/packages/console-dynamic-plugin-sdk/CHANGELOG-core.md @@ -10,6 +10,10 @@ For current development version of Console, use `4.x.0-prerelease.n` packages. For older 1.x plugin SDK packages, refer to "OpenShift Console Versions vs SDK Versions" compatibility table in [Console dynamic plugins README](./README.md). +## 4.23.0-prerelease.6 - TBD + +- Add an `onCancel` prop to `ResourceYAMLEditor` to allow overriding the default cancel behavior ([CONSOLE-5438], [#16941]) + ## 4.23.0-prerelease.5 - 2026-08-04 - **Deprecated**: The use of multiple predicates in the `useResolvedExtensions` hook is deprecated ([#16115], [CONSOLE-5065]) @@ -254,6 +258,7 @@ table in [Console dynamic plugins README](./README.md). [CONSOLE-5361]: https://issues.redhat.com/browse/CONSOLE-5361 [CONSOLE-5415]: https://issues.redhat.com/browse/CONSOLE-5415 [CONSOLE-5424]: https://issues.redhat.com/browse/CONSOLE-5424 +[CONSOLE-5438]: https://issues.redhat.com/browse/CONSOLE-5438 [OCPBUGS-19048]: https://issues.redhat.com/browse/OCPBUGS-19048 [OCPBUGS-30077]: https://issues.redhat.com/browse/OCPBUGS-30077 [OCPBUGS-31355]: https://issues.redhat.com/browse/OCPBUGS-31355 @@ -349,3 +354,4 @@ table in [Console dynamic plugins README](./README.md). [#16726]: https://github.com/openshift/console/pull/16726 [#16750]: https://github.com/openshift/console/pull/16750 [#16762]: https://github.com/openshift/console/pull/16762 +[#16941]: https://github.com/openshift/console/pull/16941 diff --git a/frontend/packages/console-dynamic-plugin-sdk/docs/api.md b/frontend/packages/console-dynamic-plugin-sdk/docs/api.md index 4749c646bfd..68c7803e6a8 100644 --- a/frontend/packages/console-dynamic-plugin-sdk/docs/api.md +++ b/frontend/packages/console-dynamic-plugin-sdk/docs/api.md @@ -2200,6 +2200,7 @@ A lazy loaded YAML editor for Kubernetes resources with hover help and completio | `initialResource` | YAML/Object representing a resource to be shown by the editor. This prop is used only during the inital render. | | `header` | Add a header on top of the YAML editor. | | `onSave` | Callback for the Save button. Passing it will override the default update performed on the resource by the editor. | +| `onCancel` | Callback function to be called on cancel. Passing it will override the default behavior of the cancel button. | | `readOnly` | Sets the YAML editor to read-only mode. | | `create` | Editor will be on creation mode. Create button will replace the Save and Cancel buttons. If no onSave method defined, the 'Create' button will trigger the creation of the defined resource. Default: false | | `onChange` | Callback triggered at any editor change. | diff --git a/frontend/packages/console-dynamic-plugin-sdk/src/api/core-api.ts b/frontend/packages/console-dynamic-plugin-sdk/src/api/core-api.ts index f9224346fec..63b4dc478ff 100644 --- a/frontend/packages/console-dynamic-plugin-sdk/src/api/core-api.ts +++ b/frontend/packages/console-dynamic-plugin-sdk/src/api/core-api.ts @@ -676,6 +676,7 @@ export const CodeEditor: ForwardRefExoticComponent< * @param {ResourceYAMLEditorProps['initialResource']} initialResource - YAML/Object representing a resource to be shown by the editor. This prop is used only during the inital render. * @param {ResourceYAMLEditorProps['header']} header - Add a header on top of the YAML editor. * @param {ResourceYAMLEditorProps['onSave']} onSave - Callback for the Save button. Passing it will override the default update performed on the resource by the editor. + * @param {ResourceYAMLEditorProps['onCancel']} onCancel - Callback function to be called on cancel. Passing it will override the default behavior of the cancel button. * @param {ResourceYAMLEditorProps['readOnly']} readOnly - Sets the YAML editor to read-only mode. * @param {ResourceYAMLEditorProps['create']} create - Editor will be on creation mode. Create button will replace the Save and Cancel buttons. If no onSave method defined, the 'Create' button will trigger the creation of the defined resource. Default: false * @param {ResourceYAMLEditorProps['onChange']} onChange - Callback triggered at any editor change. diff --git a/frontend/packages/console-dynamic-plugin-sdk/src/extensions/console-types.ts b/frontend/packages/console-dynamic-plugin-sdk/src/extensions/console-types.ts index bd988562c2b..360f14a13e2 100644 --- a/frontend/packages/console-dynamic-plugin-sdk/src/extensions/console-types.ts +++ b/frontend/packages/console-dynamic-plugin-sdk/src/extensions/console-types.ts @@ -884,6 +884,7 @@ export type ResourceYAMLEditorProps = { initialResource: K8sResourceKind; header?: string; onSave?: (content: string) => void; + onCancel?: () => void; readOnly?: boolean; create?: boolean; onChange?: (content: string) => void; diff --git a/frontend/public/components/droppable-edit-yaml.tsx b/frontend/public/components/droppable-edit-yaml.tsx index 5f121e7cf60..87f5021d9a6 100644 --- a/frontend/public/components/droppable-edit-yaml.tsx +++ b/frontend/public/components/droppable-edit-yaml.tsx @@ -162,6 +162,7 @@ export const ResourceYAMLEditor: FC = ({ initialResource, header, onSave, + onCancel, readOnly, create, onChange, @@ -171,6 +172,7 @@ export const ResourceYAMLEditor: FC = ({ initialResource={initialResource} header={header} onSave={onSave} + onCancel={onCancel} readOnly={readOnly} create={create} onChange={onChange}