import { CellProps, Column } from 'react-table'; import { AlertTriangle, ArrowRight } from 'lucide-react'; import { Icon } from '@@/Icon'; import { Badge } from '@@/Badge'; import { Ingress, TLS, Path } from '../../types'; function isHTTP(TLSs: TLS[], host: string) { return TLSs.filter((t) => t.Hosts.indexOf(host) !== -1).length === 0; } function link(host: string, path: string, isHttp: boolean) { if (!host) { return path; } return ( {`${isHttp ? 'http' : 'https'}://${host}${path}`} ); } export const ingressRules: Column = { Header: 'Rules and Paths', accessor: 'Paths', Cell: ({ row }: CellProps) => { const results = row.original.Paths?.map((path: Path) => { const isHttp = isHTTP(row.original.TLS || [], path.Host); return (
{link(path.Host, path.Path, isHttp)} {`${path.ServiceName}:${path.Port}`} {!path.HasService && ( Service doesn't exist )}
); }); return results ||
; }, id: 'ingressRules', disableFilters: true, canHide: true, disableSortBy: true, };