Просмотр исходного кода

Prevents replica execution when one of the endpoints is missing CORWEB-51

George Vrancianu 8 лет назад
Родитель
Сommit
bfbd221237

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

@@ -118,6 +118,28 @@ MigrationActions.deleteReplica.listen((replica, callback = null) => {
 
 
 MigrationActions.executeReplica.listen((replica, callback = null) => {
 MigrationActions.executeReplica.listen((replica, callback = null) => {
   if (replica.type == 'replica') {
   if (replica.type == 'replica') {
+    // check if endpoints exists
+    let connections = Reflux.GlobalState.connectionStore.connections
+    let originEndpoint = false
+    let destinationEndpoint = false
+
+    connections.forEach(connection => {
+      if (replica.origin_endpoint_id === connection.id) {
+        originEndpoint = true
+      }
+      if (replica.destination_endpoint_id === connection.id) {
+        destinationEndpoint = true
+      }
+    })
+
+    if (!originEndpoint) {
+      NotificationActions.notify("Origin endpoint is missing. Cannot execute this replica.", "error")
+      return
+    }
+    if (!destinationEndpoint) {
+      NotificationActions.notify("Destination endpoint is missing. Cannot execute this replica.", "error")
+      return
+    }
     let projectId = Reflux.GlobalState.userStore.currentUser.project.id
     let projectId = Reflux.GlobalState.userStore.currentUser.project.id
 
 
     let payload = {
     let payload = {

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

@@ -100,7 +100,7 @@ class EndpointLink extends Reflux.Component {
         onClick={this.handleClick}
         onClick={this.handleClick}
       >{this.state.connection.name}</a>)
       >{this.state.connection.name}</a>)
     } else {
     } else {
-      return <div><span className="taskIcon ERROR" />Endpoint not found</div>
+      return <div><span className="taskIcon ERROR" />Endpoint missing</div>
     }
     }
   }
   }
 }
 }