"use strict";(self.webpackChunkportal_ui=self.webpackChunkportal_ui||[]).push([[1581],{1581:function(e,t,n){n.r(t);var a=n(29439),s=n(1413),i=n(72791),o=n(36151),l=n(40986),c=n(11135),r=n(25787),u=n(61889),d=n(45248),m=n(23814),f=n(37516),Z=n(21435),h=n(56028),x=n(81207),p=n(38734),j=n(56578),v=n(87995),b=n(25469),g=n(80184);t.default=(0,r.Z)((function(e){return(0,c.Z)((0,s.Z)((0,s.Z)({},m.DF),m.ID))}))((function(e){var t=e.classes,n=e.open,s=e.enabled,c=e.cfg,r=e.selectedBucket,m=e.closeModalAndRefresh,k=(0,b.TL)(),C=(0,i.useState)(!1),S=(0,a.Z)(C,2),N=S[0],P=S[1],q=(0,i.useState)(!1),y=(0,a.Z)(q,2),B=y[0],w=y[1],E=(0,i.useState)("1"),_=(0,a.Z)(E,2),M=_[0],z=_[1],D=(0,i.useState)("Ti"),T=(0,a.Z)(D,2),F=T[0],I=T[1],L=(0,i.useState)(!1),Q=(0,a.Z)(L,2),R=Q[0],W=Q[1];(0,i.useEffect)((function(){if(s&&(w(!0),c)){var e=(0,d.Am)(c.quota,!0,!1,!0);z(e.total.toString()),I(e.unit),W(!0)}}),[s,c]),(0,i.useEffect)((function(){W(!B||/^\d*(?:\.\d{1,2})?$/.test(M))}),[B,M]);return(0,g.jsx)(h.Z,{modalOpen:n,onClose:function(){m()},title:"Enable Bucket Quota",titleIcon:(0,g.jsx)(p.Wqw,{}),children:(0,g.jsx)("form",{noValidate:!0,autoComplete:"off",onSubmit:function(e){e.preventDefault(),function(){if(!N&&R){var e={enabled:B,amount:parseInt((0,d.Pw)(M,F,!0)),quota_type:"hard"};x.Z.invoke("PUT","/api/v1/buckets/".concat(r,"/quota"),e).then((function(){P(!1),m()})).catch((function(e){P(!1),k((0,v.zb)(e))}))}}()},children:(0,g.jsxs)(u.ZP,{container:!0,children:[(0,g.jsxs)(u.ZP,{item:!0,xs:12,className:t.formScrollable,children:[(0,g.jsx)(u.ZP,{item:!0,xs:12,className:t.formFieldRow,children:(0,g.jsx)(f.Z,{value:"bucket_quota",id:"bucket_quota",name:"bucket_quota",checked:B,onChange:function(e){w(e.target.checked)},label:"Enabled"})}),B&&(0,g.jsx)(i.Fragment,{children:(0,g.jsx)(u.ZP,{item:!0,xs:12,className:t.formFieldRow,children:(0,g.jsx)(u.ZP,{container:!0,children:(0,g.jsx)(u.ZP,{item:!0,xs:12,children:(0,g.jsx)(Z.Z,{id:"quota_size",name:"quota_size",onChange:function(e){z(e.target.value),e.target.validity.valid?W(!0):W(!1)},label:"Quota",value:M,required:!0,min:"1",overlayObject:(0,g.jsx)(j.Z,{id:"quota_unit",onUnitChange:function(e){I(e)},unitSelected:F,unitsList:(0,d.zQ)(["Ki"]),disabled:!1}),error:R?"":"Please enter a valid quota"})})})})})]}),(0,g.jsxs)(u.ZP,{item:!0,xs:12,className:t.modalButtonBar,children:[(0,g.jsx)(o.Z,{type:"button",variant:"outlined",color:"primary",disabled:N,onClick:function(){m()},children:"Cancel"}),(0,g.jsx)(o.Z,{type:"submit",variant:"contained",color:"primary",disabled:N||!R,children:"Save"})]}),N&&(0,g.jsx)(u.ZP,{item:!0,xs:12,children:(0,g.jsx)(l.Z,{})})]})})})}))},56028:function(e,t,n){var a=n(29439),s=n(1413),i=n(72791),o=n(60364),l=n(13400),c=n(55646),r=n(5574),u=n(65661),d=n(39157),m=n(11135),f=n(25787),Z=n(23814),h=n(25469),x=n(29823),p=n(28057),j=n(87995),v=n(80184);t.Z=(0,f.Z)((function(e){return(0,m.Z)((0,s.Z)((0,s.Z)({},Z.Qw),{},{content:{padding:25,paddingBottom:0},customDialogSize:{width:"100%",maxWidth:765}},Z.sN))}))((function(e){var t=e.onClose,n=e.modalOpen,m=e.title,f=e.children,Z=e.classes,b=e.wideLimit,g=void 0===b||b,k=e.noContentPadding,C=e.titleIcon,S=void 0===C?null:C,N=(0,h.TL)(),P=(0,i.useState)(!1),q=(0,a.Z)(P,2),y=q[0],B=q[1],w=(0,o.v9)((function(e){return e.system.modalSnackBar}));(0,i.useEffect)((function(){N((0,j.MK)(""))}),[N]),(0,i.useEffect)((function(){if(w){if(""===w.message)return void B(!1);"error"!==w.type&&B(!0)}}),[w]);var E=g?{classes:{paper:Z.customDialogSize}}:{maxWidth:"lg",fullWidth:!0},_="";return w&&(_=w.detailedErrorMsg,(""===w.detailedErrorMsg||w.detailedErrorMsg.length<5)&&(_=w.message)),(0,v.jsxs)(r.Z,(0,s.Z)((0,s.Z)({open:n,classes:Z},E),{},{scroll:"paper",onClose:function(e,n){"backdropClick"!==n&&t()},className:Z.root,children:[(0,v.jsxs)(u.Z,{className:Z.title,children:[(0,v.jsxs)("div",{className:Z.titleText,children:[S," ",m]}),(0,v.jsx)("div",{className:Z.closeContainer,children:(0,v.jsx)(l.Z,{"aria-label":"close",id:"close",className:Z.closeButton,onClick:t,disableRipple:!0,size:"small",children:(0,v.jsx)(x.Z,{})})})]}),(0,v.jsx)(p.Z,{isModal:!0}),(0,v.jsx)(c.Z,{open:y,className:Z.snackBarModal,onClose:function(){B(!1),N((0,j.MK)(""))},message:_,ContentProps:{className:"".concat(Z.snackBar," ").concat(w&&"error"===w.type?Z.errorSnackBar:"")},autoHideDuration:w&&"error"===w.type?1e4:5e3}),(0,v.jsx)(d.Z,{className:k?"":Z.content,children:f})]}))}))}}]);
//# sourceMappingURL=1581.b372ec91.chunk.js.map