Your IP : 216.73.216.189


Current Path : /proc/thread-self/root/snap/lxd/current/share/lxd-ui/assets/
Upload File :
Current File : //proc/thread-self/root/snap/lxd/current/share/lxd-ui/assets/StorageVolumes-N20nVsvS.js

import{c as le,O as re,al as ie,j as e,d as l,R as ee,d8 as I,aJ as ce,L as me,cS as ue,s as z,T as Q,y as de,t as pe,r as k,U as b,ak as he,w as A,I as ge,b8 as je,d9 as J,S as fe,da as ye,db as P,cT as Z,dc as xe,dd as be,c4 as Se,v as Ne,M as Ce,p as we}from"./index-BFGypnt-.js";import{u as Le}from"./projects-DAlFlfjH.js";import{C as Te,a as ve,V as Ve,P as Pe,Q as Ee,S as Ie}from"./StorageVolumesFilter-E3gN2QnJ.js";import{V as ke,S as Oe}from"./VolumeAddSnapshotBtn-BVSGpQdK.js";import{a as Be}from"./useImages-DavKpFTt.js";import{g as _e,d as De}from"./images-C6WqBeZG.js";import{D as Me,u as Re}from"./DeleteStorageVolumeBtn-DIlt1DOO.js";import{i as Ae}from"./snapshots-DETOqD-5.js";import{u as $e}from"./useSortTableData-DMPSUVcX.js";import{P as E}from"./PageHeader-DZVSTM6q.js";import{H as Fe}from"./HelpLink-l4aaXUp-.js";import{b as Ke}from"./useVolumes-CXLHz-Wc.js";import{S as Ue}from"./SelectableMainTable-BZaSR8Vv.js";import{S as qe}from"./SelectedTableNotification-D7txT2Gz.js";import{B as Ye}from"./BulkDeleteButton-Cy-zhz39.js";import{e as ze}from"./storage-volumes-CNe_c3nC.js";import{u as Qe}from"./useBulkDetails-_NNE1L7C.js";import{a as He}from"./ClusterMemberRichChip-h3WaiYeI.js";import{P as We}from"./ProjectRichChip-CtiU36yR.js";import{S as Je}from"./StoragePoolRichChip-CxRTjvv2.js";import"./searchAndFilter-DtC_P-vv.js";import"./SnapshotForm-9YABarEV.js";import"./VolumeLinkChip-CgrDSaXC.js";import"./image-registries-YAuyq4CZ.js";import"./useStoragePools-qBtKr1j9.js";import"./useClusterMembers-B29_ixY7.js";import"./cluster-members-CG6XHzn4.js";import"./ClusterMemberMemoryUsage-UO8J-hw2.js";import"./Meter-VGEmUMfL.js";import"./useProfiles-CErbukD2.js";import"./StoragePoolSize-ChYxPd_8.js";const G=({projectName:s,className:i,defaultPool:u})=>{const o=le(),d=re(),{canCreateStorageVolumes:p}=Le(),{data:h}=ie(s),c=()=>{o(`${ee}/ui/project/${encodeURIComponent(s)}/storage/volumes/create${u?`?pool=${encodeURIComponent(u)}`:""}`)};return e.jsxs(l.Button,{appearance:"positive",hasIcon:!d,onClick:c,className:i,disabled:!p(h),title:p(h)?"Create volume":"You do not have permission to create volumes in this project",children:[!d&&e.jsx(l.Icon,{name:"plus",light:!0}),e.jsx("span",{children:"Create volume"})]})},O="Name",B="Pool",_="Cluster Member",L="Type",S="Content Type",D="Size",T="Used By",N="Snapshots",$="Actions",n={[O]:"10rem",[B]:"6rem",[_]:"10rem",[L]:"6rem",[S]:"6rem",[D]:"5rem",[T]:"5rem",[N]:"6rem",[$]:"8rem"},X=({volume:s,overrideName:i,className:u})=>{const o=!I(s),d=s.type==="container"||s.type==="virtual-machine",{data:p=[]}=ce(s.project),h=d&&p.find(m=>m.name===s.name),c=s.type==="image",{data:f=[]}=Be(s.project),y=c&&f.find(m=>m.fingerprint===s.name),C=s.type==="custom",a=h||y||C,r=i||(y?`${_e(y)} ${De(y)}`:s.name);return i&&!a?null:e.jsx("div",{className:z("u-flex",u),children:e.jsx("div",{className:z("u-truncate","volume-name-link"),title:r,children:a?e.jsxs(me,{to:ue(s),className:o?"has-icon":void 0,children:[r,o&&e.jsx(l.Icon,{name:l.ICONS.externalLink})]}):r})})},Ze=({volume:s,className:i})=>{const u=l.useToastNotification(),{project:o}=Q();return e.jsx(l.List,{inline:!0,className:z(i,"actions-list"),items:[e.jsx(ke,{volume:s,isCTA:!0,isDisabled:Ae(o)},"add-snapshot"),e.jsx(Me,{volume:s,project:o?.name??"",onFinish:()=>{u.success(e.jsxs(e.Fragment,{children:["Storage volume"," ",e.jsx(de,{bold:!0,type:"volume",value:s.name})," ","deleted."]}))}},"delete")]})},Ge=({volumes:s,onStart:i,onFinish:u})=>{const o=l.useToastNotification(),d=pe(),[p,h]=k.useState(!1),{canDeleteVolume:c}=Re(),f=Qe(),{project:y}=Q(),C=y?.name||"",a=s.filter(g=>c(g)),v=s.length,r=a.length,m=`Delete ${s.length} ${b("volume",s.length)}`,M=()=>{h(!0),i();const g=`${a.length} ${b("volume",a.length)} successfully deleted`;ze(a,C).then(x=>{const{fulfilledCount:w,rejectedCount:V}=he(x);w===r?o.success(g,f(x)):V===r?o.failure("Volume bulk deletion failed",void 0,e.jsxs(e.Fragment,{children:[e.jsx("b",{children:r})," ",b("volume",r)," could not be deleted."]}),f(x)):o.failure("Volume bulk deletion partially failed",void 0,e.jsxs(e.Fragment,{children:[e.jsx("b",{children:w})," ",b("volume",w)," ","deleted.",e.jsx("br",{}),e.jsx("b",{children:V})," ",b("volume",V)," could not be deleted."]}),f(x)),d.invalidateQueries({queryKey:[A.volumes,C]}),d.invalidateQueries({queryKey:[A.isoVolumes]}),d.invalidateQueries({queryKey:[A.projects,y]}),d.invalidateQueries({predicate:K=>K.queryKey[0]===A.volumes}),h(!1),u()}).catch(x=>{h(!1),o.failure("Volume bulk deletion failed",x)})},F=()=>{if(r===v)return;const g=v-r;return[`${r} ${b("volume",r)} will be deleted.`,`${g} ${b("volume",g)} that you do not have permission to delete will be ignored.`]};return e.jsx(Ye,{entities:s,deletableEntities:a,entityType:"volume",onDelete:M,disabledReason:r===0?`You do not have permission to delete the selected ${b("volume",s.length)}`:void 0,confirmationButtonProps:{disabled:p||r===0,loading:p},buttonLabel:m,bulkDeleteBreakdown:F(),className:"u-no-margin--bottom"})},Et=()=>{const s=l.useNotify(),{project:i}=ge(),[u]=je(),[o,d]=k.useState(J()),p=fe(),h=()=>{d(J())};l.useListener(window,h,"resize",!0);const[c,f]=k.useState([]),[y,C]=k.useState([]),a={queries:u.getAll(Ee).map(t=>t.toLowerCase()),pools:u.getAll(Pe),volumeTypes:u.getAll(Ve).map(t=>t==="VM"?"virtual-machine":t.toLowerCase()),contentTypes:u.getAll(ve).map(t=>t.toLowerCase()),clusterMembers:u.getAll(Te).map(t=>t.toLowerCase())};if(!i)return e.jsx(e.Fragment,{children:"Missing project"});const{project:v,isLoading:r}=Q(),{data:m=[],error:M,isLoading:F}=Ke(i),g=ye(v);M&&s.failure("Loading storage volumes failed",M),k.useEffect(()=>{const t=new Set(m.map(P)),j=c.filter(R=>t.has(R));j.length!==c.length&&f(j)},[m]);const x=[{content:O,sortKey:"name",style:{width:n[O]}},{content:B,sortKey:"pool",style:{width:n[B]},className:"pool"},...p?[{content:_,sortKey:"clusterMember",style:{width:n[_]}}]:[],{content:o?e.jsxs(e.Fragment,{children:[L,e.jsx("br",{}),e.jsx("div",{className:"header-second-row",children:S})]}):L,sortKey:o?"contentType":"type",style:{width:n[o?S:L]}},...o?[]:[{content:S,sortKey:"contentType",style:{width:n[S]}}],{content:D,className:"u-align--right size",style:{width:n[D]}},{content:o?e.jsxs(e.Fragment,{children:[T,e.jsx("br",{}),e.jsx("div",{className:"header-second-row",children:N})]}):T,sortKey:o?"snapshots":"usedBy",className:"u-align--right used_by",style:{width:n[o?N:T]}},...o?[]:[{className:"u-align--right",content:N,sortKey:"snapshots",style:{width:n[N]}}],{content:"",className:"actions u-align--right","aria-label":"Actions",style:{width:n[$]}}],w=m.filter(t=>!(Z(t)||!a.queries.every(j=>t.name.toLowerCase().includes(j))||a.pools.length>0&&!a.pools.includes(t.pool)||a.volumeTypes.length>0&&!a.volumeTypes.includes(t.type)||a.contentTypes.length>0&&!a.contentTypes.includes(t.content_type)||a.clusterMembers.length>0&&!a.clusterMembers.includes(t.location.length===0?"cluster-wide":t.location))),V=xe(m),K=w.map(t=>{const j=P(t),R=be(t),q=Se(t),Y=V[j]?.length??0,ne=I(t);return{key:j,name:ne?j:void 0,className:"u-row",columns:[{content:e.jsx(X,{volume:t}),role:"rowheader",style:{width:n[O]},"aria-label":O},{content:e.jsx(Je,{poolName:t.pool,projectName:t.project,location:t.location}),role:"cell",className:"pool",style:{width:n[B]},"aria-label":B},...p?[{content:t.location?e.jsx(He,{clusterMember:t.location}):e.jsx(Ne,{type:"cluster-group",value:"Cluster wide",to:`${ee}/ui/cluster/members`}),role:"cell",style:{width:n[_]},"aria-label":_}]:[],{content:e.jsxs(e.Fragment,{children:[R,o&&e.jsx("div",{className:"u-text--muted",children:q})]}),role:"cell","aria-label":L,style:{width:n[o?S:L]}},...o?[]:[{content:q,role:"cell","aria-label":S,style:{width:n[S]}}],{content:e.jsx(Oe,{volume:t}),role:"cell","aria-label":D,className:"u-align--right size",style:{width:n[D]}},{className:"u-align--right used_by",content:e.jsxs(e.Fragment,{children:[t.used_by?.length??0,o&&e.jsx("div",{className:"u-text--muted",children:Y})]}),role:"cell","aria-label":T,style:{width:n[o?N:T]}},...o?[]:[{className:"u-align--right",content:Y,role:"cell","aria-label":N,style:{width:n[N]}}],{className:"actions u-align--right",content:I(t)?e.jsx(Ze,{volume:t,className:"storage-volume-actions u-no-margin--bottom"}):e.jsx(X,{volume:t,overrideName:`go to ${t.type==="image"?"images list":t.content_type==="iso"?"custom ISOs":"instance"}`,className:"storage-volume-actions u-align--right"}),role:"cell","aria-label":$,style:{width:n[$]}}],sortData:{name:t.name,pool:t.pool,clusterMember:t.location,contentType:q,type:R,usedBy:t.used_by?.length??0,snapshots:Y}}}),{rows:H,updateSort:te}=$e({rows:K});if(F||r)return e.jsx(l.Spinner,{className:"u-loader",text:"Loading...",isMainComponent:!0});const se=a.pools.length===1?a.pools[0]:"",U=m.length!==0,W=!g&&e.jsxs(l.Notification,{severity:"information",children:["Showing volumes from the"," ",e.jsx(We,{projectName:"default",urlSuffix:"/storage/volumes"}),"project.",e.jsx("br",{}),e.jsx("span",{className:"u-text--muted",children:"For project-specific volumes, enable storage volume isolation in the project configuration."})]}),oe=U?e.jsxs("div",{className:"storage-volumes",children:[W,e.jsx(l.ScrollableTable,{dependencies:[m],tableId:"volume-table",belowIds:["status-bar"],children:e.jsx(l.TablePagination,{data:H,id:"pagination",itemName:"volume",className:"u-no-margin--top","aria-label":"Table pagination control",description:c.length>0&&e.jsx(qe,{totalCount:m.filter(t=>!Z(t)&&I(t)).length,itemName:"volume",parentName:"project",selectedNames:c,setSelectedNames:f,filteredNames:w.filter(I).map(P)}),children:e.jsx(Ue,{className:"storage-volume-table",id:"volume-table",headers:x,rows:H,sortable:!0,emptyStateMsg:"No volumes found matching this search",itemName:"volume",parentName:"project",selectedNames:c,setSelectedNames:f,disabledNames:y,filteredNames:w.map(P),onUpdateSort:te,defaultSortDirection:"descending"})})})]}):e.jsxs(e.Fragment,{children:[W,e.jsxs(l.EmptyState,{className:"empty-state",image:e.jsx(l.Icon,{name:"storage-volume",className:"empty-state-icon"}),title:"No volumes found in this project",children:[e.jsx("p",{children:"Storage volumes will appear here"}),e.jsx("p",{children:e.jsx(Ce,{docPath:"/explanation/storage/#storage-volumes",hasExternalIcon:!0,children:"Learn more about storage volumes"})}),g&&e.jsx(G,{projectName:i,className:"empty-state-button"})]})]}),ae=m.filter(t=>{const j=P(t);return c.includes(j)});return e.jsxs(l.CustomLayout,{mainClassName:"storage-volume-list",header:e.jsxs(E,{children:[e.jsxs(E.Left,{children:[e.jsx(E.Title,{children:e.jsx(Fe,{docPath:"/explanation/storage/#storage-volumes",title:"Learn more about storage volumes",children:"Volumes"})}),!c.length&&U&&e.jsx(E.Search,{children:e.jsx(Ie,{volumes:m},i)}),!!c.length&&e.jsx(Ge,{volumes:ae,onStart:()=>{C(c)},onFinish:()=>{C([])}})]}),U&&g&&e.jsx(E.BaseActions,{children:e.jsx(G,{projectName:i,defaultPool:se,className:"u-float-right u-no-margin--bottom"})})]}),children:[e.jsx(we,{}),e.jsx(l.Row,{children:oe})]})};export{Et as default};