@strapi/plugin-users-permissions 4.15.3 → 4.15.4

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 (125) hide show
  1. package/dist/_chunks/ar-20af7bfe.js +44 -0
  2. package/dist/_chunks/ar-20af7bfe.js.map +1 -0
  3. package/dist/_chunks/ar-56e57465.mjs +44 -0
  4. package/dist/_chunks/ar-56e57465.mjs.map +1 -0
  5. package/dist/_chunks/cs-0521a3c8.mjs +50 -0
  6. package/dist/_chunks/cs-0521a3c8.mjs.map +1 -0
  7. package/dist/_chunks/cs-6d7de06a.js +50 -0
  8. package/dist/_chunks/cs-6d7de06a.js.map +1 -0
  9. package/dist/_chunks/de-4af0884b.js +62 -0
  10. package/dist/_chunks/de-4af0884b.js.map +1 -0
  11. package/dist/_chunks/de-84fed33d.mjs +62 -0
  12. package/dist/_chunks/de-84fed33d.mjs.map +1 -0
  13. package/dist/_chunks/dk-21e25c4b.js +86 -0
  14. package/dist/_chunks/dk-21e25c4b.js.map +1 -0
  15. package/dist/_chunks/dk-d8302360.mjs +86 -0
  16. package/dist/_chunks/dk-d8302360.mjs.map +1 -0
  17. package/dist/_chunks/en-746a275e.js +86 -0
  18. package/dist/_chunks/en-746a275e.js.map +1 -0
  19. package/dist/_chunks/en-a610d7d0.mjs +86 -0
  20. package/dist/_chunks/en-a610d7d0.mjs.map +1 -0
  21. package/dist/_chunks/es-9d9ad31c.mjs +86 -0
  22. package/dist/_chunks/es-9d9ad31c.mjs.map +1 -0
  23. package/dist/_chunks/es-b6ae0f5e.js +86 -0
  24. package/dist/_chunks/es-b6ae0f5e.js.map +1 -0
  25. package/dist/_chunks/fr-0722d6cd.mjs +50 -0
  26. package/dist/_chunks/fr-0722d6cd.mjs.map +1 -0
  27. package/dist/_chunks/fr-dd77fc67.js +50 -0
  28. package/dist/_chunks/fr-dd77fc67.js.map +1 -0
  29. package/dist/_chunks/id-03eb1a4c.mjs +62 -0
  30. package/dist/_chunks/id-03eb1a4c.mjs.map +1 -0
  31. package/dist/_chunks/id-c19698f1.js +62 -0
  32. package/dist/_chunks/id-c19698f1.js.map +1 -0
  33. package/dist/_chunks/index-148dba6c.js +252 -0
  34. package/dist/_chunks/index-148dba6c.js.map +1 -0
  35. package/dist/_chunks/index-20426569.mjs +615 -0
  36. package/dist/_chunks/index-20426569.mjs.map +1 -0
  37. package/dist/_chunks/index-2968cbc6.mjs +253 -0
  38. package/dist/_chunks/index-2968cbc6.mjs.map +1 -0
  39. package/dist/_chunks/index-4e46753d.js +407 -0
  40. package/dist/_chunks/index-4e46753d.js.map +1 -0
  41. package/dist/_chunks/index-66250a65.mjs +300 -0
  42. package/dist/_chunks/index-66250a65.mjs.map +1 -0
  43. package/dist/_chunks/index-679ad8db.mjs +385 -0
  44. package/dist/_chunks/index-679ad8db.mjs.map +1 -0
  45. package/dist/_chunks/index-6bcc67ca.js +638 -0
  46. package/dist/_chunks/index-6bcc67ca.js.map +1 -0
  47. package/dist/_chunks/index-813b3a4d.mjs +1159 -0
  48. package/dist/_chunks/index-813b3a4d.mjs.map +1 -0
  49. package/dist/_chunks/index-9163f997.js +319 -0
  50. package/dist/_chunks/index-9163f997.js.map +1 -0
  51. package/dist/_chunks/index-a5573868.js +1191 -0
  52. package/dist/_chunks/index-a5573868.js.map +1 -0
  53. package/dist/_chunks/it-06b8d8a3.js +62 -0
  54. package/dist/_chunks/it-06b8d8a3.js.map +1 -0
  55. package/dist/_chunks/it-95fb8dcc.mjs +62 -0
  56. package/dist/_chunks/it-95fb8dcc.mjs.map +1 -0
  57. package/dist/_chunks/ja-557e03ee.mjs +48 -0
  58. package/dist/_chunks/ja-557e03ee.mjs.map +1 -0
  59. package/dist/_chunks/ja-e92e9903.js +48 -0
  60. package/dist/_chunks/ja-e92e9903.js.map +1 -0
  61. package/dist/_chunks/ko-5148326d.js +86 -0
  62. package/dist/_chunks/ko-5148326d.js.map +1 -0
  63. package/dist/_chunks/ko-d3b19f18.mjs +86 -0
  64. package/dist/_chunks/ko-d3b19f18.mjs.map +1 -0
  65. package/dist/_chunks/ms-1e62b726.js +49 -0
  66. package/dist/_chunks/ms-1e62b726.js.map +1 -0
  67. package/dist/_chunks/ms-b8a16476.mjs +49 -0
  68. package/dist/_chunks/ms-b8a16476.mjs.map +1 -0
  69. package/dist/_chunks/nl-66ef33aa.js +48 -0
  70. package/dist/_chunks/nl-66ef33aa.js.map +1 -0
  71. package/dist/_chunks/nl-fb114313.mjs +48 -0
  72. package/dist/_chunks/nl-fb114313.mjs.map +1 -0
  73. package/dist/_chunks/pl-5d70d4e8.mjs +86 -0
  74. package/dist/_chunks/pl-5d70d4e8.mjs.map +1 -0
  75. package/dist/_chunks/pl-7aa4933a.js +86 -0
  76. package/dist/_chunks/pl-7aa4933a.js.map +1 -0
  77. package/dist/_chunks/pt-95c2c76f.mjs +48 -0
  78. package/dist/_chunks/pt-95c2c76f.mjs.map +1 -0
  79. package/dist/_chunks/pt-BR-075f271a.mjs +44 -0
  80. package/dist/_chunks/pt-BR-075f271a.mjs.map +1 -0
  81. package/dist/_chunks/pt-BR-820fcd20.js +44 -0
  82. package/dist/_chunks/pt-BR-820fcd20.js.map +1 -0
  83. package/dist/_chunks/pt-a470d4e6.js +48 -0
  84. package/dist/_chunks/pt-a470d4e6.js.map +1 -0
  85. package/dist/_chunks/ru-625a0fe5.mjs +86 -0
  86. package/dist/_chunks/ru-625a0fe5.mjs.map +1 -0
  87. package/dist/_chunks/ru-cd0d1ac9.js +86 -0
  88. package/dist/_chunks/ru-cd0d1ac9.js.map +1 -0
  89. package/dist/_chunks/sk-495ecbe4.mjs +50 -0
  90. package/dist/_chunks/sk-495ecbe4.mjs.map +1 -0
  91. package/dist/_chunks/sk-8334fbf7.js +50 -0
  92. package/dist/_chunks/sk-8334fbf7.js.map +1 -0
  93. package/dist/_chunks/sv-137a2f79.js +86 -0
  94. package/dist/_chunks/sv-137a2f79.js.map +1 -0
  95. package/dist/_chunks/sv-60a1fabf.mjs +86 -0
  96. package/dist/_chunks/sv-60a1fabf.mjs.map +1 -0
  97. package/dist/_chunks/th-7fe328ef.js +60 -0
  98. package/dist/_chunks/th-7fe328ef.js.map +1 -0
  99. package/dist/_chunks/th-f633d0ed.mjs +60 -0
  100. package/dist/_chunks/th-f633d0ed.mjs.map +1 -0
  101. package/dist/_chunks/tr-16211986.mjs +85 -0
  102. package/dist/_chunks/tr-16211986.mjs.map +1 -0
  103. package/dist/_chunks/tr-eae92999.js +85 -0
  104. package/dist/_chunks/tr-eae92999.js.map +1 -0
  105. package/dist/_chunks/uk-0c33935a.js +49 -0
  106. package/dist/_chunks/uk-0c33935a.js.map +1 -0
  107. package/dist/_chunks/uk-f1fae414.mjs +49 -0
  108. package/dist/_chunks/uk-f1fae414.mjs.map +1 -0
  109. package/dist/_chunks/vi-b5d581a1.js +50 -0
  110. package/dist/_chunks/vi-b5d581a1.js.map +1 -0
  111. package/dist/_chunks/vi-e8fd97e4.mjs +50 -0
  112. package/dist/_chunks/vi-e8fd97e4.mjs.map +1 -0
  113. package/dist/_chunks/zh-284557f3.mjs +86 -0
  114. package/dist/_chunks/zh-284557f3.mjs.map +1 -0
  115. package/dist/_chunks/zh-9babf307.js +86 -0
  116. package/dist/_chunks/zh-9babf307.js.map +1 -0
  117. package/dist/_chunks/zh-Hans-68e4b43a.mjs +86 -0
  118. package/dist/_chunks/zh-Hans-68e4b43a.mjs.map +1 -0
  119. package/dist/_chunks/zh-Hans-baae8c78.js +86 -0
  120. package/dist/_chunks/zh-Hans-baae8c78.js.map +1 -0
  121. package/dist/admin/index.js +5 -0
  122. package/dist/admin/index.js.map +1 -0
  123. package/dist/admin/index.mjs +6 -0
  124. package/dist/admin/index.mjs.map +1 -0
  125. package/package.json +7 -6
@@ -0,0 +1,253 @@
1
+ import { prefixPluginTranslations } from "@strapi/helper-plugin";
2
+ const __variableDynamicImportRuntimeHelper = (glob, path) => {
3
+ const v = glob[path];
4
+ if (v) {
5
+ return typeof v === "function" ? v() : Promise.resolve(v);
6
+ }
7
+ return new Promise((_, reject) => {
8
+ (typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(reject.bind(null, new Error("Unknown variable dynamic import: " + path)));
9
+ });
10
+ };
11
+ const name$1 = "@strapi/plugin-users-permissions";
12
+ const version = "4.15.4";
13
+ const description = "Protect your API with a full-authentication process based on JWT";
14
+ const repository = {
15
+ type: "git",
16
+ url: "git://github.com/strapi/strapi.git"
17
+ };
18
+ const license = "SEE LICENSE IN LICENSE";
19
+ const author = {
20
+ name: "Strapi Solutions SAS",
21
+ email: "hi@strapi.io",
22
+ url: "https://strapi.io"
23
+ };
24
+ const maintainers = [
25
+ {
26
+ name: "Strapi Solutions SAS",
27
+ email: "hi@strapi.io",
28
+ url: "https://strapi.io"
29
+ }
30
+ ];
31
+ const exports = {
32
+ "./strapi-admin": {
33
+ source: "./admin/src/index.js",
34
+ "import": "./dist/admin/index.mjs",
35
+ require: "./dist/admin/index.js",
36
+ "default": "./dist/admin/index.js"
37
+ },
38
+ "./strapi-server": {
39
+ source: "./strapi-server.js",
40
+ require: "./strapi-server.js",
41
+ "default": "./strapi-server.js"
42
+ },
43
+ "./package.json": "./package.json"
44
+ };
45
+ const scripts = {
46
+ build: "pack-up build",
47
+ clean: "run -T rimraf dist",
48
+ lint: "run -T eslint .",
49
+ prepublishOnly: "yarn clean && yarn build",
50
+ "test:front": "run -T cross-env IS_EE=true jest --config ./jest.config.front.js",
51
+ "test:front:ce": "run -T cross-env IS_EE=false jest --config ./jest.config.front.js",
52
+ "test:front:watch": "run -T cross-env IS_EE=true jest --config ./jest.config.front.js --watchAll",
53
+ "test:front:watch:ce": "run -T cross-env IS_EE=false jest --config ./jest.config.front.js --watchAll",
54
+ "test:unit": "run -T jest",
55
+ "test:unit:watch": "run -T jest --watch",
56
+ watch: "pack-up watch"
57
+ };
58
+ const dependencies = {
59
+ "@strapi/design-system": "1.13.0",
60
+ "@strapi/helper-plugin": "4.15.4",
61
+ "@strapi/icons": "1.13.0",
62
+ "@strapi/utils": "4.15.4",
63
+ bcryptjs: "2.4.3",
64
+ formik: "2.4.0",
65
+ "grant-koa": "5.4.8",
66
+ immer: "9.0.19",
67
+ jsonwebtoken: "9.0.0",
68
+ "jwk-to-pem": "2.0.5",
69
+ koa: "2.13.4",
70
+ "koa2-ratelimit": "^1.1.2",
71
+ lodash: "4.17.21",
72
+ "prop-types": "^15.8.1",
73
+ purest: "4.0.2",
74
+ "react-intl": "6.4.1",
75
+ "react-query": "3.39.3",
76
+ "react-redux": "8.1.1",
77
+ "url-join": "4.0.1",
78
+ yup: "0.32.9"
79
+ };
80
+ const devDependencies = {
81
+ "@strapi/pack-up": "4.15.4",
82
+ "@strapi/strapi": "4.15.4",
83
+ "@testing-library/dom": "9.2.0",
84
+ "@testing-library/react": "14.0.0",
85
+ "@testing-library/user-event": "14.4.3",
86
+ msw: "1.3.0",
87
+ react: "^18.2.0",
88
+ "react-dom": "^18.2.0",
89
+ "react-router-dom": "5.3.4",
90
+ "styled-components": "5.3.3"
91
+ };
92
+ const peerDependencies = {
93
+ "@strapi/strapi": "^4.0.0",
94
+ react: "^17.0.0 || ^18.0.0",
95
+ "react-dom": "^17.0.0 || ^18.0.0",
96
+ "react-router-dom": "^5.2.0",
97
+ "styled-components": "^5.2.1"
98
+ };
99
+ const engines = {
100
+ node: ">=18.0.0 <=20.x.x",
101
+ npm: ">=6.0.0"
102
+ };
103
+ const strapi = {
104
+ displayName: "Roles & Permissions",
105
+ name: "users-permissions",
106
+ description: "Protect your API with a full authentication process based on JWT. This plugin comes also with an ACL strategy that allows you to manage the permissions between the groups of users.",
107
+ required: true,
108
+ kind: "plugin"
109
+ };
110
+ const gitHead = "da634b09510db5ec9ab7163670ae903f44929752";
111
+ const pluginPkg = {
112
+ name: name$1,
113
+ version,
114
+ description,
115
+ repository,
116
+ license,
117
+ author,
118
+ maintainers,
119
+ exports,
120
+ scripts,
121
+ dependencies,
122
+ devDependencies,
123
+ peerDependencies,
124
+ engines,
125
+ strapi,
126
+ gitHead
127
+ };
128
+ const PERMISSIONS = {
129
+ // Roles
130
+ accessRoles: [
131
+ { action: "plugin::users-permissions.roles.create", subject: null },
132
+ { action: "plugin::users-permissions.roles.read", subject: null }
133
+ ],
134
+ createRole: [{ action: "plugin::users-permissions.roles.create", subject: null }],
135
+ deleteRole: [{ action: "plugin::users-permissions.roles.delete", subject: null }],
136
+ readRoles: [{ action: "plugin::users-permissions.roles.read", subject: null }],
137
+ updateRole: [{ action: "plugin::users-permissions.roles.update", subject: null }],
138
+ // AdvancedSettings
139
+ readAdvancedSettings: [
140
+ { action: "plugin::users-permissions.advanced-settings.read", subject: null }
141
+ ],
142
+ updateAdvancedSettings: [
143
+ { action: "plugin::users-permissions.advanced-settings.update", subject: null }
144
+ ],
145
+ // Emails
146
+ readEmailTemplates: [{ action: "plugin::users-permissions.email-templates.read", subject: null }],
147
+ updateEmailTemplates: [
148
+ { action: "plugin::users-permissions.email-templates.update", subject: null }
149
+ ],
150
+ // Providers
151
+ readProviders: [{ action: "plugin::users-permissions.providers.read", subject: null }],
152
+ updateProviders: [{ action: "plugin::users-permissions.providers.update", subject: null }]
153
+ };
154
+ const pluginId = pluginPkg.name.replace(/^@strapi\/plugin-/i, "");
155
+ const getTrad = (id) => `${pluginId}.${id}`;
156
+ const name = pluginPkg.strapi.name;
157
+ const index = {
158
+ register(app) {
159
+ app.createSettingSection(
160
+ {
161
+ id: "users-permissions",
162
+ intlLabel: {
163
+ id: getTrad("Settings.section-label"),
164
+ defaultMessage: "Users & Permissions plugin"
165
+ }
166
+ },
167
+ [
168
+ {
169
+ intlLabel: {
170
+ id: "global.roles",
171
+ defaultMessage: "Roles"
172
+ },
173
+ id: "roles",
174
+ to: `/settings/users-permissions/roles`,
175
+ async Component() {
176
+ const component = await import("./index-813b3a4d.mjs");
177
+ return component;
178
+ },
179
+ permissions: PERMISSIONS.accessRoles
180
+ },
181
+ {
182
+ intlLabel: {
183
+ id: getTrad("HeaderNav.link.providers"),
184
+ defaultMessage: "Providers"
185
+ },
186
+ id: "providers",
187
+ to: `/settings/users-permissions/providers`,
188
+ async Component() {
189
+ const component = await import("./index-20426569.mjs");
190
+ return component;
191
+ },
192
+ permissions: PERMISSIONS.readProviders
193
+ },
194
+ {
195
+ intlLabel: {
196
+ id: getTrad("HeaderNav.link.emailTemplates"),
197
+ defaultMessage: "Email templates"
198
+ },
199
+ id: "email-templates",
200
+ to: `/settings/users-permissions/email-templates`,
201
+ async Component() {
202
+ const component = await import("./index-679ad8db.mjs");
203
+ return component;
204
+ },
205
+ permissions: PERMISSIONS.readEmailTemplates
206
+ },
207
+ {
208
+ intlLabel: {
209
+ id: getTrad("HeaderNav.link.advancedSettings"),
210
+ defaultMessage: "Advanced Settings"
211
+ },
212
+ id: "advanced-settings",
213
+ to: `/settings/users-permissions/advanced-settings`,
214
+ async Component() {
215
+ const component = await import("./index-66250a65.mjs");
216
+ return component;
217
+ },
218
+ permissions: PERMISSIONS.readAdvancedSettings
219
+ }
220
+ ]
221
+ );
222
+ app.registerPlugin({
223
+ id: "users-permissions",
224
+ name
225
+ });
226
+ },
227
+ bootstrap() {
228
+ },
229
+ async registerTrads({ locales }) {
230
+ const importedTrads = await Promise.all(
231
+ locales.map((locale) => {
232
+ return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/ar.json": () => import("./ar-56e57465.mjs"), "./translations/cs.json": () => import("./cs-0521a3c8.mjs"), "./translations/de.json": () => import("./de-84fed33d.mjs"), "./translations/dk.json": () => import("./dk-d8302360.mjs"), "./translations/en.json": () => import("./en-a610d7d0.mjs"), "./translations/es.json": () => import("./es-9d9ad31c.mjs"), "./translations/fr.json": () => import("./fr-0722d6cd.mjs"), "./translations/id.json": () => import("./id-03eb1a4c.mjs"), "./translations/it.json": () => import("./it-95fb8dcc.mjs"), "./translations/ja.json": () => import("./ja-557e03ee.mjs"), "./translations/ko.json": () => import("./ko-d3b19f18.mjs"), "./translations/ms.json": () => import("./ms-b8a16476.mjs"), "./translations/nl.json": () => import("./nl-fb114313.mjs"), "./translations/pl.json": () => import("./pl-5d70d4e8.mjs"), "./translations/pt-BR.json": () => import("./pt-BR-075f271a.mjs"), "./translations/pt.json": () => import("./pt-95c2c76f.mjs"), "./translations/ru.json": () => import("./ru-625a0fe5.mjs"), "./translations/sk.json": () => import("./sk-495ecbe4.mjs"), "./translations/sv.json": () => import("./sv-60a1fabf.mjs"), "./translations/th.json": () => import("./th-f633d0ed.mjs"), "./translations/tr.json": () => import("./tr-16211986.mjs"), "./translations/uk.json": () => import("./uk-f1fae414.mjs"), "./translations/vi.json": () => import("./vi-e8fd97e4.mjs"), "./translations/zh-Hans.json": () => import("./zh-Hans-68e4b43a.mjs"), "./translations/zh.json": () => import("./zh-284557f3.mjs") }), `./translations/${locale}.json`).then(({ default: data }) => {
233
+ return {
234
+ data: prefixPluginTranslations(data, "users-permissions"),
235
+ locale
236
+ };
237
+ }).catch(() => {
238
+ return {
239
+ data: {},
240
+ locale
241
+ };
242
+ });
243
+ })
244
+ );
245
+ return Promise.resolve(importedTrads);
246
+ }
247
+ };
248
+ export {
249
+ PERMISSIONS as P,
250
+ getTrad as g,
251
+ index as i
252
+ };
253
+ //# sourceMappingURL=index-2968cbc6.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-2968cbc6.mjs","sources":["../../admin/src/constants.js","../../admin/src/pluginId.js","../../admin/src/utils/getTrad.js","../../admin/src/index.js"],"sourcesContent":["export const PERMISSIONS = {\n // Roles\n accessRoles: [\n { action: 'plugin::users-permissions.roles.create', subject: null },\n { action: 'plugin::users-permissions.roles.read', subject: null },\n ],\n createRole: [{ action: 'plugin::users-permissions.roles.create', subject: null }],\n deleteRole: [{ action: 'plugin::users-permissions.roles.delete', subject: null }],\n readRoles: [{ action: 'plugin::users-permissions.roles.read', subject: null }],\n updateRole: [{ action: 'plugin::users-permissions.roles.update', subject: null }],\n\n // AdvancedSettings\n readAdvancedSettings: [\n { action: 'plugin::users-permissions.advanced-settings.read', subject: null },\n ],\n updateAdvancedSettings: [\n { action: 'plugin::users-permissions.advanced-settings.update', subject: null },\n ],\n\n // Emails\n readEmailTemplates: [{ action: 'plugin::users-permissions.email-templates.read', subject: null }],\n updateEmailTemplates: [\n { action: 'plugin::users-permissions.email-templates.update', subject: null },\n ],\n\n // Providers\n readProviders: [{ action: 'plugin::users-permissions.providers.read', subject: null }],\n updateProviders: [{ action: 'plugin::users-permissions.providers.update', subject: null }],\n};\n","import pluginPkg from '../../package.json';\n\nconst pluginId = pluginPkg.name.replace(/^@strapi\\/plugin-/i, '');\n\nexport default pluginId;\n","import pluginId from '../pluginId';\n\nconst getTrad = (id) => `${pluginId}.${id}`;\n\nexport default getTrad;\n","// NOTE TO PLUGINS DEVELOPERS:\n// If you modify this file by adding new options to the plugin entry point\n// Here's the file: strapi/docs/3.0.0-beta.x/plugin-development/frontend-field-api.md\n// Here's the file: strapi/docs/3.0.0-beta.x/guides/registering-a-field-in-admin.md\n// Also the strapi-generate-plugins/files/admin/src/index.js needs to be updated\n// IF THE DOC IS NOT UPDATED THE PULL REQUEST WILL NOT BE MERGED\nimport { prefixPluginTranslations } from '@strapi/helper-plugin';\n\nimport pluginPkg from '../../package.json';\n\nimport { PERMISSIONS } from './constants';\nimport getTrad from './utils/getTrad';\n\nconst name = pluginPkg.strapi.name;\n\nexport default {\n register(app) {\n // Create the plugin's settings section\n app.createSettingSection(\n {\n id: 'users-permissions',\n intlLabel: {\n id: getTrad('Settings.section-label'),\n defaultMessage: 'Users & Permissions plugin',\n },\n },\n [\n {\n intlLabel: {\n id: 'global.roles',\n defaultMessage: 'Roles',\n },\n id: 'roles',\n to: `/settings/users-permissions/roles`,\n async Component() {\n const component = await import('./pages/Roles');\n\n return component;\n },\n permissions: PERMISSIONS.accessRoles,\n },\n {\n intlLabel: {\n id: getTrad('HeaderNav.link.providers'),\n defaultMessage: 'Providers',\n },\n id: 'providers',\n to: `/settings/users-permissions/providers`,\n async Component() {\n const component = await import('./pages/Providers');\n\n return component;\n },\n permissions: PERMISSIONS.readProviders,\n },\n {\n intlLabel: {\n id: getTrad('HeaderNav.link.emailTemplates'),\n defaultMessage: 'Email templates',\n },\n id: 'email-templates',\n to: `/settings/users-permissions/email-templates`,\n async Component() {\n const component = await import('./pages/EmailTemplates');\n\n return component;\n },\n permissions: PERMISSIONS.readEmailTemplates,\n },\n {\n intlLabel: {\n id: getTrad('HeaderNav.link.advancedSettings'),\n defaultMessage: 'Advanced Settings',\n },\n id: 'advanced-settings',\n to: `/settings/users-permissions/advanced-settings`,\n async Component() {\n const component = await import('./pages/AdvancedSettings');\n\n return component;\n },\n permissions: PERMISSIONS.readAdvancedSettings,\n },\n ]\n );\n\n app.registerPlugin({\n id: 'users-permissions',\n name,\n });\n },\n bootstrap() {},\n async registerTrads({ locales }) {\n const importedTrads = await Promise.all(\n locales.map((locale) => {\n return import(`./translations/${locale}.json`)\n .then(({ default: data }) => {\n return {\n data: prefixPluginTranslations(data, 'users-permissions'),\n locale,\n };\n })\n .catch(() => {\n return {\n data: {},\n locale,\n };\n });\n })\n );\n\n return Promise.resolve(importedTrads);\n },\n};\n"],"names":[],"mappings":"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"}
@@ -0,0 +1,407 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const React = require("react");
5
+ const designSystem = require("@strapi/design-system");
6
+ const helperPlugin = require("@strapi/helper-plugin");
7
+ const reactIntl = require("react-intl");
8
+ const reactQuery = require("react-query");
9
+ const index = require("./index-148dba6c.js");
10
+ require("lodash/isEmpty");
11
+ const v2 = require("@strapi/design-system/v2");
12
+ const formik = require("formik");
13
+ const PropTypes = require("prop-types");
14
+ const yup = require("yup");
15
+ const icons = require("@strapi/icons");
16
+ const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
17
+ function _interopNamespace(e) {
18
+ if (e && e.__esModule)
19
+ return e;
20
+ const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
21
+ if (e) {
22
+ for (const k in e) {
23
+ if (k !== "default") {
24
+ const d = Object.getOwnPropertyDescriptor(e, k);
25
+ Object.defineProperty(n, k, d.get ? d : {
26
+ enumerable: true,
27
+ get: () => e[k]
28
+ });
29
+ }
30
+ }
31
+ }
32
+ n.default = e;
33
+ return Object.freeze(n);
34
+ }
35
+ const React__namespace = /* @__PURE__ */ _interopNamespace(React);
36
+ const PropTypes__default = /* @__PURE__ */ _interopDefault(PropTypes);
37
+ const yup__namespace = /* @__PURE__ */ _interopNamespace(yup);
38
+ const schema = yup__namespace.object().shape({
39
+ options: yup__namespace.object().shape({
40
+ from: yup__namespace.object().shape({
41
+ name: yup__namespace.string().required(helperPlugin.translatedErrors.required),
42
+ email: yup__namespace.string().email(helperPlugin.translatedErrors.email).required(helperPlugin.translatedErrors.required)
43
+ }).required(),
44
+ response_email: yup__namespace.string().email(helperPlugin.translatedErrors.email),
45
+ object: yup__namespace.string().required(helperPlugin.translatedErrors.required),
46
+ message: yup__namespace.string().required(helperPlugin.translatedErrors.required)
47
+ }).required(helperPlugin.translatedErrors.required)
48
+ });
49
+ const EmailForm = ({ template, onToggle, onSubmit }) => {
50
+ const { formatMessage } = reactIntl.useIntl();
51
+ return /* @__PURE__ */ jsxRuntime.jsxs(
52
+ designSystem.ModalLayout,
53
+ {
54
+ onClose: onToggle,
55
+ labelledBy: `${formatMessage({
56
+ id: index.getTrad("PopUpForm.header.edit.email-templates"),
57
+ defaultMessage: "Edit email template"
58
+ })}, ${formatMessage({ id: index.getTrad(template.display), defaultMessage: template.display })}`,
59
+ children: [
60
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.ModalHeader, { children: /* @__PURE__ */ jsxRuntime.jsxs(
61
+ v2.Breadcrumbs,
62
+ {
63
+ label: `${formatMessage({
64
+ id: index.getTrad("PopUpForm.header.edit.email-templates"),
65
+ defaultMessage: "Edit email template"
66
+ })}, ${formatMessage({
67
+ id: index.getTrad(template.display),
68
+ defaultMessage: template.display
69
+ })}`,
70
+ children: [
71
+ /* @__PURE__ */ jsxRuntime.jsx(v2.Crumb, { children: formatMessage({
72
+ id: index.getTrad("PopUpForm.header.edit.email-templates"),
73
+ defaultMessage: "Edit email template"
74
+ }) }),
75
+ /* @__PURE__ */ jsxRuntime.jsx(v2.Crumb, { isCurrent: true, children: formatMessage({ id: index.getTrad(template.display), defaultMessage: template.display }) })
76
+ ]
77
+ }
78
+ ) }),
79
+ /* @__PURE__ */ jsxRuntime.jsx(
80
+ formik.Formik,
81
+ {
82
+ onSubmit,
83
+ initialValues: template,
84
+ validateOnChange: false,
85
+ validationSchema: schema,
86
+ enableReinitialize: true,
87
+ children: ({ errors, values, handleChange, isSubmitting }) => {
88
+ return /* @__PURE__ */ jsxRuntime.jsxs(helperPlugin.Form, { children: [
89
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.ModalBody, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Grid, { gap: 5, children: [
90
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.GridItem, { col: 6, s: 12, children: /* @__PURE__ */ jsxRuntime.jsx(
91
+ helperPlugin.GenericInput,
92
+ {
93
+ intlLabel: {
94
+ id: index.getTrad("PopUpForm.Email.options.from.name.label"),
95
+ defaultMessage: "Shipper name"
96
+ },
97
+ name: "options.from.name",
98
+ onChange: handleChange,
99
+ value: values.options.from.name,
100
+ error: errors?.options?.from?.name,
101
+ type: "text"
102
+ }
103
+ ) }),
104
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.GridItem, { col: 6, s: 12, children: /* @__PURE__ */ jsxRuntime.jsx(
105
+ helperPlugin.GenericInput,
106
+ {
107
+ intlLabel: {
108
+ id: index.getTrad("PopUpForm.Email.options.from.email.label"),
109
+ defaultMessage: "Shipper email"
110
+ },
111
+ name: "options.from.email",
112
+ onChange: handleChange,
113
+ value: values.options.from.email,
114
+ error: errors?.options?.from?.email,
115
+ type: "text"
116
+ }
117
+ ) }),
118
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.GridItem, { col: 6, s: 12, children: /* @__PURE__ */ jsxRuntime.jsx(
119
+ helperPlugin.GenericInput,
120
+ {
121
+ intlLabel: {
122
+ id: index.getTrad("PopUpForm.Email.options.response_email.label"),
123
+ defaultMessage: "Response email"
124
+ },
125
+ name: "options.response_email",
126
+ onChange: handleChange,
127
+ value: values.options.response_email,
128
+ error: errors?.options?.response_email,
129
+ type: "text"
130
+ }
131
+ ) }),
132
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.GridItem, { col: 6, s: 12, children: /* @__PURE__ */ jsxRuntime.jsx(
133
+ helperPlugin.GenericInput,
134
+ {
135
+ intlLabel: {
136
+ id: index.getTrad("PopUpForm.Email.options.object.label"),
137
+ defaultMessage: "Subject"
138
+ },
139
+ name: "options.object",
140
+ onChange: handleChange,
141
+ value: values.options.object,
142
+ error: errors?.options?.object,
143
+ type: "text"
144
+ }
145
+ ) }),
146
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.GridItem, { col: 12, s: 12, children: /* @__PURE__ */ jsxRuntime.jsx(
147
+ designSystem.Textarea,
148
+ {
149
+ label: formatMessage({
150
+ id: index.getTrad("PopUpForm.Email.options.message.label"),
151
+ defaultMessage: "Message"
152
+ }),
153
+ id: "options.message",
154
+ onChange: handleChange,
155
+ value: values.options.message,
156
+ error: errors?.options?.message && formatMessage({
157
+ id: errors.options.message,
158
+ defaultMessage: errors.options.message
159
+ })
160
+ }
161
+ ) })
162
+ ] }) }),
163
+ /* @__PURE__ */ jsxRuntime.jsx(
164
+ designSystem.ModalFooter,
165
+ {
166
+ startActions: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: onToggle, variant: "tertiary", children: "Cancel" }),
167
+ endActions: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { loading: isSubmitting, type: "submit", children: "Finish" })
168
+ }
169
+ )
170
+ ] });
171
+ }
172
+ }
173
+ )
174
+ ]
175
+ }
176
+ );
177
+ };
178
+ EmailForm.propTypes = {
179
+ template: PropTypes__default.default.shape({
180
+ display: PropTypes__default.default.string,
181
+ icon: PropTypes__default.default.string,
182
+ options: PropTypes__default.default.shape({
183
+ from: PropTypes__default.default.shape({
184
+ name: PropTypes__default.default.string,
185
+ email: PropTypes__default.default.string
186
+ }),
187
+ message: PropTypes__default.default.string,
188
+ object: PropTypes__default.default.string,
189
+ response_email: PropTypes__default.default.string
190
+ })
191
+ }).isRequired,
192
+ onSubmit: PropTypes__default.default.func.isRequired,
193
+ onToggle: PropTypes__default.default.func.isRequired
194
+ };
195
+ const EmailTable = ({ canUpdate, onEditClick }) => {
196
+ const { formatMessage } = reactIntl.useIntl();
197
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Table, { colCount: 3, rowCount: 3, children: [
198
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Thead, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
199
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { width: "1%", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { children: formatMessage({
200
+ id: index.getTrad("Email.template.table.icon.label"),
201
+ defaultMessage: "icon"
202
+ }) }) }),
203
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: formatMessage({
204
+ id: index.getTrad("Email.template.table.name.label"),
205
+ defaultMessage: "name"
206
+ }) }) }),
207
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { width: "1%", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { children: formatMessage({
208
+ id: index.getTrad("Email.template.table.action.label"),
209
+ defaultMessage: "action"
210
+ }) }) })
211
+ ] }) }),
212
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tbody, { children: [
213
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { ...helperPlugin.onRowClick({ fn: () => onEditClick("reset_password") }), children: [
214
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(
215
+ icons.Refresh,
216
+ {
217
+ "aria-label": formatMessage({
218
+ id: "global.reset-password",
219
+ defaultMessage: "Reset password"
220
+ })
221
+ }
222
+ ) }) }),
223
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: formatMessage({
224
+ id: "global.reset-password",
225
+ defaultMessage: "Reset password"
226
+ }) }) }),
227
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { ...helperPlugin.stopPropagation, children: /* @__PURE__ */ jsxRuntime.jsx(
228
+ designSystem.IconButton,
229
+ {
230
+ onClick: () => onEditClick("reset_password"),
231
+ label: formatMessage({
232
+ id: index.getTrad("Email.template.form.edit.label"),
233
+ defaultMessage: "Edit a template"
234
+ }),
235
+ noBorder: true,
236
+ icon: canUpdate && /* @__PURE__ */ jsxRuntime.jsx(icons.Pencil, {})
237
+ }
238
+ ) })
239
+ ] }),
240
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { ...helperPlugin.onRowClick({ fn: () => onEditClick("email_confirmation") }), children: [
241
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(
242
+ icons.Check,
243
+ {
244
+ "aria-label": formatMessage({
245
+ id: index.getTrad("Email.template.email_confirmation"),
246
+ defaultMessage: "Email address confirmation"
247
+ })
248
+ }
249
+ ) }) }),
250
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: formatMessage({
251
+ id: index.getTrad("Email.template.email_confirmation"),
252
+ defaultMessage: "Email address confirmation"
253
+ }) }) }),
254
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { ...helperPlugin.stopPropagation, children: /* @__PURE__ */ jsxRuntime.jsx(
255
+ designSystem.IconButton,
256
+ {
257
+ onClick: () => onEditClick("email_confirmation"),
258
+ label: formatMessage({
259
+ id: index.getTrad("Email.template.form.edit.label"),
260
+ defaultMessage: "Edit a template"
261
+ }),
262
+ noBorder: true,
263
+ icon: canUpdate && /* @__PURE__ */ jsxRuntime.jsx(icons.Pencil, {})
264
+ }
265
+ ) })
266
+ ] })
267
+ ] })
268
+ ] });
269
+ };
270
+ EmailTable.propTypes = {
271
+ canUpdate: PropTypes__default.default.bool.isRequired,
272
+ onEditClick: PropTypes__default.default.func.isRequired
273
+ };
274
+ const ProtectedEmailTemplatesPage = () => /* @__PURE__ */ jsxRuntime.jsx(helperPlugin.CheckPagePermissions, { permissions: index.PERMISSIONS.readEmailTemplates, children: /* @__PURE__ */ jsxRuntime.jsx(EmailTemplatesPage, {}) });
275
+ const EmailTemplatesPage = () => {
276
+ const { formatMessage } = reactIntl.useIntl();
277
+ const { trackUsage } = helperPlugin.useTracking();
278
+ const { notifyStatus } = designSystem.useNotifyAT();
279
+ const toggleNotification = helperPlugin.useNotification();
280
+ const { lockApp, unlockApp } = helperPlugin.useOverlayBlocker();
281
+ const queryClient = reactQuery.useQueryClient();
282
+ const { get, put } = helperPlugin.useFetchClient();
283
+ const { formatAPIError } = helperPlugin.useAPIErrorHandler();
284
+ helperPlugin.useFocusWhenNavigate();
285
+ const [isModalOpen, setIsModalOpen] = React__namespace.useState(false);
286
+ const [templateToEdit, setTemplateToEdit] = React__namespace.useState(null);
287
+ const {
288
+ isLoading: isLoadingForPermissions,
289
+ allowedActions: { canUpdate }
290
+ } = helperPlugin.useRBAC({ update: index.PERMISSIONS.updateEmailTemplates });
291
+ const { isLoading: isLoadingData, data } = reactQuery.useQuery(
292
+ ["users-permissions", "email-templates"],
293
+ async () => {
294
+ const { data: data2 } = await get("/users-permissions/email-templates");
295
+ return data2;
296
+ },
297
+ {
298
+ onSuccess() {
299
+ notifyStatus(
300
+ formatMessage({
301
+ id: index.getTrad("Email.template.data.loaded"),
302
+ defaultMessage: "Email templates has been loaded"
303
+ })
304
+ );
305
+ },
306
+ onError(error) {
307
+ toggleNotification({
308
+ type: "warning",
309
+ message: formatAPIError(error)
310
+ });
311
+ }
312
+ }
313
+ );
314
+ const isLoading = isLoadingForPermissions || isLoadingData;
315
+ const handleToggle = () => {
316
+ setIsModalOpen((prev) => !prev);
317
+ };
318
+ const handleEditClick = (template) => {
319
+ setTemplateToEdit(template);
320
+ handleToggle();
321
+ };
322
+ const submitMutation = reactQuery.useMutation(
323
+ (body) => put("/users-permissions/email-templates", { "email-templates": body }),
324
+ {
325
+ async onSuccess() {
326
+ await queryClient.invalidateQueries(["users-permissions", "email-templates"]);
327
+ toggleNotification({
328
+ type: "success",
329
+ message: { id: "notification.success.saved", defaultMessage: "Saved" }
330
+ });
331
+ trackUsage("didEditEmailTemplates");
332
+ unlockApp();
333
+ handleToggle();
334
+ },
335
+ onError(error) {
336
+ toggleNotification({
337
+ type: "warning",
338
+ message: formatAPIError(error)
339
+ });
340
+ unlockApp();
341
+ },
342
+ refetchActive: true
343
+ }
344
+ );
345
+ const handleSubmit = (body) => {
346
+ lockApp();
347
+ trackUsage("willEditEmailTemplates");
348
+ const editedTemplates = { ...data, [templateToEdit]: body };
349
+ submitMutation.mutate(editedTemplates);
350
+ };
351
+ if (isLoading) {
352
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Main, { "aria-busy": "true", children: [
353
+ /* @__PURE__ */ jsxRuntime.jsx(
354
+ helperPlugin.SettingsPageTitle,
355
+ {
356
+ name: formatMessage({
357
+ id: index.getTrad("HeaderNav.link.emailTemplates"),
358
+ defaultMessage: "Email templates"
359
+ })
360
+ }
361
+ ),
362
+ /* @__PURE__ */ jsxRuntime.jsx(
363
+ designSystem.HeaderLayout,
364
+ {
365
+ title: formatMessage({
366
+ id: index.getTrad("HeaderNav.link.emailTemplates"),
367
+ defaultMessage: "Email templates"
368
+ })
369
+ }
370
+ ),
371
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.ContentLayout, { children: /* @__PURE__ */ jsxRuntime.jsx(helperPlugin.LoadingIndicatorPage, {}) })
372
+ ] });
373
+ }
374
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Main, { "aria-busy": submitMutation.isLoading, children: [
375
+ /* @__PURE__ */ jsxRuntime.jsx(
376
+ helperPlugin.SettingsPageTitle,
377
+ {
378
+ name: formatMessage({
379
+ id: index.getTrad("HeaderNav.link.emailTemplates"),
380
+ defaultMessage: "Email templates"
381
+ })
382
+ }
383
+ ),
384
+ /* @__PURE__ */ jsxRuntime.jsx(
385
+ designSystem.HeaderLayout,
386
+ {
387
+ title: formatMessage({
388
+ id: index.getTrad("HeaderNav.link.emailTemplates"),
389
+ defaultMessage: "Email templates"
390
+ })
391
+ }
392
+ ),
393
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.ContentLayout, { children: [
394
+ /* @__PURE__ */ jsxRuntime.jsx(EmailTable, { onEditClick: handleEditClick, canUpdate }),
395
+ isModalOpen && /* @__PURE__ */ jsxRuntime.jsx(
396
+ EmailForm,
397
+ {
398
+ template: data[templateToEdit],
399
+ onToggle: handleToggle,
400
+ onSubmit: handleSubmit
401
+ }
402
+ )
403
+ ] })
404
+ ] });
405
+ };
406
+ exports.default = ProtectedEmailTemplatesPage;
407
+ //# sourceMappingURL=index-4e46753d.js.map