| Current Path : /snap/lxd/current/share/lxd-ui/assets/ |
| Current File : //snap/lxd/current/share/lxd-ui/assets/CustomIsoList-BfKJzFtp.js |
import{d as o,v as y,H as N,ay as I,j as e,w as f,R as S,x as C,r as v,C as w,z as L,aC as O,a0 as P,L as U,p as T,b3 as z}from"./index-BsQN_SZU.js";import{D as R}from"./DeleteStorageVolumeBtn-Cr5fXZmM.js";import{C as _}from"./CreateInstanceFromImageBtn-qtdjIDOh.js";import{U as B}from"./UploadCustomIso-C4mIsVip.js";import{u as F}from"./projects-CczQ3aFg.js";import{u as K}from"./useSortTableData-DkMx8bMp.js";import{P as l}from"./PageHeader-BkhUaI4-.js";import{H as M}from"./HelpLink-BJF9zWZL.js";import{u as k}from"./useVolumes-Bxw5lKYj.js";import"./storage-volumes-CG043sqG.js";import"./ProgressBar-CZqVHpuJ.js";import"./StoragePoolSelector-Bvqvds5t.js";import"./StoragePoolSize-BNbqTfwA.js";import"./Meter-cq8smrSm.js";import"./images-dZFGKb1g.js";const b=({className:u,projectName:n})=>{const d=o.useToastNotification(),{openPortal:t,closePortal:a,isOpen:p,Portal:h}=o.usePortal(),x=y(),i=N(),{data:c}=I(n),{canCreateStorageVolumes:m}=F(),r=()=>{a()},j=s=>{d.success(e.jsxs(e.Fragment,{children:["Custom ISO"," ",e.jsx(f,{to:`${S}/ui/project/${encodeURIComponent(n)}/storage/custom-isos`,type:"iso-volume",value:s})," ","uploaded successfully."]})),x.invalidateQueries({queryKey:[C.isoVolumes]}),a()};return e.jsxs(e.Fragment,{children:[e.jsxs(o.Button,{appearance:"positive",onClick:t,className:u,hasIcon:!i,disabled:!m(c),title:m(c)?"Upload custom ISO":"You do not have permission to create custom ISOs in this project.",children:[!i&&e.jsx(o.Icon,{name:"upload",light:!0}),e.jsx("span",{children:"Upload custom ISO"})]}),p&&e.jsx(h,{children:e.jsx(o.Modal,{close:a,title:"Upload custom ISO",children:e.jsx(B,{onCancel:r,onFinish:j})})})]})},se=()=>{const u=o.useToastNotification(),[n,d]=v.useState(""),{project:t}=w();if(!t)return e.jsx(e.Fragment,{children:"Missing project"});const{data:a=[],isLoading:p}=k(t),h=[{content:"Name",sortKey:"name"},{content:"Storage pool",sortKey:"storagePool",className:"pool"},{content:"Upload date",sortKey:"uploadedAt",className:"uploaded_at"},{content:"Size",sortKey:"size",className:"u-align--right size"},{content:"Used by",sortKey:"usedBy",className:"u-align--right used_by"},{"aria-label":"Actions",className:"actions"}],i=a.filter(s=>!n||s.aliases.toLowerCase().includes(n.toLowerCase())).map(s=>{const g=s.volume&&e.jsx(o.List,{inline:!0,className:"actions-list u-no-margin--bottom",items:[e.jsx(_,{projectName:t,image:s},"launch"),e.jsx(R,{volume:s.volume,project:t,onFinish:()=>u.success(e.jsxs(e.Fragment,{children:["Custom iso"," ",e.jsx(L,{bold:!0,type:"iso-volume",value:s.aliases})," ","deleted."]}))},"delete")]});return{key:s.fingerprint,columns:[{content:s.aliases,role:"rowheader","aria-label":"Name"},{content:e.jsx("div",{className:"u-truncate",title:s.pool,children:e.jsx(U,{to:`${S}/ui/project/${encodeURIComponent(t)}/storage/pool/${encodeURIComponent(s.pool??"")}`,children:s.pool})}),role:"cell","aria-label":"Storage pool",className:"pool"},{content:O(new Date(s.created_at).toISOString()),role:"cell","aria-label":"Uploaded at",className:"uploaded_at"},{content:s.volume?.config.size&&P(+s.volume.config.size),role:"cell","aria-label":"Size",className:"u-align--right size"},{content:s.volume?.used_by?.length??0,role:"cell","aria-label":"Used by",className:"u-align--right used_by"},{content:g,role:"cell","aria-label":"Actions",className:"u-align--right actions"}],sortData:{name:s.aliases.toLowerCase(),storagePool:s.pool?.toLowerCase(),size:+(s.volume?.config.size??0),uploadedAt:s.created_at,usedBy:s.volume?.used_by?.length??0}}}),{rows:c,updateSort:m}=K({rows:i});if(p)return e.jsx(o.Spinner,{className:"u-loader",text:"Loading...",isMainComponent:!0});const r=a.length!==0,j=r?e.jsx("div",{className:"custom-iso-list",children:e.jsx(o.ScrollableTable,{dependencies:[a],tableId:"custom-iso-table",belowIds:["status-bar"],children:e.jsx(o.TablePagination,{data:c,id:"pagination",itemName:"custom ISO",className:"u-no-margin--top","aria-label":"Table pagination control",children:e.jsx(o.MainTable,{id:"custom-iso-table",headers:h,sortable:!0,className:"custom-iso-table",onUpdateSort:m,emptyStateMsg:"No custom ISOs found matching this search"})})})}):e.jsxs(o.EmptyState,{className:"empty-state",image:e.jsx(o.Icon,{name:"iso",className:"empty-state-icon"}),title:"No custom ISOs found in this project",children:[e.jsx("p",{children:"Custom ISOs will appear here"}),e.jsx("p",{children:e.jsx(z,{docPath:"/howto/instances_create/#instances-create-iso",hasExternalIcon:!0,children:"Learn how to create a VM that boots from an ISO"})}),e.jsx(b,{className:"empty-state-button",projectName:t})]});return e.jsxs(o.CustomLayout,{mainClassName:"custom-iso-list",header:e.jsxs(l,{children:[e.jsxs(l.Left,{children:[e.jsx(l.Title,{children:e.jsx(M,{docPath:"/howto/instances_create/#instances-create-iso",title:"Learn how to create a VM that boots from an ISO",children:"Custom ISOs"})}),r&&e.jsx(l.Search,{children:e.jsx("div",{className:"search-box-wrapper",children:e.jsx(o.SearchBox,{name:"search-snapshot",className:"search-box margin-right u-no-margin--bottom",type:"text",onChange:s=>{d(s)},placeholder:"Search for custom ISOs",value:n,"aria-label":"Search for custom ISOs"})})})]}),r&&e.jsx(l.BaseActions,{children:e.jsx(b,{className:"u-float-right u-no-margin--bottom",projectName:t})})]}),children:[e.jsx(T,{}),e.jsx(o.Row,{children:j})]})};export{se as default};