Browse Source

Allow further progress even if the selected instances have no NICs

This means that the message from previous commit is still displayed, but the 'Next' button is enabled.
Sergiu Miclea 8 years ago
parent
commit
db9948bc26

+ 6 - 4
src/actions/MigrationActions/MigrationActions.js

@@ -266,9 +266,11 @@ MigrationActions.addMigration.listen((migration, callback = null, errorCallback
   })
 
   let networkMap = {}
-  migration.networks.forEach(network => {
-    networkMap[network.network_name] = network.migrateNetwork
-  })
+  if (migration.networks) {
+    migration.networks.forEach(network => {
+      networkMap[network.network_name] = network.migrateNetwork
+    })
+  }
 
   let destinationEnv = {}
 
@@ -300,7 +302,7 @@ MigrationActions.addMigration.listen((migration, callback = null, errorCallback
     }
   }
 
-  destinationEnv["network_map"] = networkMap // eslint-disable-line dot-notation
+  destinationEnv.network_map = networkMap
 
   payload[migration.migrationType] = {
     origin_endpoint_id: migration.sourceCloud.credential.id,

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

@@ -168,7 +168,7 @@ class MigrationWizard extends Reflux.Component {
         step = <WizardVms setWizardState={(e) => this.setWizardState(e)} data={this.state} />
         break;
       case "WizardNetworks":
-        step = <WizardNetworks setWizardState={(e) => this.setWizardState(e)} data={this.state} />
+        step = <WizardNetworks data={this.state} />
         break;
       case "WizardMigrationType":
         step = (<WizardMigrationType

+ 7 - 5
src/components/WizardNetworks/WizardNetworks.js

@@ -33,7 +33,6 @@ class WizardNetworks extends Component {
 
   static propTypes = {
     data: PropTypes.object,
-    setWizardState: PropTypes.func
   }
 
   constructor(props) {
@@ -126,10 +125,13 @@ class WizardNetworks extends Component {
       }, this)
     }
 
-    this.setState({
-      networks: networks,
-      hasNoNics: hasNoNics
-    })
+    if (!this.state.valid && hasNoNics) {
+      this.setState({ networks, hasNoNics, valid: true }, () => {
+        WizardActions.updateWizardState({ networks, valid: true })
+      })
+    } else {
+      this.setState({ networks, hasNoNics })
+    }
   }
 
   handleChangeNetwork(event, network) {

+ 38 - 30
src/components/WizardSummary/WizardSummary.js

@@ -78,29 +78,44 @@ class WizardSummary extends Component {
       </div>
     ))
 
-    let networks = this.props.summary.networks.map((network, index) => {
-      if (network.selected || true) {
-        return (
-          <div className="item" key={"Network_" + index}>
-            <span className="cell">
-              <TextTruncate line={1} text={network.network_name} truncateText="..." />
-            </span>
-            <span className="cell">
-              <div className="arrow"></div>
-            </span>
-            <span className="cell">
-              <TextTruncate
-                line={1}
-                text={network.migrateNetwork ? network.migrateNetwork : "Create new"}
-                truncateText="..."
-              />
-            </span>
+    let networksContainer = null
+    if (this.props.summary.networks) {
+      let networks = this.props.summary.networks && this.props.summary.networks.map((network, index) => {
+        if (network.selected || true) {
+          return (
+            <div className="item" key={"Network_" + index}>
+              <span className="cell">
+                <TextTruncate line={1} text={network.network_name} truncateText="..." />
+              </span>
+              <span className="cell">
+                <div className="arrow"></div>
+              </span>
+              <span className="cell">
+                <TextTruncate
+                  line={1}
+                  text={network.migrateNetwork ? network.migrateNetwork : "Create new"}
+                  truncateText="..."
+                />
+              </span>
+            </div>
+          )
+        } else {
+          return null
+        }
+      })
+
+      networksContainer = (
+        <div className={s.group}>
+          <h3>
+            Networks
+              </h3>
+          <div className={s.networks + " items-list"}>
+            {networks}
           </div>
-        )
-      } else {
-        return null
-      }
-    })
+        </div>
+      )
+    }
+
     return (
       <div className={s.root}>
         <div className={s.container}>
@@ -151,14 +166,7 @@ class WizardSummary extends Component {
                 {instances}
               </div>
             </div>
-            <div className={s.group}>
-              <h3>
-                Networks
-              </h3>
-              <div className={s.networks + " items-list"}>
-                {networks}
-              </div>
-            </div>
+            {networksContainer}
           </div>
         </div>
       </div>