فهرست منبع

Merge pull request #29 from smiclea/CORWEB-56

Sort replicas by last execution date CORWEB-56
Dorin Paslaru 8 سال پیش
والد
کامیت
32fc754f60
2فایلهای تغییر یافته به همراه5 افزوده شده و 8 حذف شده
  1. 2 7
      src/components/ReplicaList/ReplicaList.js
  2. 3 1
      src/stores/MigrationStore/MigrationStore.js

+ 2 - 7
src/components/ReplicaList/ReplicaList.js

@@ -111,12 +111,7 @@ class ReplicaList extends Reflux.Component {
     if (count == 0) {
       tasksRemaining = "-"
     }
-
-    let lastExecution = null
-    if (item.executions.length) {
-      lastExecution = Helper.getTimeObject(item.executions[item.executions.length - 1].created_at)
-    }
-
+    
     return (
       <div className={"item " + (item.selected ? "selected" : "")} key={"replica_" + item.id}>
         <span className="cell cell-icon" onClick={(e) => this.replicaDetail(e, item)}>
@@ -134,7 +129,7 @@ class ReplicaList extends Reflux.Component {
         <span className={"cell " + s.composite} onClick={(e) => this.replicaDetail(e, item)}>
           <span className={s.label}>Last execution</span>
           <span className={s.value}>
-            {lastExecution ? <Moment format="MMM Do YYYY HH:mm" date={lastExecution} /> : "-"}
+            {item.lastExecution ? <Moment format="MMM Do YYYY HH:mm" date={Helper.getTimeObject(item.lastExecution)} /> : "-"}
           </span>
         </span>
         <span className={"cell " + s.composite} onClick={(e) => this.replicaDetail(e, item)}>

+ 3 - 1
src/stores/MigrationStore/MigrationStore.js

@@ -90,11 +90,13 @@ class MigrationStore extends Reflux.Store
 
       if (replica.executions.length) {
         MigrationActions.getReplicaExecutions(replica)
+        
+        replica.lastExecution = replica.executions[replica.executions.length - 1].created_at
       }
     })
 
     replicas.sort((a, b) => {
-      return moment(b.created_at).isAfter(moment(a.created_at))
+      return moment(b.lastExecution || b.created_at).isAfter(moment(a.lastExecution || a.created_at))
     })
 
     this.setState({