"use strict";(self.webpackChunkportal_ui=self.webpackChunkportal_ui||[]).push([[1581],{1581:function(t,e,n){n.r(e);var a=n(29439),o=n(72791),i=n(29945),u=n(45248),r=n(23814),l=n(56028),c=n(84741),s=n(87995),d=n(81551),f=n(31776),b=n(82342),h=n(40986),v=n(80184);e.default=function(t){var e=t.open,n=t.enabled,x=t.cfg,g=t.selectedBucket,p=t.closeModalAndRefresh,m=(0,d.TL)(),j=(0,o.useState)(!1),k=(0,a.Z)(j,2),Z=k[0],C=k[1],S=(0,o.useState)(!1),q=(0,a.Z)(S,2),z=q[0],_=q[1],y=(0,o.useState)("1"),B=(0,a.Z)(y,2),w=B[0],E=B[1],T=(0,o.useState)("Ti"),F=(0,a.Z)(T,2),O=F[0],Q=F[1],A=(0,o.useState)(!1),I=(0,a.Z)(A,2),L=I[0],P=I[1];(0,o.useEffect)((function(){if(n&&(_(!0),x)){var t=(0,u.Am)(x.quota||0,!0,!1,!0);E(t.total.toString()),Q(t.unit),P(!0)}}),[n,x]),(0,o.useEffect)((function(){P(!z||/^\d*(?:\.\d{1,2})?$/.test(w))}),[z,w]);return(0,v.jsx)(l.Z,{modalOpen:e,onClose:function(){p()},title:"Enable Bucket Quota",titleIcon:(0,v.jsx)(i.Wqw,{}),children:(0,v.jsx)("form",{noValidate:!0,autoComplete:"off",onSubmit:function(t){t.preventDefault(),!Z&&L&&f.h.buckets.setBucketQuota(g,{enabled:z,amount:parseInt((0,u.Pw)(w,O,!0)),quota_type:"hard"}).then((function(){C(!1),p()})).catch((function(t){C(!1),m((0,s.zb)((0,b.g)(t.error)))}))},children:(0,v.jsxs)(i.ltY,{withBorders:!1,containerPadding:!1,children:[(0,v.jsx)(i.rsf,{value:"bucket_quota",id:"bucket_quota",name:"bucket_quota",checked:z,onChange:function(t){_(t.target.checked)},label:"Enabled"}),z&&(0,v.jsx)(i.Wzg,{id:"quota_size",name:"quota_size",onChange:function(t){E(t.target.value),t.target.validity.valid?P(!0):P(!1)},label:"Quota",value:w,required:!0,min:"1",overlayObject:(0,v.jsx)(c.Z,{id:"quota_unit",onUnitChange:function(t){Q(t)},unitSelected:O,unitsList:(0,u.zQ)(["Ki"]),disabled:!1}),error:L?"":"Please enter a valid quota"}),(0,v.jsxs)(i.rjZ,{item:!0,xs:12,sx:r.ID.modalButtonBar,children:[(0,v.jsx)(i.zxk,{id:"cancel",type:"button",variant:"regular",disabled:Z,onClick:function(){p()},label:"Cancel"}),(0,v.jsx)(i.zxk,{id:"save",type:"submit",variant:"callAction",disabled:Z||!L,label:"Save"})]}),Z&&(0,v.jsx)(i.rjZ,{item:!0,xs:12,children:(0,v.jsx)(h.Z,{})})]})})})}},84741:function(t,e,n){var a=n(29439),o=n(72791),i=n(11135),u=n(25787),r=n(71715),l=n(77865),c=n(80184);e.Z=(0,u.Z)((function(t){return(0,i.Z)({buttonTrigger:{border:"#F0F2F2 1px solid",borderRadius:3,color:"#838383",backgroundColor:"#fff",fontSize:12}})}))((function(t){var e=t.classes,n=t.id,i=t.unitSelected,u=t.unitsList,s=t.disabled,d=void 0!==s&&s,f=t.onUnitChange,b=o.useState(null),h=(0,a.Z)(b,2),v=h[0],x=h[1],g=Boolean(v),p=function(t){x(null),""!==t&&f&&f(t)};return(0,c.jsxs)(o.Fragment,{children:[(0,c.jsx)("button",{id:"".concat(n,"-button"),"aria-controls":"".concat(n,"-menu"),"aria-haspopup":"true","aria-expanded":g?"true":void 0,onClick:function(t){x(t.currentTarget)},className:e.buttonTrigger,disabled:d,type:"button",children:i}),(0,c.jsx)(r.Z,{id:"".concat(n,"-menu"),"aria-labelledby":"".concat(n,"-button"),anchorEl:v,open:g,onClose:function(){p("")},anchorOrigin:{vertical:"bottom",horizontal:"center"},transformOrigin:{vertical:"top",horizontal:"center"},children:u.map((function(t){return(0,c.jsx)(l.Z,{onClick:function(){return p(t.value)},children:t.label},"itemUnit-".concat(t.value,"-").concat(t.label))}))})]})}))}}]);
//# sourceMappingURL=1581.a911ee27.chunk.js.map