"use strict";(self.webpackChunkportal_ui=self.webpackChunkportal_ui||[]).push([[9952],{99952:function(e,n,t){t.r(n),t.d(n,{default:function(){return g}});var s=t(74165),a=t(15861),r=t(29439),i=t(72791),c=t(40986),o=t(29945),l=t(66315),u=t(31776),d=t(82342),f=t(23814),p=t(87995),x=t(81551),m=t(56087),h=t(38442),k=t(27454),b=t(9505),y=t(23508),j=t(40214),v=t(80184),S=function(e){var n=e.closeAddModalAndRefresh,t=e.addOpen,s=(0,x.TL)(),a=(0,b.Z)((function(){return n(!0)}),(function(e){n(!1),s((0,p.Ih)(e))})),c=(0,r.Z)(a,2),l=c[0],u=c[1],d=(0,i.useState)(""),f=(0,r.Z)(d,2),m=f[0],h=f[1];return(0,v.jsx)(y.Z,{title:"",confirmText:"Create",isOpen:t,isLoading:l,onConfirm:function(){u("POST","/api/v1/kms/keys/",{key:m})},onClose:function(){return n(!1)},confirmButtonProps:{disabled:-1!==m.indexOf(" ")||""===m||l,variant:"callAction"},confirmationContent:(0,v.jsxs)(i.Fragment,{children:[(0,v.jsx)(j.Z,{helpText:"Create Key",contents:["Create a new cryptographic key in the Key Management Service server connected to MINIO."]}),(0,v.jsx)(o.rjZ,{item:!0,xs:12,sx:{marginTop:15},children:(0,v.jsx)(o.Wzg,{id:"key-name",name:"key-name",label:"Key Name",autoFocus:!0,value:m,error:-1!==m.indexOf(" ")?"Key name cannot contain spaces":"",onChange:function(e){h(e.target.value)}})})]})})},Z=t(56028),g=function(e){var n=e.open,t=e.encryptionCfg,b=e.selectedBucket,y=e.closeModalAndRefresh,j=(0,x.TL)(),g=(0,i.useState)(!1),C=(0,r.Z)(g,2),K=C[0],E=C[1],M=(0,i.useState)(""),A=(0,r.Z)(M,2),I=A[0],T=A[1],B=(0,i.useState)("disabled"),O=(0,r.Z)(B,2),w=O[0],P=O[1],z=(0,i.useState)([]),D=(0,r.Z)(z,2),F=D[0],J=D[1],L=(0,i.useState)(!1),R=(0,r.Z)(L,2),_=R[0],N=R[1],X=(0,i.useState)(!1),Y=(0,r.Z)(X,2),V=Y[0],W=Y[1];(0,i.useEffect)((function(){t&&("AES256"===t.algorithm?P(l.bJ.SseS3):(P(l.bJ.SseKms),T(t.kmsMasterKeyID||"")))}),[t]),(0,i.useEffect)((function(){"sse-kms"===w&&u.h.kms.kmsListKeys().then((function(e){J(e.data.results),N(!1)})).catch((function(e){N(!1),j((0,p.zb)((0,d.g)(e.error)))}))}),[w,_,j]);return(0,v.jsxs)(i.Fragment,{children:[V&&(0,v.jsx)(S,{addOpen:V,closeAddModalAndRefresh:function(e){W(!1),N(!0)}}),(0,v.jsx)(Z.Z,{modalOpen:n,onClose:function(){y()},title:"Enable Bucket Encryption",titleIcon:(0,v.jsx)(o.Xn4,{}),children:(0,v.jsx)("form",{noValidate:!0,autoComplete:"off",onSubmit:function(e){e.preventDefault(),K||("disabled"===w?u.h.buckets.disableBucketEncryption(b).then((function(){E(!1),y()})).catch(function(){var e=(0,a.Z)((0,s.Z)().mark((function e(n){var t;return(0,s.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.json();case 2:t=e.sent,E(!1),j((0,p.zb)((0,d.g)(t)));case 5:case"end":return e.stop()}}),e)})));return function(n){return e.apply(this,arguments)}}()):u.h.buckets.enableBucketEncryption(b,{encType:w,kmsKeyID:I}).then((function(){E(!1),y()})).catch(function(){var e=(0,a.Z)((0,s.Z)().mark((function e(n){var t;return(0,s.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.json();case 2:t=e.sent,E(!1),j((0,p.zb)((0,d.g)(t)));case 5:case"end":return e.stop()}}),e)})));return function(n){return e.apply(this,arguments)}}()))},children:(0,v.jsxs)(o.ltY,{withBorders:!1,containerPadding:!1,children:[(0,v.jsx)(o.PhF,{onChange:function(e){P(e)},id:"select-encryption-type",name:"select-encryption-type",label:"Encryption Type",value:w,options:[{label:"Disabled",value:"disabled"},{label:"SSE-S3",value:l.bJ.SseS3},{label:"SSE-KMS",value:l.bJ.SseKms}]}),"sse-kms"===w&&(0,v.jsxs)(o.xuv,{sx:{display:"flex",gap:10},className:"inputItem",children:[F&&(0,v.jsx)(o.PhF,{onChange:function(e){T(e)},id:"select-kms-key-id",name:"select-kms-key-id",label:"KMS Key ID",value:I,options:F.map((function(e){return{label:e.name||"",value:e.name||""}}))}),(0,v.jsx)(h.s,{scopes:[m.Ft.KMS_IMPORT_KEY],resource:m.C3,errorProps:{disabled:!0},children:(0,v.jsx)(k.Z,{tooltip:"Add key",children:(0,v.jsx)(o.zxk,{id:"import-key",variant:"regular",icon:(0,v.jsx)(o.dtP,{}),onClick:function(e){W(!0),e.preventDefault()}})})})]}),(0,v.jsxs)(o.rjZ,{item:!0,xs:12,sx:f.ID.modalButtonBar,children:[(0,v.jsx)(o.zxk,{id:"cancel",type:"submit",variant:"regular",onClick:function(){y()},disabled:K,label:"Cancel"}),(0,v.jsx)(o.zxk,{id:"save",type:"submit",variant:"callAction",disabled:K,label:"Save"})]}),K&&(0,v.jsx)(o.rjZ,{item:!0,xs:12,children:(0,v.jsx)(c.Z,{})})]})})})]})}},40214:function(e,n,t){var s=t(72791),a=t(29945),r=t(80184);n.Z=function(e){var n=e.helpText,t=e.contents;return(0,r.jsx)(a.KfX,{iconComponent:(0,r.jsx)(a.M9A,{}),title:n,help:(0,r.jsx)(s.Fragment,{children:t.map((function(e){return(0,r.jsx)(a.xuv,{sx:{paddingBottom:"20px"},children:e})}))})})}}}]);
//# sourceMappingURL=9952.e9660829.chunk.js.map