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