Your IP : 216.73.216.52


Current Path : /snap/lxd/38768/share/lxd-ui/assets/
Upload File :
Current File : //snap/lxd/38768/share/lxd-ui/assets/StorageVolumes-CbExRm9O.js

import{c as le,H as re,ay as ie,j as e,d as l,R as ee,e3 as I,a_ as ce,K as me,s as Q,L as ue,dD as de,S as Y,z as pe,v as he,r as k,T as b,ax as ge,x as A,C as je,bu as fe,e4 as G,Q as ye,e5 as xe,e6 as P,dG as Z,e7 as be,e8 as Ne,cj as Se,w as Ce,b3 as we,p as Le}from"./index-BsQN_SZU.js";import{u as Te}from"./projects-CczQ3aFg.js";import{C as ve,a as Ve,V as Pe,P as Ee,Q as Ie,S as ke}from"./StorageVolumesFilter-DpWoiZ3T.js";import{V as _e,S as Be}from"./VolumeAddSnapshotBtn-BceLfSvp.js";import{g as De,e as Oe}from"./images-dZFGKb1g.js";import{D as Me,u as Re}from"./DeleteStorageVolumeBtn-Cr5fXZmM.js";import{i as Ae}from"./snapshots-LtzKNDw1.js";import{u as $e}from"./useSortTableData-DkMx8bMp.js";import{P as E}from"./PageHeader-BkhUaI4-.js";import{H as Fe}from"./HelpLink-BJF9zWZL.js";import{b as Ke}from"./useVolumes-Bxw5lKYj.js";import{S as Ue}from"./SelectableMainTable-DBx4rRiq.js";import{S as qe}from"./SelectedTableNotification-BpePAhdG.js";import{B as ze}from"./BulkDeleteButton-DbqPCHnz.js";import{e as Qe}from"./storage-volumes-CG043sqG.js";import{u as Ye}from"./useBulkDetails-ydqvQ5wa.js";import{a as He}from"./ClusterMemberRichChip-Di9w-E3M.js";import{P as We}from"./ProjectRichChip-DZzjTfq6.js";import{S as Ge}from"./StoragePoolRichChip-Daex_aZU.js";import"./searchAndFilter-DtC_P-vv.js";import"./SnapshotForm-BuAjnGGJ.js";import"./VolumeLinkChip-BDzYNacj.js";import"./ClusterMemberMemoryUsage-DYUQFY0n.js";import"./Meter-cq8smrSm.js";import"./StoragePoolSize-BNbqTfwA.js";const J=({projectName:s,className:i,defaultPool:u})=>{const o=le(),d=re(),{canCreateStorageVolumes:p}=Te(),{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"})]})},_="Name",B="Pool",D="Cluster Member",L="Type",N="Content Type",O="Size",T="Used By",S="Snapshots",$="Actions",n={[_]:"10rem",[B]:"6rem",[D]:"10rem",[L]:"6rem",[N]:"6rem",[O]:"5rem",[T]:"5rem",[S]:"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=[]}=me(s.project),y=c&&f.find(m=>m.fingerprint===s.name),C=s.type==="custom",a=h||y||C,r=i||(y?`${De(y)} ${Oe(y)}`:s.name);return i&&!a?null:e.jsx("div",{className:Q("u-flex",u),children:e.jsx("div",{className:Q("u-truncate","volume-name-link"),title:r,children:a?e.jsxs(ue,{to:de(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}=Y();return e.jsx(l.List,{inline:!0,className:Q(i,"actions-list"),items:[e.jsx(_e,{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(pe,{bold:!0,type:"volume",value:s.name})," ","deleted."]}))}},"delete")]})},Je=({volumes:s,onStart:i,onFinish:u})=>{const o=l.useToastNotification(),d=he(),[p,h]=k.useState(!1),{canDeleteVolume:c}=Re(),f=Ye(),{project:y}=Y(),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`;Qe(a,C).then(x=>{const{fulfilledCount:w,rejectedCount:V}=ge(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(ze,{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"})},wt=()=>{const s=l.useNotify(),{project:i}=je(),[u]=fe(),[o,d]=k.useState(G()),p=ye(),h=()=>{d(G())};l.useListener(window,h,"resize",!0);const[c,f]=k.useState([]),[y,C]=k.useState([]),a={queries:u.getAll(Ie).map(t=>t.toLowerCase()),pools:u.getAll(Ee),volumeTypes:u.getAll(Pe).map(t=>t==="VM"?"virtual-machine":t.toLowerCase()),contentTypes:u.getAll(Ve).map(t=>t.toLowerCase()),clusterMembers:u.getAll(ve).map(t=>t.toLowerCase())};if(!i)return e.jsx(e.Fragment,{children:"Missing project"});const{project:v,isLoading:r}=Y(),{data:m=[],error:M,isLoading:F}=Ke(i),g=xe(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:_,sortKey:"name",style:{width:n[_]}},{content:B,sortKey:"pool",style:{width:n[B]},className:"pool"},...p?[{content:D,sortKey:"clusterMember",style:{width:n[D]}}]:[],{content:o?e.jsxs(e.Fragment,{children:[L,e.jsx("br",{}),e.jsx("div",{className:"header-second-row",children:N})]}):L,sortKey:o?"contentType":"type",style:{width:n[o?N:L]}},...o?[]:[{content:N,sortKey:"contentType",style:{width:n[N]}}],{content:O,className:"u-align--right size",style:{width:n[O]}},{content:o?e.jsxs(e.Fragment,{children:[T,e.jsx("br",{}),e.jsx("div",{className:"header-second-row",children:S})]}):T,sortKey:o?"snapshots":"usedBy",className:"u-align--right used_by",style:{width:n[o?S:T]}},...o?[]:[{className:"u-align--right",content:S,sortKey:"snapshots",style:{width:n[S]}}],{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=be(m),K=w.map(t=>{const j=P(t),R=Ne(t),q=Se(t),z=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[_]},"aria-label":_},{content:e.jsx(Ge,{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(Ce,{type:"cluster-group",value:"Cluster wide",to:`${ee}/ui/cluster/members`}),role:"cell",style:{width:n[D]},"aria-label":D}]:[],{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?N:L]}},...o?[]:[{content:q,role:"cell","aria-label":N,style:{width:n[N]}}],{content:e.jsx(Be,{volume:t}),role:"cell","aria-label":O,className:"u-align--right size",style:{width:n[O]}},{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:z})]}),role:"cell","aria-label":T,style:{width:n[o?S:T]}},...o?[]:[{className:"u-align--right",content:z,role:"cell","aria-label":S,style:{width:n[S]}}],{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:z}}}),{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(we,{docPath:"/explanation/storage/#storage-volumes",hasExternalIcon:!0,children:"Learn more about storage volumes"})}),g&&e.jsx(J,{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(ke,{volumes:m},i)}),!!c.length&&e.jsx(Je,{volumes:ae,onStart:()=>{C(c)},onFinish:()=>{C([])}})]}),U&&g&&e.jsx(E.BaseActions,{children:e.jsx(J,{projectName:i,defaultPool:se,className:"u-float-right u-no-margin--bottom"})})]}),children:[e.jsx(Le,{}),e.jsx(l.Row,{children:oe})]})};export{wt as default};