mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
85 lines
2.6 KiB
TypeScript
85 lines
2.6 KiB
TypeScript
import "./service-details.scss"
|
|
|
|
import React from "react";
|
|
import { observer } from "mobx-react";
|
|
import { t, Trans } from "@lingui/macro";
|
|
import { DrawerItem, DrawerTitle } from "../drawer";
|
|
import { Badge } from "../badge";
|
|
import { KubeEventDetails } from "../+events/kube-event-details";
|
|
import { KubeObjectDetailsProps } from "../kube-object";
|
|
import { Service, serviceApi, endpointApi } from "../../api/endpoints";
|
|
import { _i18n } from "../../i18n";
|
|
import { apiManager } from "../../api/api-manager";
|
|
import { KubeObjectMeta } from "../kube-object/kube-object-meta";
|
|
import { ServicePorts } from "./service-ports";
|
|
import { endpointStore } from "../+network-endpoints/endpoints.store";
|
|
import { ServiceDetailsEndpoint } from "./service-details-endpoint";
|
|
|
|
interface Props extends KubeObjectDetailsProps<Service> {
|
|
}
|
|
|
|
@observer
|
|
export class ServiceDetails extends React.Component<Props> {
|
|
componentDidMount() {
|
|
if (!endpointStore.isLoaded) {
|
|
endpointStore.loadAll();
|
|
}
|
|
endpointApi.watch()
|
|
}
|
|
|
|
render() {
|
|
const { object: service } = this.props;
|
|
if (!service) return;
|
|
const { spec } = service;
|
|
const endpoint = endpointStore.getByName(service.getName(), service.getNs())
|
|
return (
|
|
<div className="ServicesDetails">
|
|
<KubeObjectMeta object={service}/>
|
|
|
|
<DrawerItem name={<Trans>Selector</Trans>} labelsOnly>
|
|
{service.getSelector().map(selector => <Badge key={selector} label={selector}/>)}
|
|
</DrawerItem>
|
|
|
|
<DrawerItem name={<Trans>Type</Trans>}>
|
|
{spec.type}
|
|
</DrawerItem>
|
|
|
|
<DrawerItem name={<Trans>Session Affinity</Trans>}>
|
|
{spec.sessionAffinity}
|
|
</DrawerItem>
|
|
|
|
<DrawerTitle title={_i18n._(t`Connection`)}/>
|
|
|
|
<DrawerItem name={<Trans>Cluster IP</Trans>}>
|
|
{spec.clusterIP}
|
|
</DrawerItem>
|
|
|
|
{service.getExternalIps().length > 0 && (
|
|
<DrawerItem name={<Trans>External IPs</Trans>}>
|
|
{service.getExternalIps().map(ip => <div key={ip}>{ip}</div>)}
|
|
</DrawerItem>
|
|
)}
|
|
|
|
<DrawerItem name={<Trans>Ports</Trans>}>
|
|
<ServicePorts service={service}/>
|
|
</DrawerItem>
|
|
|
|
{spec.type === "LoadBalancer" && spec.loadBalancerIP && (
|
|
<DrawerItem name={<Trans>Load Balancer IP</Trans>}>
|
|
{spec.loadBalancerIP}
|
|
</DrawerItem>
|
|
)}
|
|
<DrawerTitle title={_i18n._(t`Endpoint`)}/>
|
|
|
|
<ServiceDetailsEndpoint endpoint={endpoint} />
|
|
|
|
<KubeEventDetails object={service}/>
|
|
</div>
|
|
);
|
|
}
|
|
}
|
|
|
|
apiManager.registerViews(serviceApi, {
|
|
Details: ServiceDetails,
|
|
})
|