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): string => replicaSet.getName(), [sortBy.namespace]: (replicaSet: ReplicaSet): string => replicaSet.getNs(), [sortBy.age]: (replicaSet: ReplicaSet): string => replicaSet.metadata.creationTimestamp, [sortBy.pods]: (replicaSet: ReplicaSet): number => replicaSetStore.getChildPods(replicaSet).length, } render(): JSX.Element { 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()} {replicaSetStore.getChildPods(replica).length} {replica.getAge()} ); }) }
); } } export function ReplicaSetMenu(props: KubeObjectMenuProps): JSX.Element { return ( ); } apiManager.registerViews(replicaSetApi, { Menu: ReplicaSetMenu, });