Преглед изворни кода

- Moves Networking step after Options step in Wizard
- Adds env parameter to networks API call

George Vrancianu пре 8 година
родитељ
комит
db327daf26

+ 12 - 9
src/components/WizardNetworks/WizardNetworks.js

@@ -40,14 +40,8 @@ class WizardNetworks extends Component {
     super(props)
 
     this.networkOptions = [] // [{ label: "Create new", value: null }]
-    if (this.props.data.targetNetworks && this.props.data.targetNetworks.length) {
-      this.props.data.targetNetworks.forEach((network) => {
-        this.networkOptions.push({
-          label: network.name,
-          value: network.name
-        })
-      }, this)
-    }
+
+    ConnectionsActions.loadNetworks(this.props.data.targetCloud.credential)
 
     props.data.selectedInstances.forEach((vm) => {
       ConnectionsActions.loadInstanceDetail({ id: this.props.data.sourceCloud.credential.id }, vm)
@@ -66,7 +60,7 @@ class WizardNetworks extends Component {
 
     this.state = {
       networks: props.data.networks || null,
-      nextStep: "WizardOptions",
+      nextStep: "WizardSchedule",
       valid: valid
     }
   }
@@ -105,6 +99,15 @@ class WizardNetworks extends Component {
     if (networks.length == 0) {
       networks = null
     }
+    if (props.data.targetNetworks && props.data.targetNetworks.length) {
+      this.networkOptions = []
+      props.data.targetNetworks.forEach((network) => {
+        this.networkOptions.push({
+          label: network.name,
+          value: network.name
+        })
+      }, this)
+    }
     this.setState({ networks: networks })
   }
 

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

@@ -45,7 +45,7 @@ class WizardOptions extends Reflux.Component {
       diskFormat: "VHD",
       fipPool: "public",
       valid: true,
-      nextStep: "WizardSchedule",
+      nextStep: "WizardNetworks",
       formSubmitted: false,
       nextCallback: (e) => this.nextCallback(e),
       showAdvancedOptions: props.data.showAdvancedOptions

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

@@ -108,7 +108,6 @@ class WizardTarget extends Component {
       connection = this.state.connections.filter(item => item.name === connection.name)[0]
     }
 
-    ConnectionsActions.loadNetworks(connection)
     if (callback) {
       callback()
     }

+ 1 - 1
src/components/WizardVms/WizardVms.js

@@ -55,7 +55,7 @@ class WizardVms extends Component {
       page: 0,
       filterStatus: 'All',
       filteredData: this.props.data.instances ? this.props.data.instances.slice(0, itemsPerPage) : [],
-      nextStep: "WizardNetworks"
+      nextStep: "WizardOptions"
     }
   }
 

+ 5 - 5
src/config.sample.js

@@ -83,16 +83,16 @@ export const migrationSteps = [
     title: "Select instances",
     component: "WizardVms"
   },
-  {
-    name: "Network Mapping",
-    title: "Network Mapping",
-    component: "WizardNetworks"
-  },
   {
     name: "Options",
     title: "Options",
     component: "WizardOptions"
   },
+  {
+    name: "Network Mapping",
+    title: "Network Mapping",
+    component: "WizardNetworks"
+  },
   {
     name: "Schedule",
     title: "Schedule",

+ 2 - 3
src/stores/WizardStore/WizardStore.js

@@ -139,8 +139,8 @@ class UsersStore extends Reflux.Store
       targetNetworks: null
     })
     let projectId = Reflux.GlobalState.userStore.currentUser.project.id
-
-    let url = `${servicesUrl.coriolis}/${projectId}/endpoints/${endpoint.id}/networks`
+    let targetEnv = btoa(JSON.stringify(this.state.destination_environment))
+    let url = `${servicesUrl.coriolis}/${projectId}/endpoints/${endpoint.id}/networks?env=${targetEnv}`
 
     Api.sendAjaxRequest({
       url: url,
@@ -150,7 +150,6 @@ class UsersStore extends Reflux.Store
   }
 
   onLoadNetworksCompleted(response) {
-    console.log(response.data.networks)
     if (response.data.networks) {
       this.setState({
         targetNetworks: response.data.networks