1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
lens/src/renderer/components/+namespaces/namespace-details.tsx
Panu Horsmalahti f65861bfee Add eslint no-trailing-spaces, quote-props, space-infix-ops and arrow-parens rules
Signed-off-by: Panu Horsmalahti <phorsmalahti@mirantis.com>
2020-12-03 10:36:37 +02:00

69 lines
2.0 KiB
TypeScript

import "./namespace-details.scss";
import React from "react";
import { computed } from "mobx";
import { observer } from "mobx-react";
import { Trans } from "@lingui/macro";
import { DrawerItem } from "../drawer";
import { cssNames } from "../../utils";
import { Namespace } from "../../api/endpoints";
import { KubeObjectDetailsProps } from "../kube-object";
import { Link } from "react-router-dom";
import { getDetailsUrl } from "../../navigation";
import { Spinner } from "../spinner";
import { resourceQuotaStore } from "../+config-resource-quotas/resource-quotas.store";
import { KubeObjectMeta } from "../kube-object/kube-object-meta";
import { kubeObjectDetailRegistry } from "../../api/kube-object-detail-registry";
interface Props extends KubeObjectDetailsProps<Namespace> {
}
@observer
export class NamespaceDetails extends React.Component<Props> {
@computed get quotas() {
const namespace = this.props.object.getName();
return resourceQuotaStore.getAllByNs(namespace);
}
componentDidMount() {
resourceQuotaStore.loadAll();
}
render() {
const { object: namespace } = this.props;
if (!namespace) return;
const status = namespace.getStatus();
return (
<div className="NamespaceDetails">
<KubeObjectMeta object={namespace}/>
<DrawerItem name={<Trans>Status</Trans>}>
<span className={cssNames("status", status.toLowerCase())}>{status}</span>
</DrawerItem>
<DrawerItem name={<Trans>Resource Quotas</Trans>} className="quotas flex align-center">
{!this.quotas && resourceQuotaStore.isLoading && <Spinner/>}
{this.quotas.map((quota) => {
return (
<Link key={quota.getId()} to={getDetailsUrl(quota.selfLink)}>
{quota.getName()}
</Link>
);
})}
</DrawerItem>
</div>
);
}
}
kubeObjectDetailRegistry.add({
kind: "Namespace",
apiVersions: ["v1"],
components: {
Details: props => <NamespaceDetails {...props} />
}
});