Jelajahi Sumber

Sort connections by creation date CORWEB-80

Sergiu Miclea 8 tahun lalu
induk
melakukan
a93776c14a
1 mengubah file dengan 3 tambahan dan 13 penghapusan
  1. 3 13
      src/stores/ConnectionsStore/ConnectionsStore.js

+ 3 - 13
src/stores/ConnectionsStore/ConnectionsStore.js

@@ -20,6 +20,7 @@
 
 import React from 'react';
 import Reflux from 'reflux';
+import moment from 'moment'
 import ConnectionsActions from '../../actions/ConnectionsActions';
 import MigrationActions from '../../actions/MigrationActions';
 import Helper from '../../components/Helper';
@@ -181,21 +182,10 @@ class ConnectionsStore extends Reflux.Store
     if (data.data.endpoints.length) {
       data.data.endpoints.forEach(endpoint => {
         connections.push(endpoint)
-        /*let cloudType = endpoint.name.substr(0, endpoint.name.indexOf("::"))
-        let secretName = endpoint.name.substr(endpoint.name.indexOf("::") + 2)
-        let secretId = secret.secret_ref.substr(secret.secret_ref.lastIndexOf("/") + 1)
-        connections.push({
-          id: secretId,
-          name: secretName,
-          description: "",
-          created: new Date(secret.created),
-          cloudName: cloudType,
-          secretUrl: secret.secret_ref,
-          credentials: {}
-        })*/
       })
     }
-
+    
+    connections.sort((c1, c2) => moment(c2.created_at).isAfter(c1.created_at))
     this.setState({connections: connections})
 
     if (window.location.pathname === "/" || window.location.pathname === "/login") {