import{s as j,d as t,H as x,a4 as w,aY as N,j as e,r as y,L,R as u,e as f,D as k}from"./index-C88DWJny.js";import{H as C}from"./HelpLink-c8Zoz7ma.js";import{P as o}from"./PageHeader-6_Og6mu3.js";import{a as b}from"./useNetworkAcls-P_dd657c.js";import"./network-acls-DoFbevfN.js";const v=()=>{const m=j(),g=t.useNotify(),{project:n}=x(),{project:i}=w(),{canCreateNetworkAcls:c}=N();if(!n)return e.jsx(e.Fragment,{children:"Missing project"});const{data:r=[],error:a,isLoading:l}=b(n);y.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"}],p=r.map(s=>({columns:[{content:e.jsx(L,{to:`${u}/ui/project/${encodeURIComponent(n)}/network-acl/${encodeURIComponent(s.name)}`,children:s.name}),role:"rowheader","aria-label":"Name"},{content:s.description,role:"cell","aria-label":"Description"},{content:s.ingress.length,role:"cell","aria-label":"Ingress rules",className:"u-align--right"},{content:s.egress.length,role:"cell","aria-label":"Egress rules",className:"u-align--right"},{content:(s.used_by??[]).length,role:"cell","aria-label":"Used by",className:"u-align--right"}],sortData:{name:s.name.toLowerCase(),description:s.description?.toLowerCase(),ingress:s.ingress.length,egress:s.egress.length,usedBy:s.used_by?.length??0}}));if(l)return e.jsx(t.Spinner,{className:"u-loader",text:"Loading...",isMainComponent:!0});const d=e.jsxs(t.Button,{appearance:"positive",className:"u-no-margin--bottom",hasIcon:!0,onClick:async()=>m(`${u}/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(t.Icon,{name:"plus",light:!0}),e.jsx("span",{children:"Create ACL"})]});return e.jsxs(t.CustomLayout,{header:e.jsxs(o,{children:[e.jsx(o.Left,{children:e.jsx(o.Title,{children:e.jsx(C,{docPath:"/howto/network_acls/",title:"Learn more about network access control lists",children:"Network Access Control Lists"})})}),e.jsx(o.BaseActions,{children:r.length>0&&d})]}),children:[e.jsx(f,{}),e.jsxs(t.Row,{children:[r.length>0&&e.jsx(t.MainTable,{headers:h,rows:p,responsive:!0,sortable:!0,emptyStateMsg:"No data to display"}),!l&&r.length===0&&e.jsxs(t.EmptyState,{className:"empty-state",image:e.jsx(t.Icon,{className:"empty-state-icon",name:"exposed"}),title:"No network access control lists found",children:[e.jsx("p",{children:"There are no network ACLs in this project."}),e.jsx("p",{children:e.jsx(k,{docPath:"/howto/network_acls/",hasExternalIcon:!0,children:"Learn more about network ACLs"})}),d]})]})]})};export{v as default};
