|
|
@@ -8,6 +8,7 @@ import api from '../../../shared/api';
|
|
|
|
|
|
import ChartList from './chart/ChartList';
|
|
|
import NamespaceSelector from './NamespaceSelector';
|
|
|
+import SortSelector from './SortSelector';
|
|
|
import ExpandedChart from './expanded-chart/ExpandedChart';
|
|
|
|
|
|
type PropsType = {
|
|
|
@@ -18,20 +19,28 @@ type PropsType = {
|
|
|
|
|
|
type StateType = {
|
|
|
namespace: string,
|
|
|
+ sortType: string,
|
|
|
currentChart: ChartType | null
|
|
|
};
|
|
|
|
|
|
export default class ClusterDashboard extends Component<PropsType, StateType> {
|
|
|
state = {
|
|
|
namespace: 'default',
|
|
|
+ sortType: 'Newest',
|
|
|
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', currentChart: null });
|
|
|
+ this.setState({ namespace: 'default', sortType: 'Newest', currentChart: null });
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -101,15 +110,22 @@ export default class ClusterDashboard extends Component<PropsType, StateType> {
|
|
|
>
|
|
|
<i className="material-icons">add</i> Deploy Template
|
|
|
</Button>
|
|
|
- <NamespaceSelector
|
|
|
- setNamespace={(namespace) => this.setState({ namespace })}
|
|
|
- namespace={this.state.namespace}
|
|
|
- />
|
|
|
+ <SortFilterWrapper>
|
|
|
+ <SortSelector
|
|
|
+ setSortType={(sortType) => this.setState({ sortType })}
|
|
|
+ sortType={this.state.sortType}
|
|
|
+ />
|
|
|
+ <NamespaceSelector
|
|
|
+ setNamespace={(namespace) => this.setState({ namespace })}
|
|
|
+ namespace={this.state.namespace}
|
|
|
+ />
|
|
|
+ </SortFilterWrapper>
|
|
|
</ControlRow>
|
|
|
|
|
|
<ChartList
|
|
|
currentCluster={currentCluster}
|
|
|
namespace={this.state.namespace}
|
|
|
+ sortType={this.state.sortType}
|
|
|
setCurrentChart={(x: ChartType | null) => this.setState({ currentChart: x })}
|
|
|
/>
|
|
|
</div>
|
|
|
@@ -297,4 +313,10 @@ const TitleSection = styled.div`
|
|
|
}
|
|
|
margin-bottom: -3px;
|
|
|
}
|
|
|
+`;
|
|
|
+
|
|
|
+const SortFilterWrapper = styled.div`
|
|
|
+ width: 468px;
|
|
|
+ display: flex;
|
|
|
+ justify-content: space-between;
|
|
|
`;
|