"use strict";(self.webpackChunkweb_app=self.webpackChunkweb_app||[]).push([[7540],{40692:(e,l,t)=>{t.d(l,{c:()=>p});var s=t(69060),i=t(66152),c=t(43528),n=t(86116),o=t(95705),a=t(66156),r=t(20928),d=t(19536),u=t(61180),h=t(82496);const p=e=>{let{noTitle:l=!1}=e;const t=(0,a.Ab)(),[p,x]=(0,s.useState)([]),[v,m]=(0,s.useState)(!1),[y,j]=(0,s.useState)(""),g=(0,d.w1)((e=>e.createUser.selectedPolicies)),b=(0,s.useCallback)((()=>{m(!0),u.m.policies.listPolicies().then((e=>{var l;const t=null!==(l=e.data.policies)&&void 0!==l?l:[];m(!1),x(t.sort(c.aw))})).catch((e=>{m(!1),t((0,o.op)(e))}))}),[t]);(0,s.useEffect)((()=>{m(!0)}),[]),(0,s.useEffect)((()=>{v&&b()}),[v,b]);const f=p.filter((e=>e.name.includes(y)));return(0,h.jsxs)(i.yeN,{item:!0,xs:12,className:"inputItem",children:[v&&(0,h.jsx)(i.cHM,{}),p.length>0?(0,h.jsxs)(s.Fragment,{children:[(0,h.jsx)(i.yeN,{item:!0,xs:12,className:"inputItem",children:(0,h.jsx)(n.c,{placeholder:"Start typing to search for a Policy",onChange:e=>{j(e)},value:y,label:l?"":"Assign Policies"})}),(0,h.jsx)(i.iSL,{columns:[{label:"Policy",elementKey:"name"}],onSelect:e=>{const l=e.target,s=l.value,i=l.checked;let c=[...g];i?c.push(s):c=c.filter((e=>e!==s)),c=c.filter((e=>""!==e)),t((0,r.yw)(c))},selectedItems:g,isLoading:v,records:f,entityName:"Policies",idField:"name",customPaperHeight:"200px"})]}):(0,h.jsx)(i.kvh,{sx:{textAlign:"center",padding:"10px 0"},children:"No Policies Available"})]})}},27540:(e,l,t)=>{t.r(l),t.d(l,{default:()=>y});var s=t(69060),i=t(58564),c=t.n(i),n=t(19536),o=t(66152),a=t(61060),r=t(95705),d=t(66156),u=t(61628),h=t(20928),p=t(4836),x=t(40692),v=t(50900),m=t(82496);const y=e=>{let{closeModalAndRefresh:l,selectedUser:t,selectedGroups:i,open:y}=e;const j=(0,d.Ab)(),[g,b]=(0,s.useState)(!1),[f,w]=(0,s.useState)([]),[k,P]=(0,s.useState)([]),S=(0,n.w1)((e=>e.createUser.selectedPolicies));(0,s.useEffect)((()=>{if(y){if(1===(null===i||void 0===i?void 0:i.length))return void(1===(null===i||void 0===i?void 0:i.length)&&v.c.invoke("GET","/api/v1/group/".concat((0,a.CO)(i[0]))).then((e=>{const l=c()(e,"policy","");w(l.split(",")),P(l.split(",")),j((0,h.yw)(l.split(",")))})).catch((e=>{j((0,r.op)(e)),b(!1)})));const e=c()(t,"policy",[]);w(e),P(e),j((0,h.yw)(e))}}),[y,null===i||void 0===i?void 0:i.length,t]);const C=c()(t,"accessKey","");return(0,m.jsxs)(p.c,{onClose:()=>{l()},modalOpen:y,title:"Set Policies",children:[(0,m.jsxs)(o.yE_,{withBorders:!1,containerPadding:!1,children:[(1===(null===i||void 0===i?void 0:i.length)||null!=t)&&(0,m.jsxs)(s.Fragment,{children:[(0,m.jsx)(o.E$k,{label:"Selected ".concat(null!==i?"Group":"User"),sx:{width:"100%"},children:null!==i?i[0]:C}),(0,m.jsx)(o.E$k,{label:"Current Policy",sx:{width:"100%"},children:f.join(", ")})]}),i&&(null===i||void 0===i?void 0:i.length)>1&&(0,m.jsx)(o.E$k,{label:"Selected Groups",sx:{width:"100%"},children:i.join(", ")}),(0,m.jsx)(o.yeN,{item:!0,xs:12,children:(0,m.jsx)(x.c,{selectedPolicy:k})})]}),(0,m.jsxs)(o.yeN,{item:!0,xs:12,sx:u.W2.modalButtonBar,children:[(0,m.jsx)(o.qaq,{id:"reset",type:"button",variant:"regular",onClick:()=>{P(f),j((0,h.yw)(f))},label:"Reset"}),(0,m.jsx)(o.qaq,{id:"save",type:"button",variant:"callAction",color:"primary",disabled:g,onClick:()=>{let e=null,s=null;null!==i?s=i:null!==t&&(e=[t.accessKey]||0),b(!0),v.c.invoke("PUT","/api/v1/set-policy-multi",{name:S,groups:s,users:e}).then((()=>{b(!1),l()})).catch((e=>{b(!1),j((0,r.op)(e))}))},label:"Save"})]}),g&&(0,m.jsx)(o.yeN,{item:!0,xs:12,children:(0,m.jsx)(o.cHM,{})})]})}}}]);
//# sourceMappingURL=7540.672b21be.chunk.js.map