import { CellContext } from '@tanstack/react-table'; import { AlertTriangle, ArrowRight } from 'lucide-react'; import { Icon } from '@@/Icon'; import { Badge } from '@@/Badge'; import { Ingress, TLS, Path } from '../../types'; import { columnHelper } from './helper'; export const ingressRules = columnHelper.accessor('Paths', { header: 'Rules and Paths', id: 'ingressRules', cell: Cell, }); function Cell({ row, getValue }: CellContext) { const paths = getValue(); if (!paths) { return
; } return paths.map((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 )}
); }); } 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}`} ); }