Skip to content

Commit

Permalink
fix(CodeEditor): hide button and link when read-only (#9668)
Browse files Browse the repository at this point in the history
  • Loading branch information
mfrances17 authored Oct 6, 2023
1 parent 8a6d4d4 commit 0346933
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 25 deletions.
42 changes: 23 additions & 19 deletions packages/react-code-editor/src/components/CodeEditor/CodeEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -526,18 +526,20 @@ class CodeEditor extends React.Component<CodeEditorProps, CodeEditorState> {
headingLevel="h4"
/>
<EmptyStateBody>{emptyStateBody}</EmptyStateBody>
<EmptyStateFooter>
<EmptyStateActions>
<Button variant="primary" onClick={open}>
{emptyStateButton}
</Button>
</EmptyStateActions>
<EmptyStateActions>
<Button variant="link" onClick={this.toggleEmptyState}>
{emptyStateLink}
</Button>
</EmptyStateActions>
</EmptyStateFooter>
{!isReadOnly && (
<EmptyStateFooter>
<EmptyStateActions>
<Button variant="primary" onClick={open}>
{emptyStateButton}
</Button>
</EmptyStateActions>
<EmptyStateActions>
<Button variant="link" onClick={this.toggleEmptyState}>
{emptyStateLink}
</Button>
</EmptyStateActions>
</EmptyStateFooter>
)}
</EmptyState>
) : (
<EmptyState variant={EmptyStateVariant.sm}>
Expand All @@ -546,13 +548,15 @@ class CodeEditor extends React.Component<CodeEditorProps, CodeEditorState> {
icon={<EmptyStateIcon icon={CodeIcon} />}
headingLevel="h4"
/>
<EmptyStateFooter>
<EmptyStateActions>
<Button variant="primary" onClick={this.toggleEmptyState}>
{emptyStateLink}
</Button>
</EmptyStateActions>
</EmptyStateFooter>
{!isReadOnly && (
<EmptyStateFooter>
<EmptyStateActions>
<Button variant="primary" onClick={this.toggleEmptyState}>
{emptyStateLink}
</Button>
</EmptyStateActions>
</EmptyStateFooter>
)}
</EmptyState>
));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ export const CodeEditorBasic: React.FunctionComponent = () => {
};

const onEditorDidMount = (editor, monaco) => {
// eslint-disable-next-line no-console
console.log(editor.getValue());
editor.layout();
editor.focus();
monaco.editor.getModels()[0].updateOptions({ tabSize: 5 });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { Grid, GridItem, Chip } from '@patternfly/react-core';

export const CodeEditorShortcutMainHeader: React.FunctionComponent = () => {
const onEditorDidMount = (editor, monaco) => {
// eslint-disable-next-line no-console
console.log(editor.getValue());
editor.layout();
editor.focus();
monaco.editor.getModels()[0].updateOptions({ tabSize: 5 });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { CodeEditor, Language } from '@patternfly/react-code-editor';

export const CodeEditorSizeToFit: React.FunctionComponent = () => {
const onEditorDidMount = (editor, monaco) => {
// eslint-disable-next-line no-console
console.log(editor.getValue());
editor.layout();
editor.focus();
monaco.editor.getModels()[0].updateOptions({ tabSize: 5 });
Expand Down

0 comments on commit 0346933

Please sign in to comment.