Explorar o código

template sorting

Sean Rhee %!s(int64=5) %!d(string=hai) anos
pai
achega
01f212bc59
Modificáronse 1 ficheiros con 5 adicións e 1 borrados
  1. 5 1
      dashboard/src/main/home/templates/Templates.tsx

+ 5 - 1
dashboard/src/main/home/templates/Templates.tsx

@@ -45,7 +45,11 @@ export default class Templates extends Component<PropsType, StateType> {
       if (err) {
       if (err) {
         this.setState({ loading: false, error: true });
         this.setState({ loading: false, error: true });
       } else {
       } else {
-        this.setState({ porterTemplates: res.data, loading: false, error: false });
+        this.setState({ porterTemplates: res.data, error: false }, () => {
+          this.state.porterTemplates.sort((a, b) => (a.name > b.name) ? 1 : -1);
+          this.state.porterTemplates.sort((a,b) => (a.name === 'docker') ? -1 : (b.name === 'docker') ? 1 : 0);
+          this.setState({ loading: false });
+        });
       }
       }
     });
     });
   }
   }