%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /snap/lxd/current/share/lxd-ui/assets/
Upload File :
Create Path :
Current File : //snap/lxd/current/share/lxd-ui/assets/Images-40cc8e59.js

import{x as j,d as t,r as b,i as f,j as e,V as N,q as g,e as L,m as w,f as C,W as I,X as S,o as v,L as K,P as z,S as B,s as T,l as q,B as A,H as D,b as P}from"./index-13b2882d.js";import{l as Q}from"./images-2ea813f2.js";const k=({image:n,project:s})=>{const i=j(),l=t.useNotify(),[o,r]=b.useState(!1),u=f(),m=()=>{r(!0),N(n,s).then(c=>i.set(c.metadata.id,()=>{u.invalidateQueries({queryKey:[g.images]}),u.invalidateQueries({queryKey:[g.projects,s]}),l.success(`Image ${n.properties.description} deleted.`)},p=>l.failure("Image deletion failed",new Error(p)),()=>r(!1)))};return e.jsx(t.ConfirmationButton,{loading:o,confirmationModalProps:{title:"Confirm delete",children:e.jsxs("p",{children:["This will permanently delete image"," ",e.jsx("b",{children:n.properties.description}),".",e.jsx("br",{}),"This action cannot be undone, and can result in data loss."]}),confirmButtonLabel:"Delete",onConfirm:m},className:"has-icon",appearance:"base",disabled:o,shiftClickEnabled:!0,showShiftClickHint:!0,children:e.jsx(t.Icon,{name:"delete"})})},E=({image:n,project:s})=>{const i=L(),l=()=>{i(`/ui/project/${s}/instances/create`,{state:{selectedImage:n,cancelLocation:window.location.pathname}})};return e.jsx(t.Button,{appearance:"base",onClick:l,type:"button",title:"Create instance",hasIcon:!0,children:e.jsx(t.Icon,{name:"play"})})},_=()=>{const n=t.useNotify(),{project:s}=w(),[i,l]=b.useState("");if(!s)return e.jsx(e.Fragment,{children:"Missing project"});const{data:o=[],error:r,isLoading:u}=C({queryKey:[g.images,s],queryFn:()=>T(s)});r&&n.failure("Loading images failed",r);const m=[{content:"Name",sortKey:"name"},{content:"Alias",sortKey:"alias"},{content:"Architecture",sortKey:"architecture",className:"architecture"},{content:"Public",sortKey:"public",className:"public"},{content:"Type",sortKey:"type",className:"type"},{content:"Upload date",sortKey:"uploaded_at",className:"uploaded_at"},{content:"Size",sortKey:"size",className:"u-align--right size"},{"aria-label":"Actions",className:"actions"}],c=o.filter(a=>!i||a.properties.description.toLowerCase().includes(i.toLowerCase())||a.aliases.map(h=>h.name).join(", ").toLowerCase().includes(i.toLowerCase())),p=c.map(a=>{const h=e.jsx(t.List,{inline:!0,className:"actions-list u-no-margin--bottom",items:[e.jsx(E,{project:s,image:Q(a)},"launch"),e.jsx(k,{image:a,project:s},"delete")]}),y=a.aliases.map(x=>x.name).join(", ");return{columns:[{content:a.properties.description,role:"cell","aria-label":"Name"},{content:y,role:"cell","aria-label":"Aliases",className:"aliases"},{content:a.architecture,role:"cell","aria-label":"Architecture",className:"architecture"},{content:a.public?"Yes":"No",role:"cell","aria-label":"Public",className:"public"},{content:a.type=="virtual-machine"?"VM":"Container",role:"cell","aria-label":"Type",className:"type"},{content:I(a.uploaded_at),role:"cell","aria-label":"Upload date",className:"uploaded_at"},{content:S(a.size),role:"cell","aria-label":"Size",className:"u-align--right size"},{content:h,role:"cell","aria-label":"Actions",className:"u-align--right actions"}],sortData:{name:a.properties.description.toLowerCase(),alias:y.toLowerCase(),architecture:a.architecture,public:a.public,type:a.type,size:+a.size,uploaded_at:a.uploaded_at}}}),d=v(p);return u?e.jsx(K,{text:"Loading images..."}):o.length===0?e.jsx(t.EmptyState,{className:"empty-state",image:e.jsx(t.Icon,{name:"mount",className:"empty-state-icon"}),title:"No images found in this project",children:e.jsx("p",{children:"Images will appear here, when launching an instance from a remote."})}):e.jsxs("div",{className:"image-list",children:[e.jsx("div",{className:"upper-controls-bar",children:e.jsx("div",{className:"search-box-wrapper",children:e.jsx(t.SearchBox,{name:"search-images",className:"search-box margin-right",type:"text",onChange:a=>{l(a)},placeholder:"Search for images",value:i,"aria-label":"Search for images"})})}),e.jsx(z,{...d,id:"pagination",className:"u-no-margin--top",totalCount:o.length,visibleCount:c.length===o.length?d.pageData.length:c.length,keyword:"image"}),e.jsx(B,{dependencies:[o],children:e.jsx(t.MainTable,{headers:m,rows:d.pageData,sortable:!0,className:"image-table",emptyStateMsg:"No images found matching this search",onUpdateSort:d.updateSort})})]})},R=()=>{const n=q();return e.jsxs(A,{title:e.jsx(D,{href:`${n}/image-handling/`,title:"Learn more about images",children:"Images"}),children:[e.jsx(P,{}),e.jsx(t.Row,{children:e.jsx(_,{})})]})};export{R as default};

Zerion Mini Shell 1.0