Procházet zdrojové kódy

localStorage for preferred sorting type

Sean Rhee před 5 roky
rodič
revize
6c6b735d23

+ 7 - 1
dashboard/src/main/home/cluster-dashboard/ClusterDashboard.tsx

@@ -30,8 +30,14 @@ export default class ClusterDashboard extends Component<PropsType, StateType> {
     currentChart: null as (ChartType | null)
   }
 
-  componentDidUpdate(prevProps: PropsType) {
+  componentDidMount() {
+    if (localStorage.getItem("SortType")) {
+      this.setState({ sortType: localStorage.getItem("SortType") });
+    }
+  }
 
+  componentDidUpdate(prevProps: PropsType) {
+    localStorage.setItem("SortType", this.state.sortType);
     // Reset namespace filter and close expanded chart on cluster change
     if (prevProps.currentCluster !== this.props.currentCluster) {
       this.setState({ namespace: 'default', sortType: 'chronological', currentChart: null });

+ 0 - 2
dashboard/src/main/home/cluster-dashboard/chart/ChartList.tsx

@@ -54,8 +54,6 @@ export default class ChartList extends Component<PropsType, StateType> {
         this.setState({ loading: false, error: true });
       } else {
         let charts = res.data || [];
-        console.log(Date.parse(charts[0].info.last_deployed));
-        console.log(charts[0].name);
         if (this.props.sortType == "chronological") {
           charts.sort((a: any, b: any) => (Date.parse(a.info.last_deployed) > Date.parse(b.info.last_deployed)) ? -1 : 1);
         } else if (this.props.sortType == "alphabetical") {