import{k as x,d as s,n as L,F as N,j as e,r as w,L as y,b3 as f}from"./index-lOezWVmi.js";import{N as C}from"./NotificationRow-DdxAfFhk.js";import{H as k}from"./HelpLink-8_zL-2ID.js";import{P as o}from"./PageHeader-DVTHSBni.js";import{u as b}from"./projects-DygTcZJV.js";import{a as A}from"./useNetworkAcls-Bclr5QsB.js";import"./network-acls-B9tLpGS2.js";const U=()=>{const p=x(),g=s.useNotify(),{project:n}=L(),{project:i}=N(),{canCreateNetworkAcls:c}=b();if(!n)return e.jsx(e.Fragment,{children:"Missing project"});const{data:r=[],error:a,isLoading:l}=A(n);w.useEffect(()=>{a&&g.failure("Loading ACLs failed",a)},[a]);const h=[{content:"Name",sortKey:"name"},{content:"Description",sortKey:"description"},{content:"Ingress Rules",sortKey:"ingress",className:"u-align--right"},{content:"Egress Rules",sortKey:"egress",className:"u-align--right"},{content:"Used by",sortKey:"usedBy",className:"u-align--right"}],j=r.map(t=>{var u,d;return{columns:[{content:e.jsx(y,{to:`/ui/project/${encodeURIComponent(n)}/network-acl/${encodeURIComponent(t.name)}`,children:t.name}),role:"rowheader","aria-label":"Name"},{content:t.description,role:"cell","aria-label":"Description"},{content:t.ingress.length,role:"cell","aria-label":"Ingress rules",className:"u-align--right"},{content:t.egress.length,role:"cell","aria-label":"Egress rules",className:"u-align--right"},{content:(t.used_by??[]).length,role:"cell","aria-label":"Used by",className:"u-align--right"}],sortData:{name:t.name.toLowerCase(),description:(u=t.description)==null?void 0:u.toLowerCase(),ingress:t.ingress.length,egress:t.egress.length,usedBy:((d=t.used_by)==null?void 0:d.length)??0}}});if(l)return e.jsx(s.Spinner,{className:"u-loader",text:"Loading...",isMainComponent:!0});const m=e.jsxs(s.Button,{appearance:"positive",className:"u-no-margin--bottom",hasIcon:!0,onClick:async()=>p(`/ui/project/${encodeURIComponent(n)}/network-acls/create`),disabled:!c(i),title:c(i)?"":"You do not have permission to create ACLs in this project",children:[e.jsx(s.Icon,{name:"plus",light:!0}),e.jsx("span",{children:"Create ACL"})]});return e.jsxs(s.CustomLayout,{header:e.jsxs(o,{children:[e.jsx(o.Left,{children:e.jsx(o.Title,{children:e.jsx(k,{docPath:"/howto/network_acls/",title:"Learn more about network ACLs",children:"Network ACLs"})})}),e.jsx(o.BaseActions,{children:r.length>0&&m})]}),children:[e.jsx(C,{}),e.jsxs(s.Row,{children:[r.length>0&&e.jsx(s.MainTable,{headers:h,rows:j,responsive:!0,sortable:!0,emptyStateMsg:"No data to display"}),!l&&r.length===0&&e.jsxs(s.EmptyState,{className:"empty-state",image:e.jsx(s.Icon,{className:"empty-state-icon",name:"exposed"}),title:"No network ACLs found",children:[e.jsx("p",{children:"There are no network ACLs in this project."}),e.jsx("p",{children:e.jsx(f,{docPath:"/howto/network_acls/",hasExternalIcon:!0,children:"Learn more about network ACLs"})}),m]})]})]})};export{U as default};
