|
@@ -1,19 +1,19 @@
|
|
|
/*
|
|
/*
|
|
|
-Copyright (C) 2017 Cloudbase Solutions SRL
|
|
|
|
|
|
|
+ Copyright (C) 2017 Cloudbase Solutions SRL
|
|
|
|
|
|
|
|
-This program is free software: you can redistribute it and/or modify
|
|
|
|
|
-it under the terms of the GNU Affero General Public License as
|
|
|
|
|
-published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
-License, or (at your option) any later version.
|
|
|
|
|
|
|
+ This program is free software: you can redistribute it and/or modify
|
|
|
|
|
+ it under the terms of the GNU Affero General Public License as
|
|
|
|
|
+ published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
+ License, or (at your option) any later version.
|
|
|
|
|
|
|
|
-This program is distributed in the hope that it will be useful,
|
|
|
|
|
-but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
-GNU Affero General Public License for more details.
|
|
|
|
|
|
|
+ This program is distributed in the hope that it will be useful,
|
|
|
|
|
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
+ GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
-You should have received a copy of the GNU Affero General Public License
|
|
|
|
|
-along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
-*/
|
|
|
|
|
|
|
+ You should have received a copy of the GNU Affero General Public License
|
|
|
|
|
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
+ */
|
|
|
|
|
|
|
|
import React, { PropTypes } from 'react';
|
|
import React, { PropTypes } from 'react';
|
|
|
import withStyles from 'isomorphic-style-loader/lib/withStyles';
|
|
import withStyles from 'isomorphic-style-loader/lib/withStyles';
|
|
@@ -45,7 +45,7 @@ class AddCloudConnection extends Reflux.Component {
|
|
|
this.store = ConnectionsStore
|
|
this.store = ConnectionsStore
|
|
|
|
|
|
|
|
this.state = {
|
|
this.state = {
|
|
|
- connectionName: null,
|
|
|
|
|
|
|
+ connectionName: "",
|
|
|
description: null,
|
|
description: null,
|
|
|
currentCloud: this.props.cloud,
|
|
currentCloud: this.props.cloud,
|
|
|
currentCloudData: null,
|
|
currentCloudData: null,
|
|
@@ -92,27 +92,43 @@ class AddCloudConnection extends Reflux.Component {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
handleSave() {
|
|
handleSave() {
|
|
|
- let credentials = Object.assign({}, this.state.currentCloudData)
|
|
|
|
|
- for (let key in credentials) {
|
|
|
|
|
- if (credentials[key].label) {
|
|
|
|
|
- credentials[key] = credentials[key].value
|
|
|
|
|
|
|
+ let valid = true
|
|
|
|
|
+
|
|
|
|
|
+ for (let i in this.state.currentCloudData) {
|
|
|
|
|
+ if (this.state.requiredFields.indexOf(i) > -1 && !this.state.currentCloudData[i]) {
|
|
|
|
|
+ valid = false
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- if (this.props.type == "new") {
|
|
|
|
|
- ConnectionsActions.newConnection({
|
|
|
|
|
- name: this.state.connectionName,
|
|
|
|
|
- description: this.state.description,
|
|
|
|
|
- type: this.state.currentCloud.name,
|
|
|
|
|
- connection_info: credentials
|
|
|
|
|
- })
|
|
|
|
|
- this.props.addHandle(this.state.connectionName);
|
|
|
|
|
|
|
+ if (this.state.connectionName.trim().length == 0) {
|
|
|
|
|
+ valid = false
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!valid) {
|
|
|
|
|
+ NotificationActions.notify("Please fill all required fields", "error")
|
|
|
|
|
+ this.setState({ cloudFormsSubmitted: true })
|
|
|
} else {
|
|
} else {
|
|
|
- ConnectionsActions.editEndpoint(this.props.connection, {
|
|
|
|
|
- name: this.state.connectionName,
|
|
|
|
|
- description: this.state.description,
|
|
|
|
|
- type: this.state.currentCloud.name,
|
|
|
|
|
- connection_info: credentials
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ let credentials = Object.assign({}, this.state.currentCloudData)
|
|
|
|
|
+ for (let key in credentials) {
|
|
|
|
|
+ if (credentials[key].label) {
|
|
|
|
|
+ credentials[key] = credentials[key].value
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (this.props.type == "new") {
|
|
|
|
|
+ ConnectionsActions.newConnection({
|
|
|
|
|
+ name: this.state.connectionName,
|
|
|
|
|
+ description: this.state.description,
|
|
|
|
|
+ type: this.state.currentCloud.name,
|
|
|
|
|
+ connection_info: credentials
|
|
|
|
|
+ })
|
|
|
|
|
+ this.props.addHandle(this.state.connectionName);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ ConnectionsActions.editEndpoint(this.props.connection, {
|
|
|
|
|
+ name: this.state.connectionName,
|
|
|
|
|
+ description: this.state.description,
|
|
|
|
|
+ type: this.state.currentCloud.name,
|
|
|
|
|
+ connection_info: credentials
|
|
|
|
|
+ })
|
|
|
|
|
+ this.props.closeHandle()
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -151,7 +167,7 @@ class AddCloudConnection extends Reflux.Component {
|
|
|
currentCloudData: null,
|
|
currentCloudData: null,
|
|
|
currentCloud: null,
|
|
currentCloud: null,
|
|
|
requiredFields: null,
|
|
requiredFields: null,
|
|
|
- connectionName: null,
|
|
|
|
|
|
|
+ connectionName: "",
|
|
|
description: null
|
|
description: null
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
@@ -307,26 +323,6 @@ class AddCloudConnection extends Reflux.Component {
|
|
|
return returnValue
|
|
return returnValue
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- connectToCloud() {
|
|
|
|
|
- // TODO: Validation here
|
|
|
|
|
- let valid = true
|
|
|
|
|
-
|
|
|
|
|
- for (var i in this.state.currentCloudData) {
|
|
|
|
|
- if (this.state.requiredFields.indexOf(i) > -1 && !this.state.currentCloudData[i]) {
|
|
|
|
|
- valid = false
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- if (!valid) {
|
|
|
|
|
- NotificationActions.notify("Please fill all required fields", "error")
|
|
|
|
|
- this.setState({ cloudFormsSubmitted: true })
|
|
|
|
|
- } else {
|
|
|
|
|
- this.setState({ isConnecting: true })
|
|
|
|
|
- setTimeout(() => {
|
|
|
|
|
- this.setState({ isConnecting: false, connected: true })
|
|
|
|
|
- }, 1000)
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
handleCloudFieldChange(e, field) {
|
|
handleCloudFieldChange(e, field) {
|
|
|
let currentCloudData = this.state.currentCloudData
|
|
let currentCloudData = this.state.currentCloudData
|
|
|
if (field.type == 'dropdown') {
|
|
if (field.type == 'dropdown') {
|
|
@@ -348,10 +344,12 @@ class AddCloudConnection extends Reflux.Component {
|
|
|
<div className={s.cloudImage}>
|
|
<div className={s.cloudImage}>
|
|
|
<div className={" icon large-cloud " + this.state.currentCloud.name}></div>
|
|
<div className={" icon large-cloud " + this.state.currentCloud.name}></div>
|
|
|
</div>
|
|
</div>
|
|
|
- <div className="form-group">
|
|
|
|
|
|
|
+ <div className={"form-group " + (this.state.cloudFormsSubmitted &&
|
|
|
|
|
+ this.state.connectionName.trim().length == 0 ? s.error : "")}
|
|
|
|
|
+ >
|
|
|
<input
|
|
<input
|
|
|
type="text"
|
|
type="text"
|
|
|
- placeholder="Endpoint Name"
|
|
|
|
|
|
|
+ placeholder="Endpoint Name *"
|
|
|
onChange={(e) => this.handleChangeName(e)}
|
|
onChange={(e) => this.handleChangeName(e)}
|
|
|
value={this.state.connectionName}
|
|
value={this.state.connectionName}
|
|
|
/>
|
|
/>
|
|
@@ -417,7 +415,7 @@ class AddCloudConnection extends Reflux.Component {
|
|
|
if (this.state.allClouds) {
|
|
if (this.state.allClouds) {
|
|
|
modalBody = this.renderCloudList()
|
|
modalBody = this.renderCloudList()
|
|
|
} else {
|
|
} else {
|
|
|
- modalBody = <LoadingIcon/>
|
|
|
|
|
|
|
+ modalBody = <LoadingIcon />
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
modalBody = this.renderCloudFields(this.state.currentCloud)
|
|
modalBody = this.renderCloudFields(this.state.currentCloud)
|