/
snap
/
lxd
/
35210
/
share
/
lxd-ui
/
assets
/
File Upload :
llllll
Current File: //snap/lxd/35210/share/lxd-ui/assets/StorageBuckets-BGbHJN5C.js
import{r as B,aS as H,j as e,d as a,x as X,ak as ee,F as R,l as Q,ah as j,aj as te,q as T,f as se,g as q,i as ae,e as Y,R as V,L as oe,n as ne,o as re}from"./index-dL2n30-Z.js";import{S as le}from"./ScrollableTable-CQDmfMtz.js";import{s as ie,p as ce}from"./searchAndFilter-B29FrImZ.js";import{u as de}from"./useSortTableData-8PACcjA7.js";import{P as w}from"./PageHeader-5dI4zJHr.js";import{H as ue}from"./HelpLink-C3KAssP1.js";import{u as me,d as pe,c as he,S as ge,a as fe,b as Se,e as be,E as je}from"./EditStorageBucketPanel-CgvzJxUU.js";import{u as K,p as z}from"./usePanelParams-BJBr0ywH.js";import{S as ke}from"./SelectableMainTable-DeGTWeiA.js";import{S as xe}from"./SelectedTableNotification-BHmDbErh.js";import{B as ye}from"./BulkDeleteButton-DzyTAjHk.js";import{S as Ne}from"./ScrollableContainer-ceiHesUW.js";import{t as Be,g as J}from"./storageBucket-Bz2jIa5m.js";import{I as Ce}from"./ItemName-BzCTqTL3.js";import"./AutoExpandingTextArea-CQuEMXHF.js";import"./StoragePoolSelector-BbIrdWMX.js";import"./StoragePoolSize-BwIynhzl.js";import"./Meter-BBGrNnHA.js";import"./DiskSizeSelector-DZsA03GF.js";import"./limits-CLEFMbq-.js";const W="query",_="pool",U=[W,_],we=({buckets:s})=>{const[o,n]=H(),i=[{id:1,heading:"Pool",chips:[...new Set(s.map(m=>m.pool))].map(m=>({lead:_,value:m}))}],h=m=>{const g=ce(m,o,U);g.toString()!==o.toString()&&n(g)};return e.jsxs("div",{className:"search-wrapper margin-right",children:[e.jsx("h2",{className:"u-off-screen",children:"Search and filter"}),e.jsx(a.SearchAndFilter,{existingSearchData:ie(o,U),filterPanelData:i,returnSearchData:h,onExpandChange:()=>{window.dispatchEvent(new CustomEvent("resize",{detail:"search-and-filter"}))},onPanelToggle:()=>{window.dispatchEvent(new CustomEvent("sfp-toggle"))}})]})},Pe=B.memo(we),P="Name",L="Pool",v="Size",D="Description",E="S3 URL",$="Keys",I="Actions",u={[P]:"8rem",[L]:"8rem",[v]:"5rem",[D]:"10rem",[E]:"15rem",[$]:"3rem",[I]:"8.5rem"},M=({className:s})=>{const o=X(),{canCreateStorageBuckets:n}=ee(),{project:d}=R(),i=K();return e.jsxs(a.Button,{appearance:"positive",hasIcon:!o,onClick:()=>{i.openCreateStorageBucket((d==null?void 0:d.name)||"")},className:s,disabled:!n(d),title:n(d)?"Create bucket":"You do not have permission to create buckets in this project",children:[!o&&e.jsx(a.Icon,{name:"plus",light:!0}),e.jsx("span",{children:"Create bucket"})]})},Le=({buckets:s,onStart:o,onFinish:n})=>{const d=a.useToastNotification(),i=Q(),[h,m]=B.useState(!1),{canDeleteBucket:g}=me(),{project:r}=R(),c=(r==null?void 0:r.name)||"",l=s.filter(b=>g(b)),k=s.length,p=l.length,S=`Delete ${s.length} ${j("bucket",s.length)}`,O=()=>{m(!0),o();const b=`${l.length} ${j("bucket",l.length)} successfully deleted`;pe(l,c).then(N=>{const{fulfilledCount:C,rejectedCount:x}=te(N);C===p?d.success(b):x===p?d.failure("Bucket bulk deletion failed",void 0,e.jsxs(e.Fragment,{children:[e.jsx("b",{children:p})," ",j("bucket",p)," could not be deleted."]})):d.failure("Bucket bulk deletion partially failed",void 0,e.jsxs(e.Fragment,{children:[e.jsx("b",{children:C})," ",j("bucket",C)," ","deleted.",e.jsx("br",{}),e.jsx("b",{children:x})," ",j("bucket",x)," could not be deleted."]})),i.invalidateQueries({queryKey:[T.storage,c,T.buckets]}),m(!1),n()}).catch(N=>{m(!1),d.failure("Bucket bulk deletion failed",N)})},y=()=>{if(p===k)return;const b=k-p;return[`${p} ${j("bucket",p)} will be deleted.`,`${b} ${j("bucket",b)} that you do not have permission to delete will be ignored.`]};return e.jsx(ye,{entities:s,deletableEntities:l,entityType:"bucket",onDelete:O,disabledReason:p===0?`You do not have permission to delete the selected ${j("bucket",s.length)}`:void 0,confirmationButtonProps:{disabled:h||p===0,loading:h},buttonLabel:S,bulkDeleteBreakdown:y(),className:"u-no-margin--bottom"})},ve=()=>{const s=K(),o=a.useNotify(),n=a.useToastNotification(),d=B.useState(null),i=Q(),h=()=>{s.clear(),o.clear()},m=se().shape({name:q().test(...Be(s.project,d)).required("Bucket name is required"),pool:q().required("Pool must have a Ceph Object driver")}),g=(c,l)=>{n.success(e.jsxs(e.Fragment,{children:["Bucket"," ",e.jsx(V,{type:"bucket",value:c,to:J(c,l,s.project)})," ","created."]})),h()},r=ae({initialValues:{name:"",pool:""},validationSchema:m,onSubmit:c=>{const l={name:c.name,config:{size:c.size},description:c.description};he(JSON.stringify(l),s.project,c.pool,c.target).then(()=>{i.invalidateQueries({queryKey:[T.storage,s.project,T.buckets]}),g(c.name,c.pool)}).catch(k=>{r.setSubmitting(!1),o.failure("Bucket creation failed",k)})}});return e.jsx(e.Fragment,{children:e.jsxs(a.SidePanel,{children:[e.jsx(a.SidePanel.Header,{children:e.jsx(a.SidePanel.HeaderTitle,{children:"Create storage bucket"})}),e.jsx(Y,{className:"u-no-padding"}),e.jsx(a.SidePanel.Content,{className:"u-no-padding",children:e.jsx(Ne,{dependencies:[o.notification],belowIds:["panel-footer"],children:e.jsx(ge,{formik:r})})}),e.jsxs(a.SidePanel.Footer,{className:"u-align--right",children:[e.jsx(a.Button,{appearance:"base",onClick:h,className:"u-no-margin--bottom",children:"Cancel"}),e.jsx(a.ActionButton,{appearance:"positive",loading:r.isSubmitting,onClick:()=>void r.submitForm(),className:"u-no-margin--bottom",disabled:!r.isValid||r.isSubmitting||!r.values.name,children:"Create bucket"})]})]})})},De=({bucket:s,project:o})=>e.jsx(oe,{to:J(s.name,s.pool,o),onClick:n=>{n.stopPropagation()},children:e.jsx(Ce,{item:s})}),Ee=({bucket:s})=>{const{project:o}=R(),{data:n=[]}=fe(s,(o==null?void 0:o.name)??"");return e.jsx(e.Fragment,{children:n?n.length:"-"})},Ge=()=>{const s=ne(),o=a.useNotify(),{project:n}=re(),[d]=H(),[i,h]=B.useState([]),[m,g]=B.useState([]),r=K(),c={queries:d.getAll(W),pools:d.getAll(_)};if(!n)return e.jsx(e.Fragment,{children:"Missing project"});const{data:l=[],error:k,isLoading:p}=Se(n),S=t=>`${t.name}-${t.pool}-${t.location||""}`;B.useEffect(()=>{const t=new Set(l.map(S)),f=i.filter(F=>t.has(F));f.length!==i.length&&h(f)},[l]),k&&o.failure("Loading storage buckets failed",k);const O=[{content:P,sortKey:"name",className:"name",style:{width:u[P]}},{content:L,sortKey:"pool",className:"pool",style:{width:u[L]}},{content:v,sortKey:"size",className:"size",style:{width:u[v]}},{content:D,className:"description",style:{width:u[D]}},{content:E,sortKey:"s3_url",style:{width:u[E]}},{content:$,style:{width:u[$]},className:"keys"},{className:"actions u-align--right","aria-label":"Actions",style:{width:u[I]}}],y=l.filter(t=>!(!c.queries.every(f=>t.name.toLowerCase().includes(f))||c.pools.length>0&&!c.pools.includes(t.pool))),b=y.map(t=>{var f,F;return{key:S(t),name:S(t),className:"u-row",columns:[{content:e.jsx(De,{bucket:t,project:n}),role:"rowheader","aria-label":P,style:{width:u[P]}},{content:e.jsx(V,{type:"pool",value:t.pool,to:`/ui/project/${encodeURIComponent(n)}/storage/pool/${encodeURIComponent(t.pool)}`}),role:"cell","aria-label":L,style:{width:u[L]}},{content:((f=t.config)==null?void 0:f.size)??"-",role:"cell","aria-label":v,style:{width:u[v]}},{content:t.description||"-",role:"cell","aria-label":D,style:{width:u[D]},className:"description u-truncate"},{content:e.jsx("div",{className:"u-truncate",title:t.s3_url,children:t.s3_url}),role:"cell","aria-label":E,style:{width:u[E]}},{content:e.jsx(Ee,{bucket:t}),role:"cell","aria-label":$,style:{width:u[$]},className:"keys"},{className:"actions u-align--right",content:e.jsx(be,{bucket:t,className:"storage-bucket-actions u-no-margin--bottom"}),role:"cell","aria-label":I,style:{width:u[I]}}],sortData:{name:t.name,pool:t.pool,size:((F=t.config)==null?void 0:F.size)??"",s3_url:t.s3_url}}}),{rows:N,updateSort:C}=de({rows:b,defaultSortDirection:"descending"});if(p)return e.jsx(a.Spinner,{className:"u-loader",text:"Loading...",isMainComponent:!0});const x=l.length!==0,Z=x?e.jsx("div",{className:"storage-buckets",children:e.jsx(le,{dependencies:[y],tableId:"bucket-table",belowIds:["status-bar"],children:e.jsx(a.TablePagination,{data:N,id:"pagination",itemName:"bucket",className:"u-no-margin--top","aria-label":"Table pagination control",description:i.length>0&&e.jsx(xe,{totalCount:l.length??0,itemName:"bucket",parentName:"project",selectedNames:i,setSelectedNames:h,filteredNames:y.map(t=>S(t))}),children:e.jsx(ke,{id:"bucket-table",className:"storage-buckets-table",headers:O,rows:N,sortable:!0,emptyStateMsg:"No bucket found matching this search",itemName:"bucket",parentName:"project",selectedNames:i,setSelectedNames:h,disabledNames:m,filteredNames:y.map(S),onUpdateSort:C,defaultSortDirection:"descending",responsive:!0})})})}):e.jsxs(a.EmptyState,{className:"empty-state",image:e.jsx(a.Icon,{name:"switcher-dashboard",className:"empty-state-icon"}),title:"No buckets found in this project",children:[e.jsx("p",{children:"Storage buckets will appear here"}),e.jsx("p",{children:e.jsxs("a",{href:`${s}/explanation/storage/`,target:"_blank",rel:"noopener noreferrer",children:["Learn more about storage",e.jsx(a.Icon,{className:"external-link-icon",name:"external-link"})]})}),e.jsx(M,{className:"empty-state-button"})]}),G=l.filter(t=>{const f=S(t);return i.includes(f)}),A=l.find(t=>t.name==r.bucket&&t.pool==r.pool&&t.location==r.target);return e.jsxs(e.Fragment,{children:[e.jsxs(a.CustomLayout,{mainClassName:"storage-bucket-list",header:e.jsxs(w,{children:[e.jsxs(w.Left,{children:[e.jsx(w.Title,{children:e.jsx(ue,{href:`${s}/explanation/storage/`,title:"Learn more about storage pools, volumes and buckets",children:"Buckets"})}),!i.length&&!r.panel&&x&&e.jsx(w.Search,{children:e.jsx(Pe,{buckets:l},n)}),!!i.length&&e.jsx(Le,{buckets:G,onStart:()=>{g(i)},onFinish:()=>{g([])}})]}),x&&e.jsx(w.BaseActions,{children:e.jsx(M,{className:"u-float-right u-no-margin--bottom"})})]}),children:[!r.panel&&e.jsx(Y,{}),e.jsx(a.Row,{children:Z})]}),r.panel===z.createStorageBucket&&e.jsx(ve,{}),r.panel===z.editStorageBucket&&A&&e.jsx(je,{bucket:A})]})};export{Ge as default};
Copyright ©2k19 -
Hexid
|
Tex7ure