|
@@ -24,6 +24,7 @@ import ConnectionsActions from '../../actions/ConnectionsActions';
|
|
|
import NotificationActions from '../../actions/NotificationActions';
|
|
import NotificationActions from '../../actions/NotificationActions';
|
|
|
import Dropdown from '../NewDropdown';
|
|
import Dropdown from '../NewDropdown';
|
|
|
import LoadingIcon from "../LoadingIcon/LoadingIcon";
|
|
import LoadingIcon from "../LoadingIcon/LoadingIcon";
|
|
|
|
|
+import ValidateEndpoint from '../ValidateEndpoint';
|
|
|
|
|
|
|
|
const title = 'Add Cloud Endpoint';
|
|
const title = 'Add Cloud Endpoint';
|
|
|
|
|
|
|
@@ -45,11 +46,13 @@ class AddCloudConnection extends Reflux.Component {
|
|
|
this.store = ConnectionsStore
|
|
this.store = ConnectionsStore
|
|
|
|
|
|
|
|
this.state = {
|
|
this.state = {
|
|
|
|
|
+ type: props.type,
|
|
|
|
|
+ connection: props.connection,
|
|
|
connectionName: "",
|
|
connectionName: "",
|
|
|
description: null,
|
|
description: null,
|
|
|
currentCloud: this.props.cloud,
|
|
currentCloud: this.props.cloud,
|
|
|
currentCloudData: null,
|
|
currentCloudData: null,
|
|
|
- connected: false,
|
|
|
|
|
|
|
+ validateEndpoint: false,
|
|
|
isConnecting: false,
|
|
isConnecting: false,
|
|
|
requiredFields: [],
|
|
requiredFields: [],
|
|
|
cloudFormsSubmitted: false
|
|
cloudFormsSubmitted: false
|
|
@@ -62,17 +65,17 @@ class AddCloudConnection extends Reflux.Component {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
componentDidMount() {
|
|
|
- if (this.props.connection) {
|
|
|
|
|
|
|
+ if (this.state.connection) {
|
|
|
this.state.allClouds.forEach(item => {
|
|
this.state.allClouds.forEach(item => {
|
|
|
- if (item.name === this.props.connection.type) {
|
|
|
|
|
- let credentials = this.props.connection.credentials
|
|
|
|
|
|
|
+ if (item.name === this.state.connection.type) {
|
|
|
|
|
+ let credentials = this.state.connection.credentials
|
|
|
for (let i in credentials) {
|
|
for (let i in credentials) {
|
|
|
credentials[i] = credentials[i] + ""
|
|
credentials[i] = credentials[i] + ""
|
|
|
}
|
|
}
|
|
|
this.setState({
|
|
this.setState({
|
|
|
currentCloudData: credentials,
|
|
currentCloudData: credentials,
|
|
|
- connectionName: this.props.connection.name,
|
|
|
|
|
- description: this.props.connection.description
|
|
|
|
|
|
|
+ connectionName: this.state.connection.name,
|
|
|
|
|
+ description: this.state.connection.description
|
|
|
}, () => {
|
|
}, () => {
|
|
|
this.chooseCloud(item)
|
|
this.chooseCloud(item)
|
|
|
})
|
|
})
|
|
@@ -112,16 +115,22 @@ class AddCloudConnection extends Reflux.Component {
|
|
|
credentials[key] = credentials[key].value
|
|
credentials[key] = credentials[key].value
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- if (this.props.type == "new") {
|
|
|
|
|
|
|
+ if (this.state.type == "new") {
|
|
|
ConnectionsActions.newEndpoint({
|
|
ConnectionsActions.newEndpoint({
|
|
|
name: this.state.connectionName,
|
|
name: this.state.connectionName,
|
|
|
description: this.state.description,
|
|
description: this.state.description,
|
|
|
type: this.state.currentCloud.name,
|
|
type: this.state.currentCloud.name,
|
|
|
connection_info: credentials
|
|
connection_info: credentials
|
|
|
|
|
+ }, (response) => {
|
|
|
|
|
+ this.setState({
|
|
|
|
|
+ validateEndpoint: response.data.endpoint,
|
|
|
|
|
+ type: "edit",
|
|
|
|
|
+ connection: response.data.endpoint
|
|
|
|
|
+ })
|
|
|
})
|
|
})
|
|
|
this.props.addHandle(this.state.connectionName);
|
|
this.props.addHandle(this.state.connectionName);
|
|
|
} else {
|
|
} else {
|
|
|
- ConnectionsActions.editEndpoint(this.props.connection, {
|
|
|
|
|
|
|
+ ConnectionsActions.editEndpoint(this.state.connection, {
|
|
|
name: this.state.connectionName,
|
|
name: this.state.connectionName,
|
|
|
description: this.state.description,
|
|
description: this.state.description,
|
|
|
connection_info: credentials
|
|
connection_info: credentials
|
|
@@ -163,6 +172,10 @@ class AddCloudConnection extends Reflux.Component {
|
|
|
}, this.setDefaultValues)
|
|
}, this.setDefaultValues)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ backToEdit() {
|
|
|
|
|
+ this.setState({ validateEndpoint: null })
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
handleBack() {
|
|
handleBack() {
|
|
|
this.setState({
|
|
this.setState({
|
|
|
currentCloudData: null,
|
|
currentCloudData: null,
|
|
@@ -366,7 +379,7 @@ class AddCloudConnection extends Reflux.Component {
|
|
|
{fields}
|
|
{fields}
|
|
|
</div>
|
|
</div>
|
|
|
<div className={s.buttons}>
|
|
<div className={s.buttons}>
|
|
|
- {this.props.type == "new" ? (
|
|
|
|
|
|
|
+ {this.state.type == "new" ? (
|
|
|
<button className={s.leftBtn + " gray"} onClick={(e) => this.handleBack(e)}>Back</button>
|
|
<button className={s.leftBtn + " gray"} onClick={(e) => this.handleBack(e)}>Back</button>
|
|
|
) : (
|
|
) : (
|
|
|
<button className={s.leftBtn + " gray"} onClick={(e) => this.handleCancel(e)}>Cancel</button>
|
|
<button className={s.leftBtn + " gray"} onClick={(e) => this.handleCancel(e)}>Cancel</button>
|
|
@@ -411,8 +424,15 @@ class AddCloudConnection extends Reflux.Component {
|
|
|
|
|
|
|
|
render() {
|
|
render() {
|
|
|
let modalBody
|
|
let modalBody
|
|
|
-
|
|
|
|
|
- if (this.state.currentCloud == null) {
|
|
|
|
|
|
|
+ if (this.state.validateEndpoint) {
|
|
|
|
|
+ modalBody = (
|
|
|
|
|
+ <ValidateEndpoint
|
|
|
|
|
+ closeHandle={this.props.closeHandle}
|
|
|
|
|
+ endpoint={this.state.validateEndpoint}
|
|
|
|
|
+ backHandle={(e) => this.backToEdit(e)}
|
|
|
|
|
+ />
|
|
|
|
|
+ )
|
|
|
|
|
+ } else if (this.state.currentCloud == null) {
|
|
|
if (this.state.allClouds) {
|
|
if (this.state.allClouds) {
|
|
|
modalBody = this.renderCloudList()
|
|
modalBody = this.renderCloudList()
|
|
|
} else {
|
|
} else {
|