diff --git a/src/ic/edit-ic.js b/src/ic/edit-ic.js index b97d02a..404642c 100644 --- a/src/ic/edit-ic.js +++ b/src/ic/edit-ic.js @@ -30,23 +30,38 @@ class EditICDialog extends React.Component { this.state = { name: '', - endpoint: '' + host: '', + type: '', + category: '', + properties: {}, }; } onClose(canceled) { if (canceled === false) { if (this.valid) { - let data = this.props.ic.properties; + let data = this.props.ic; - if (this.state.name != null && this.state.name !== "" && this.state.name !== _.get(this.props.ic, 'rawProperties.name')) { + if (this.state.name != null && this.state.name !== "" && this.state.name !== this.props.ic.name) { data.name = this.state.name; } - if (this.state.endpoint != null && this.state.endpoint !== "" && this.state.endpoint !== "http://" && this.state.endpoint !== _.get(this.props.ic, 'rawProperties.endpoint')) { - data.endpoint = this.state.endpoint; + if (this.state.host != null && this.state.host !== "" && this.state.host !== "http://" && this.state.host !== this.props.ic.host) { + data.host = this.state.host; } + if (this.state.type != null && this.state.type !== "" && this.state.type !== this.props.ic.type) { + data.type = this.state.type; + } + + if (this.state.category != null && this.state.category !== "" && this.state.category !== this.props.ic.category) { + data.category = this.state.category; + } + if (this.state.properties !== {}) { + data.properties = this.state.properties + } + + this.props.onClose(data); } } else { @@ -60,8 +75,11 @@ class EditICDialog extends React.Component { resetState() { this.setState({ - name: _.get(this.props.ic, 'properties.name') || _.get(this.props.ic, 'rawProperties.name'), - endpoint: _.get(this.props.ic, 'properties.endpoint') || _.get(this.props.ic, 'rawProperties.endpoint') + name: this.props.ic.name, + host: this.props.ic.host, + type: this.props.ic.type, + category: this.props.ic.category, + properties: _.merge({}, _.get(this.props.ic, 'rawProperties'), _.get(this.props.ic, 'properties')) }); } @@ -71,17 +89,27 @@ class EditICDialog extends React.Component {
diff --git a/src/ic/ics.js b/src/ic/ics.js index a66b271..603e474 100644 --- a/src/ic/ics.js +++ b/src/ic/ics.js @@ -127,13 +127,13 @@ class InfrastructureComponents extends Component { this.setState({ editModal : false }); if (data) { - let ic = this.state.ics[this.state.modalIndex]; - ic.properties = data; - this.setState({ ic: ic }); + //let ic = this.state.ics[this.state.modalIndex]; + //ic = data; + //this.setState({ ic: ic }); AppDispatcher.dispatch({ type: 'ics/start-edit', - data: ic, + data: data, token: this.state.sessionToken, }); } @@ -272,10 +272,10 @@ class InfrastructureComponents extends Component {