import "./replicasets.scss"; import React from "react"; import { observer } from "mobx-react"; import { Trans } from "@lingui/macro"; import { ReplicaSet, replicaSetApi } from "../../api/endpoints"; import { KubeObjectMenu, KubeObjectMenuProps } from "../kube-object/kube-object-menu"; import { replicaSetStore } from "./replicasets.store"; import { Spinner } from "../spinner"; import { prevDefault, stopPropagation } from "../../utils"; import { DrawerTitle } from "../drawer"; import { Table, TableCell, TableHead, TableRow } from "../table"; import { showDetails } from "../../navigation"; import { apiManager } from "../../api/api-manager"; enum sortBy { name = "name", namespace = "namespace", pods = "pods", age = "age", } interface Props { replicaSets: ReplicaSet[]; } @observer export class ReplicaSets extends React.Component { private sortingCallbacks = { [sortBy.name]: (replicaSet: ReplicaSet) => replicaSet.getName(), [sortBy.namespace]: (replicaSet: ReplicaSet) => replicaSet.getNs(), [sortBy.age]: (replicaSet: ReplicaSet) => replicaSet.getAge(false), [sortBy.pods]: (replicaSet: ReplicaSet) => this.getPodsLength(replicaSet), } getPodsLength(replicaSet: ReplicaSet) { return replicaSetStore.getChildPods(replicaSet).length; } render() { const { replicaSets } = this.props; if (!replicaSets.length && !replicaSetStore.isLoaded) return (
); if (!replicaSets.length) return null; return (
Deploy Revisions}/> Name Namespace Pods Age { replicaSets.map(replica => { return ( showDetails(replica.selfLink, false))} > {replica.getName()} {replica.getNs()} {this.getPodsLength(replica)} {replica.getAge()} ) }) }
); } } export function ReplicaSetMenu(props: KubeObjectMenuProps) { return ( ) } apiManager.registerViews(replicaSetApi, { Menu: ReplicaSetMenu, });