import{j as e,g as y,q as o,n as f,f as N,d as t,o as b,e as w,L}from"./index-CzUo07dn.js";import{i as v}from"./networks-AOdNDxHC.js";import{B as F}from"./BaseLayout-D6pt0Et9.js";import{N as K}from"./NotificationRow-IVGrYQV6.js";import{H as I}from"./HelpLink-INVHAe6u.js";import{a as S}from"./network-forwards-DoiUK_R5.js";import{u as k}from"./useSmallScreen-DnOiQRh8.js";const B=({network:r,project:n})=>{if(r.managed===!1||r.type!="bridge"&&r.type!="ovn")return e.jsx(e.Fragment,{children:"-"});const{data:l=[],isLoading:s}=y({queryKey:[o.projects,n,o.networks,r,o.forwards,n],queryFn:()=>S(r.name,n)});return e.jsx(e.Fragment,{children:s?"":l.length})},V=()=>{const r=f(),n=N(),l=t.useNotify(),{project:s}=b(),i=k();if(!s)return e.jsx(e.Fragment,{children:"Missing project"});const{data:d=[],error:m,isLoading:p}=y({queryKey:[o.projects,s,o.networks],queryFn:()=>v(s)});m&&l.failure("Loading networks failed",m);const c=d.length>0,x=[{content:"Name",sortKey:"name"},{content:"Type",sortKey:"type"},{content:"Managed",sortKey:"managed"},{content:"IPV4",sortKey:"ipv4",className:"u-align--right"},{content:"IPV6",sortKey:"ipv6"},{content:"Description",sortKey:"description"},{content:"Forwards",className:"u-align--right"},{content:"Used by",sortKey:"usedBy",className:"u-align--right"},{content:"State",sortKey:"state"}],j=d.map(a=>{var u,g,h;return{columns:[{content:e.jsx(w,{to:`/ui/project/${s}/network/${a.name}`,children:a.name}),role:"rowheader","aria-label":"Name"},{content:a.type,role:"rowheader","aria-label":"Type"},{content:a.managed?"Yes":"No",role:"rowheader","aria-label":"Managed"},{content:a.config["ipv4.address"],className:"u-align--right",role:"rowheader","aria-label":"IPV4"},{content:a.config["ipv6.address"],role:"rowheader","aria-label":"IPV6"},{content:a.description,role:"rowheader","aria-label":"Description"},{content:e.jsx(B,{network:a,project:s}),role:"rowheader",className:"u-align--right","aria-label":"Forwards"},{content:((u=a.used_by)==null?void 0:u.length)??"0",role:"rowheader",className:"u-align--right","aria-label":"Used by"},{content:a.status,role:"rowheader","aria-label":"State"}],sortData:{name:a.name.toLowerCase(),type:a.type,managed:a.managed,description:(g=a.description)==null?void 0:g.toLowerCase(),state:a.status,usedBy:((h=a.used_by)==null?void 0:h.length)??0,ipv4:a.config["ipv4.address"],ipv6:a.config["ipv6.address"]}}});return p?e.jsx(L,{}):e.jsx(e.Fragment,{children:e.jsxs(F,{title:e.jsx(I,{href:`${r}/explanation/networks/`,title:"Learn more about networking",children:"Networks"}),controls:e.jsxs(e.Fragment,{children:[c&&e.jsxs(t.Button,{className:"u-no-margin--bottom",onClick:()=>n(`/ui/project/${s}/networks/map`),hasIcon:!i,children:[!i&&e.jsx(t.Icon,{name:"map"}),e.jsx("span",{children:"See network map"})]}),e.jsxs(t.Button,{appearance:"positive",className:"u-no-margin--bottom",onClick:()=>n(`/ui/project/${s}/networks/create`),hasIcon:!i,children:[!i&&e.jsx(t.Icon,{name:"plus",light:!0}),e.jsx("span",{children:"Create network"})]})]}),children:[e.jsx(K,{}),e.jsxs(t.Row,{children:[c&&e.jsx(t.MainTable,{headers:x,rows:j,paginate:30,responsive:!0,sortable:!0,className:"u-table-layout--auto",emptyStateMsg:"No data to display"}),!p&&!c&&e.jsxs(t.EmptyState,{className:"empty-state",image:e.jsx(t.Icon,{className:"empty-state-icon",name:"exposed"}),title:"No networks found",children:[e.jsx("p",{children:"There are no networks in this project."}),e.jsx("p",{children:e.jsxs("a",{href:`${r}/explanation/networks/`,target:"_blank",rel:"noopener noreferrer",children:["Learn more about networks",e.jsx(t.Icon,{className:"external-link-icon",name:"external-link"})]})})]})]})]})})};export{V as default};
