Parcourir la source

Merge branch 'master' into corweb-24

george-vrancianu il y a 8 ans
Parent
commit
0ef7e126a1

+ 15 - 18
src/actions/ConnectionsActions/ConnectionsActions.js

@@ -82,20 +82,25 @@ ConnectionsActions.loadNetworks.listen((endpoint) => {
     .catch(ConnectionsActions.loadNetworks.failed);
     .catch(ConnectionsActions.loadNetworks.failed);
 })
 })
 
 
-ConnectionsActions.newEndpoint.listen((data, callback = null) => {
-  if (useSecret) {
-    let barbicanPayload = {
-      payload: JSON.stringify(data.connection_info),
-      payload_content_type: "text/plain",
-      content_types: {
-        default: "text/plain"
-      }
+function getBarbicanPayload(data) {
+  return {
+    payload: JSON.stringify(data),
+    payload_content_type: "text/plain",
+    algorithm: "aes",
+    bit_length: 256,
+    mode: "cbc",
+    content_types: {
+      default: "text/plain"
     }
     }
+  }
+}
 
 
+ConnectionsActions.newEndpoint.listen((data, callback = null) => {
+  if (useSecret) {
     Api.sendAjaxRequest({
     Api.sendAjaxRequest({
       url: servicesUrl.barbican + "/v1/secrets",
       url: servicesUrl.barbican + "/v1/secrets",
       method: "POST",
       method: "POST",
-      data: barbicanPayload
+      data: getBarbicanPayload(data.connection_info)
     }).then((response) => {
     }).then((response) => {
       ConnectionsActions.newEndpoint.success(response, data, callback)
       ConnectionsActions.newEndpoint.success(response, data, callback)
     }, ConnectionsActions.newEndpoint.failed)
     }, ConnectionsActions.newEndpoint.failed)
@@ -141,18 +146,11 @@ ConnectionsActions.editEndpoint.listen((connection, data, callback = null) => {
       url: servicesUrl.barbican + "/v1/secrets/" + uuid,
       url: servicesUrl.barbican + "/v1/secrets/" + uuid,
       method: "DELETE"
       method: "DELETE"
     })
     })
-    let barbicanPayload = {
-      payload: JSON.stringify(data.connection_info),
-      payload_content_type: "text/plain",
-      content_types: {
-        default: "text/plain"
-      }
-    }
 
 
     Api.sendAjaxRequest({
     Api.sendAjaxRequest({
       url: servicesUrl.barbican + "/v1/secrets",
       url: servicesUrl.barbican + "/v1/secrets",
       method: "POST",
       method: "POST",
-      data: barbicanPayload
+      data: getBarbicanPayload(data.connection_info)
     }).then((response) => {
     }).then((response) => {
       ConnectionsActions.editEndpoint.success(response, connection, data, callback)
       ConnectionsActions.editEndpoint.success(response, connection, data, callback)
     }, ConnectionsActions.editEndpoint.failed)
     }, ConnectionsActions.editEndpoint.failed)
@@ -177,7 +175,6 @@ ConnectionsActions.saveEditEndpoint.listen((connection, data, callback = null) =
     method: "PUT",
     method: "PUT",
     data: payload
     data: payload
   }).then((response) => {
   }).then((response) => {
-    console.log("CALLBACK", callback)
     if (typeof callback === "function") {
     if (typeof callback === "function") {
       callback(response)
       callback(response)
     }
     }

+ 1 - 0
src/actions/MigrationActions/MigrationActions.js

@@ -68,6 +68,7 @@ MigrationActions.loadReplicas.listen(() => {
 
 
 MigrationActions.loadReplicas.shouldEmit = () => {
 MigrationActions.loadReplicas.shouldEmit = () => {
   let projectId = Reflux.GlobalState.userStore.currentUser.project.id
   let projectId = Reflux.GlobalState.userStore.currentUser.project.id
+
   let scoped = Reflux.GlobalState.userStore.currentUser.scoped
   let scoped = Reflux.GlobalState.userStore.currentUser.scoped
   return typeof projectId !== "undefined" && scoped
   return typeof projectId !== "undefined" && scoped
 }
 }

+ 1 - 5
src/components/AddCloudConnection/AddCloudConnection.js

@@ -337,11 +337,7 @@ class AddCloudConnection extends Reflux.Component {
   isValid(field) {
   isValid(field) {
     if (field.required && this.state.cloudFormsSubmitted) {
     if (field.required && this.state.cloudFormsSubmitted) {
       if (this.state.currentCloudData[field.name]) {
       if (this.state.currentCloudData[field.name]) {
-        if (this.state.currentCloudData[field.name] && this.state.currentCloudData[field.name].length == 0) {
-          return false
-        } else {
-          return true
-        }
+        return !(this.state.currentCloudData[field.name] && this.state.currentCloudData[field.name].length == 0);
       } else {
       } else {
         return false
         return false
       }
       }

+ 3 - 3
src/components/ApiCaller/ApiCaller.js

@@ -16,7 +16,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 */
 /* eslint-disable */
 /* eslint-disable */
 
 
-import React, { Component } from 'react';
+import React from 'react';
 import NotificationActions from '../../actions/NotificationActions';
 import NotificationActions from '../../actions/NotificationActions';
 import Location from '../../core/Location';
 import Location from '../../core/Location';
 
 
@@ -45,12 +45,12 @@ class ApiCaller {
       let headers = Object.assign({}, this.defaultHeaders)
       let headers = Object.assign({}, this.defaultHeaders)
 
 
       if (options.headers) {
       if (options.headers) {
-        for (var key in options.headers) {
+        for (let key in options.headers) {
           headers[key] = options.headers[key]
           headers[key] = options.headers[key]
         }
         }
       }
       }
 
 
-      for (name in headers) {
+      for (let name in headers) {
         request.setRequestHeader(name, headers[name])
         request.setRequestHeader(name, headers[name])
       }
       }
 
 

+ 2 - 2
src/components/CloudConnectionAuth/CloudConnectionAuth.js

@@ -18,7 +18,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 import React, { Component, PropTypes } from 'react';
 import React, { Component, PropTypes } from 'react';
 import withStyles from 'isomorphic-style-loader/lib/withStyles';
 import withStyles from 'isomorphic-style-loader/lib/withStyles';
 import s from './CloudConnectionAuth.scss';
 import s from './CloudConnectionAuth.scss';
-import { defaultLabels } from '../../constants/CloudLabels';
+import Helper from '../Helper';
 import LoadingIcon from "../LoadingIcon/LoadingIcon";
 import LoadingIcon from "../LoadingIcon/LoadingIcon";
 
 
 
 
@@ -56,7 +56,7 @@ class CloudConnectionAuth extends Component {
         if (value === false) value = "No"
         if (value === false) value = "No"
 
 
         fields.push({
         fields.push({
-          fieldName: defaultLabels[fieldName] ? defaultLabels[fieldName] : fieldName,
+          fieldName: Helper.convertCloudFieldLabel(fieldName),
           fieldValue: value
           fieldValue: value
         })
         })
       }
       }

+ 2 - 3
src/components/CloudConnectionDetail/CloudConnectionDetail.js

@@ -20,7 +20,6 @@ import withStyles from 'isomorphic-style-loader/lib/withStyles';
 import s from './CloudConnectionDetail.scss';
 import s from './CloudConnectionDetail.scss';
 import Moment from 'react-moment';
 import Moment from 'react-moment';
 import LoadingIcon from '../LoadingIcon';
 import LoadingIcon from '../LoadingIcon';
-import { defaultLabels } from '../../constants/CloudLabels';
 import Helper from '../Helper';
 import Helper from '../Helper';
 
 
 const title = 'connection details';
 const title = 'connection details';
@@ -61,7 +60,7 @@ class CloudConnectionDetail extends Component {
         if (value === false) value = "No"
         if (value === false) value = "No"
 
 
         fields.push({
         fields.push({
-          fieldName: defaultLabels[fieldName] ? defaultLabels[fieldName] : fieldName,
+          fieldName: Helper.convertCloudFieldLabel(fieldName),
           fieldValue: value
           fieldValue: value
         })
         })
       }
       }
@@ -135,7 +134,7 @@ class CloudConnectionDetail extends Component {
                 Type
                 Type
               </div>
               </div>
               <div className={s.value}>
               <div className={s.value}>
-                {item.type}
+                {Helper.convertCloudLabel(item.type)}
               </div>
               </div>
             </div>
             </div>
             <div className={s.formGroup}>
             <div className={s.formGroup}>

+ 1 - 5
src/components/EditProfile/EditProfile.js

@@ -100,11 +100,7 @@ class EditProfile extends Component {
 
 
   isValid(field) {
   isValid(field) {
     if (field.required && this.state.formSubmitted) {
     if (field.required && this.state.formSubmitted) {
-      if (this.state.currentCloudData[field.name].length == 0) {
-        return false
-      } else {
-        return true
-      }
+      return this.state.currentCloudData[field.name].length != 0;
     } else {
     } else {
       return true
       return true
     }
     }

+ 9 - 0
src/components/Helper/Helper.js

@@ -17,6 +17,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
 import { Component } from 'react';
 import { Component } from 'react';
 import moment from 'moment';
 import moment from 'moment';
+import { cloudLabels, defaultLabels } from '../../constants/CloudLabels';
 
 
 class Helper extends Component {
 class Helper extends Component {
   static getRandomArbitrary(min, max) {
   static getRandomArbitrary(min, max) {
@@ -40,6 +41,14 @@ class Helper extends Component {
     }
     }
     return hiddenPass
     return hiddenPass
   }
   }
+
+  static convertCloudFieldLabel(label) {
+    return defaultLabels[label] || label
+  }
+
+  static convertCloudLabel(label) {
+    return cloudLabels[label] || label
+  }
 }
 }
 
 
 export default Helper;
 export default Helper;

+ 0 - 1
src/components/TextBox/TextBox.js

@@ -17,7 +17,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 /* eslint-disable */
 /* eslint-disable */
 
 
 import React, { Component, PropTypes } from 'react';
 import React, { Component, PropTypes } from 'react';
-import withStyles from 'isomorphic-style-loader/lib/withStyles';
 import s from './TextBox.scss';
 import s from './TextBox.scss';
 
 
 class TextBox extends Component {
 class TextBox extends Component {

+ 11 - 2
src/components/WizardNetworks/WizardNetworks.js

@@ -57,8 +57,13 @@ class WizardNetworks extends Component {
       valid = false
       valid = false
     }
     }
 
 
+    let networks = props.data.networks
+    if (networks && networks.length) {
+      networks.sort((a, b) => a.network_name > b.network_name)
+    }
+
     this.state = {
     this.state = {
-      networks: props.data.networks || null,
+      networks: networks || null,
       nextStep: "WizardSchedule",
       nextStep: "WizardSchedule",
       valid: valid
       valid: valid
     }
     }
@@ -100,7 +105,11 @@ class WizardNetworks extends Component {
     }
     }
     if (props.data.targetNetworks && props.data.targetNetworks.length) {
     if (props.data.targetNetworks && props.data.targetNetworks.length) {
       this.networkOptions = []
       this.networkOptions = []
-      props.data.targetNetworks.forEach((network) => {
+      
+      let targetNetworks = props.data.targetNetworks
+      targetNetworks.sort((a, b) => a.name > b.name)
+
+      targetNetworks.forEach((network) => {
         this.networkOptions.push({
         this.networkOptions.push({
           label: network.name,
           label: network.name,
           value: network.name
           value: network.name

+ 1 - 5
src/components/WizardOptions/WizardOptions.js

@@ -91,11 +91,7 @@ class WizardOptions extends Reflux.Component {
       if (!this.state.destination_environment[field.name]) {
       if (!this.state.destination_environment[field.name]) {
         return false
         return false
       } else {
       } else {
-        if (this.state.destination_environment[field.name].trim().length == 0) {
-          return false
-        } else {
-          return true
-        }
+        return this.state.destination_environment[field.name].trim().length != 0;
       }
       }
     } else {
     } else {
       return true
       return true

+ 4 - 5
src/components/WizardSummary/WizardSummary.js

@@ -20,8 +20,7 @@ import withStyles from 'isomorphic-style-loader/lib/withStyles';
 import s from './WizardSummary.scss';
 import s from './WizardSummary.scss';
 import moment from 'moment';
 import moment from 'moment';
 import TextTruncate from 'react-text-truncate';
 import TextTruncate from 'react-text-truncate';
-import { defaultLabels } from '../../constants/CloudLabels';
-
+import Helper from '../Helper';
 
 
 const title = 'Summary';
 const title = 'Summary';
 
 
@@ -54,7 +53,7 @@ class WizardSummary extends Component {
     let fields = []
     let fields = []
     for (let i in this.props.summary.destination_environment) {
     for (let i in this.props.summary.destination_environment) {
       fields.push({
       fields.push({
-        label: defaultLabels[i] ? defaultLabels[i] : i,
+        label: Helper.convertCloudFieldLabel(i),
         value: this.props.summary.destination_environment[i]
         value: this.props.summary.destination_environment[i]
       })
       })
     }
     }
@@ -128,14 +127,14 @@ class WizardSummary extends Component {
                   <span>Source: <br /> </span>
                   <span>Source: <br /> </span>
                   <span>
                   <span>
                     <TextTruncate line={1} text={this.props.summary.sourceCloud.credential.name} truncateText="..." />
                     <TextTruncate line={1} text={this.props.summary.sourceCloud.credential.name} truncateText="..." />
-                    <span className={s.cloudBox}>{this.props.summary.sourceCloud.name}</span>
+                    <span className={s.cloudBox}>{Helper.convertCloudLabel(this.props.summary.sourceCloud.name)}</span>
                   </span>
                   </span>
                 </div>
                 </div>
                 <div className={s.row}>
                 <div className={s.row}>
                   <span>Target:</span>
                   <span>Target:</span>
                   <span>
                   <span>
                     <TextTruncate line={1} text={this.props.summary.targetCloud.credential.name} truncateText="..." />
                     <TextTruncate line={1} text={this.props.summary.targetCloud.credential.name} truncateText="..." />
-                    <span className={s.cloudBox}>{this.props.summary.targetCloud.name}</span>
+                    <span className={s.cloudBox}>{Helper.convertCloudLabel(this.props.summary.targetCloud.name)}</span>
                   </span>
                   </span>
                 </div>
                 </div>
               </div>
               </div>

+ 4 - 0
src/constants/CloudLabels.js

@@ -59,3 +59,7 @@ export const defaultLabels = {
   allow_untrusted_swift: "Allow Untrusted Swift",
   allow_untrusted_swift: "Allow Untrusted Swift",
   glance_api_version: "Glance API Version"
   glance_api_version: "Glance API Version"
 }
 }
+
+export const cloudLabels = {
+  vmware_vsphere: 'vmware'
+}

+ 7 - 46
src/stores/ConnectionsStore/ConnectionsStore.js

@@ -18,52 +18,16 @@
  */
  */
 
 
 
 
-import React, { Component, PropTypes } from 'react';
+import React from 'react';
 import Reflux from 'reflux';
 import Reflux from 'reflux';
 import ConnectionsActions from '../../actions/ConnectionsActions';
 import ConnectionsActions from '../../actions/ConnectionsActions';
-import WizardActions from '../../actions/WizardActions';
 import MigrationActions from '../../actions/MigrationActions';
 import MigrationActions from '../../actions/MigrationActions';
-import { defaultLabels } from '../../constants/CloudLabels';
+import Helper from '../../components/Helper';
 import Api from '../../components/ApiCaller'
 import Api from '../../components/ApiCaller'
 import {servicesUrl, providerType} from '../../config';
 import {servicesUrl, providerType} from '../../config';
 
 
 class ConnectionsStore extends Reflux.Store
 class ConnectionsStore extends Reflux.Store
 {
 {
-  connections = [
-    {
-      id: "vSphere-Cluster",
-      name: "vSphere-Cluster",
-      description: "",
-      created: new Date(),
-      cloudName: "vmware",
-      secretUrl: null,
-      credentials: {
-
-      }
-    },
-    {
-      id: "vSphere-Cluster2",
-      name: "vSphere-Cluster2",
-      description: "",
-      created: new Date(),
-      cloudName: "vmware",
-      secretUrl: null,
-      credentials: {
-
-      }
-    },
-    {
-      id: "azure-Cluster",
-      name: "Azure-Cluster",
-      description: "",
-      created: new Date(),
-      cloudName: "azure",
-      secretUrl: null,
-      credentials: {
-
-      }
-    }
-  ]
 
 
   constructor()
   constructor()
   {
   {
@@ -84,7 +48,7 @@ class ConnectionsStore extends Reflux.Store
     let clouds = []
     let clouds = []
     if (response.data.providers) {
     if (response.data.providers) {
       let providers = response.data.providers
       let providers = response.data.providers
-      for (var provider in providers) {
+      for (let provider in providers) {
         let cloud = {
         let cloud = {
           name: provider,
           name: provider,
           credentialSelected: null,
           credentialSelected: null,
@@ -139,7 +103,7 @@ class ConnectionsStore extends Reflux.Store
 
 
   onUpdateProvider(provider) {
   onUpdateProvider(provider) {
     let allClouds = this.state.allClouds
     let allClouds = this.state.allClouds
-    for (var i in allClouds) {
+    for (let i in allClouds) {
       if (allClouds[i].name == provider.name) {
       if (allClouds[i].name == provider.name) {
         allClouds[i] = provider
         allClouds[i] = provider
       }
       }
@@ -152,7 +116,7 @@ class ConnectionsStore extends Reflux.Store
       return false
       return false
     } else {
     } else {
       let allClouds = this.state.allClouds
       let allClouds = this.state.allClouds
-      for (var i in allClouds) {
+      for (let i in allClouds) {
         allClouds[i].credentials = []
         allClouds[i].credentials = []
         this.state.connections.forEach(connection => {
         this.state.connections.forEach(connection => {
           if (connection.type == allClouds[i].name) {
           if (connection.type == allClouds[i].name) {
@@ -296,9 +260,6 @@ class ConnectionsStore extends Reflux.Store
     }
     }
 
 
     if (providerName == "azure" && type == "connection") {
     if (providerName == "azure" && type == "connection") {
-      let subscriptionId = {
-        subscription_id: cloudData.properties.subscription_id
-      }
       let userCredentialFields = {
       let userCredentialFields = {
         properties: { subscription_id: cloudData.properties.subscription_id },
         properties: { subscription_id: cloudData.properties.subscription_id },
         required: cloudData.properties.user_credentials.required
         required: cloudData.properties.user_credentials.required
@@ -340,10 +301,10 @@ class ConnectionsStore extends Reflux.Store
     } else {
     } else {
       let fields = []
       let fields = []
       let sortedFields = [{}, {}]
       let sortedFields = [{}, {}]
-      for (var propName in cloudData.properties) {
+      for (let propName in cloudData.properties) {
         let field = {
         let field = {
           name: propName,
           name: propName,
-          label: defaultLabels[propName] ? defaultLabels[propName] : propName
+          label: Helper.convertCloudFieldLabel(propName)
         }
         }
 
 
         if (cloudData.properties[propName].default) {
         if (cloudData.properties[propName].default) {