diff --git a/README.md b/README.md index 20ad1189..e738aae3 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,7 @@ Name|Type|Default|Description `quotesOnKeys`|`boolean`|`true`|set to false to remove quotes from keys (eg. `"name":` vs. `name:`) `validationMessage`|`string`|"Validation Error"|Custom message for validation failures to `onEdit`, `onAdd`, or `onDelete` callbacks `displayArrayKey`|`boolean`|`true`|When set to `true`, the index of the elements prefix values +`nonEditableFields`|`array`|`[]`|Array of variable names which should be explicitly set as non-editable ### Features * `onEdit`, `onAdd` and `onDelete` props allow users to edit the `src` variable diff --git a/src/js/components/DataTypes/Object.js b/src/js/components/DataTypes/Object.js index 4c7cb93f..d5b25ab2 100644 --- a/src/js/components/DataTypes/Object.js +++ b/src/js/components/DataTypes/Object.js @@ -205,7 +205,7 @@ class RjvObject extends React.PureComponent { return (
this.setState({ ...this.state, hovered: true }) } diff --git a/src/js/components/VariableEditor.js b/src/js/components/VariableEditor.js index a78aab4e..ebf6835b 100644 --- a/src/js/components/VariableEditor.js +++ b/src/js/components/VariableEditor.js @@ -55,7 +55,8 @@ class VariableEditor extends React.PureComponent { onDelete, onSelect, displayArrayKey, - quotesOnKeys + quotesOnKeys, + nonEditableFields } = this.props; const { editMode } = this.state; return ( @@ -69,7 +70,7 @@ class VariableEditor extends React.PureComponent { onMouseLeave={() => this.setState({ ...this.state, hovered: false }) } - class="variable-row" + class={`variable-row ${variable.name}`} key={variable.name} > {type == 'array' ? ( @@ -138,10 +139,10 @@ class VariableEditor extends React.PureComponent { {...{ theme, namespace: [...namespace, variable.name] }} /> ) : null} - {onEdit !== false && editMode == false + {onEdit !== false && !nonEditableFields.includes(variable.name) && editMode == false ? this.getEditIcon() : null} - {onDelete !== false && editMode == false + {onDelete !== false && !nonEditableFields.includes(variable.name) && editMode == false ? this.getRemoveIcon() : null}
diff --git a/src/js/index.js b/src/js/index.js index f47338df..bcbd1ee0 100644 --- a/src/js/index.js +++ b/src/js/index.js @@ -56,7 +56,8 @@ class ReactJsonView extends React.PureComponent { style: {}, validationMessage: 'Validation Error', defaultValue: null, - displayArrayKey: true + displayArrayKey: true, + nonEditableFields: [] }; // will trigger whenever setState() is called, or parent passes in new props.