@strapi/admin 4.12.1 → 4.12.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/admin/src/content-manager/pages/EditSettingsView/index.js +1 -1
  2. package/admin/src/content-manager/pages/ListView/components/BulkActionButtons/SelectedEntriesModal/index.js +7 -2
  3. package/admin/src/content-manager/pages/ListView/index.js +7 -1
  4. package/admin/src/hooks/index.js +0 -3
  5. package/admin/src/hooks/useAdminRolePermissions/__mocks__/index.js +5 -0
  6. package/admin/src/hooks/useAdminRolePermissions/index.js +34 -0
  7. package/admin/src/hooks/useAdminRoles/__mocks__/index.js +5 -0
  8. package/admin/src/hooks/useAdminRoles/index.js +40 -0
  9. package/admin/src/pages/InstalledPluginsPage/Plugins.js +2 -2
  10. package/admin/src/pages/InstalledPluginsPage/hooks/usePlugins/index.js +29 -0
  11. package/admin/src/pages/MarketplacePage/hooks/useFetchMarketplacePlugins/index.js +44 -0
  12. package/admin/src/pages/MarketplacePage/hooks/useFetchMarketplaceProviders/index.js +44 -0
  13. package/admin/src/pages/MarketplacePage/utils/useMarketplaceData.js +2 -2
  14. package/admin/src/pages/SettingsPage/pages/Roles/CreatePage/index.js +24 -9
  15. package/admin/src/pages/SettingsPage/pages/Roles/EditPage/components/RoleForm/index.js +1 -0
  16. package/admin/src/pages/SettingsPage/pages/Roles/EditPage/index.js +34 -20
  17. package/admin/src/pages/SettingsPage/pages/Roles/ListPage/index.js +31 -84
  18. package/admin/src/pages/SettingsPage/pages/Roles/hooks/useAdminRolePermissionLayout/index.js +23 -0
  19. package/admin/src/translations/en.json +1 -1
  20. package/build/1049.f76cb14b.chunk.js +1 -0
  21. package/build/{2225.0e4f8c77.chunk.js → 2225.c6244756.chunk.js} +1 -1
  22. package/build/{Admin-authenticatedApp.8dfbc48d.chunk.js → Admin-authenticatedApp.3c585a0d.chunk.js} +2 -2
  23. package/build/{Admin_marketplace.f0b87fce.chunk.js → Admin_marketplace.dde9c148.chunk.js} +6 -6
  24. package/build/Admin_pluginsPage.bbe79434.chunk.js +6 -0
  25. package/build/{Admin_profilePage.ca82c67b.chunk.js → Admin_profilePage.192edc52.chunk.js} +1 -1
  26. package/build/{Admin_settingsPage.50c867bf.chunk.js → Admin_settingsPage.97cb9d41.chunk.js} +1 -1
  27. package/build/admin-app.91898385.chunk.js +36 -0
  28. package/build/admin-edit-roles-page.6d567273.chunk.js +267 -0
  29. package/build/admin-roles-list.23ddff26.chunk.js +22 -0
  30. package/build/content-manager.2af15f57.chunk.js +1099 -0
  31. package/build/content-type-builder.40534de5.chunk.js +170 -0
  32. package/build/{en-json.01456e61.chunk.js → en-json.08c05fcf.chunk.js} +1 -1
  33. package/build/index.html +1 -1
  34. package/build/{main.1f8cc299.js → main.f13fc96c.js} +204 -204
  35. package/build/{runtime~main.80a43c16.js → runtime~main.2902859a.js} +2 -2
  36. package/build/sso-settings-page.12b6d8ae.chunk.js +1 -0
  37. package/build/transfer-tokens-list-page.22147d2c.chunk.js +16 -0
  38. package/build/{upload.77d8a64c.chunk.js → upload.37488080.chunk.js} +3 -3
  39. package/ee/admin/pages/SettingsPage/pages/SingleSignOn/index.js +15 -24
  40. package/index.js +2 -0
  41. package/package.json +8 -8
  42. package/scripts/build.js +1 -0
  43. package/server/controllers/role.js +9 -1
  44. package/server/services/role.js +3 -2
  45. package/webpack.config.js +2 -1
  46. package/admin/src/hooks/marketplace/useFetchMarketplacePlugins/index.js +0 -44
  47. package/admin/src/hooks/marketplace/useFetchMarketplaceProviders/index.js +0 -44
  48. package/admin/src/hooks/useFetchEnabledPlugins/index.js +0 -24
  49. package/admin/src/hooks/useFetchEnabledPlugins/utils/api.js +0 -10
  50. package/admin/src/hooks/useFetchPermissionsLayout/index.js +0 -42
  51. package/admin/src/hooks/useFetchPermissionsLayout/reducer.js +0 -35
  52. package/admin/src/hooks/useFetchRole/index.js +0 -68
  53. package/admin/src/hooks/useFetchRole/reducer.js +0 -33
  54. package/admin/src/hooks/useRolesList/index.js +0 -58
  55. package/admin/src/hooks/useRolesList/init.js +0 -5
  56. package/admin/src/hooks/useRolesList/reducer.js +0 -31
  57. package/build/1049.c3d082e9.chunk.js +0 -1
  58. package/build/Admin_pluginsPage.8728ff6e.chunk.js +0 -6
  59. package/build/admin-app.041dcd81.chunk.js +0 -36
  60. package/build/admin-edit-roles-page.a49b9f4f.chunk.js +0 -267
  61. package/build/admin-roles-list.0c129e98.chunk.js +0 -23
  62. package/build/content-manager.098eb004.chunk.js +0 -1099
  63. package/build/content-type-builder.64f4d6ac.chunk.js +0 -170
  64. package/build/sso-settings-page.81152e62.chunk.js +0 -1
  65. package/build/transfer-tokens-list-page.692eee77.chunk.js +0 -16
  66. /package/admin/src/{hooks/marketplace → pages/MarketplacePage}/constants.js +0 -0
@@ -1,267 +0,0 @@
1
- (self.webpackChunk_strapi_admin=self.webpackChunk_strapi_admin||[]).push([[2544],{15570:function(X,B,r){"use strict";r.r(B),r.d(B,{CreatePage:function(){return Ee},default:function(){return $e}});var e=r(32735),b=r(27649),P=r(82055),R=r(87933),Z=r(41415),O=r(17e3),S=r(72850),x=r(49372),D=r(15335),q=r(5803),a=r(10369),H=r(33475),p=r(19565),A=r(29439),F=r(14723),f=r(92802),C=r(33795),w=r.n(C),ue=r(86834),ae=r.n(ue),ie=r(67879),y=r(15062),le=r(53038),Y=r(8471),G=r(2160),_=r(30305),xe=r(1283),me=r(24346),oe=me.Ry().shape({name:me.Z_().required(p.I0.required),description:me.Z_().required(p.I0.required)});const Pe=Y.ZP.div`
2
- border: 1px solid ${({theme:T})=>T.colors.primary200};
3
- background: ${({theme:T})=>T.colors.primary100};
4
- padding: ${({theme:T})=>`${T.spaces[2]} ${T.spaces[4]}`};
5
- color: ${({theme:T})=>T.colors.primary600};
6
- border-radius: ${({theme:T})=>T.borderRadius};
7
- font-size: ${12/16}rem;
8
- font-weight: bold;
9
- `,Ee=()=>{const T=(0,p.lm)(),{lockApp:ne,unlockApp:z}=(0,p.o1)(),{formatMessage:k}=(0,ie.Z)(),[Q,pe]=(0,e.useState)(!1),{replace:de}=(0,le.k6)(),ee=(0,e.useRef)(),{trackUsage:ce}=(0,p.rS)(),Ze=(0,le.$B)("/settings/roles/duplicate/:id"),Ae=w()(Ze,"params.id",null),{isLoading:Be,data:he}=(0,G.U_)(),{permissions:Oe,isLoading:De}=(0,G.Dq)(Ae),{post:Fe,put:je}=(0,p.kY)(),He=re=>{ne(),pe(!0),ce(Ae?"willDuplicateRole":"willCreateNewRole"),Promise.resolve(Fe("/admin/roles",re)).then(async({data:W})=>{const{permissionsToSend:U}=ee.current.getPermissions();return ce(Ae?"didDuplicateRole":"didCreateNewRole"),W.data.id&&!ae()(U)&&await je(`/admin/roles/${W.data.id}/permissions`,{permissions:U}),W}).then(W=>{pe(!1),T({type:"success",message:{id:"Settings.roles.created",defaultMessage:"created"}}),de(`/settings/roles/${W.data.id}`)}).catch(W=>{console.error(W),pe(!1),T({type:"warning",message:{id:"notification.error"}})}).finally(()=>{z()})},Le=`${k({id:"Settings.roles.form.created",defaultMessage:"Created"})} ${(0,F.Z)(new Date,"PPP")}`;return e.createElement(b.o,null,e.createElement(p.SL,{name:"Roles"}),e.createElement(f.J9,{initialValues:{name:"",description:Le},onSubmit:He,validationSchema:oe,validateOnChange:!1},({handleSubmit:re,values:W,errors:U,handleReset:ye,handleChange:Ce})=>e.createElement(p.l0,{noValidate:!0},e.createElement(e.Fragment,null,e.createElement(P.T,{primaryAction:e.createElement(R.k,{gap:2},e.createElement(Z.z,{variant:"secondary",onClick:()=>{ye(),ee.current.resetForm()},size:"L"},k({id:"app.components.Button.reset",defaultMessage:"Reset"})),e.createElement(Z.z,{onClick:re,loading:Q,size:"L"},k({id:"global.save",defaultMessage:"Save"}))),title:k({id:"Settings.roles.create.title",defaultMessage:"Create a role"}),subtitle:k({id:"Settings.roles.create.description",defaultMessage:"Define the rights given to the role"}),navigationAction:e.createElement(p.rU,{startIcon:e.createElement(A.Z,null),to:"/settings/roles"},k({id:"global.back",defaultMessage:"Back"}))}),e.createElement(O.D,null,e.createElement(R.k,{direction:"column",alignItems:"stretch",gap:6},e.createElement(S.x,{background:"neutral0",padding:6,shadow:"filterShadow",hasRadius:!0},e.createElement(R.k,{direction:"column",alignItems:"stretch",gap:4},e.createElement(R.k,{justifyContent:"space-between"},e.createElement(S.x,null,e.createElement(S.x,null,e.createElement(x.Z,{fontWeight:"bold"},k({id:"global.details",defaultMessage:"Details"}))),e.createElement(S.x,null,e.createElement(x.Z,{variant:"pi",textColor:"neutral600"},k({id:"Settings.roles.form.description",defaultMessage:"Name and description of the role"})))),e.createElement(Pe,null,k({id:"Settings.roles.form.button.users-with-role",defaultMessage:"{number, plural, =0 {# users} one {# user} other {# users}} with this role"},{number:0}))),e.createElement(D.r,{gap:4},e.createElement(q.P,{col:6},e.createElement(a.o,{name:"name",error:U.name&&k({id:U.name}),label:k({id:"global.name",defaultMessage:"Name"}),onChange:Ce,value:W.name})),e.createElement(q.P,{col:6},e.createElement(H.g,{label:k({id:"global.description",defaultMessage:"Description"}),id:"description",error:U.description&&k({id:U.description}),onChange:Ce},W.description))))),!Be&&!De?e.createElement(S.x,{shadow:"filterShadow",hasRadius:!0},e.createElement(xe.Z,{isFormDisabled:!1,ref:ee,permissions:Oe,layout:he})):e.createElement(S.x,{background:"neutral0",padding:6,shadow:"filterShadow",hasRadius:!0},e.createElement(p.dO,null))))))))};function $e(){const T=(0,y.v9)(_._);return e.createElement(p.O4,{permissions:T.settings.roles.create},e.createElement(Ee,null))}},1283:function(X,B,r){"use strict";r.d(B,{Z:function(){return es}});var e=r(32735),b=r(91215),P=r(90980),R=r(3653),Z=r(19565),O=r(23973),S=r.n(O),x=r(86834),D=r.n(x),q=r(60216),a=r.n(q),H=r(67879),p=r(72850),A=r(98978),F=r.n(A),f=r(8471),C=r(87933),w=r(82884),ue=r(15974),ae=r(96441),ie=r(33795),y=r.n(ie),le=r(9086),Y=r.n(le),G=r(2160),_=r(41415),xe=r(45112);const me=f.ZP.div`
10
- position: relative;
11
-
12
- ${({hasConditions:t,disabled:n,theme:o})=>t&&`
13
- &:before {
14
- content: '';
15
- position: absolute;
16
- top: -3px;
17
- left: -10px;
18
- width: 6px;
19
- height: 6px;
20
- border-radius: ${20/16}rem;;
21
- background: ${n?o.colors.neutral100:o.colors.primary600};
22
- }
23
- `}
24
- `,Re=({onClick:t,className:n,hasConditions:o,variant:s})=>{const{formatMessage:i}=(0,H.Z)();return e.createElement(me,{hasConditions:o,className:n},e.createElement(_.z,{variant:s,startIcon:e.createElement(xe.Z,null),onClick:t},i({id:"global.settings",defaultMessage:"Settings"})))};Re.defaultProps={className:null,hasConditions:!1,variant:"tertiary"},Re.propTypes={onClick:a().func.isRequired,className:a().string,hasConditions:a().bool,variant:a().string};var oe=(0,f.ZP)(Re)``,Pe=r(85025),Ee=r(55225),$e=r(31600),T=r(49372),ne=r(11406),z=r(26858),k=r(51654),Q=r(97889),pe=r(81346),de=r.n(pe),ee=r(23940),ce=r.n(ee),Ze=r(27799);const Ae=t=>Object.values(t).map(n=>Object.entries(n).filter(([,o])=>o).map(([o])=>o)).flat(),Be=t=>t.reduce((n,[o,s])=>(n.push({label:ce()(o),children:s.map(i=>({label:i.displayName,value:i.id}))}),n),[]),he=(t,n)=>t.map(([,o])=>o).flat().reduce((o,s)=>({[s.id]:n.includes(s.id),...o}),{}),Oe=({arrayOfOptionsGroupedByCategory:t,isFormDisabled:n,isGrey:o,label:s,name:i,onChange:l,value:d})=>{const{formatMessage:c}=(0,H.Z)(),m=u=>{l(i,he(t,u))};return e.createElement(C.k,{as:"li",background:o?"neutral100":"neutral0",paddingBottom:3,paddingTop:3},e.createElement(C.k,{paddingLeft:6,style:{width:180}},e.createElement(T.Z,{variant:"sigma",textColor:"neutral600"},c({id:"Settings.permissions.conditions.can",defaultMessage:"Can"}),"\xA0"),e.createElement(T.Z,{variant:"sigma",title:s,textColor:"primary600",ellipsis:!0},c({id:`Settings.roles.form.permissions.${s.toLowerCase()}`,defaultMessage:s})),e.createElement(T.Z,{variant:"sigma",textColor:"neutral600"},"\xA0",c({id:"Settings.permissions.conditions.when",defaultMessage:"When"}))),e.createElement(p.x,{style:{maxWidth:430,width:"100%"}},e.createElement(Ze.Q,{id:i,customizeContent:u=>`${u.length} currently selected`,onChange:m,value:Ae(d),options:Be(t),disabled:n})))};Oe.propTypes={arrayOfOptionsGroupedByCategory:a().array.isRequired,isFormDisabled:a().bool.isRequired,isGrey:a().bool.isRequired,label:a().string.isRequired,name:a().string.isRequired,value:a().object.isRequired,onChange:a().func.isRequired};var De=Oe;const Fe=(t,n)=>t.reduce((o,s)=>(o[s.id]=y()(n,s.id,!1),o),{}),je=(t,n)=>t.reduce((o,s)=>{const[i,l]=s,d=Fe(l,n);return o[i]=d,o},{});var Le=(t,n,o)=>t.reduce((s,i)=>{const l=y()(n,[...i.pathToConditionsObject,"conditions"],{}),d=je(o,l);return s[i.pathToConditionsObject.join("..")]=d,s},{});const re=({actions:t,headerBreadCrumbs:n,isFormDisabled:o,onClosed:s,onToggle:i})=>{const{formatMessage:l}=(0,H.Z)(),{availableConditions:d,modifiedData:c,onChangeConditions:m}=(0,G.$_)(),u=(0,e.useMemo)(()=>Object.entries(de()(d,"category")),[d]),g=t.filter(({isDisplayed:h,hasSomeActionsSelected:L,hasAllActionsSelected:$})=>h&&(L||$)),v=(0,e.useMemo)(()=>Le(g,c,u),[g,c,u]),[M,N]=(0,e.useState)(v),j=(h,L)=>{N((0,Q.ZP)($=>{$[h]||($[h]={}),$[h].default||($[h].default={}),$[h].default=L}))},E=()=>{const h=Object.entries(M).reduce((L,$)=>{const[I,te]=$,K=Object.values(te).reduce((J,V)=>({...J,...V}),{});return L[I]=K,L},{});m(h),i()};return e.createElement(Pe.P,{labelledBy:"condition-modal-breadcrumbs",onClose:s},e.createElement(Ee.x,null,e.createElement(z.O,{id:"condition-modal-breadcrumbs",label:n.join(", ")},n.map((h,L,$)=>e.createElement(k.$,{isCurrent:L===$.length-1,key:h},ce()(l({id:h,defaultMessage:h})))))),e.createElement($e.f,null,g.length===0&&e.createElement(T.Z,null,l({id:"Settings.permissions.conditions.no-actions",defaultMessage:"You first need to select actions (create, read, update, ...) before defining conditions on them."})),e.createElement("ul",null,g.map(({actionId:h,label:L,pathToConditionsObject:$},I)=>{const te=$.join("..");return e.createElement(De,{key:h,arrayOfOptionsGroupedByCategory:u,label:L,isFormDisabled:o,isGrey:I%2===0,name:te,onChange:j,value:y()(M,te,{})})}))),e.createElement(ne.m,{startActions:e.createElement(_.z,{variant:"tertiary",onClick:i},l({id:"app.components.Button.cancel",defaultMessage:"Cancel"})),endActions:e.createElement(_.z,{onClick:E},l({id:"Settings.permissions.conditions.apply",defaultMessage:"Apply"}))}))};re.propTypes={actions:a().arrayOf(a().shape({actionId:a().string.isRequired,checkboxName:a().string,hasSomeActionsSelected:a().bool.isRequired,hasAllActionsSelected:a().bool,isDisplayed:a().bool.isRequired,label:a().string})).isRequired,headerBreadCrumbs:a().arrayOf(a().string).isRequired,isFormDisabled:a().bool.isRequired,onClosed:a().func.isRequired,onToggle:a().func.isRequired};var W=re;const U=`${120/16}rem`,ye=`${200/16}rem`,Ce=`${53/16}rem`;var Ue=f.ZP.div`
25
- width: ${U};
26
- `,ot=(0,f.ZP)(C.k)`
27
- padding-right: ${({theme:t})=>t.spaces[2]};
28
- overflow: hidden;
29
- flex: 1;
30
- ${({isCollapsable:t})=>t&&"cursor: pointer;"}
31
- `;const Ke=({children:t,isCollapsable:n,isActive:o,isFormDisabled:s,label:i,onChange:l,onClick:d,checkboxName:c,someChecked:m,value:u})=>{const{formatMessage:g}=(0,H.Z)();return e.createElement(C.k,{alignItems:"center",paddingLeft:6,style:{width:ye,flexShrink:0}},e.createElement(p.x,{paddingRight:2},e.createElement(w.C,{name:c,"aria-label":g({id:"Settings.permissions.select-all-by-permission",defaultMessage:"Select all {label} permissions"},{label:i}),disabled:s,onValueChange:v=>l({target:{name:c,value:v}}),indeterminate:m,value:u})),e.createElement(ot,{title:i,alignItems:"center",isCollapsable:n,...n&&{onClick:d,"aria-expanded":o,onKeyDown:({key:v})=>(v==="Enter"||v===" ")&&d(),tabIndex:0,role:"button"}},e.createElement(T.Z,{fontWeight:o?"bold":"",textColor:o?"primary600":"neutral800",ellipsis:!0},ce()(i)),t))};Ke.defaultProps={children:null,checkboxName:"",onChange(){},value:!1,someChecked:!1,isCollapsable:!1},Ke.propTypes={checkboxName:a().string,children:a().node,label:a().string.isRequired,isCollapsable:a().bool,isFormDisabled:a().bool.isRequired,onChange:a().func,onClick:a().func.isRequired,someChecked:a().bool,value:a().bool,isActive:a().bool.isRequired};var rt=(0,e.memo)(Ke),Ft=r(72091),Nt=r.n(Ft),Wt=r(85973),be=r.n(Wt);const at=t=>be()(t)?Nt()(Object.values(t).map(n=>be()(n)?at(n):n)):[];var ke=at,ze=t=>t?Object.keys(t).reduce((n,o)=>(o!=="conditions"&&(n[o]=t[o]),n),{}):null,Te=t=>{const n=ze(t),o=ke(n);if(!o.length)return{hasAllActionsSelected:!1,hasSomeActionsSelected:!1};const s=o.every(l=>l),i=o.some(l=>l)&&!s;return{hasAllActionsSelected:s,hasSomeActionsSelected:i}},Vt=r(16899),Ne=(0,f.ZP)(Vt.Z)`
32
- display: none;
33
- width: ${10/16}rem;
34
- transform: rotate(${({$isActive:t})=>t?"180":"0"}deg);
35
- margin-left: ${({theme:t})=>t.spaces[2]};
36
- `,We=t=>`
37
- ${T.Z} {
38
- color: ${t.colors.primary600};
39
- font-weight: ${t.fontWeights.bold}
40
- }
41
- ${Ne} {
42
- display: block;
43
- path {
44
- fill: ${t.colors.primary600}
45
- };
46
- }
47
- `,Ht=(t,n,o)=>t.map(({actionId:s,isDisplayed:i,applyToProperties:l,label:d})=>{if(!i)return{actionId:s,hasSomeActionsSelected:!1,isDisplayed:i};const c=[...o.split(".."),s],m=D()(l)?[...c,"properties","enabled"]:c,u=m.join(".."),g=y()(n,[...c,"conditions"],null),v=ke(g).some(E=>E);if(D()(l)){const E=y()(n,m,!1);return{actionId:s,checkboxName:u,hasAllActionsSelected:E,hasConditions:v,hasSomeActionsSelected:E,isDisplayed:i,isParentCheckbox:!1,label:d,pathToConditionsObject:c}}const M=y()(n,m,null),{hasAllActionsSelected:N,hasSomeActionsSelected:j}=Te(M);return{actionId:s,checkboxName:u,hasAllActionsSelected:N,hasConditions:v,hasSomeActionsSelected:j,isDisplayed:i,isParentCheckbox:!0,label:d,pathToConditionsObject:c}});const Xe=(t,n)=>`
48
- ${it} {
49
- background-color: ${t.colors.primary100};
50
- color: ${t.colors.primary600};
51
- border-radius: ${n?"2px 2px 0 0":"2px"};
52
- }
53
- ${dt} {
54
- display: flex;
55
- }
56
- ${oe} {
57
- display: block;
58
- }
59
- &:hover {
60
- ${We(t)}
61
- }
62
-
63
- &:focus-within {
64
- ${({theme:o,isActive:s})=>Xe(o,s)}
65
- }
66
-
67
- `,it=f.ZP.div`
68
- flex: 1;
69
- display: flex;
70
- align-items: center;
71
- height: ${Ce};
72
- background-color: ${({isGrey:t,theme:n})=>t?n.colors.neutral100:n.colors.neutral0};
73
- border: 1px solid transparent;
74
- `,Gt=f.ZP.div`
75
- display: inline-flex;
76
- min-width: 100%;
77
-
78
- ${oe} {
79
- display: none;
80
- }
81
- ${({isActive:t,theme:n})=>t&&Xe(n,t)}
82
- &:hover {
83
- ${({theme:t,isActive:n})=>Xe(t,n)}
84
- }
85
- `,lt=(0,f.ZP)(C.k)`
86
- width: ${U};
87
- position: relative;
88
- `,dt=(0,f.ZP)(p.x)`
89
- display: none;
90
- svg {
91
- width: 11px;
92
- }
93
- * {
94
- fill: ${({theme:t})=>t.colors.primary600};
95
- }
96
- `,ct=f.ZP.span`
97
- position: absolute;
98
- top: -6px;
99
- left: 37px;
100
- width: 6px;
101
- height: 6px;
102
- border-radius: 20px;
103
- background: ${({theme:t})=>t.colors.primary600};
104
- `,Ut=(0,f.ZP)(p.x)`
105
- position: absolute;
106
- right: 9px;
107
- transform: translateY(10px);
108
- `,ut=({availableActions:t,isActive:n,isGrey:o,isFormDisabled:s,label:i,onClickToggle:l,pathToData:d})=>{const[c,m]=(0,e.useState)(!1),{formatMessage:u}=(0,H.Z)(),{modifiedData:g,onChangeParentCheckbox:v,onChangeSimpleCheckbox:M}=(0,G.$_)(),N=()=>{m(K=>!K)},j=()=>{m(!1)},E=y()(g,d.split(".."),{}),h=(0,e.useMemo)(()=>Object.keys(E).reduce((K,J)=>(K[J]=Y()(E[J],"conditions"),K),{}),[E]),{hasAllActionsSelected:L,hasSomeActionsSelected:$}=Te(h),I=(0,e.useMemo)(()=>Ht(t,g,d),[t,g,d]),te=I.some(({hasConditions:K})=>K);return e.createElement(Gt,{isActive:n},e.createElement(it,{isGrey:o},e.createElement(rt,{isCollapsable:!0,isFormDisabled:s,label:i,checkboxName:d,onChange:v,onClick:l,someChecked:$,value:L,isActive:n},e.createElement(dt,{paddingLeft:2},n?e.createElement(ue.Z,null):e.createElement(ae.Z,null))),e.createElement(C.k,{style:{flex:1}},I.map(({actionId:K,hasConditions:J,hasAllActionsSelected:V,hasSomeActionsSelected:fe,isDisplayed:Ie,isParentCheckbox:se,checkboxName:ve,label:Ve})=>Ie?se?e.createElement(lt,{key:K,justifyContent:"center",alignItems:"center"},J&&e.createElement(ct,null),e.createElement(w.C,{disabled:s,name:ve,"aria-label":u({id:"Settings.permissions.select-by-permission",defaultMessage:"Select {label} permission"},{label:`${Ve} ${i}`}),onValueChange:Se=>{v({target:{name:ve,value:Se}})},indeterminate:fe,value:V})):e.createElement(lt,{key:K,justifyContent:"center",alignItems:"center"},J&&e.createElement(ct,null),e.createElement(w.C,{disabled:s,indeterminate:J,name:ve,onValueChange:Se=>{M({target:{name:ve,value:Se}})},value:V})):e.createElement(Ue,{key:K}))),c&&e.createElement(W,{headerBreadCrumbs:[i,"Settings.permissions.conditions.conditions"],actions:I,isFormDisabled:s,onClosed:j,onToggle:N})),e.createElement(Ut,null,e.createElement(oe,{onClick:N,hasConditions:te})))};ut.propTypes={availableActions:a().array.isRequired,isActive:a().bool.isRequired,isGrey:a().bool.isRequired,isFormDisabled:a().bool.isRequired,label:a().string.isRequired,onClickToggle:a().func.isRequired,pathToData:a().string.isRequired};var Kt=ut;const zt=f.ZP.span`
109
- color: ${({theme:t})=>t.colors.danger700};
110
- padding-left: ${({theme:t})=>t.spaces[1]}px;
111
- `;var mt=()=>e.createElement(zt,null,"*"),Xt=(t,n)=>t.map(o=>{const s=Array.isArray(o.subjects)&&o.subjects.indexOf(n)!==-1;return{...o,isDisplayed:s}});const wt=(0,f.ZP)(p.x)`
112
- transform: translate(-4px, -12px);
113
-
114
- &:before {
115
- content: '';
116
- width: ${4/16}rem;
117
- height: ${12/16}rem;
118
- background: ${({theme:t})=>t.colors.primary200};
119
- display: block;
120
- }
121
- `,Yt=f.ZP.svg`
122
- position: relative;
123
- flex-shrink: 0;
124
- transform: translate(-0.5px, -1px);
125
-
126
- * {
127
- fill: ${({theme:t,color:n})=>t.colors[n]};
128
- }
129
- `,we=t=>e.createElement(wt,null,e.createElement(Yt,{width:"20",height:"23",viewBox:"0 0 20 23",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},e.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7.02477 14.7513C8.65865 17.0594 11.6046 18.6059 17.5596 18.8856C18.6836 18.9384 19.5976 19.8435 19.5976 20.9688V20.9688C19.5976 22.0941 18.6841 23.0125 17.5599 22.9643C10.9409 22.6805 6.454 20.9387 3.75496 17.1258C0.937988 13.1464 0.486328 7.39309 0.486328 0.593262H4.50974C4.50974 7.54693 5.06394 11.9813 7.02477 14.7513Z",fill:"#D9D8FF"})));we.defaultProps={fill:"primary200"},we.propTypes={fill:a().string};var Jt=(0,e.memo)(we);const pt=(0,f.ZP)(C.k)`
130
- width: ${U};
131
- position: relative;
132
- `,Qt=(0,f.ZP)(C.k)`
133
- height: ${Ce};
134
- `,qt=(0,f.ZP)(p.x)`
135
- padding-left: ${31/16}rem;
136
- `,_t=(0,f.ZP)(p.x)`
137
- border-left: ${({isVisible:t,theme:n})=>t?`4px solid ${n.colors.primary200}`:"4px solid transparent"};
138
- `,en=(0,f.ZP)(C.k)`
139
- padding-left: ${({theme:t})=>t.spaces[4]};
140
- width: ${({level:t})=>145-t*36}px;
141
-
142
- ${({isCollapsable:t,theme:n})=>t&&`
143
- ${Ne} {
144
- display: block;
145
- color: ${n.colors.neutral100};
146
- }
147
- &:hover {
148
- ${We(n)}
149
- }
150
- `}
151
- ${({isActive:t,theme:n})=>t&&We(n)};
152
- `,tn=f.ZP.div`
153
- padding-top: ${({theme:t})=>t.spaces[2]};
154
- margin-top: ${({theme:t})=>t.spaces[2]};
155
- width: ${4/16}rem;
156
- background-color: ${({theme:t})=>t.colors.primary200};
157
- border-top-left-radius: 2px;
158
- border-top-right-radius: 2px;
159
- `,Ye=({childrenForm:t,isFormDisabled:n,recursiveLevel:o,pathToDataFromActionRow:s,propertyActions:i,parentName:l,propertyName:d})=>{const{formatMessage:c}=(0,H.Z)(),{modifiedData:m,onChangeParentCheckbox:u,onChangeSimpleCheckbox:g}=(0,G.$_)(),[v,M]=(0,e.useState)(null),N=E=>{M(h=>h===E?null:E)},j=(0,e.useMemo)(()=>v?t.find(({value:E})=>E===v):null,[v,t]);return e.createElement(qt,null,e.createElement(tn,null),t.map(({label:E,value:h,required:L,children:$},I)=>{const te=I+1<t.length,K=Array.isArray($),J=v===h;return e.createElement(_t,{key:h,isVisible:te},e.createElement(Qt,null,e.createElement(Jt,{color:"primary200"}),e.createElement(C.k,{style:{flex:1}},e.createElement(en,{level:o,isActive:J,isCollapsable:K},e.createElement(ot,{alignItems:"center",isCollapsable:K,...K&&{onClick:()=>N(h),"aria-expanded":J,onKeyDown:({key:V})=>(V==="Enter"||V===" ")&&N(h),tabIndex:0,role:"button"},title:E},e.createElement(T.Z,{ellipsis:!0},ce()(E)),L&&e.createElement(mt,null),e.createElement(Ne,{$isActive:J}))),e.createElement(C.k,{style:{flex:1}},i.map(({actionId:V,label:fe,isActionRelatedToCurrentProperty:Ie})=>{if(!Ie)return e.createElement(Ue,{key:V});const se=[...s.split(".."),V,"properties",d,...l.split(".."),h],ve=y()(m,se,!1);if(!$)return e.createElement(pt,{key:fe,justifyContent:"center",alignItems:"center"},e.createElement(w.C,{disabled:n,name:se.join(".."),"aria-label":c({id:"Settings.permissions.select-by-permission",defaultMessage:"Select {label} permission"},{label:`${l} ${E} ${fe}`}),onValueChange:Me=>{g({target:{name:se.join(".."),value:Me}})},value:ve}));const{hasAllActionsSelected:Ve,hasSomeActionsSelected:Se}=Te(ve);return e.createElement(pt,{key:fe,justifyContent:"center",alignItems:"center"},e.createElement(w.C,{key:fe,disabled:n,name:se.join(".."),"aria-label":c({id:"Settings.permissions.select-by-permission",defaultMessage:"Select {label} permission"},{label:`${l} ${E} ${fe}`}),onValueChange:Me=>{u({target:{name:se.join(".."),value:Me}})},value:Ve,indeterminate:Se}))})))),j&&J&&e.createElement(p.x,{paddingBottom:2},e.createElement(Ye,{isFormDisabled:n,parentName:`${l}..${h}`,pathToDataFromActionRow:s,propertyActions:i,propertyName:d,recursiveLevel:o+1,childrenForm:j.children})))}))};Ye.propTypes={childrenForm:a().array.isRequired,isFormDisabled:a().bool.isRequired,parentName:a().string.isRequired,pathToDataFromActionRow:a().string.isRequired,propertyActions:a().array.isRequired,propertyName:a().string.isRequired,recursiveLevel:a().number.isRequired};var nn=(0,e.memo)(Ye);const sn=t=>t.reduce((o,s)=>(s.isActionRelatedToCurrentProperty&&o.push(s.actionId),o),[]);var on=(t,n,o,s,i)=>{const d=sn(t).reduce((c,m)=>{const u=[...o.split(".."),m,"properties",s,i],g=y()(n,u,!1);return c[m]=g,c},{});return Te(d)};const gt=(0,f.ZP)(C.k)`
160
- width: ${U};
161
- position: relative;
162
- `,rn=(0,f.ZP)(C.k)`
163
- height: ${Ce};
164
- flex: 1;
165
-
166
- ${({isCollapsable:t,theme:n})=>t&&`
167
- ${Ne} {
168
- display: block;
169
- color: ${n.colors.neutral100};
170
- }
171
- &:hover {
172
- ${We(n)}
173
- }
174
- `}
175
- ${({isActive:t,theme:n})=>t&&We(n)};
176
- `,Je=({childrenForm:t,label:n,isFormDisabled:o,name:s,required:i,pathToData:l,propertyActions:d,propertyName:c,isOdd:m})=>{const{formatMessage:u}=(0,H.Z)(),[g,v]=(0,e.useState)(null),{modifiedData:M,onChangeCollectionTypeLeftActionRowCheckbox:N,onChangeParentCheckbox:j,onChangeSimpleCheckbox:E}=(0,G.$_)(),h=g===s,L=(0,e.useMemo)(()=>Array.isArray(t)?t:[],[t]),$=L.length>0,I=(0,e.useCallback)(()=>{$&&v(V=>V===s?null:s)},[$,s]),te=({target:{value:V}})=>{N(l,c,s,V)},{hasAllActionsSelected:K,hasSomeActionsSelected:J}=(0,e.useMemo)(()=>on(d,M,l,c,s),[d,M,l,c,s]);return e.createElement(e.Fragment,null,e.createElement(rn,{alignItems:"center",isCollapsable:$,isActive:h,background:m?"neutral100":"neutral0"},e.createElement(C.k,null,e.createElement(rt,{onChange:te,onClick:I,isCollapsable:$,isFormDisabled:o,label:n,someChecked:J,value:K,isActive:h},i&&e.createElement(mt,null),e.createElement(Ne,{$isActive:h})),e.createElement(C.k,null,d.map(({label:V,isActionRelatedToCurrentProperty:fe,actionId:Ie})=>{if(!fe)return e.createElement(Ue,{key:V});const se=[...l.split(".."),Ie,"properties",c,s];if(!$){const Me=y()(M,se,!1);return e.createElement(gt,{key:Ie,justifyContent:"center",alignItems:"center"},e.createElement(w.C,{disabled:o,name:se.join(".."),"aria-label":u({id:"Settings.permissions.select-by-permission",defaultMessage:"Select {label} permission"},{label:`${s} ${V}`}),onValueChange:ts=>{E({target:{name:se.join(".."),value:ts}})},value:Me}))}const ve=y()(M,se,{}),{hasAllActionsSelected:Ve,hasSomeActionsSelected:Se}=Te(ve);return e.createElement(gt,{key:V,justifyContent:"center",alignItems:"center"},e.createElement(w.C,{disabled:o,name:se.join(".."),onValueChange:Me=>{j({target:{name:se.join(".."),value:Me}})},"aria-label":u({id:"Settings.permissions.select-by-permission",defaultMessage:"Select {label} permission"},{label:`${s} ${V}`}),value:Ve,indeterminate:Se}))})))),h&&e.createElement(nn,{childrenForm:L,isFormDisabled:o,parentName:s,pathToDataFromActionRow:l,propertyName:c,propertyActions:d,recursiveLevel:0}))};Je.defaultProps={childrenForm:[],required:!1},Je.propTypes={childrenForm:a().array,label:a().string.isRequired,isFormDisabled:a().bool.isRequired,name:a().string.isRequired,pathToData:a().string.isRequired,propertyActions:a().array.isRequired,propertyName:a().string.isRequired,required:a().bool,isOdd:a().bool.isRequired};var an=(0,e.memo)(Je);const ft=(0,f.ZP)(C.k)`
177
- width: ${U};
178
- flex-shrink: 0;
179
- `,ln=(0,f.ZP)(C.k)`
180
- width: ${ye};
181
- height: ${Ce};
182
- flex-shrink: 0;
183
- `,ht=({headers:t,label:n})=>{const{formatMessage:o}=(0,H.Z)(),s=o({id:"Settings.roles.form.permission.property-label",defaultMessage:"{label} permissions"},{label:n});return e.createElement(C.k,null,e.createElement(ln,{alignItems:"center",paddingLeft:6},e.createElement(T.Z,{variant:"sigma",textColor:"neutral500"},s)),t.map(i=>i.isActionRelatedToCurrentProperty?e.createElement(ft,{justifyContent:"center",key:i.label},e.createElement(T.Z,{variant:"sigma",textColor:"neutral500"},o({id:`Settings.roles.form.permissions.${i.label.toLowerCase()}`,defaultMessage:i.label}))):e.createElement(ft,{key:i.label})))};ht.propTypes={headers:a().arrayOf(a().shape({label:a().string.isRequired,isActionRelatedToCurrentProperty:a().bool.isRequired})).isRequired,label:a().string.isRequired};var dn=ht,cn=(t,n)=>t.map(o=>{const s=Array.isArray(o.applyToProperties)&&o.applyToProperties.indexOf(n)!==-1&&o.isDisplayed;return{label:o.label,actionId:o.actionId,isActionRelatedToCurrentProperty:s}});const un=f.ZP.div`
184
- display: inline-flex;
185
- flex-direction: column;
186
- min-width: 0;
187
- `,yt=({availableActions:t,childrenForm:n,isFormDisabled:o,label:s,pathToData:i,propertyName:l})=>{const d=(0,e.useMemo)(()=>cn(t,l),[t,l]);return e.createElement(un,null,e.createElement(dn,{label:s,headers:d}),e.createElement(p.x,null,n.map(({children:c,label:m,value:u,required:g},v)=>e.createElement(an,{childrenForm:c,key:u,label:m,isFormDisabled:o,name:u,required:g,propertyActions:d,pathToData:i,propertyName:l,isOdd:v%2===0}))))};yt.propTypes={childrenForm:a().array.isRequired,availableActions:a().array.isRequired,isFormDisabled:a().bool.isRequired,label:a().string.isRequired,pathToData:a().string.isRequired,propertyName:a().string.isRequired};var mn=yt;const pn=f.ZP.div`
188
- flex-direction: column;
189
- display: inline-flex;
190
- min-width: 100%;
191
- ${({theme:t,isActive:n})=>n&&`border: 1px solid ${t.colors.primary600};`}
192
- `,Ct=({allActions:t,contentTypeName:n,label:o,index:s,isActive:i,isFormDisabled:l,onClickToggleCollapse:d,pathToData:c,properties:m})=>{const u=(0,e.useCallback)(()=>{d(n)},[n,d]),g=(0,e.useMemo)(()=>Xt(t,n),[t,n]);return e.createElement(pn,{isActive:i},e.createElement(Kt,{availableActions:g,isActive:i,isGrey:s%2===0,isFormDisabled:l,label:o,onClickToggle:u,pathToData:c}),i&&m.map(({label:v,value:M,children:N})=>e.createElement(mn,{availableActions:g,childrenForm:N,isFormDisabled:l,label:v,pathToData:c,propertyName:M,key:M})))};Ct.propTypes={allActions:a().array.isRequired,contentTypeName:a().string.isRequired,index:a().number.isRequired,isActive:a().bool.isRequired,isFormDisabled:a().bool.isRequired,label:a().string.isRequired,onClickToggleCollapse:a().func.isRequired,pathToData:a().string.isRequired,properties:a().array.isRequired};var gn=Ct;const Qe=({actions:t,isFormDisabled:n,pathToData:o,subjects:s})=>{const[i,l]=(0,e.useState)(null),d=c=>{l(i===c?null:c)};return s.map(({uid:c,label:m,properties:u},g)=>e.createElement(gn,{allActions:t,key:c,contentTypeName:c,label:m,isActive:i===c,isFormDisabled:n,index:g,onClickToggleCollapse:d,pathToData:`${o}..${c}`,properties:u}))};Qe.defaultProps={actions:[],subjects:[]},Qe.propTypes={actions:a().array.isRequired,isFormDisabled:a().bool.isRequired,pathToData:a().string.isRequired,subjects:a().arrayOf(a().shape({uid:a().string.isRequired,label:a().string.isRequired,properties:a().array.isRequired}))};var fn=(0,e.memo)(Qe),hn=t=>t.filter(({subjects:n})=>n&&n.length);const yn=t=>t.map(({actionId:n})=>n),Cn=(t,n)=>t.reduce((o,s)=>(Object.keys(n).forEach(i=>{const l=y()(n,[i,s],{}),d={[i]:ze(l)};o[s]?o[s]={...o[s],...d}:o[s]=d}),o),{});var vn=(t,n)=>{const o=yn(t),s=Cn(o,n);return Object.keys(s).reduce((l,d)=>(l[d]=Te(s[d]),l),{})};const En=(0,f.ZP)(C.k)`
193
- width: ${U};
194
- flex-shrink: 0;
195
- `,qe=({actions:t,isFormDisabled:n,kind:o})=>{const{formatMessage:s}=(0,H.Z)(),{modifiedData:i,onChangeCollectionTypeGlobalActionCheckbox:l}=(0,G.$_)(),d=(0,e.useMemo)(()=>hn(t),[t]),c=(0,e.useMemo)(()=>vn(d,i[o]),[i,d,o]);return e.createElement(p.x,{paddingBottom:4,paddingTop:6,style:{paddingLeft:ye}},e.createElement(C.k,{gap:0},d.map(({label:m,actionId:u})=>e.createElement(En,{direction:"column",alignItems:"center",justifyContent:"center",key:u,gap:3},e.createElement(T.Z,{variant:"sigma",textColor:"neutral500"},s({id:`Settings.roles.form.permissions.${m.toLowerCase()}`,defaultMessage:m})),e.createElement(w.C,{disabled:n,onValueChange:g=>{l(o,u,g)},name:u,"aria-label":s({id:"Settings.permissions.select-all-by-permission",defaultMessage:"Select all {label} permissions"},{label:s({id:`Settings.roles.form.permissions.${m.toLowerCase()}`,defaultMessage:m})}),value:y()(c,[u,"hasAllActionsSelected"],!1),indeterminate:y()(c,[u,"hasSomeActionsSelected"],!1)})))))};qe.defaultProps={actions:[]},qe.propTypes={actions:a().arrayOf(a().shape({label:a().string.isRequired,actionId:a().string.isRequired,subjects:a().array.isRequired})),isFormDisabled:a().bool.isRequired,kind:a().string.isRequired};var bn=(0,e.memo)(qe);const xn=(0,f.ZP)(p.x)`
196
- overflow-x: auto;
197
- `,vt=({isFormDisabled:t,kind:n,layout:{actions:o,subjects:s}})=>{const i=F()([...s],"label");return e.createElement(xn,{background:"neutral0"},e.createElement(bn,{actions:o,kind:n,isFormDisabled:t}),e.createElement(fn,{actions:o,isFormDisabled:t,pathToData:n,subjects:i}))};vt.propTypes={isFormDisabled:a().bool.isRequired,kind:a().string.isRequired,layout:a().shape({actions:a().array,subjects:a().arrayOf(a().shape({uid:a().string.isRequired,label:a().string.isRequired,properties:a().array.isRequired}))}).isRequired};var Et=(0,e.memo)(vt),Rn=r(76402);const bt=({children:t,value:n})=>e.createElement(Rn.$l.Provider,{value:n},t);bt.propTypes={children:a().node.isRequired,value:a().exact({availableConditions:a().array.isRequired,modifiedData:a().object.isRequired,onChangeCollectionTypeLeftActionRowCheckbox:a().func.isRequired,onChangeConditions:a().func.isRequired,onChangeSimpleCheckbox:a().func.isRequired,onChangeParentCheckbox:a().func.isRequired,onChangeCollectionTypeGlobalActionCheckbox:a().func.isRequired}).isRequired};var Pn=bt,An=r(83828),Tn=r(61762),Sn=r(89966),xt=r(8284),Mn=r(15335),$n=r(5803),On=(t,n,o)=>t.map(s=>{const i=[...o,s.action,"properties","enabled"],l=y()(n,i,!1),d=y()(n,[...o,s.action,"conditions"],{}),c=ke(d).some(m=>m);return{...s,isDisplayed:l,checkboxName:i.join(".."),hasSomeActionsSelected:l,value:l,hasConditions:c,label:s.displayName,actionId:s.action,pathToConditionsObject:[...o,s.action]}}),Dn=t=>{const n=Object.entries(t).reduce((s,i)=>{const[l,{conditions:d}]=i;return s[l]=d,s},{});return ke(n).some(s=>s)};const jn=f.ZP.div`
198
- flex: 1;
199
- align-self: center;
200
- border-top: 1px solid ${({theme:t})=>t.colors.neutral150};
201
- `,Ln=f.ZP.div`
202
- position: relative;
203
- word-break: keep-all;
204
- ${({hasConditions:t,disabled:n,theme:o})=>t&&`
205
- &:before {
206
- content: '';
207
- position: absolute;
208
- top: ${-4/16}rem;
209
- left: ${-8/16}rem;
210
- width: ${6/16}rem;
211
- height: ${6/16}rem;
212
- border-radius: ${20/16}rem;
213
- background: ${n?o.colors.neutral100:o.colors.primary600};
214
- }
215
- `}
216
- `,Rt=({categoryName:t,isFormDisabled:n,subCategoryName:o,actions:s,pathToData:i})=>{const[l,d]=(0,e.useState)(!1),{modifiedData:c,onChangeParentCheckbox:m,onChangeSimpleCheckbox:u}=(0,G.$_)(),{formatMessage:g}=(0,H.Z)(),v=y()(c,i,{}),M=(0,e.useMemo)(()=>Object.keys(v).reduce((I,te)=>(I[te]=ze(v[te]),I),{}),[v]),{hasAllActionsSelected:N,hasSomeActionsSelected:j}=Te(M),E=()=>{d(I=>!I)},h=()=>{d(!1)},L=On(s,c,i),$=Dn(y()(c,[...i],{}));return e.createElement(e.Fragment,null,e.createElement(p.x,null,e.createElement(C.k,{justifyContent:"space-between",alignItems:"center"},e.createElement(p.x,{paddingRight:4},e.createElement(T.Z,{variant:"sigma",textColor:"neutral600"},o)),e.createElement(jn,null),e.createElement(p.x,{paddingLeft:4},e.createElement(xt.X,{name:i.join(".."),disabled:n,onValueChange:I=>{m({target:{name:i.join(".."),value:I}})},indeterminate:j,value:N},g({id:"app.utils.select-all",defaultMessage:"Select all"})))),e.createElement(C.k,{paddingTop:6,paddingBottom:6},e.createElement(Mn.r,{gap:2,style:{flex:1}},L.map(({checkboxName:I,value:te,action:K,displayName:J,hasConditions:V})=>e.createElement($n.P,{col:3,key:K},e.createElement(Ln,{disabled:n,hasConditions:V},e.createElement(xt.X,{name:I,disabled:n,onValueChange:fe=>{u({target:{name:I,value:fe}})},value:te},J))))),e.createElement(oe,{hasConditions:$,onClick:E}))),l&&e.createElement(W,{headerBreadCrumbs:[t,o],actions:L,isFormDisabled:n,onClosed:h,onToggle:E}))};Rt.propTypes={actions:a().array.isRequired,categoryName:a().string.isRequired,isFormDisabled:a().bool.isRequired,subCategoryName:a().string.isRequired,pathToData:a().array.isRequired};var kn=Rt;const _e=({childrenForm:t,kind:n,name:o,isOpen:s,isFormDisabled:i,isWhite:l,onOpenCategory:d,pathToData:c})=>{const{formatMessage:m}=(0,H.Z)(),u=()=>{d(o)},g=(0,e.useMemo)(()=>o.split("::").pop(),[o]);return e.createElement(An.U,{expanded:s,onToggle:u,id:`accordion-${o}`,variant:l?"primary":"secondary"},e.createElement(Tn.B,{title:ce()(g),description:`${m({id:"Settings.permissions.category"},{category:g})} ${n==="plugins"?"plugin":n}`}),e.createElement(Sn.v,null,e.createElement(p.x,{padding:6},t.map(({actions:v,subCategoryName:M,subCategoryId:N})=>e.createElement(kn,{key:M,actions:v,categoryName:g,isFormDisabled:i,subCategoryName:M,pathToData:[...c,N]})))))};_e.defaultProps={},_e.propTypes={childrenForm:a().array.isRequired,isOpen:a().bool.isRequired,isFormDisabled:a().bool.isRequired,isWhite:a().bool.isRequired,kind:a().string.isRequired,name:a().string.isRequired,onOpenCategory:a().func.isRequired,pathToData:a().array.isRequired};var In=_e;const Pt=({isFormDisabled:t,kind:n,layout:o})=>{const[s,i]=(0,e.useState)(null),l=d=>{i(d===s?null:d)};return e.createElement(p.x,{padding:6,background:"neutral0"},o.map(({category:d,categoryId:c,childrenForm:m},u)=>e.createElement(In,{key:d,childrenForm:m,kind:n,isFormDisabled:t,isOpen:s===d,isWhite:u%2===1,name:d,onOpenCategory:l,pathToData:[n,c]})))};Pt.propTypes={isFormDisabled:a().bool.isRequired,kind:a().string.isRequired,layout:a().arrayOf(a().shape({category:a().string.isRequired,categoryId:a().string.isRequired,childrenForm:a().arrayOf(a().shape({actions:a().array.isRequired})).isRequired}).isRequired).isRequired};var At=Pt,Zn=r(86349),Bn=r.n(Zn),Fn=r(3040),ge=r.n(Fn),Tt=(t,n,o)=>t.find(s=>s.action===n&&s.subject===o);const St=(t,n=[])=>t.reduce((o,s)=>(o[s.id]=n.indexOf(s.id)!==-1,o),{}),Mt=({children:t},n,o="")=>t.reduce((s,i)=>{if(i.children)return{...s,[i.value]:Mt(i,n,`${o}${i.value}.`)};const l=n.indexOf(`${o}${i.value}`)!==-1;return s[i.value]=l,s},{}),Nn=(t,n,o)=>t.reduce((s,i)=>{const l=n.properties.find(({value:d})=>d===i);if(l){const d=y()(o,["properties",l.value],[]),c=Mt(l,d);s.properties[i]=c}return s},{properties:{}}),Wn=(t,n)=>n.reduce((o,s)=>{const i=t.find(({uid:l})=>l===s)||null;return i&&(o[s]=i),o},{});var $t=({subjects:t},n,o,s=[])=>n.reduce((i,l)=>{const d=l.subjects,c=Wn(t,d);if(D()(c))return i;const m=Object.keys(c).reduce((u,g)=>{const{actionId:v,applyToProperties:M}=l,E=c[g].properties.map(({value:I})=>I).every(I=>(M||[]).indexOf(I)===-1),h=Tt(s,v,g),L=St(o,y()(h,"conditions",[]));if(D()(M)||E)return ge()(u,[g,v],{properties:{enabled:h!==void 0},conditions:L}),u;const $=Nn(M,c[g],h);return ge()(u,[g,v],{...$,conditions:L}),u},{});return Bn()(i,m)},{});const Vn=(t,n,o)=>t.reduce((s,i)=>{const l=Tt(o,i.action,null);return s[i.action]={properties:{enabled:l!==void 0},conditions:St(n,l?.conditions??[])},s},{}),Hn=(t,n,o)=>t.reduce((s,i)=>(s[i.subCategoryId]=Vn(i.actions,n,o),s),{});var Ot=(t,n,o=[])=>t.reduce((s,{categoryId:i,childrenForm:l})=>{const d=Hn(l,n,o);return s[i]=d,s},{});const Dt=t=>t.split(" ").join("-");var jt=(t,n)=>Object.entries(de()(t,n)).map(([o,s])=>({category:o,categoryId:Dt(o),childrenForm:Object.entries(de()(s,"subCategory")).map(([i,l])=>({subCategoryName:i,subCategoryId:Dt(i),actions:l}))})),Gn=(t,n)=>{const{conditions:o,sections:{collectionTypes:s,singleTypes:i,plugins:l,settings:d}}=t,c={collectionTypes:s,singleTypes:i,plugins:jt(l,"plugin"),settings:jt(d,"category")},m={collectionTypes:$t(s,s.actions||[],o,n),singleTypes:$t(i,i.actions||[],o,n),plugins:Ot(c.plugins,o,n),settings:Ot(c.settings,o,n)};return{initialData:m,modifiedData:m,layouts:c}},Un=r(99381),et=r.n(Un);const Lt=t=>Object.keys(t).reduce((n,o)=>{const s=t[o];if(be()(s)&&!S()(s,"conditions"))return{...n,[o]:Lt(s)};if(be()(s)&&S()(s,"conditions")&&!ke(Y()(s,"conditions")).some(l=>l)){const l=Object.keys(s.conditions).reduce((d,c)=>(d[c]=!1,d),{});return{...n,[o]:{...s,conditions:l}}}return n[o]=s,n},{});var tt=Lt;const kt=(t,n,o=!1)=>Object.keys(t).reduce((s,i)=>{const l=t[i];return i==="conditions"&&!o?(s[i]=l,s):be()(l)?{...s,[i]:kt(l,n,i==="fields")}:(s[i]=n,s)},{});var Ge=kt;const Kn={initialData:{},modifiedData:{},layouts:{}};var zn=(t,n)=>(0,Q.ZP)(t,o=>{switch(n.type){case"ON_CHANGE_COLLECTION_TYPE_GLOBAL_ACTION_CHECKBOX":{const{collectionTypeKind:s,actionId:i,value:l}=n,d=["modifiedData",s];Object.keys(y()(t,d)).forEach(c=>{const m=y()(t,[...d,c,i],void 0);if(m){let u=Ge(m,l);if(!l&&u.conditions){const g=Ge(u.conditions,!1);u={...u,conditions:g}}ge()(o,[...d,c,i],u)}});break}case"ON_CHANGE_COLLECTION_TYPE_ROW_LEFT_CHECKBOX":{const{pathToCollectionType:s,propertyName:i,rowName:l,value:d}=n;let c=et()(t.modifiedData);const m=s.split(".."),u=y()(c,m,{});Object.keys(u).forEach(g=>{if(S()(u[g],`properties.${i}`)){const v=y()(u,[g,"properties",i,l]),M=[...m,g,"properties",i,l];if(!be()(v))ge()(c,M,d);else{const N=Ge(v,d);ge()(c,M,N)}}}),d||(c=tt(c)),ge()(o,"modifiedData",c);break}case"ON_CHANGE_CONDITIONS":{Object.entries(n.conditions).forEach(s=>{const[i,l]=s;ge()(o,["modifiedData",...i.split(".."),"conditions"],l)});break}case"ON_CHANGE_SIMPLE_CHECKBOX":{let s=et()(t.modifiedData);ge()(s,[...n.keys.split("..")],n.value),n.value||(s=tt(s)),ge()(o,"modifiedData",s);break}case"ON_CHANGE_TOGGLE_PARENT_CHECKBOX":{const{keys:s,value:i}=n,l=[...s.split("..")];let d=et()(t.modifiedData);const c=y()(d,l,{}),m=Ge(c,i);ge()(d,l,m),i||(d=tt(d)),ge()(o,["modifiedData"],d);break}case"RESET_FORM":{o.modifiedData=t.initialData;break}case"SET_FORM_AFTER_SUBMIT":{o.initialData=t.modifiedData;break}default:return o}});const nt=t=>Object.entries(t).filter(([,n])=>n).map(([n])=>n),Xn=t=>{const[n,{conditions:o}]=t;return{action:n,subject:null,conditions:nt(o),properties:{}}},wn=t=>Object.values(t).reduce((n,o)=>{const s=Object.entries(o).reduce((i,l)=>{const[,{properties:{enabled:d}}]=l;if(!d)return i;const c=Xn(l);return i.push(c),i},[]);return[...n,...s]},[]);var It=t=>Object.values(t).reduce((n,o)=>{const s=wn(o);return[...n,...s]},[]);const Zt=(t,n="")=>Object.entries(t).reduce((o,s)=>{const[i,l]=s;return be()(l)?[...o,...Zt(l,`${n}${i}.`)]:(l&&!be()(l)&&o.push(`${n}${i}`),o)},[]),Yn=(t,n,{conditions:o,properties:s})=>Object.entries(s).reduce((i,l)=>{const[d,c]=l;return i.properties[d]=Zt(c),i},{action:t,subject:n,conditions:nt(o),properties:{}}),Jn=(t,n,{conditions:o})=>({action:t,subject:n,properties:{},conditions:nt(o)}),Qn=(t,n)=>Object.entries(n).reduce((s,i)=>{const[l,d]=i;if(!ke(d).some(u=>u))return s;if(!d?.properties?.enabled){const u=Yn(l,t,d);return[...s,u]}if(!d.properties.enabled)return s;const m=Jn(l,t,d);return s.push(m),s},[]);var Bt=t=>Object.entries(t).reduce((o,s)=>{const[i,l]=s,d=Qn(i,l);return[...o,...d]},[]),qn=t=>{const n=It(t.plugins),o=It(t.settings),s=Bt(t.collectionTypes),i=Bt(t.singleTypes);return[...n,...o,...s,...i]},_n=[{labelId:"app.components.LeftMenuLinkContainer.collectionTypes",defaultMessage:"Collection Types",id:"collectionTypes"},{labelId:"app.components.LeftMenuLinkContainer.singleTypes",id:"singleTypes",defaultMessage:"Single Types"},{labelId:"app.components.LeftMenuLinkContainer.plugins",defaultMessage:"Plugins",id:"plugins"},{labelId:"app.components.LeftMenuLinkContainer.settings",defaultMessage:"Settings",id:"settings"}];const st=(0,e.forwardRef)(({layout:t,isFormDisabled:n,permissions:o},s)=>{const[{initialData:i,layouts:l,modifiedData:d},c]=(0,e.useReducer)(zn,Kn,()=>Gn(t,o)),{formatMessage:m}=(0,H.Z)();(0,e.useImperativeHandle)(s,()=>({getPermissions(){const j=(0,Z.e5)(i.collectionTypes,d.collectionTypes),E=(0,Z.e5)(i.singleTypes,d.singleTypes),h={...j,...E};let L;return D()(h)?L=!1:L=Object.values(h).some($=>Object.values($).some(I=>S()(I,"conditions"))),{permissionsToSend:qn(d),didUpdateConditions:L}},resetForm(){c({type:"RESET_FORM"})},setFormAfterSubmit(){c({type:"SET_FORM_AFTER_SUBMIT"})}}));const u=(j,E,h,L)=>{c({type:"ON_CHANGE_COLLECTION_TYPE_ROW_LEFT_CHECKBOX",pathToCollectionType:j,propertyName:E,rowName:h,value:L})},g=(j,E,h)=>{c({type:"ON_CHANGE_COLLECTION_TYPE_GLOBAL_ACTION_CHECKBOX",collectionTypeKind:j,actionId:E,value:h})},v=j=>{c({type:"ON_CHANGE_CONDITIONS",conditions:j})},M=(0,e.useCallback)(({target:{name:j,value:E}})=>{c({type:"ON_CHANGE_SIMPLE_CHECKBOX",keys:j,value:E})},[]),N=(0,e.useCallback)(({target:{name:j,value:E}})=>{c({type:"ON_CHANGE_TOGGLE_PARENT_CHECKBOX",keys:j,value:E})},[]);return e.createElement(Pn,{value:{availableConditions:t.conditions,modifiedData:d,onChangeConditions:v,onChangeSimpleCheckbox:M,onChangeParentCheckbox:N,onChangeCollectionTypeLeftActionRowCheckbox:u,onChangeCollectionTypeGlobalActionCheckbox:g}},e.createElement(b.v,{id:"tabs",label:m({id:"Settings.permissions.users.tabs.label",defaultMessage:"Tabs Permissions"})},e.createElement(P.m,null,_n.map(j=>e.createElement(P.O,{key:j.id},m({id:j.labelId,defaultMessage:j.defaultMessage})))),e.createElement(R.n,{style:{position:"relative"}},e.createElement(R.x,null,e.createElement(Et,{layout:l.collectionTypes,kind:"collectionTypes",isFormDisabled:n})),e.createElement(R.x,null,e.createElement(Et,{layout:l.singleTypes,kind:"singleTypes",isFormDisabled:n})),e.createElement(R.x,null,e.createElement(At,{layout:l.plugins,kind:"plugins",isFormDisabled:n})),e.createElement(R.x,null,e.createElement(At,{layout:l.settings,kind:"settings",isFormDisabled:n})))))});st.defaultProps={permissions:[],layout:{conditions:[],sections:{collectionTypes:{},singleTypes:{actions:[]},settings:[],plugins:[]}}},st.propTypes={layout:a().object,isFormDisabled:a().bool.isRequired,permissions:a().array};var es=(0,e.memo)(st)},87056:function(X,B,r){"use strict";r.r(B),r.d(B,{default:function(){return T}});var e=r(32735),b=r(19565),P=r(15062),R=r(53038),Z=r(30305),O=r(27649),S=r(82055),x=r(87933),D=r(41415),q=r(17e3),a=r(72850),H=r(29439),p=r(92802),A=r(33795),F=r.n(A),f=r(67879),C=r(2160),w=r(1283),ue=r(49372),ae=r(15335),ie=r(5803),y=r(10369),le=r(33475),Y=r(60216),G=r.n(Y);const _=({disabled:ne,role:z,values:k,errors:Q,onChange:pe,onBlur:de})=>{const{formatMessage:ee}=(0,f.Z)();return e.createElement(a.x,{background:"neutral0",padding:6,shadow:"filterShadow",hasRadius:!0},e.createElement(x.k,{direction:"column",alignItems:"stretch",gap:4},e.createElement(x.k,{justifyContent:"space-between"},e.createElement(a.x,null,e.createElement(a.x,null,e.createElement(ue.Z,{fontWeight:"bold"},z?z.name:ee({id:"global.details",defaultMessage:"Details"}))),e.createElement(a.x,null,e.createElement(ue.Z,{textColor:"neutral500",variant:"pi"},z?z.description:ee({id:"Settings.roles.form.description",defaultMessage:"Name and description of the role"})))),e.createElement(D.z,{disabled:!0,variant:"secondary"},ee({id:"Settings.roles.form.button.users-with-role",defaultMessage:"{number, plural, =0 {# users} one {# user} other {# users}} with this role"},{number:z.usersCount}))),e.createElement(ae.r,{gap:4},e.createElement(ie.P,{col:6},e.createElement(y.o,{disabled:ne,name:"name",error:Q.name&&ee({id:Q.name}),label:ee({id:"global.name",defaultMessage:"Name"}),onChange:pe,onBlur:de,value:k.name||""})),e.createElement(ie.P,{col:6},e.createElement(le.g,{disabled:ne,label:ee({id:"global.description",defaultMessage:"Description"}),id:"description",error:Q.name&&ee({id:Q.name}),onChange:pe,onBlur:de},k.description||"")))))};_.defaultProps={disabled:!1,role:null,values:{name:"",description:""}},_.propTypes={disabled:G().bool,errors:G().object.isRequired,onBlur:G().func.isRequired,onChange:G().func.isRequired,role:G().object,values:G().object};var xe=_,me=r(24346),oe=me.Ry().shape({name:me.Z_().required(b.I0.required)}),Ee=()=>{const ne=(0,b.lm)(),{formatMessage:z}=(0,f.Z)(),{params:{id:k}}=(0,R.$B)("/settings/roles/:id"),[Q,pe]=(0,e.useState)(!1),de=(0,e.useRef)(),{lockApp:ee,unlockApp:ce}=(0,b.o1)(),{trackUsage:Ze}=(0,b.rS)(),{isLoading:Ae,data:Be}=(0,C.U_)(k),{role:he,permissions:Oe,isLoading:De,onSubmitSucceeded:Fe}=(0,C.Dq)(k),{put:je}=(0,b.kY)(),He=async re=>{try{ee(),pe(!0);const{permissionsToSend:W,didUpdateConditions:U}=de.current.getPermissions();await je(`/admin/roles/${k}`,re),he.code!=="strapi-super-admin"&&(await je(`/admin/roles/${k}/permissions`,{permissions:W}),U&&Ze("didUpdateConditions")),de.current.setFormAfterSubmit(),Fe({name:re.name,description:re.description}),ne({type:"success",message:{id:"notification.success.saved"}})}catch(W){console.error(W.response);const U=F()(W,"response.payload.message","An error occured"),ye=F()(W,"response.payload.data.permissions[0]",U);ne({type:"warning",message:ye})}finally{pe(!1),ce()}},Le=he.code==="strapi-super-admin";return e.createElement(O.o,null,e.createElement(b.SL,{name:"Roles"}),e.createElement(p.J9,{enableReinitialize:!0,initialValues:{name:he.name,description:he.description},onSubmit:He,validationSchema:oe,validateOnChange:!1},({handleSubmit:re,values:W,errors:U,handleChange:ye,handleBlur:Ce})=>e.createElement("form",{onSubmit:re},e.createElement(S.T,{primaryAction:e.createElement(x.k,{gap:2},e.createElement(D.z,{disabled:he.code==="strapi-super-admin",onClick:re,loading:Q,size:"L"},z({id:"global.save",defaultMessage:"Save"}))),title:z({id:"Settings.roles.edit.title",defaultMessage:"Edit a role"}),subtitle:z({id:"Settings.roles.create.description",defaultMessage:"Define the rights given to the role"}),navigationAction:e.createElement(b.rU,{startIcon:e.createElement(H.Z,null),to:"/settings/roles"},z({id:"global.back",defaultMessage:"Back"}))}),e.createElement(q.D,null,e.createElement(x.k,{direction:"column",alignItems:"stretch",gap:6},e.createElement(xe,{isLoading:De,disabled:Le,errors:U,values:W,onChange:ye,onBlur:Ce,role:he}),!Ae&&!De?e.createElement(a.x,{shadow:"filterShadow",hasRadius:!0},e.createElement(w.Z,{isFormDisabled:Le,permissions:Oe,ref:de,layout:Be})):e.createElement(a.x,{background:"neutral0",padding:6,shadow:"filterShadow",hasRadius:!0},e.createElement(b.dO,null)))))))},T=()=>{const ne=(0,P.v9)(Z._),{isLoading:z,allowedActions:{canRead:k,canUpdate:Q}}=(0,b.ss)({read:ne.settings.roles.read,update:ne.settings.roles.update});return z?e.createElement(b.dO,null):!k&&!Q?e.createElement(R.l_,{to:"/"}):e.createElement(Ee,null)}},84802:function(X){function B(r,e,b,P){for(var R=-1,Z=r==null?0:r.length;++R<Z;){var O=r[R];e(P,O,b(O),r)}return P}X.exports=B},62435:function(X,B,r){var e=r(56671);function b(P,R,Z,O){return e(P,function(S,x,D){R(O,S,Z(S),D)}),O}X.exports=b},85580:function(X,B,r){var e=r(84802),b=r(62435),P=r(88904),R=r(77236);function Z(O,S){return function(x,D){var q=R(x)?e:b,a=S?S():{};return q(x,O,P(D,2),a)}}X.exports=Z},72091:function(X,B,r){var e=r(40314),b=1/0;function P(R){var Z=R==null?0:R.length;return Z?e(R,b):[]}X.exports=P},81346:function(X,B,r){var e=r(40999),b=r(85580),P=Object.prototype,R=P.hasOwnProperty,Z=b(function(O,S,x){R.call(O,x)?O[x].push(S):e(O,x,[S])});X.exports=Z},83828:function(X,B,r){"use strict";r.d(B,{U:function(){return H},y:function(){return q}});var e=r(74512),b=r(32735),P=r(8471),R=r(91045),Z=r(74971),O=r(49372),S=r(87933),x=r(72850);const D=({theme:p,expanded:A,variant:F,disabled:f,error:C})=>C?`1px solid ${p.colors.danger600} !important`:f?`1px solid ${p.colors.neutral150}`:A?`1px solid ${p.colors.primary600}`:F==="primary"?`1px solid ${p.colors.neutral0}`:`1px solid ${p.colors.neutral100}`,q=(0,P.ZP)(O.Z)``,a=(0,P.ZP)(x.x)`
217
- border: ${D};
218
-
219
- &:hover:not([aria-disabled='true']) {
220
- border: 1px solid ${({theme:p})=>p.colors.primary600};
221
-
222
- ${q} {
223
- color: ${({theme:p,expanded:A})=>A?void 0:p.colors.primary700};
224
- }
225
-
226
- ${O.Z} {
227
- color: ${({theme:p,expanded:A})=>A?void 0:p.colors.primary600};
228
- }
229
-
230
- & > ${S.k} {
231
- background: ${({theme:p})=>p.colors.primary100};
232
- }
233
-
234
- [data-strapi-dropdown='true'] {
235
- background: ${({theme:p})=>p.colors.primary200};
236
- }
237
- }
238
- `,H=({children:p,disabled:A=!1,error:F,expanded:f=!1,hasErrorMessage:C=!0,id:w,onToggle:ue,toggle:ae,size:ie="M",variant:y="primary",shadow:le})=>{const Y=(0,Z.M)(w),G=b.useMemo(()=>({expanded:f,onToggle:ue,toggle:ae,id:Y,size:ie,variant:y,disabled:A}),[A,f,Y,ue,ie,ae,y]);return(0,e.jsxs)(R.S.Provider,{value:G,children:[(0,e.jsx)(a,{"data-strapi-expanded":f,disabled:A,"aria-disabled":A,expanded:f,hasRadius:!0,variant:y,error:F,shadow:le,children:p}),F&&C&&(0,e.jsx)(x.x,{paddingTop:1,children:(0,e.jsx)(O.Z,{variant:"pi",textColor:"danger600",children:F})})]})}},89966:function(X,B,r){"use strict";r.d(B,{v:function(){return R}});var e=r(74512),b=r(91045),P=r(72850);const R=({children:Z,...O})=>{const{expanded:S,id:x}=(0,b.A)();if(!S)return null;const D=`accordion-content-${x}`,q=`accordion-label-${x}`,a=`accordion-desc-${x}`;return(0,e.jsx)(P.x,{role:"region",id:D,"aria-labelledby":q,"aria-describedby":a,...O,children:Z})}},91045:function(X,B,r){"use strict";r.d(B,{A:function(){return P},S:function(){return b}});var e=r(32735);const b=(0,e.createContext)({disabled:!1,expanded:!1,id:"",size:"M",variant:"primary"}),P=()=>(0,e.useContext)(b)},61762:function(X,B,r){"use strict";r.d(B,{B:function(){return p}});var e=r(74512),b=r(16899),P=r(8471),R=r(83828),Z=r(91045);const O=({expanded:A,disabled:F,variant:f})=>{let C="neutral100";return A?C="primary100":F?C="neutral150":f==="primary"&&(C="neutral0"),C};var S=r(7563),x=r(99140),D=r(87933),q=r(49372);const a=(0,P.ZP)(S.A)`
239
- text-align: left;
240
-
241
- // necessary to make the ellipsis prop work on the title
242
- > span {
243
- max-width: 100%;
244
- }
245
-
246
- svg {
247
- width: ${14/16}rem;
248
- height: ${14/16}rem;
249
-
250
- path {
251
- fill: ${({theme:A,expanded:F})=>F?A.colors.primary600:A.colors.neutral500};
252
- }
253
- }
254
- `,H=(0,P.ZP)(D.k)`
255
- min-height: ${({theme:A,size:F})=>A.sizes.accordions[F]};
256
- border-radius: ${({theme:A,expanded:F})=>F?`${A.borderRadius} ${A.borderRadius} 0 0`:A.borderRadius};
257
-
258
- &:hover {
259
- svg {
260
- path {
261
- fill: ${({theme:A})=>A.colors.primary600};
262
- }
263
- }
264
- }
265
- `,p=({title:A,description:F,as:f="span",togglePosition:C="right",action:w,...ue})=>{const{onToggle:ae,toggle:ie,expanded:y,id:le,size:Y,variant:G,disabled:_}=(0,Z.A)(),xe=`accordion-content-${le}`,me=`accordion-label-${le}`,Re=`accordion-desc-${le}`,oe=Y==="M"?6:4,Pe=Y==="M"?oe:oe-2,Ee=O({expanded:y,disabled:_,variant:G}),$e={as:f,fontWeight:Y==="S"?"bold":void 0,id:me,textColor:y?"primary600":"neutral700",ellipsis:!0,variant:Y==="M"?"delta":void 0},T=y?"primary600":"neutral600",ne=y?"primary200":"neutral200",z=Y==="M"?`${32/16}rem`:`${24/16}rem`,k=()=>{_||(ie&&!ae?(console.warn('Deprecation warning: Usage of "toggle" prop in Accordion component is deprecated. This is discouraged and will be removed in the next major release. Please use "onToggle" instead'),ie()):ae&&ae())},Q=(0,e.jsx)(D.k,{justifyContent:"center",borderRadius:"50%",height:z,width:z,transform:y?"rotate(180deg)":void 0,"data-strapi-dropdown":!0,"aria-hidden":!0,as:"span",background:ne,cursor:_?"not-allowed":"pointer",onClick:k,shrink:0,children:(0,e.jsx)(x.J,{as:b.Z,width:Y==="M"?`${11/16}rem`:`${8/16}rem`,color:y?"primary600":"neutral600"})});return(0,e.jsx)(H,{paddingBottom:Pe,paddingLeft:oe,paddingRight:oe,paddingTop:Pe,background:Ee,expanded:y,size:Y,justifyContent:"space-between",cursor:_?"not-allowed":"",children:(0,e.jsxs)(D.k,{gap:3,flex:1,maxWidth:"100%",children:[C==="left"&&Q,(0,e.jsx)(a,{onClick:k,"aria-disabled":_,"aria-expanded":y,"aria-controls":xe,"aria-labelledby":me,"data-strapi-accordion-toggle":!0,expanded:y,type:"button",flex:1,minWidth:0,...ue,children:(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(R.y,{...$e,children:A}),F&&(0,e.jsx)(q.Z,{as:"p",id:Re,textColor:T,children:F})]})}),C==="right"&&(0,e.jsxs)(D.k,{gap:3,children:[Q,w]}),C==="left"&&w]})})}},27799:function(X,B,r){"use strict";r.d(B,{Q:function(){return R}});var e=r(74512),b=r(8471),P=r(6407);const R=({options:O,...S})=>(0,e.jsx)(P.NU,{...S,children:O.map(x=>"children"in x?(0,e.jsx)(P.Ab,{label:x.label,values:x.children.map(D=>D.value.toString()),children:x.children.map(D=>(0,e.jsx)(Z,{value:D.value,children:D.label},D.value))},x.label):(0,e.jsx)(P.ML,{value:x.value,children:x.label},x.value))}),Z=(0,b.ZP)(P.ML)`
266
- padding-left: ${({theme:O})=>O.spaces[7]};
267
- `}}]);
@@ -1,23 +0,0 @@
1
- "use strict";(self.webpackChunk_strapi_admin=self.webpackChunk_strapi_admin||[]).push([[3455],{32239:function(N,x,t){t.r(x),t.d(x,{default:function(){return ge}});var e=t(32735),n=t(19565),f=t(15062),T=t(30305),y=t(27649),b=t(82055),W=t(41415),U=t(99223),S=t(17e3),E=t(56755),F=t(73269),K=t(33827),V=t(94547),v=t(19786),O=t(49372),z=t(3685),X=t(35658),G=t(47765),J=t(68625),Y=t(4038),k=t(19406),w=t(33795),q=t.n(w),Z=t(67879),_=t(53038),ee=t(2160),te=()=>"todo empty role",ne=t(87933),le=t(72850),se=t(50563),ae=t(60216),L=t.n(ae);const $=({id:s,name:d,description:l,usersCount:h,icons:c,rowIndex:o,canUpdate:M})=>{const{formatMessage:p}=(0,Z.Z)(),[,r]=c,C=p({id:"Roles.RoleRow.user-count",defaultMessage:"{number, plural, =0 {# user} one {# user} other {# users}}"},{number:h});return e.createElement(V.Tr,{"aria-rowindex":o,key:s,...M?(0,n.X7)({fn:r.onClick}):{}},e.createElement(v.Td,{maxWidth:(0,n.Q1)(130)},e.createElement(O.Z,{ellipsis:!0,textColor:"neutral800"},d)),e.createElement(v.Td,{maxWidth:(0,n.Q1)(250)},e.createElement(O.Z,{ellipsis:!0,textColor:"neutral800"},l)),e.createElement(v.Td,null,e.createElement(O.Z,{textColor:"neutral800"},C)),e.createElement(v.Td,null,e.createElement(ne.k,{justifyContent:"flex-end",...n.UW},c.map((u,R)=>u?e.createElement(le.x,{key:u.label,paddingLeft:R===0?0:1},e.createElement(se.h,{onClick:u.onClick,label:u.label,noBorder:!0,icon:u.icon})):null))))};$.propTypes={id:L().number.isRequired,name:L().string.isRequired,description:L().string.isRequired,usersCount:L().number.isRequired,icons:L().array.isRequired,rowIndex:L().number.isRequired,canUpdate:L().bool},$.defaultProps={canUpdate:!1};var oe=$,re=t(97889);const ie={roleToDelete:null,showModalConfirmButtonLoading:!1,shouldRefetchData:!1};var de=(s,d)=>(0,re.ZP)(s,l=>{switch(d.type){case"ON_REMOVE_ROLES":{l.showModalConfirmButtonLoading=!0;break}case"ON_REMOVE_ROLES_SUCCEEDED":{l.shouldRefetchData=!0,l.roleToDelete=null;break}case"RESET_DATA_TO_DELETE":{l.shouldRefetchData=!1,l.roleToDelete=null,l.showModalConfirmButtonLoading=!1;break}case"SET_ROLE_TO_DELETE":{l.roleToDelete=d.id;break}default:return l}});const ce=()=>{(0,n.go)();const{locale:s}=(0,Z.Z)(),d=(0,f.v9)(T._),{isLoading:l,allowedActions:{canCreate:h,canDelete:c,canRead:o,canUpdate:M}}=(0,n.ss)(d.settings.roles),{getData:p,roles:r,isLoading:C}=(0,ee.bF)(!1),[{query:u}]=(0,n.Kx)(),R=u?._q||"",{includes:D}=(0,n.L0)(s,{sensitivity:"base"}),P=(0,n.Xe)(s,{sensitivity:"base"}),j=(r||[]).filter(m=>D(m.name,R)||D(m.description,R)).sort((m,A)=>P.compare(m.name,A.name)||P.compare(m.description,A.description));return(0,e.useEffect)(()=>{!l&&o&&p()},[l,o,p]),{isLoadingForPermissions:l,canCreate:h,canDelete:c,canRead:o,canUpdate:M,isLoading:C,getData:p,sortedRoles:j,roles:r}},ue=({getData:s,canCreate:d,canDelete:l,canUpdate:h})=>{const{formatMessage:c}=(0,Z.Z)(),o=(0,n.lm)(),[M,p]=(0,e.useState)(!1),{push:r}=(0,_.k6)(),[{selectedRoles:C,showModalConfirmButtonLoading:u,roleToDelete:R},D]=(0,e.useReducer)(de,ie),{post:P}=(0,n.tg)(),j=async()=>{try{D({type:"ON_REMOVE_ROLES"}),await P("/admin/roles/batch-delete",{ids:[R]}),await s(),D({type:"RESET_DATA_TO_DELETE"})}catch(a){const i=q()(a,["response","payload","data","ids"],null);if(i&&Array.isArray(i)){const he=i.join(`
2
- `);o({type:"warning",message:he})}else o({type:"warning",message:{id:"notification.error"}})}g()},m=(0,e.useCallback)(a=>{r(`/settings/roles/duplicate/${a}`)},[r]),A=()=>r("/settings/roles/new"),B=(0,e.useCallback)(a=>{D({type:"SET_ROLE_TO_DELETE",id:a}),g()},[]),g=()=>p(a=>!a),I=(0,e.useCallback)(a=>{r(`/settings/roles/${a}`)},[r]),H=(0,e.useCallback)((a,i)=>{a.preventDefault(),a.stopPropagation(),i.usersCount?o({type:"info",message:{id:"Roles.ListPage.notification.delete-not-allowed"}}):B(i.id)},[o,B]),Q=(0,e.useCallback)((a,i)=>{a.preventDefault(),a.stopPropagation(),m(i.id)},[m]),Ee=(0,e.useCallback)(a=>[...d?[{onClick:i=>Q(i,a),label:c({id:"app.utils.duplicate",defaultMessage:"Duplicate"}),icon:e.createElement(G.Z,null)}]:[],...h?[{onClick:()=>I(a.id),label:c({id:"app.utils.edit",defaultMessage:"Edit"}),icon:e.createElement(J.Z,null)}]:[],...l?[{onClick:i=>H(i,a),label:c({id:"global.delete",defaultMessage:"Delete"}),icon:e.createElement(Y.Z,null)}]:[]],[c,H,Q,I,d,h,l]);return{handleNewRoleClick:A,getIcons:Ee,selectedRoles:C,isWarningDeleteAllOpened:M,showModalConfirmButtonLoading:u,handleToggleModal:g,handleDeleteData:j}};var me=()=>{const{formatMessage:s}=(0,Z.Z)(),{isLoadingForPermissions:d,canCreate:l,canRead:h,canDelete:c,canUpdate:o,isLoading:M,getData:p,sortedRoles:r}=ce(),{handleNewRoleClick:C,getIcons:u,isWarningDeleteAllOpened:R,showModalConfirmButtonLoading:D,handleToggleModal:P,handleDeleteData:j}=ue({getData:p,canCreate:l,canDelete:c,canUpdate:o}),m=r.length+1,A=6;if(d)return e.createElement(y.o,null,e.createElement(n.dO,null));const B=s({id:"global.roles",defaultMessage:"roles"});return e.createElement(y.o,null,e.createElement(n.SL,{name:"Roles"}),e.createElement(b.T,{primaryAction:l?e.createElement(W.z,{onClick:C,startIcon:e.createElement(k.Z,null),size:"S"},s({id:"Settings.roles.list.button.add",defaultMessage:"Add new role"})):null,title:B,subtitle:s({id:"Settings.roles.list.description",defaultMessage:"List of roles"}),as:"h2"}),h&&e.createElement(U.Z,{startActions:e.createElement(n.m,{label:s({id:"app.component.search.label",defaultMessage:"Search for {target}"},{target:B})})}),h&&e.createElement(S.D,null,e.createElement(E.i,{colCount:A,rowCount:m,footer:l?e.createElement(F.c,{onClick:C,icon:e.createElement(k.Z,null)},s({id:"Settings.roles.list.button.add",defaultMessage:"Add new role"})):null},e.createElement(K.h,null,e.createElement(V.Tr,{"aria-rowindex":1},e.createElement(v.Th,null,e.createElement(O.Z,{variant:"sigma",textColor:"neutral600"},s({id:"global.name",defaultMessage:"Name"}))),e.createElement(v.Th,null,e.createElement(O.Z,{variant:"sigma",textColor:"neutral600"},s({id:"global.description",defaultMessage:"Description"}))),e.createElement(v.Th,null,e.createElement(O.Z,{variant:"sigma",textColor:"neutral600"},s({id:"global.users",defaultMessage:"Users"}))),e.createElement(v.Th,null,e.createElement(z.T,null,s({id:"global.actions",defaultMessage:"Actions"}))))),e.createElement(X.p,null,r?.map((g,I)=>e.createElement(oe,{key:g.id,id:g.id,name:g.name,description:g.description,usersCount:g.usersCount,icons:u(g),rowIndex:I+2,canUpdate:o})))),!m&&!M&&e.createElement(te,null)),e.createElement(n.QH,{isOpen:R,onConfirm:j,isConfirmButtonLoading:D,onToggleDialog:P}))},ge=()=>{const s=(0,f.v9)(T._);return e.createElement(n.O4,{permissions:s.settings.roles.main},e.createElement(me,null))}},99223:function(N,x,t){t.d(x,{Z:function(){return f}});var e=t(74512),n=t(87933);const f=({startActions:T,endActions:y})=>!T&&!y?null:(0,e.jsxs)(n.k,{justifyContent:"space-between",alignItems:"flex-start",paddingBottom:4,paddingLeft:10,paddingRight:10,children:[(0,e.jsx)(n.k,{gap:2,wrap:"wrap",children:T}),(0,e.jsx)(n.k,{gap:2,shrink:0,wrap:"wrap",children:y})]})},73269:function(N,x,t){t.d(x,{c:function(){return S}});var e=t(74512),n=t(8471),f=t(72850),T=t(9026),y=t(87933),b=t(49372);const W=(0,n.ZP)(f.x)`
3
- height: ${24/16}rem;
4
- width: ${24/16}rem;
5
- border-radius: 50%;
6
- display: flex;
7
- justify-content: center;
8
- align-items: center;
9
-
10
- svg {
11
- height: ${10/16}rem;
12
- width: ${10/16}rem;
13
- }
14
-
15
- svg path {
16
- fill: ${({theme:E})=>E.colors.primary600};
17
- }
18
- `,U=(0,n.ZP)(f.x)`
19
- border-radius: 0 0 ${({theme:E})=>E.borderRadius} ${({theme:E})=>E.borderRadius};
20
- display: block;
21
- width: 100%;
22
- border: none;
23
- `,S=({children:E,icon:F,...K})=>(0,e.jsxs)("div",{children:[(0,e.jsx)(T.i,{}),(0,e.jsx)(U,{as:"button",background:"primary100",padding:5,...K,children:(0,e.jsxs)(y.k,{children:[(0,e.jsx)(W,{"aria-hidden":!0,background:"primary200",children:F}),(0,e.jsx)(f.x,{paddingLeft:3,children:(0,e.jsx)(b.Z,{variant:"pi",fontWeight:"bold",textColor:"primary600",children:E})})]})})]})}}]);