Skip to content
This repository has been archived by the owner on Mar 27, 2019. It is now read-only.

52 json diff patch #84

Merged
merged 3 commits into from
Jun 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"presets": [
"es2015",
"react",
"stage-2"
"stage-2",
"stage-0"
]
}
1 change: 1 addition & 0 deletions app/components/Secrets/Generic/Generic.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ class GenericSecretBackend extends React.Component {
modal={false}
actions={actions}
open={this.state.openEditObjectModal}
autoDetectWindowHeight={true}
autoScrollBodyContent={true}
onRequestClose={() => {
this.setState({ openEditObjectModal: false, secretContent: '' })
Expand Down
28 changes: 28 additions & 0 deletions app/components/shared/JsonEditor.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import React, { PropTypes } from 'react';
import JSONEditor from 'jsoneditor';
import JsonDiffReact from 'jsondiffpatch-for-react';
import Checkbox from 'material-ui/Checkbox';
import Divider from 'material-ui/Divider';
import 'jsoneditor/src/css/reset.css';
import 'jsoneditor/src/css/jsoneditor.css';
import 'jsoneditor/src/css/menu.css';
Expand Down Expand Up @@ -32,6 +35,8 @@ class JsonEditor extends React.Component {

state = {
hasValue: false,
initialValue: this.props.value,
showDiff: true
};

constructor(props) {
Expand Down Expand Up @@ -81,9 +86,32 @@ class JsonEditor extends React.Component {
this._jsoneditor.destroy();
}

renderDiff = () => {
if (_.isEqual(this.state.initialValue, this.props.value)) {
return <div>No difference detected.</div>;
} else {
return (
<JsonDiffReact
left={this.state.initialValue}
right={this.props.value}
annotated={true}
/>
);
}
}

render() {
return (
<div>
<div style={this.props.height ? {height: this.props.height} : null} ref={(c) => { this.editorEl = c; }} />
<Divider/>
<Checkbox
label="Show Diff"
checked={this.state.showDiff}
onCheck={(e,isChecked) => this.setState({showDiff: isChecked})}
/>
{this.state.showDiff && this.renderDiff()}
</div>
);
}
}
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"babel-loader": "^6.2.7",
"babel-preset-es2015": "^6.18.0",
"babel-preset-react": "^6.16.0",
"babel-preset-stage-0": "^6.22.0",
"babel-preset-stage-2": "^6.18.0",
"css-loader": "^0.25.0",
"eslint": "^3.14.0",
Expand All @@ -59,6 +60,8 @@
"hbs": "^4.0.1",
"hcl-to-json": "0.0.4",
"immutability-helper": "^2.1.2",
"jsondiffpatch": "^0.2.4",
"jsondiffpatch-for-react": "^1.0.1",
"jsoneditor": "^5.5.11",
"lodash": "^4.16.6",
"material-ui": "^0.16.1",
Expand Down