Browse Source

Merge pull request #19 from george-vrancianu/corweb-42

Disables "Execute" button in replica view after it is pressed CORWEB-42
Alessandro Pilotti 8 years ago
parent
commit
461e849dba

+ 13 - 3
src/actions/MigrationActions/MigrationActions.js

@@ -116,7 +116,7 @@ MigrationActions.deleteReplica.listen((replica, callback = null) => {
     .catch(MigrationActions.deleteReplica.failed);
     .catch(MigrationActions.deleteReplica.failed);
 })
 })
 
 
-MigrationActions.executeReplica.listen((replica, callback = null) => {
+MigrationActions.executeReplica.listen((replica, callback = null, errorCallback = null) => {
   if (replica.type == 'replica') {
   if (replica.type == 'replica') {
     // check if endpoints exists
     // check if endpoints exists
     let connections = Reflux.GlobalState.connectionStore.connections
     let connections = Reflux.GlobalState.connectionStore.connections
@@ -158,8 +158,18 @@ MigrationActions.executeReplica.listen((replica, callback = null) => {
         if (callback) {
         if (callback) {
           callback(replica, response)
           callback(replica, response)
         }
         }
-      }, MigrationActions.executeReplica.failed)
-      .catch(MigrationActions.executeReplica.failed);
+      }, (err) => {
+        MigrationActions.executeReplica.failed(err)
+        if (errorCallback) {
+          errorCallback(replica, err)
+        }
+      })
+      .catch((err) => {
+        MigrationActions.executeReplica.failed(err)
+        if (errorCallback) {
+          errorCallback(replica, err)
+        }
+      });
   } else {
   } else {
     NotificationActions.notify("You cannot execute a migration.", "warning")
     NotificationActions.notify("You cannot execute a migration.", "warning")
   }
   }

+ 8 - 2
src/components/ReplicaView/ReplicaView.js

@@ -44,6 +44,7 @@ class ReplicaView extends Reflux.Component {
 
 
     this.state = {
     this.state = {
       title: 'Coriolis: View Replica',
       title: 'Coriolis: View Replica',
+      isBeingExecuted: false,
       confirmationDialog: {
       confirmationDialog: {
         visible: false,
         visible: false,
         message: "Are you sure?",
         message: "Are you sure?",
@@ -64,8 +65,13 @@ class ReplicaView extends Reflux.Component {
   }
   }
 
 
   executeReplica() {
   executeReplica() {
+    this.setState({ isBeingExecuted: true })
     let item = this.state.replicas.filter(replica => replica.id == this.props.replicaId)[0]
     let item = this.state.replicas.filter(replica => replica.id == this.props.replicaId)[0]
-    MigrationActions.executeReplica(item)
+    MigrationActions.executeReplica(item, () => {
+      this.setState({ isBeingExecuted: false })
+    }, () => {
+      this.setState({ isBeingExecuted: false })
+    })
   }
   }
 
 
   goBack() {
   goBack() {
@@ -127,7 +133,7 @@ class ReplicaView extends Reflux.Component {
                 <div>
                 <div>
                   <button
                   <button
                     className="gray"
                     className="gray"
-                    disabled={item.status === "RUNNING"}
+                    disabled={item.status === "RUNNING" || this.state.isBeingExecuted}
                     onClick={(e) => this.executeReplica(e)}
                     onClick={(e) => this.executeReplica(e)}
                   >
                   >
                     Execute Now
                     Execute Now