|
@@ -162,28 +162,20 @@ class AddCloudConnection extends Reflux.Component {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // If Azure, explicitly setting the fields right
|
|
|
|
|
- if (this.state.currentCloud.name == "azure") {
|
|
|
|
|
- credentials = {}
|
|
|
|
|
- credentials["subscription_id"] = this.state.currentCloudData["subscription_id"]
|
|
|
|
|
- if (this.state.currentCloudData["login_type"] == "user_credentials") {
|
|
|
|
|
- credentials["user_credentials"] = {
|
|
|
|
|
- username: this.state.currentCloudData["username"],
|
|
|
|
|
- password: this.state.currentCloudData["password"]
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- credentials["service_principal_credentials"] = {
|
|
|
|
|
- tenant_id: this.state.currentCloudData["tenant_id"],
|
|
|
|
|
- client_id: this.state.currentCloudData["client_id"],
|
|
|
|
|
- client_secret: this.state.currentCloudData["client_secret"]
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // If there's a switch radio, create a hierarchical structure with the selected radio as the root.
|
|
|
|
|
+ this.state.currentCloud.endpoint.fields.forEach(field => {
|
|
|
|
|
+ if (field.type === 'switch-radio') {
|
|
|
|
|
+ credentials[credentials[field.name]] = {}
|
|
|
|
|
+
|
|
|
|
|
+ field.options.forEach(fieldOptions => {
|
|
|
|
|
+ if (fieldOptions.value === credentials[field.name]) {
|
|
|
|
|
+ fieldOptions.fields.forEach(fieldOptionField => {
|
|
|
|
|
+ credentials[credentials[field.name]][fieldOptionField.name] = credentials[fieldOptionField.name]
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // Remove the login_type since it is not needed
|
|
|
|
|
- if (this.state.currentCloud.name == "azure") {
|
|
|
|
|
- delete credentials.login_type
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ })
|
|
|
|
|
|
|
|
// If endpoint is new
|
|
// If endpoint is new
|
|
|
if (this.state.type == "new") {
|
|
if (this.state.type == "new") {
|
|
@@ -304,7 +296,7 @@ class AddCloudConnection extends Reflux.Component {
|
|
|
break
|
|
break
|
|
|
case 'switch-radio':
|
|
case 'switch-radio':
|
|
|
field.options.forEach(option => {
|
|
field.options.forEach(option => {
|
|
|
- if (option.default && !currentCloudData[field.name]){
|
|
|
|
|
|
|
+ if (option.default && !currentCloudData[field.name]) {
|
|
|
currentCloudData[field.name] = option.value
|
|
currentCloudData[field.name] = option.value
|
|
|
this.setRadioRequiredFields(field, option.value)
|
|
this.setRadioRequiredFields(field, option.value)
|
|
|
this.setState({ currentCloudData: currentCloudData })
|
|
this.setState({ currentCloudData: currentCloudData })
|
|
@@ -342,16 +334,16 @@ class AddCloudConnection extends Reflux.Component {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Dinamically change the required fields affected by the current radio selection
|
|
* Dinamically change the required fields affected by the current radio selection
|
|
|
- * @param field
|
|
|
|
|
- * @param currentValue
|
|
|
|
|
|
|
+ * @param field
|
|
|
|
|
+ * @param currentValue
|
|
|
*/
|
|
*/
|
|
|
setRadioRequiredFields(field, currentValue) {
|
|
setRadioRequiredFields(field, currentValue) {
|
|
|
let requiredFields = this.state.requiredFields || [];
|
|
let requiredFields = this.state.requiredFields || [];
|
|
|
|
|
|
|
|
// Remove fields set by previous radio change
|
|
// Remove fields set by previous radio change
|
|
|
field.options.forEach(option => {
|
|
field.options.forEach(option => {
|
|
|
- option.fields.forEach(field => {
|
|
|
|
|
- requiredFields = requiredFields.filter(rf => rf !== field.name)
|
|
|
|
|
|
|
+ option.fields.forEach(f => {
|
|
|
|
|
+ requiredFields = requiredFields.filter(rf => rf !== f.name)
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|