/** * Copyright (c) 2021 OpenLens Authors * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of * the Software, and to permit persons to whom the Software is furnished to do so, * subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ import "./endpoint-subset-list.scss"; import React from "react"; import { observer } from "mobx-react"; import { EndpointSubset, Endpoint, EndpointAddress} from "../../api/endpoints"; import { Table, TableCell, TableHead, TableRow } from "../table"; import { boundMethod } from "../../utils"; import { lookupApiLink } from "../../api/kube-api"; import { Link } from "react-router-dom"; import { getDetailsUrl } from "../kube-object"; interface Props { subset: EndpointSubset; endpoint: Endpoint; } @observer export class EndpointSubsetList extends React.Component { getAddressTableRow(ip: string) { const { subset } = this.props; const address = subset.getAddresses().find(address => address.getId() == ip); return this.renderAddressTableRow(address); } @boundMethod getNotReadyAddressTableRow(ip: string) { const { subset} = this.props; const address = subset.getNotReadyAddresses().find(address => address.getId() == ip); return this.renderAddressTableRow(address); } @boundMethod renderAddressTable(addresses: EndpointAddress[], virtual: boolean) { return (
Addresses
IP Hostname Target { !virtual && addresses.map(address => this.getAddressTableRow(address.getId())) }
); } @boundMethod renderAddressTableRow(address: EndpointAddress) { const { endpoint } = this.props; return ( {address.ip} {address.hostname} { address.targetRef && ( {address.targetRef.name} )} ); } render() { const { subset } = this.props; const addresses = subset.getAddresses(); const notReadyAddresses = subset.getNotReadyAddresses(); const addressesVirtual = addresses.length > 100; const notReadyAddressesVirtual = notReadyAddresses.length > 100; return(
{addresses.length > 0 && (
Addresses
IP Hostname Target { !addressesVirtual && addresses.map(address => this.getAddressTableRow(address.getId())) }
)} {notReadyAddresses.length > 0 && (
Not Ready Addresses
IP Hostname Target { !notReadyAddressesVirtual && notReadyAddresses.map(address => this.getNotReadyAddressTableRow(address.getId())) }
)}
Ports
Port Name Protocol { subset.ports.map(port => { return ( {port.port} {port.name} {port.protocol} ); }) }
); } }