"use strict";(self.webpackChunkhws_plugin_authorization_access_manager=self.webpackChunkhws_plugin_authorization_access_manager||[]).push([[228],{60228:function(e,i,n){n.r(i),n.d(i,{default:function(){return f}});var o=n(1995),l=n(29434),a=n(57868),s=n(36856),t=n(46875),r=n(25793),d=n(26385),c=n(32591),A=n(905),u=n(60707),_=n(74985),S=n(28578),I=n(18160),N=n(46141),v=n(48671),E=n(3718),h=n(85052);let C=e=>{var i,n,o,l;return null!==(l=null===(o=window)||void 0===o?void 0:null===(n=o.HWS)||void 0===n?void 0:null===(i=n.I18n)||void 0===i?void 0:i.t(e))&&void 0!==l?l:e};function m(e){let{open:i,onClose:n,id:a}=e,{deleteData:s}=(0,E.A)(),[t,r]=l.useState(!1),d=async()=>{r(!0),null!=a&&await s(h.H.Policies,a),r(!1),n()};return(0,o.jsxs)(c.A,{open:i,disableEnforceFocus:!0,disableAutoFocus:!0,disableRestoreFocus:!0,onClose:n,sx:{"& .MuiDialog-paper":{width:"30%",maxHeight:400}},maxWidth:"sm",children:[(0,o.jsxs)(A.A,{id:"alert-dialog-title",sx:{textAlign:"center",alignItems:"center",display:"flex"},children:[(0,o.jsx)(v.A,{sx:{color:"red",marginRight:"0.5rem"}}),C("HWS_PLUGIN_AUTHORIZATION_ACCESS_MANAGER_DELETE")]}),(0,o.jsx)(u.A,{dividers:!0,children:(0,o.jsx)(_.A,{id:"alert-dialog-description",sx:{color:"red"},children:C("HWS_PLUGIN_AUTHORIZATION_ACCESS_MANAGER_DELETE_POLICY_DIALOG")})}),(0,o.jsxs)(S.A,{children:[(0,o.jsx)(I.A,{onClick:n,disabled:t,color:"primary",children:C("HWS_PLUGIN_AUTHORIZATION_ACCESS_MANAGER_NO")}),(0,o.jsxs)(I.A,{onClick:d,disabled:t,variant:"contained",color:"error",children:[C("HWS_PLUGIN_AUTHORIZATION_ACCESS_MANAGER_YES"),t&&(0,o.jsx)(N.A,{style:{marginLeft:"3px"},size:"2rem"})]})]})]})}var R=n(6701);let T=e=>{var i,n,o,l;return null!==(l=null===(o=window)||void 0===o?void 0:null===(n=o.HWS)||void 0===n?void 0:null===(i=n.I18n)||void 0===i?void 0:i.t(e))&&void 0!==l?l:e};var f=function(){var e;let{policyComponents:i,policies:n}=(0,E.A)(),[c,A]=l.useState([]),[u,_]=l.useState(!1),[S,I]=l.useState(null),N=e=>{I(e),_(!0)},v=(0,l.useMemo)(()=>[{accessorKey:"Name",header:T("HWS_PLUGIN_AUTHORIZATION_ACCESS_MANAGER_NAME"),Cell:e=>{let{row:i}=e;return(0,o.jsx)(d.A,{component:r.Link,to:"/plugin/access-manager/policies?action=edit&id=".concat(i.original.Id),className:"underline",color:"secondary",role:"button",children:i.original.Name})}},{accessorKey:"Description",header:T("HWS_PLUGIN_AUTHORIZATION_ACCESS_MANAGER_DESCRIPTION"),accessorFn:e=>e.Description},{accessorKey:"Subject",header:T("HWS_PLUGIN_AUTHORIZATION_ACCESS_MANAGER_SUBJECT"),accessorFn:e=>e.Subject},{accessorKey:"Action",header:T("HWS_PLUGIN_AUTHORIZATION_ACCESS_MANAGER_ACTION"),accessorFn:e=>e.Action},{accessorKey:"Resource",header:T("HWS_PLUGIN_AUTHORIZATION_ACCESS_MANAGER_RESOURCE"),accessorFn:e=>e.Resource},{accessorKey:"Effect",header:T("HWS_PLUGIN_AUTHORIZATION_ACCESS_MANAGER_EFFECT"),accessorFn:e=>e.Effect}],[]);return l.useEffect(()=>{var e;(null==n?void 0:null===(e=n.data)||void 0===e?void 0:e.length)>0?A(n.data.map(e=>{var n,o,l,a;return{Id:e.Id,Name:e.Name,Description:e.Description,Subject:"*"!=e.Subject&&(null==i?void 0:null===(n=i.data)||void 0===n?void 0:n.some(i=>i.Id==e.Subject))?null===(o=i.data.find(i=>i.Id==e.Subject))||void 0===o?void 0:o.Name:e.Subject,Action:"*"!==e.Action&&(null==i?void 0:null===(l=i.data)||void 0===l?void 0:l.some(i=>i.Id==e.Action))?null===(a=i.data.find(i=>i.Id==e.Action))||void 0===a?void 0:a.Name:e.Action,Resource:e.Resource.split(",").map(e=>{var n;let o=null==i?void 0:null===(n=i.data)||void 0===n?void 0:n.find(i=>i.Id==e);return o?o.Name:e}).join(","),Effect:e.Effect}})):A([])},[i,n]),(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(a.A,{className:"flex flex-col flex-auto shadow-3 rounded-t-16 overflow-hidden rounded-b-0 w-full h-full",elevation:0,children:(0,o.jsx)(R.qZ,{name:"dataTable",column:{Name:"dataTable",Datatype:"DataTable"},data:c,columns:v,enableSelectAll:!1,enableRowSelection:!1,enableRowActions:null==n?void 0:null===(e=n.permissions)||void 0===e?void 0:e.includes("Delete"),renderRowActionMenuItems:e=>{let{closeMenu:i,row:n,table:l}=e;return[(0,o.jsxs)(s.A,{onClick:()=>{N(n.original.Id)},children:[(0,o.jsx)(t.A,{children:(0,o.jsx)(R.ri,{children:"heroicons-outline:trash"})}),T("HWS_PLUGIN_AUTHORIZATION_ACCESS_MANAGER_DELETE")]},0)]}})}),u&&(0,o.jsx)(m,{open:u,id:S,onClose:()=>{I(null),_(!1)}})]})}}}]);