Skip to content

Commit

Permalink
consume isReadOnly in all the other non core fields
Browse files Browse the repository at this point in the history
  • Loading branch information
gautamsi committed Mar 5, 2020
1 parent a05ec26 commit e7d361d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
3 changes: 2 additions & 1 deletion packages/field-content/src/views/Field.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class ErrorBoundary extends Component {
}
}

let ContentField = ({ field, value, onChange, autoFocus, errors }) => {
let ContentField = ({ field, value, onChange, autoFocus, errors, isReadOnly }) => {
const htmlID = `ks-content-editor-${field.path}`;

return (
Expand Down Expand Up @@ -62,6 +62,7 @@ let ContentField = ({ field, value, onChange, autoFocus, errors }) => {
padding: '16px 32px',
minHeight: 200,
}}
isReadOnly={isReadOnly}
/>
)}
</ErrorBoundary>
Expand Down
3 changes: 2 additions & 1 deletion packages/field-content/src/views/editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function getSchema(blocks) {
return schema;
}

function Stories({ value: editorState, onChange, blocks, className, id }) {
function Stories({ value: editorState, onChange, blocks, className, id, isReadOnly }) {
let schema = useMemo(() => {
return getSchema(blocks);
}, [blocks]);
Expand Down Expand Up @@ -75,6 +75,7 @@ function Stories({ value: editorState, onChange, blocks, className, id }) {
onChange={({ value }) => {
onChange(value);
}}
readOnly={isReadOnly}
/>
<AddBlock editor={editor} editorState={editorState} blocks={blocks} />
<Toolbar {...{ editorState, editor, blocks }} />
Expand Down
4 changes: 3 additions & 1 deletion packages/fields-markdown/src/views/Field.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ let IconToolbarButton = ({ isActive, label, icon, tooltipPlacement = 'top', ...p
);
};

export default function MarkdownField({ field, errors, value, onChange }) {
export default function MarkdownField({ field, errors, value, onChange, isReadOnly }) {
const htmlID = `ks-input-${field.path}`;
const accessError = errors.find(
error => error instanceof Error && error.name === 'AccessDeniedError'
Expand All @@ -81,6 +81,7 @@ export default function MarkdownField({ field, errors, value, onChange }) {
icon={<tool.icon />}
onClick={onClick}
label={tool.label}
disabled={isReadOnly}
/>
);
})}
Expand Down Expand Up @@ -122,6 +123,7 @@ export default function MarkdownField({ field, errors, value, onChange }) {
tabSize: '2',
lineWrapping: true,
addModeClass: true,
readOnly: isReadOnly,
}}
editorDidMount={editor => {
setTools(getTools(editor));
Expand Down
3 changes: 2 additions & 1 deletion packages/fields-wysiwyg-tinymce/src/views/Field.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const GlobalStyles = () => (
/>
);

const WysiwygField = ({ onChange, autoFocus, field, errors, value: serverValue }) => {
const WysiwygField = ({ onChange, autoFocus, field, errors, value: serverValue, isReadOnly }) => {
const handleChange = value => {
if (typeof value === 'string') {
onChange(value);
Expand All @@ -63,6 +63,7 @@ const WysiwygField = ({ onChange, autoFocus, field, errors, value: serverValue }
init={{ ...defaultOptions, auto_focus: autoFocus, ...overrideOptions }}
onEditorChange={handleChange}
value={value}
isDisabled={isReadOnly}
/>
</div>
</FieldContainer>
Expand Down

0 comments on commit e7d361d

Please sign in to comment.