"use strict";(self.webpackChunkportal_ui=self.webpackChunkportal_ui||[]).push([[1581],{1581:function(e,t,a){a.r(t);var n=a(29439),s=a(1413),i=a(72791),l=a(40986),o=a(75952),c=a(11135),r=a(25787),u=a(61889),d=a(45248),f=a(23814),m=a(37516),Z=a(21435),x=a(56028),h=a(81207),p=a(38734),j=a(56578),v=a(87995),b=a(25469),g=a(80184);t.default=(0,r.Z)((function(e){return(0,c.Z)((0,s.Z)((0,s.Z)({},f.DF),f.ID))}))((function(e){var t=e.classes,a=e.open,s=e.enabled,c=e.cfg,r=e.selectedBucket,f=e.closeModalAndRefresh,k=(0,b.TL)(),C=(0,i.useState)(!1),S=(0,n.Z)(C,2),N=S[0],P=S[1],q=(0,i.useState)(!1),B=(0,n.Z)(q,2),w=B[0],y=B[1],z=(0,i.useState)("1"),E=(0,n.Z)(z,2),_=E[0],M=E[1],D=(0,i.useState)("Ti"),T=(0,n.Z)(D,2),F=T[0],I=T[1],L=(0,i.useState)(!1),Q=(0,n.Z)(L,2),R=Q[0],W=Q[1];(0,i.useEffect)((function(){if(s&&(y(!0),c)){var e=(0,d.Am)(c.quota,!0,!1,!0);M(e.total.toString()),I(e.unit),W(!0)}}),[s,c]),(0,i.useEffect)((function(){W(!w||/^\d*(?:\.\d{1,2})?$/.test(_))}),[w,_]);return(0,g.jsx)(x.Z,{modalOpen:a,onClose:function(){f()},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:w,amount:parseInt((0,d.Pw)(_,F,!0)),quota_type:"hard"};h.Z.invoke("PUT","/api/v1/buckets/".concat(r,"/quota"),e).then((function(){P(!1),f()})).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)(m.Z,{value:"bucket_quota",id:"bucket_quota",name:"bucket_quota",checked:w,onChange:function(e){y(e.target.checked)},label:"Enabled"})}),w&&(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){M(e.target.value),e.target.validity.valid?W(!0):W(!1)},label:"Quota",value:_,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,{id:"cancel",type:"button",variant:"regular",disabled:N,onClick:function(){f()},label:"Cancel"}),(0,g.jsx)(o.z,{id:"save",type:"submit",variant:"callAction",disabled:N||!R,label:"Save"})]}),N&&(0,g.jsx)(u.ZP,{item:!0,xs:12,children:(0,g.jsx)(l.Z,{})})]})})})}))},56028:function(e,t,a){var n=a(29439),s=a(1413),i=a(72791),l=a(60364),o=a(13400),c=a(55646),r=a(5574),u=a(65661),d=a(39157),f=a(11135),m=a(25787),Z=a(23814),x=a(25469),h=a(29823),p=a(28057),j=a(87995),v=a(80184);t.Z=(0,m.Z)((function(e){return(0,f.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,a=e.modalOpen,f=e.title,m=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,x.TL)(),P=(0,i.useState)(!1),q=(0,n.Z)(P,2),B=q[0],w=q[1],y=(0,l.v9)((function(e){return e.system.modalSnackBar}));(0,i.useEffect)((function(){N((0,j.MK)(""))}),[N]),(0,i.useEffect)((function(){if(y){if(""===y.message)return void w(!1);"error"!==y.type&&w(!0)}}),[y]);var z=g?{classes:{paper:Z.customDialogSize}}:{maxWidth:"lg",fullWidth:!0},E="";return y&&(E=y.detailedErrorMsg,(""===y.detailedErrorMsg||y.detailedErrorMsg.length<5)&&(E=y.message)),(0,v.jsxs)(r.Z,(0,s.Z)((0,s.Z)({open:a,classes:Z},z),{},{scroll:"paper",onClose:function(e,a){"backdropClick"!==a&&t()},className:Z.root,children:[(0,v.jsxs)(u.Z,{className:Z.title,children:[(0,v.jsxs)("div",{className:Z.titleText,children:[S," ",f]}),(0,v.jsx)("div",{className:Z.closeContainer,children:(0,v.jsx)(o.Z,{"aria-label":"close",id:"close",className:Z.closeButton,onClick:t,disableRipple:!0,size:"small",children:(0,v.jsx)(h.Z,{})})})]}),(0,v.jsx)(p.Z,{isModal:!0}),(0,v.jsx)(c.Z,{open:B,className:Z.snackBarModal,onClose:function(){w(!1),N((0,j.MK)(""))},message:E,ContentProps:{className:"".concat(Z.snackBar," ").concat(y&&"error"===y.type?Z.errorSnackBar:"")},autoHideDuration:y&&"error"===y.type?1e4:5e3}),(0,v.jsx)(d.Z,{className:k?"":Z.content,children:m})]}))}))}}]);
//# sourceMappingURL=1581.5d8bdb2a.chunk.js.map