Skip to content

Commit

Permalink
Merge pull request #13694 from rhamilto/OCPBUGS-31355
Browse files Browse the repository at this point in the history
OCPBUGS-31355: add readOnly option to ResourceYAMLEditor
  • Loading branch information
openshift-merge-bot[bot] committed Apr 3, 2024
2 parents 7ea10c5 + 9fe4ef6 commit bad1104
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions frontend/packages/console-dynamic-plugin-sdk/docs/api.md
Expand Up @@ -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. |



Expand Down
Expand Up @@ -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<ResourceYAMLEditorProps> = require('@console/internal/components/AsyncResourceYAMLEditor')
.AsyncResourceYAMLEditor;
Expand Down
Expand Up @@ -677,6 +677,7 @@ export type ResourceYAMLEditorProps = {
initialResource: string | { [key: string]: any };
header?: string;
onSave?: (content: string) => void;
readOnly?: boolean;
};

export type ResourceEventStreamProps = {
Expand Down
10 changes: 9 additions & 1 deletion frontend/public/components/droppable-edit-yaml.tsx
Expand Up @@ -38,7 +38,15 @@ export const ResourceYAMLEditor: React.FC<ResourceYAMLEditorProps> = ({
initialResource,
header,
onSave,
}) => <DroppableEditYAML initialResource={initialResource} header={header} onSave={onSave} />;
readOnly,
}) => (
<DroppableEditYAML
initialResource={initialResource}
header={header}
onSave={onSave}
readOnly={readOnly}
/>
);

export const DroppableEditYAML = withDragDropContext<DroppableEditYAMLProps>(
class DroppableEditYAML extends React.Component<DroppableEditYAMLProps, DroppableEditYAMLState> {
Expand Down

0 comments on commit bad1104

Please sign in to comment.