diff --git a/frontend/packages/console-dynamic-plugin-sdk/docs/api.md b/frontend/packages/console-dynamic-plugin-sdk/docs/api.md index 0268e11c490..d4d7fa7055f 100644 --- a/frontend/packages/console-dynamic-plugin-sdk/docs/api.md +++ b/frontend/packages/console-dynamic-plugin-sdk/docs/api.md @@ -1952,6 +1952,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. | +| `readOnly` | Sets the YAML editor to read-only mode. | diff --git a/frontend/packages/console-dynamic-plugin-sdk/src/api/dynamic-core-api.ts b/frontend/packages/console-dynamic-plugin-sdk/src/api/dynamic-core-api.ts index 014a3029ea4..4a9be1ae900 100644 --- a/frontend/packages/console-dynamic-plugin-sdk/src/api/dynamic-core-api.ts +++ b/frontend/packages/console-dynamic-plugin-sdk/src/api/dynamic-core-api.ts @@ -640,6 +640,7 @@ export const CodeEditor: React.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['readOnly']} readOnly - Sets the YAML editor to read-only mode. */ export const ResourceYAMLEditor: React.FC = require('@console/internal/components/AsyncResourceYAMLEditor') .AsyncResourceYAMLEditor; 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 90677c46098..bc70d94167f 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 @@ -677,6 +677,7 @@ export type ResourceYAMLEditorProps = { initialResource: string | { [key: string]: any }; header?: string; onSave?: (content: string) => void; + readOnly?: boolean; }; export type ResourceEventStreamProps = { diff --git a/frontend/public/components/droppable-edit-yaml.tsx b/frontend/public/components/droppable-edit-yaml.tsx index a0af6980857..73285b0b122 100644 --- a/frontend/public/components/droppable-edit-yaml.tsx +++ b/frontend/public/components/droppable-edit-yaml.tsx @@ -38,7 +38,15 @@ export const ResourceYAMLEditor: React.FC = ({ initialResource, header, onSave, -}) => ; + readOnly, +}) => ( + +); export const DroppableEditYAML = withDragDropContext( class DroppableEditYAML extends React.Component {