-
Notifications
You must be signed in to change notification settings - Fork 701
/
AccessURLTableContainer.tsx
41 lines (36 loc) · 1.16 KB
/
AccessURLTableContainer.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { connect } from "react-redux";
import { Action } from "redux";
import { ThunkDispatch } from "redux-thunk";
import actions from "../../actions";
import AccessURLTable from "../../components/AppView/AccessURLTable";
import ResourceRef from "../../shared/ResourceRef";
import { IStoreState } from "../../shared/types";
import { filterByResourceRefs } from "../helpers";
interface IAccessURLTableContainerProps {
serviceRefs: ResourceRef[];
ingressRefs: ResourceRef[];
}
function mapStateToProps({ kube }: IStoreState, props: IAccessURLTableContainerProps) {
// Extract the Services and Ingresses form the Redux state using the keys for
// each ResourceRef.
return {
services: filterByResourceRefs(props.serviceRefs, kube.items),
ingresses: filterByResourceRefs(props.ingressRefs, kube.items),
};
}
function mapDispatchToProps(
dispatch: ThunkDispatch<IStoreState, null, Action>,
props: IAccessURLTableContainerProps,
) {
return {
fetchIngresses: () => {
props.ingressRefs.forEach(r => {
dispatch(actions.kube.getResource(r));
});
},
};
}
export default connect(
mapStateToProps,
mapDispatchToProps,
)(AccessURLTable);