@strapi/plugin-documentation 4.20.5 → 5.0.0-alpha.1

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 (64) hide show
  1. package/admin/src/hooks/useDocumentation.js +9 -7
  2. package/admin/src/index.js +5 -19
  3. package/admin/src/pages/PluginPage/index.jsx +12 -28
  4. package/admin/src/pages/PluginPage/tests/index.test.jsx +13 -14
  5. package/admin/src/pages/SettingsPage/index.jsx +138 -146
  6. package/admin/src/pages/SettingsPage/tests/index.test.jsx +6 -13
  7. package/admin/src/utils/prefixPluginTranslations.js +13 -0
  8. package/dist/_chunks/EditViewPage-kgrZ8rEg-N3ylaYYT.mjs +84382 -0
  9. package/dist/_chunks/EditViewPage-kgrZ8rEg-N3ylaYYT.mjs.map +1 -0
  10. package/dist/_chunks/EditViewPage-kgrZ8rEg-QXBi74pP.js +84410 -0
  11. package/dist/_chunks/EditViewPage-kgrZ8rEg-QXBi74pP.js.map +1 -0
  12. package/dist/_chunks/ListViewPage-BNB0ptO7-Y0blKENS.js +1617 -0
  13. package/dist/_chunks/ListViewPage-BNB0ptO7-Y0blKENS.js.map +1 -0
  14. package/dist/_chunks/ListViewPage-BNB0ptO7-qPG-Y69A.mjs +1594 -0
  15. package/dist/_chunks/ListViewPage-BNB0ptO7-qPG-Y69A.mjs.map +1 -0
  16. package/dist/_chunks/ReviewWorkflowsColumn-56Z6l-FH-j4yjCkjD.js +33 -0
  17. package/dist/_chunks/ReviewWorkflowsColumn-56Z6l-FH-j4yjCkjD.js.map +1 -0
  18. package/dist/_chunks/ReviewWorkflowsColumn-56Z6l-FH-jOwjGO3o.mjs +33 -0
  19. package/dist/_chunks/ReviewWorkflowsColumn-56Z6l-FH-jOwjGO3o.mjs.map +1 -0
  20. package/dist/_chunks/constants-evLWZCaJ-Oxpg3z7Q.mjs +190 -0
  21. package/dist/_chunks/constants-evLWZCaJ-Oxpg3z7Q.mjs.map +1 -0
  22. package/dist/_chunks/constants-evLWZCaJ-ZpfIp8P_.js +209 -0
  23. package/dist/_chunks/constants-evLWZCaJ-ZpfIp8P_.js.map +1 -0
  24. package/dist/_chunks/{index-8QCog8RN.js → index-7OS1Qe_4.js} +15 -13
  25. package/dist/_chunks/index-7OS1Qe_4.js.map +1 -0
  26. package/dist/_chunks/{index-6c_gUVrM.mjs → index-JM6LA3Oe.mjs} +26 -24
  27. package/dist/_chunks/index-JM6LA3Oe.mjs.map +1 -0
  28. package/dist/_chunks/index-R7UT09YY.js +17934 -0
  29. package/dist/_chunks/index-R7UT09YY.js.map +1 -0
  30. package/dist/_chunks/index-lggLaJiY.mjs +17909 -0
  31. package/dist/_chunks/index-lggLaJiY.mjs.map +1 -0
  32. package/dist/_chunks/{index-r8UM9pKc.js → index-ri1exVbc.js} +29 -27
  33. package/dist/_chunks/index-ri1exVbc.js.map +1 -0
  34. package/dist/_chunks/{index-SdK6c8ae.mjs → index-ynnbYrP0.mjs} +12 -10
  35. package/dist/_chunks/index-ynnbYrP0.mjs.map +1 -0
  36. package/dist/_chunks/{useDocumentation-uuvchj5L.js → useDocumentation-GsX6iQVe.js} +15 -13
  37. package/dist/_chunks/useDocumentation-GsX6iQVe.js.map +1 -0
  38. package/dist/_chunks/{useDocumentation-DcjdYl47.mjs → useDocumentation-jTKQvwxD.mjs} +11 -9
  39. package/dist/_chunks/useDocumentation-jTKQvwxD.mjs.map +1 -0
  40. package/dist/_chunks/useSyncRbac-83vFRiaG-5ec8lrUQ.js +57 -0
  41. package/dist/_chunks/useSyncRbac-83vFRiaG-5ec8lrUQ.js.map +1 -0
  42. package/dist/_chunks/useSyncRbac-83vFRiaG-oJpvBKQE.mjs +39 -0
  43. package/dist/_chunks/useSyncRbac-83vFRiaG-oJpvBKQE.mjs.map +1 -0
  44. package/dist/admin/index.js +1 -2
  45. package/dist/admin/index.js.map +1 -1
  46. package/dist/admin/index.mjs +1 -2
  47. package/dist/admin/index.mjs.map +1 -1
  48. package/dist/style.css +84 -0
  49. package/package.json +13 -13
  50. package/server/controllers/documentation.js +2 -2
  51. package/server/middlewares/restrict-access.js +1 -1
  52. package/server/services/__mocks__/mock-content-types.js +0 -5
  53. package/server/services/documentation.js +2 -3
  54. package/server/services/override.js +1 -1
  55. package/dist/_chunks/index-6c_gUVrM.mjs.map +0 -1
  56. package/dist/_chunks/index-8QCog8RN.js.map +0 -1
  57. package/dist/_chunks/index-SdK6c8ae.mjs.map +0 -1
  58. package/dist/_chunks/index-iIEENwT0.js +0 -169
  59. package/dist/_chunks/index-iIEENwT0.js.map +0 -1
  60. package/dist/_chunks/index-r8UM9pKc.js.map +0 -1
  61. package/dist/_chunks/index-uTcHJZnf.mjs +0 -167
  62. package/dist/_chunks/index-uTcHJZnf.mjs.map +0 -1
  63. package/dist/_chunks/useDocumentation-DcjdYl47.mjs.map +0 -1
  64. package/dist/_chunks/useDocumentation-uuvchj5L.js.map +0 -1
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
- const helperPlugin = require("@strapi/helper-plugin");
3
- const icons = require("@strapi/icons");
2
+ const Icons = require("@strapi/icons");
4
3
  const __variableDynamicImportRuntimeHelper = (glob, path) => {
5
4
  const v = glob[path];
6
5
  if (v) {
@@ -11,7 +10,7 @@ const __variableDynamicImportRuntimeHelper = (glob, path) => {
11
10
  });
12
11
  };
13
12
  const name$1 = "@strapi/plugin-documentation";
14
- const version = "4.20.4";
13
+ const version = "5.0.0-alpha.0";
15
14
  const description = "Create an OpenAPI Document and visualize your API with SWAGGER UI.";
16
15
  const repository = {
17
16
  type: "git",
@@ -57,19 +56,19 @@ const scripts = {
57
56
  };
58
57
  const dependencies = {
59
58
  "@strapi/design-system": "1.16.0",
60
- "@strapi/helper-plugin": "4.20.4",
59
+ "@strapi/helper-plugin": "5.0.0-alpha.0",
61
60
  "@strapi/icons": "1.16.0",
62
- "@strapi/utils": "4.20.4",
61
+ "@strapi/utils": "5.0.0-alpha.0",
63
62
  bcryptjs: "2.4.3",
64
63
  cheerio: "^1.0.0-rc.12",
65
- formik: "2.4.0",
66
- "fs-extra": "10.0.0",
67
- immer: "9.0.19",
64
+ formik: "2.4.5",
65
+ "fs-extra": "10.1.0",
66
+ immer: "9.0.21",
68
67
  "koa-static": "^5.0.0",
69
68
  lodash: "4.17.21",
70
69
  "path-to-regexp": "6.2.1",
71
70
  "react-helmet": "^6.1.0",
72
- "react-intl": "6.4.1",
71
+ "react-intl": "6.6.2",
73
72
  "react-query": "3.39.3",
74
73
  "swagger-ui-dist": "4.19.0",
75
74
  yaml: "1.10.2",
@@ -77,21 +76,21 @@ const dependencies = {
77
76
  };
78
77
  const devDependencies = {
79
78
  "@apidevtools/swagger-parser": "^10.1.0",
80
- "@strapi/pack-up": "4.20.4",
81
- "@strapi/strapi": "4.20.4",
79
+ "@strapi/pack-up": "5.0.0-alpha.0",
80
+ "@strapi/strapi": "5.0.0-alpha.0",
82
81
  "@testing-library/react": "14.0.0",
83
82
  "@testing-library/user-event": "14.4.3",
84
83
  msw: "1.3.0",
85
84
  react: "^18.2.0",
86
85
  "react-dom": "^18.2.0",
87
- "react-router-dom": "5.3.4",
88
- "styled-components": "5.3.3"
86
+ "react-router-dom": "6.22.3",
87
+ "styled-components": "5.3.11"
89
88
  };
90
89
  const peerDependencies = {
91
90
  "@strapi/strapi": "^4.0.0",
92
91
  react: "^17.0.0 || ^18.0.0",
93
92
  "react-dom": "^17.0.0 || ^18.0.0",
94
- "react-router-dom": "^5.2.0",
93
+ "react-router-dom": "^6.0.0",
95
94
  "styled-components": "^5.2.1"
96
95
  };
97
96
  const engines = {
@@ -138,21 +137,27 @@ const PERMISSIONS = {
138
137
  update: [{ action: "plugin::documentation.settings.update", subject: null }]
139
138
  };
140
139
  const pluginId = pluginPkg.name.replace(/^@strapi\/plugin-/i, "");
140
+ const prefixPluginTranslations = (trad, pluginId2) => {
141
+ if (!pluginId2) {
142
+ throw new TypeError("pluginId can't be empty");
143
+ }
144
+ return Object.keys(trad).reduce((acc, current) => {
145
+ acc[`${pluginId2}.${current}`] = trad[current];
146
+ return acc;
147
+ }, {});
148
+ };
141
149
  const name = pluginPkg.strapi.name;
142
150
  const index = {
143
151
  register(app) {
144
152
  app.addMenuLink({
145
- to: `/plugins/${pluginId}`,
146
- icon: icons.Information,
153
+ to: `plugins/${pluginId}`,
154
+ icon: Icons.Information,
147
155
  intlLabel: {
148
156
  id: `${pluginId}.plugin.name`,
149
157
  defaultMessage: "Documentation"
150
158
  },
151
159
  permissions: PERMISSIONS.main,
152
- async Component() {
153
- const component = await Promise.resolve().then(() => require("./index-iIEENwT0.js"));
154
- return component;
155
- }
160
+ Component: () => Promise.resolve().then(() => require("./index-R7UT09YY.js")).then((n) => n.index)
156
161
  });
157
162
  app.registerPlugin({
158
163
  id: pluginId,
@@ -166,11 +171,8 @@ const index = {
166
171
  defaultMessage: "Documentation"
167
172
  },
168
173
  id: "documentation",
169
- to: `/settings/${pluginId}`,
170
- async Component() {
171
- const component = await Promise.resolve().then(() => require("./index-8QCog8RN.js"));
172
- return component;
173
- },
174
+ to: pluginId,
175
+ Component: () => Promise.resolve().then(() => require("./index-7OS1Qe_4.js")),
174
176
  permissions: PERMISSIONS.main
175
177
  });
176
178
  },
@@ -179,7 +181,7 @@ const index = {
179
181
  locales.map((locale) => {
180
182
  return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/ar.json": () => Promise.resolve().then(() => require("./ar-4yWQcJB-.js")), "./translations/cs.json": () => Promise.resolve().then(() => require("./cs-knLCHelx.js")), "./translations/de.json": () => Promise.resolve().then(() => require("./de-D0HJjv1r.js")), "./translations/dk.json": () => Promise.resolve().then(() => require("./dk-OGCIxZ4f.js")), "./translations/en.json": () => Promise.resolve().then(() => require("./en-YgFnjikD.js")), "./translations/es.json": () => Promise.resolve().then(() => require("./es-5fRDaTSK.js")), "./translations/fr.json": () => Promise.resolve().then(() => require("./fr-qviymkcR.js")), "./translations/id.json": () => Promise.resolve().then(() => require("./id-caKGgafZ.js")), "./translations/it.json": () => Promise.resolve().then(() => require("./it-e3T319Va.js")), "./translations/ko.json": () => Promise.resolve().then(() => require("./ko-nWCOH-TF.js")), "./translations/ms.json": () => Promise.resolve().then(() => require("./ms-CSGAOmvV.js")), "./translations/nl.json": () => Promise.resolve().then(() => require("./nl-82NK6g7v.js")), "./translations/pl.json": () => Promise.resolve().then(() => require("./pl-UMuW3iDh.js")), "./translations/pt-BR.json": () => Promise.resolve().then(() => require("./pt-BR-G0-nWgFV.js")), "./translations/pt.json": () => Promise.resolve().then(() => require("./pt-2sEtQifY.js")), "./translations/ru.json": () => Promise.resolve().then(() => require("./ru-wJyWus4I.js")), "./translations/sk.json": () => Promise.resolve().then(() => require("./sk-mcEz1PMW.js")), "./translations/sv.json": () => Promise.resolve().then(() => require("./sv-V86KaP9y.js")), "./translations/th.json": () => Promise.resolve().then(() => require("./th-pZN4HdUY.js")), "./translations/tr.json": () => Promise.resolve().then(() => require("./tr-fCijT6nA.js")), "./translations/uk.json": () => Promise.resolve().then(() => require("./uk-TEHpQuls.js")), "./translations/vi.json": () => Promise.resolve().then(() => require("./vi-Nxtm0xZz.js")), "./translations/zh-Hans.json": () => Promise.resolve().then(() => require("./zh-Hans-tFSnVett.js")), "./translations/zh.json": () => Promise.resolve().then(() => require("./zh-bgauBZz8.js")) }), `./translations/${locale}.json`).then(({ default: data }) => {
181
183
  return {
182
- data: helperPlugin.prefixPluginTranslations(data, pluginId),
184
+ data: prefixPluginTranslations(data, pluginId),
183
185
  locale
184
186
  };
185
187
  }).catch(() => {
@@ -196,4 +198,4 @@ const index = {
196
198
  exports.PERMISSIONS = PERMISSIONS;
197
199
  exports.index = index;
198
200
  exports.pluginId = pluginId;
199
- //# sourceMappingURL=index-r8UM9pKc.js.map
201
+ //# sourceMappingURL=index-ri1exVbc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-ri1exVbc.js","sources":["../../admin/src/constants.js","../../admin/src/pluginId.js","../../admin/src/utils/prefixPluginTranslations.js","../../admin/src/index.js"],"sourcesContent":["export const PERMISSIONS = {\n // This permission regards the main component (App) and is used to tell\n // If the plugin link should be displayed in the menu\n // And also if the plugin is accessible. This use case is found when a user types the url of the\n // plugin directly in the browser\n main: [\n { action: 'plugin::documentation.read', subject: null },\n { action: 'plugin::documentation.settings.regenerate', subject: null },\n { action: 'plugin::documentation.settings.update', subject: null },\n ],\n open: [\n { action: 'plugin::documentation.read', subject: null },\n { action: 'plugin::documentation.settings.regenerate', subject: null },\n ],\n regenerate: [{ action: 'plugin::documentation.settings.regenerate', subject: null }],\n update: [{ action: 'plugin::documentation.settings.update', subject: null }],\n};\n","import pluginPkg from '../../package.json';\n\nconst pluginId = pluginPkg.name.replace(/^@strapi\\/plugin-/i, '');\n\nexport default pluginId;\n","const prefixPluginTranslations = (trad, pluginId) => {\n if (!pluginId) {\n throw new TypeError(\"pluginId can't be empty\");\n }\n\n return Object.keys(trad).reduce((acc, current) => {\n acc[`${pluginId}.${current}`] = trad[current];\n\n return acc;\n }, {});\n};\n\nexport { prefixPluginTranslations };\n","import { Information } from '@strapi/icons';\n\nimport pluginPkg from '../../package.json';\n\nimport { PERMISSIONS } from './constants';\nimport pluginId from './pluginId';\nimport { prefixPluginTranslations } from './utils/prefixPluginTranslations';\n\nconst name = pluginPkg.strapi.name;\n\nexport default {\n register(app) {\n app.addMenuLink({\n to: `plugins/${pluginId}`,\n icon: Information,\n intlLabel: {\n id: `${pluginId}.plugin.name`,\n defaultMessage: 'Documentation',\n },\n permissions: PERMISSIONS.main,\n Component: () => import('./pages/PluginPage'),\n });\n\n app.registerPlugin({\n id: pluginId,\n name,\n });\n },\n bootstrap(app) {\n app.addSettingsLink('global', {\n intlLabel: {\n id: `${pluginId}.plugin.name`,\n defaultMessage: 'Documentation',\n },\n id: 'documentation',\n to: pluginId,\n Component: () => import('./pages/SettingsPage'),\n permissions: PERMISSIONS.main,\n });\n },\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, pluginId),\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":["pluginId","Information"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAY,MAAC,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA,EAKzB,MAAM;AAAA,IACJ,EAAE,QAAQ,8BAA8B,SAAS,KAAM;AAAA,IACvD,EAAE,QAAQ,6CAA6C,SAAS,KAAM;AAAA,IACtE,EAAE,QAAQ,yCAAyC,SAAS,KAAM;AAAA,EACnE;AAAA,EACD,MAAM;AAAA,IACJ,EAAE,QAAQ,8BAA8B,SAAS,KAAM;AAAA,IACvD,EAAE,QAAQ,6CAA6C,SAAS,KAAM;AAAA,EACvE;AAAA,EACD,YAAY,CAAC,EAAE,QAAQ,6CAA6C,SAAS,KAAI,CAAE;AAAA,EACnF,QAAQ,CAAC,EAAE,QAAQ,yCAAyC,SAAS,KAAI,CAAE;AAC7E;ACdK,MAAC,WAAW,UAAU,KAAK,QAAQ,sBAAsB,EAAE;ACFhE,MAAM,2BAA2B,CAAC,MAAMA,cAAa;AACnD,MAAI,CAACA,WAAU;AACb,UAAM,IAAI,UAAU,yBAAyB;AAAA,EAC9C;AAED,SAAO,OAAO,KAAK,IAAI,EAAE,OAAO,CAAC,KAAK,YAAY;AAChD,QAAI,GAAGA,SAAQ,IAAI,OAAO,EAAE,IAAI,KAAK,OAAO;AAE5C,WAAO;AAAA,EACR,GAAE,CAAE,CAAA;AACP;ACFA,MAAM,OAAO,UAAU,OAAO;AAE9B,MAAe,QAAA;AAAA,EACb,SAAS,KAAK;AACZ,QAAI,YAAY;AAAA,MACd,IAAI,WAAW,QAAQ;AAAA,MACvB,MAAMC,MA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1,22 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useState } from "react";
3
- import { Main, HeaderLayout, Button, ContentLayout, Box, Flex, Typography, Grid, GridItem, ToggleInput, TextInput, FieldAction } from "@strapi/design-system";
4
- import { translatedErrors, useFocusWhenNavigate, useRBAC, LoadingIndicatorPage, Form } from "@strapi/helper-plugin";
3
+ import { HeaderLayout, Button, ContentLayout, Box, Flex, Typography, Grid, GridItem, ToggleInput, TextInput, FieldAction } from "@strapi/design-system";
4
+ import { useRBAC } from "@strapi/helper-plugin";
5
5
  import { Check, Eye, EyeStriked } from "@strapi/icons";
6
- import { Formik } from "formik";
6
+ import { translatedErrors, Page } from "@strapi/strapi/admin";
7
+ import { Formik, Form } from "formik";
7
8
  import { useIntl } from "react-intl";
8
9
  import styled from "styled-components";
9
10
  import * as yup from "yup";
10
- import { P as PERMISSIONS } from "./index-6c_gUVrM.mjs";
11
- import { u as useDocumentation, g as getTrad } from "./useDocumentation-DcjdYl47.mjs";
12
- import "react-query";
11
+ import { P as PERMISSIONS } from "./index-JM6LA3Oe.mjs";
12
+ import { u as useDocumentation, g as getTrad } from "./useDocumentation-jTKQvwxD.mjs";
13
13
  const schema = yup.object().shape({
14
14
  restrictedAccess: yup.boolean(),
15
15
  password: yup.string().when("restrictedAccess", (value, initSchema) => {
16
- return value ? initSchema.required(translatedErrors.required) : initSchema;
16
+ return value ? initSchema.required(translatedErrors.required.id) : initSchema;
17
17
  })
18
18
  });
19
19
  const SettingsPage = () => {
20
- useFocusWhenNavigate();
21
20
  const { formatMessage } = useIntl();
22
21
  const { submit, data, isLoading } = useDocumentation();
23
22
  const [passwordShown, setPasswordShown] = useState(false);
@@ -28,7 +27,10 @@ const SettingsPage = () => {
28
27
  body
29
28
  });
30
29
  };
31
- return /* @__PURE__ */ jsx(Main, { children: isLoading ? /* @__PURE__ */ jsx(LoadingIndicatorPage, { children: "Plugin settings are loading" }) : /* @__PURE__ */ jsx(
30
+ if (isLoading) {
31
+ return /* @__PURE__ */ jsx(Page.Loading, {});
32
+ }
33
+ return /* @__PURE__ */ jsx(Page.Main, { children: /* @__PURE__ */ jsx(
32
34
  Formik,
33
35
  {
34
36
  initialValues: {
@@ -170,4 +172,4 @@ const FieldActionWrapper = styled(FieldAction)`
170
172
  export {
171
173
  SettingsPage as default
172
174
  };
173
- //# sourceMappingURL=index-SdK6c8ae.mjs.map
175
+ //# sourceMappingURL=index-ynnbYrP0.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-ynnbYrP0.mjs","sources":["../../admin/src/pages/SettingsPage/index.jsx"],"sourcesContent":["import React, { useState } from 'react';\n\nimport {\n Box,\n Button,\n ContentLayout,\n Flex,\n Grid,\n GridItem,\n HeaderLayout,\n TextInput,\n ToggleInput,\n Typography,\n FieldAction,\n} from '@strapi/design-system';\nimport { useRBAC } from '@strapi/helper-plugin';\nimport { Check, Eye as Show, EyeStriked as Hide } from '@strapi/icons';\nimport { translatedErrors, Page } from '@strapi/strapi/admin';\nimport { Form, Formik } from 'formik';\nimport { useIntl } from 'react-intl';\nimport styled from 'styled-components';\nimport * as yup from 'yup';\n\nimport { PERMISSIONS } from '../../constants';\nimport { useDocumentation } from '../../hooks/useDocumentation';\nimport { getTrad } from '../../utils';\n\nconst schema = yup.object().shape({\n restrictedAccess: yup.boolean(),\n password: yup.string().when('restrictedAccess', (value, initSchema) => {\n return value ? initSchema.required(translatedErrors.required.id) : initSchema;\n }),\n});\n\nconst SettingsPage = () => {\n const { formatMessage } = useIntl();\n const { submit, data, isLoading } = useDocumentation();\n const [passwordShown, setPasswordShown] = useState(false);\n const { allowedActions } = useRBAC(PERMISSIONS);\n\n const handleUpdateSettingsSubmit = (body) => {\n submit.mutate({\n prefix: data?.prefix,\n body,\n });\n };\n\n if (isLoading) {\n return <Page.Loading />;\n }\n\n return (\n <Page.Main>\n <Formik\n initialValues={{\n restrictedAccess: data?.documentationAccess.restrictedAccess || false,\n password: '',\n }}\n onSubmit={handleUpdateSettingsSubmit}\n validationSchema={schema}\n >\n {({\n handleSubmit,\n values,\n handleChange,\n errors,\n setFieldTouched,\n setFieldValue,\n dirty,\n }) => {\n return (\n <Form noValidate onSubmit={handleSubmit}>\n <HeaderLayout\n title={formatMessage({\n id: getTrad('plugin.name'),\n defaultMessage: 'Documentation',\n })}\n subtitle={formatMessage({\n id: getTrad('pages.SettingsPage.header.description'),\n defaultMessage: 'Configure the documentation plugin',\n })}\n primaryAction={\n <Button\n type=\"submit\"\n startIcon={<Check />}\n disabled={!dirty && allowedActions.canUpdate}\n >\n {formatMessage({\n id: getTrad('pages.SettingsPage.Button.save'),\n defaultMessage: 'Save',\n })}\n </Button>\n }\n />\n <ContentLayout>\n <Box\n background=\"neutral0\"\n hasRadius\n shadow=\"filterShadow\"\n paddingTop={6}\n paddingBottom={6}\n paddingLeft={7}\n paddingRight={7}\n >\n <Flex direction=\"column\" alignItems=\"stretch\" gap={4}>\n <Typography variant=\"delta\" as=\"h2\">\n {formatMessage({\n id: 'global.settings',\n defaultMessage: 'Settings',\n })}\n </Typography>\n <Grid gap={4}>\n <GridItem col={6} s={12}>\n <ToggleInput\n name=\"restrictedAccess\"\n label={formatMessage({\n id: getTrad('pages.SettingsPage.toggle.label'),\n defaultMessage: 'Restricted Access',\n })}\n hint={formatMessage({\n id: getTrad('pages.SettingsPage.toggle.hint'),\n defaultMessage: 'Make the documentation endpoint private',\n })}\n checked={values.restrictedAccess}\n onChange={() => {\n if (values.restrictedAccess === true) {\n setFieldValue('password', '', false);\n setFieldTouched('password', false, false);\n }\n\n setFieldValue('restrictedAccess', !values.restrictedAccess, false);\n }}\n onLabel=\"On\"\n offLabel=\"Off\"\n />\n </GridItem>\n {values.restrictedAccess && (\n <GridItem col={6} s={12}>\n <TextInput\n label={formatMessage({\n id: 'global.password',\n defaultMessage: 'Password',\n })}\n name=\"password\"\n placeholder=\"**********\"\n type={passwordShown ? 'text' : 'password'}\n value={values.password}\n onChange={handleChange}\n error={\n errors.password\n ? formatMessage({\n id: errors.password,\n defaultMessage: 'Invalid value',\n })\n : null\n }\n endAction={\n <FieldActionWrapper\n onClick={(e) => {\n e.stopPropagation();\n setPasswordShown((prev) => !prev);\n }}\n label={formatMessage(\n passwordShown\n ? {\n id: 'Auth.form.password.show-password',\n defaultMessage: 'Show password',\n }\n : {\n id: 'Auth.form.password.hide-password',\n defaultMessage: 'Hide password',\n }\n )}\n >\n {passwordShown ? <Show /> : <Hide />}\n </FieldActionWrapper>\n }\n />\n </GridItem>\n )}\n </Grid>\n </Flex>\n </Box>\n </ContentLayout>\n </Form>\n );\n }}\n </Formik>\n </Page.Main>\n );\n};\n\nconst FieldActionWrapper = styled(FieldAction)`\n svg {\n height: 1rem;\n width: 1rem;\n path {\n fill: ${({ theme }) => theme.colors.neutral600};\n }\n }\n`;\n\nexport default SettingsPage;\n"],"names":["Show","Hide"],"mappings":";;;;;;;;;;;;AA2BA,MAAM,SAAS,IAAI,OAAO,EAAE,MAAM;AAAA,EAChC,kBAAkB,IAAI,QAAQ;AAAA,EAC9B,UAAU,IAAI,OAAO,EAAE,KAAK,oBAAoB,CAAC,OAAO,eAAe;AACrE,WAAO,QAAQ,WAAW,SAAS,iBAAiB,SAAS,EAAE,IAAI;AAAA,EAAA,CACpE;AACH,CAAC;AAED,MAAM,eAAe,MAAM;AACnB,QAAA,EAAE,kBAAkB;AAC1B,QAAM,EAAE,QAAQ,MAAM,cAAc,iBAAiB;AACrD,QAAM,CAAC,eAAe,gBAAgB,IAAI,SAAS,KAAK;AACxD,QAAM,EAAE,eAAA,IAAmB,QAAQ,WAAW;AAExC,QAAA,6BAA6B,CAAC,SAAS;AAC3C,WAAO,OAAO;AAAA,MACZ,QAAQ,MAAM;AAAA,MACd;AAAA,IAAA,CACD;AAAA,EAAA;AAGH,MAAI,WAAW;AACN,WAAA,oBAAC,KAAK,SAAL,CAAa,CAAA;AAAA,EACvB;AAGE,SAAA,oBAAC,KAAK,MAAL,EACC,UAAA;AAAA,IAAC;AAAA,IAAA;AA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A,IAElB;AAAA,8BACE,IAAI;AAAA,8BACJ,gBAAgB;AAAA,4BAClB;AAAA,0BACN;AAAA,0BAEC,UAAgB,gBAAA,oBAACA,KAAK,CAAA,CAAA,wBAAMC,YAAK,EAAA;AAAA,wBAAA;AAAA,sBACpC;AAAA,oBAAA;AAAA,kBAAA,GAGN;AAAA,gBAAA,GAEJ;AAAA,cAAA,GACF;AAAA,YAAA;AAAA,UAAA,GAEJ;AAAA,QACF,EAAA,CAAA;AAAA,MAEJ;AAAA,IAAA;AAAA,EAEJ,EAAA,CAAA;AAEJ;AAEA,MAAM,qBAAqB,OAAO,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA,cAK/B,CAAC,EAAE,MAAA,MAAY,MAAM,OAAO,UAAU;AAAA;AAAA;AAAA;"}
@@ -1,13 +1,15 @@
1
1
  "use strict";
2
- const react = require("react");
3
- const helperPlugin = require("@strapi/helper-plugin");
2
+ const React = require("react");
3
+ const admin = require("@strapi/strapi/admin");
4
+ const reactIntl = require("react-intl");
4
5
  const reactQuery = require("react-query");
5
- const index = require("./index-r8UM9pKc.js");
6
+ const index = require("./index-ri1exVbc.js");
6
7
  const getTrad = (id) => `${index.pluginId}.${id}`;
7
8
  const useDocumentation = () => {
8
- const toggleNotification = helperPlugin.useNotification();
9
- const { del, post, put, get } = helperPlugin.useFetchClient();
10
- const { formatAPIError } = helperPlugin.useAPIErrorHandler();
9
+ const { toggleNotification } = admin.useNotification();
10
+ const { formatMessage } = reactIntl.useIntl();
11
+ const { del, post, put, get } = admin.useFetchClient();
12
+ const { formatAPIError } = admin.useAPIErrorHandler();
11
13
  const { isLoading, isError, data, refetch, error } = reactQuery.useQuery(
12
14
  ["get-documentation", index.pluginId],
13
15
  async () => {
@@ -15,17 +17,17 @@ const useDocumentation = () => {
15
17
  return data2;
16
18
  }
17
19
  );
18
- react.useEffect(() => {
20
+ React.useEffect(() => {
19
21
  if (isError && error) {
20
22
  toggleNotification({
21
- type: "warning",
22
- message: error ? formatAPIError(error) : { id: "notification.error" }
23
+ type: "danger",
24
+ message: error ? formatAPIError(error) : formatMessage({ id: "notification.error" })
23
25
  });
24
26
  }
25
- }, [isError, error, toggleNotification, formatAPIError]);
27
+ }, [isError, error, toggleNotification, formatAPIError, formatMessage]);
26
28
  const handleError = (err) => {
27
29
  toggleNotification({
28
- type: "warning",
30
+ type: "danger",
29
31
  message: formatAPIError(err)
30
32
  });
31
33
  };
@@ -33,7 +35,7 @@ const useDocumentation = () => {
33
35
  refetch();
34
36
  toggleNotification({
35
37
  type,
36
- message: { id: getTrad(tradId), defaultMessage }
38
+ message: formatMessage({ id: getTrad(tradId), defaultMessage })
37
39
  });
38
40
  };
39
41
  const deleteMutation = reactQuery.useMutation(
@@ -62,4 +64,4 @@ const useDocumentation = () => {
62
64
  };
63
65
  exports.getTrad = getTrad;
64
66
  exports.useDocumentation = useDocumentation;
65
- //# sourceMappingURL=useDocumentation-uuvchj5L.js.map
67
+ //# sourceMappingURL=useDocumentation-GsX6iQVe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDocumentation-GsX6iQVe.js","sources":["../../admin/src/utils/getTrad.js","../../admin/src/hooks/useDocumentation.js"],"sourcesContent":["import pluginId from '../pluginId';\n\nconst getTrad = (id) => `${pluginId}.${id}`;\n\nexport default getTrad;\n","import { useEffect } from 'react';\n\nimport { useAPIErrorHandler, useNotification, useFetchClient } from '@strapi/strapi/admin';\nimport { useIntl } from 'react-intl';\nimport { useMutation, useQuery } from 'react-query';\n\nimport pluginId from '../pluginId';\nimport getTrad from '../utils/getTrad';\n\nexport const useDocumentation = () => {\n const { toggleNotification } = useNotification();\n const { formatMessage } = useIntl();\n const { del, post, put, get } = useFetchClient();\n\n const { formatAPIError } = useAPIErrorHandler();\n\n const { isLoading, isError, data, refetch, error } = useQuery(\n ['get-documentation', pluginId],\n async () => {\n const { data } = await get(`/${pluginId}/getInfos`);\n\n return data;\n }\n );\n\n useEffect(() => {\n if (isError && error) {\n toggleNotification({\n type: 'danger',\n message: error ? formatAPIError(error) : formatMessage({ id: 'notification.error' }),\n });\n }\n }, [isError, error, toggleNotification, formatAPIError, formatMessage]);\n\n const handleError = (err) => {\n toggleNotification({\n type: 'danger',\n message: formatAPIError(err),\n });\n };\n\n const handleSuccess = (type, tradId, defaultMessage) => {\n refetch();\n toggleNotification({\n type,\n message: formatMessage({ id: getTrad(tradId), defaultMessage }),\n });\n };\n\n const deleteMutation = useMutation(\n ({ prefix, version }) => del(`${prefix}/deleteDoc/${version}`),\n {\n onSuccess: () =>\n handleSuccess('info', 'notification.delete.success', 'Successfully deleted documentation'),\n onError: handleError,\n }\n );\n\n const submit = useMutation(({ prefix, body }) => put(`${prefix}/updateSettings`, body), {\n onSuccess: () =>\n handleSuccess('success', 'notification.update.success', 'Successfully updated settings'),\n onError: handleError,\n });\n\n const regenerate = useMutation(\n ({ prefix, version }) => post(`${prefix}/regenerateDoc`, { version }),\n {\n onSuccess: () =>\n handleSuccess(\n 'info',\n 'notification.generate.success',\n 'Successfully generated documentation'\n ),\n onError: handleError,\n }\n );\n\n return { data, isLoading, isError, remove: deleteMutation, submit, regenerate };\n};\n"],"names":["pluginId","useNotification","useIntl","useFetchClient","useAPIErrorHandler","useQuery","data","useEffect","useMutation"],"mappings":";;;;;;AAEK,MAAC,UAAU,CAAC,OAAO,GAAGA,MAAAA,QAAQ,IAAI,EAAE;ACO7B,MAAC,mBAAmB,MAAM;AACpC,QAAM,EAAE,uBAAuBC,MAAAA;AAC/B,QAAM,EAAE,kBAAkBC,UAAAA;AAC1B,QAAM,EAAE,KAAK,MAAM,KAAK,IAAG,IAAKC,MAAAA;AAEhC,QAAM,EAAE,mBAAmBC,MAAAA;AAE3B,QAAM,EAAE,WAAW,SAAS,MAAM,SAAS,MAAK,IAAKC,WAAQ;AAAA,IAC3D,CAAC,qBAAqBL,MAAAA,QAAQ;AAAA,IAC9B,YAAY;AACV,YAAM,EAAE,MAAAM,MAAM,IAAG,MAAM,IAAI,IAAIN,MAAQ,QAA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AW,SAAS,QAAQ,gBAAgB,QAAQ;AACrE;;;"}
@@ -1,10 +1,12 @@
1
1
  import { useEffect } from "react";
2
- import { useNotification, useFetchClient, useAPIErrorHandler } from "@strapi/helper-plugin";
2
+ import { useNotification, useFetchClient, useAPIErrorHandler } from "@strapi/strapi/admin";
3
+ import { useIntl } from "react-intl";
3
4
  import { useQuery, useMutation } from "react-query";
4
- import { p as pluginId } from "./index-6c_gUVrM.mjs";
5
+ import { p as pluginId } from "./index-JM6LA3Oe.mjs";
5
6
  const getTrad = (id) => `${pluginId}.${id}`;
6
7
  const useDocumentation = () => {
7
- const toggleNotification = useNotification();
8
+ const { toggleNotification } = useNotification();
9
+ const { formatMessage } = useIntl();
8
10
  const { del, post, put, get } = useFetchClient();
9
11
  const { formatAPIError } = useAPIErrorHandler();
10
12
  const { isLoading, isError, data, refetch, error } = useQuery(
@@ -17,14 +19,14 @@ const useDocumentation = () => {
17
19
  useEffect(() => {
18
20
  if (isError && error) {
19
21
  toggleNotification({
20
- type: "warning",
21
- message: error ? formatAPIError(error) : { id: "notification.error" }
22
+ type: "danger",
23
+ message: error ? formatAPIError(error) : formatMessage({ id: "notification.error" })
22
24
  });
23
25
  }
24
- }, [isError, error, toggleNotification, formatAPIError]);
26
+ }, [isError, error, toggleNotification, formatAPIError, formatMessage]);
25
27
  const handleError = (err) => {
26
28
  toggleNotification({
27
- type: "warning",
29
+ type: "danger",
28
30
  message: formatAPIError(err)
29
31
  });
30
32
  };
@@ -32,7 +34,7 @@ const useDocumentation = () => {
32
34
  refetch();
33
35
  toggleNotification({
34
36
  type,
35
- message: { id: getTrad(tradId), defaultMessage }
37
+ message: formatMessage({ id: getTrad(tradId), defaultMessage })
36
38
  });
37
39
  };
38
40
  const deleteMutation = useMutation(
@@ -63,4 +65,4 @@ export {
63
65
  getTrad as g,
64
66
  useDocumentation as u
65
67
  };
66
- //# sourceMappingURL=useDocumentation-DcjdYl47.mjs.map
68
+ //# sourceMappingURL=useDocumentation-jTKQvwxD.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDocumentation-jTKQvwxD.mjs","sources":["../../admin/src/utils/getTrad.js","../../admin/src/hooks/useDocumentation.js"],"sourcesContent":["import pluginId from '../pluginId';\n\nconst getTrad = (id) => `${pluginId}.${id}`;\n\nexport default getTrad;\n","import { useEffect } from 'react';\n\nimport { useAPIErrorHandler, useNotification, useFetchClient } from '@strapi/strapi/admin';\nimport { useIntl } from 'react-intl';\nimport { useMutation, useQuery } from 'react-query';\n\nimport pluginId from '../pluginId';\nimport getTrad from '../utils/getTrad';\n\nexport const useDocumentation = () => {\n const { toggleNotification } = useNotification();\n const { formatMessage } = useIntl();\n const { del, post, put, get } = useFetchClient();\n\n const { formatAPIError } = useAPIErrorHandler();\n\n const { isLoading, isError, data, refetch, error } = useQuery(\n ['get-documentation', pluginId],\n async () => {\n const { data } = await get(`/${pluginId}/getInfos`);\n\n return data;\n }\n );\n\n useEffect(() => {\n if (isError && error) {\n toggleNotification({\n type: 'danger',\n message: error ? formatAPIError(error) : formatMessage({ id: 'notification.error' }),\n });\n }\n }, [isError, error, toggleNotification, formatAPIError, formatMessage]);\n\n const handleError = (err) => {\n toggleNotification({\n type: 'danger',\n message: formatAPIError(err),\n });\n };\n\n const handleSuccess = (type, tradId, defaultMessage) => {\n refetch();\n toggleNotification({\n type,\n message: formatMessage({ id: getTrad(tradId), defaultMessage }),\n });\n };\n\n const deleteMutation = useMutation(\n ({ prefix, version }) => del(`${prefix}/deleteDoc/${version}`),\n {\n onSuccess: () =>\n handleSuccess('info', 'notification.delete.success', 'Successfully deleted documentation'),\n onError: handleError,\n }\n );\n\n const submit = useMutation(({ prefix, body }) => put(`${prefix}/updateSettings`, body), {\n onSuccess: () =>\n handleSuccess('success', 'notification.update.success', 'Successfully updated settings'),\n onError: handleError,\n });\n\n const regenerate = useMutation(\n ({ prefix, version }) => post(`${prefix}/regenerateDoc`, { version }),\n {\n onSuccess: () =>\n handleSuccess(\n 'info',\n 'notification.generate.success',\n 'Successfully generated documentation'\n ),\n onError: handleError,\n }\n );\n\n return { data, isLoading, isError, remove: deleteMutation, submit, regenerate };\n};\n"],"names":["data"],"mappings":";;;;;AAEK,MAAC,UAAU,CAAC,OAAO,GAAG,QAAQ,IAAI,EAAE;ACO7B,MAAC,mBAAmB,MAAM;AACpC,QAAM,EAAE,uBAAuB;AAC/B,QAAM,EAAE,kBAAkB;AAC1B,QAAM,EAAE,KAAK,MAAM,KAAK,IAAG,IAAK;AAEhC,QAAM,EAAE,mBAAmB;AAE3B,QAAM,EAAE,WAAW,SAAS,MAAM,SAAS,MAAK,IAAK;AAAA,IACnD,CAAC,qBAAqB,QAAQ;AAAA,IAC9B,YAAY;AACV,YAAM,EAAE,MAAAA,MAAM,IAAG,MAAM,IAAI,IAAI,QAAQ,WAAW;AAElD,aAAOA;AAAA,IACR;AAAA,EACL;AAEE,YAAU,MAAM;AACd,QAAI,WAAW,OAAO;AACpB,yBAAmB;AAAA,QACjB,MAAM;AAAA,QACN,SAAS,QAAQ,eAAe,KAAK,IAAI,cAAc,EAAE,IAAI,sBAAsB;AAAA,MAC3F,CAAO;AAAA,IACF;AAAA,EACL,GAAK,CAAC,SAAS,OAAO,oBAAoB,gBAAgB,aAAa,CAAC;AAEtE,QAAM,cAAc,CAAC,QAAQ;AAC3B,uBAAmB;AAAA,MACjB,MAAM;AAAA,MACN,SAAS,eAAe,GAAG;AAAA,IACjC,CAAK;AAAA,EACL;AAEE,QAAM,gBAAgB,CAAC,MAAM,QAAQ,mBAAmB;AACtD;AACA,uBAAmB;AAAA,MACjB;AAAA,MACA,SAAS,cAAc,EAAE,IAAI,QAAQ,MAAM,GAAG,gBAAgB;AAAA,IACpE,CAAK;AAAA,EACL;AAEE,QAAM,iBAAiB;AAAA,IACrB,CAAC,EAAE,QAAQ,QAAO,MAAO,IAAI,GAAG,MAAM,cAAc,OAAO,EAAE;AAAA,IAC7D;AAAA,MACE,WAAW,MACT,cAAc,QAAQ,+BAA+B,oCAAoC;AAAA,MAC3F,SAAS;AAAA,IACV;AAAA,EACL;AAEE,QAAM,SAAS,YAAY,CAAC,EAAE,QAAQ,KAAI,MAAO,IAAI,GAAG,MAAM,mBAAmB,IAAI,GAAG;AAAA,IACtF,WAAW,MACT,cAAc,WAAW,+BAA+B,+BAA+B;AAAA,IACzF,SAAS;AAAA,EACb,CAAG;AAED,QAAM,aAAa;AAAA,IACjB,CAAC,EAAE,QAAQ,QAAO,MAAO,KAAK,GAAG,MAAM,kBAAkB,EAAE,SAAS;AAAA,IACpE;AAAA,MACE,WAAW,MACT;AAAA,QACE;AAAA,QACA;AAAA,QACA;AAAA,MACD;AAAA,MACH,SAAS;AAAA,IACV;AAAA,EACL;AAEE,SAAO,EAAE,MAAM,WAAW,SAAS,QAAQ,gBAAgB,QAAQ;AACrE;"}
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ const React = require("react");
3
+ const index = require("./index-R7UT09YY.js");
4
+ function _interopNamespace(e) {
5
+ if (e && e.__esModule)
6
+ return e;
7
+ const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
8
+ if (e) {
9
+ for (const k in e) {
10
+ if (k !== "default") {
11
+ const d = Object.getOwnPropertyDescriptor(e, k);
12
+ Object.defineProperty(n, k, d.get ? d : {
13
+ enumerable: true,
14
+ get: () => e[k]
15
+ });
16
+ }
17
+ }
18
+ }
19
+ n.default = e;
20
+ return Object.freeze(n);
21
+ }
22
+ const React__namespace = /* @__PURE__ */ _interopNamespace(React);
23
+ const useSyncRbac = (collectionTypeUID, query, containerName = "listView") => {
24
+ const [isLoading, setIsLoading] = React__namespace.useState(true);
25
+ const dispatch = index.useTypedDispatch();
26
+ const collectionTypesRelatedPermissions = index.useTypedSelector(
27
+ (state) => state.rbacProvider.collectionTypesRelatedPermissions
28
+ );
29
+ const relatedPermissions = collectionTypesRelatedPermissions[collectionTypeUID];
30
+ React__namespace.useEffect(() => {
31
+ setIsLoading(true);
32
+ if (relatedPermissions) {
33
+ dispatch(
34
+ index.setPermissions({
35
+ permissions: relatedPermissions,
36
+ __meta__: {
37
+ plugins: query ? query.plugins : void 0,
38
+ containerName
39
+ }
40
+ })
41
+ );
42
+ }
43
+ setIsLoading(false);
44
+ return () => {
45
+ dispatch(index.resetPermissions());
46
+ };
47
+ }, [relatedPermissions, dispatch, query, containerName]);
48
+ const permissions = index.useTypedSelector((state) => state["content-manager"].rbac.permissions);
49
+ const isPermissionMismatch = permissions && permissions.some((permission) => permission.subject !== collectionTypeUID) ? true : false;
50
+ return {
51
+ isLoading,
52
+ isError: !isLoading && isPermissionMismatch,
53
+ permissions
54
+ };
55
+ };
56
+ exports.useSyncRbac = useSyncRbac;
57
+ //# sourceMappingURL=useSyncRbac-83vFRiaG-5ec8lrUQ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSyncRbac-83vFRiaG-5ec8lrUQ.js","sources":["../../../../core/admin/dist/_chunks/useSyncRbac-83vFRiaG.mjs"],"sourcesContent":["import * as React from \"react\";\nimport { r as useTypedDispatch, q as useTypedSelector, aJ as setPermissions, aK as resetPermissions } from \"./index-YFPS5vYF.mjs\";\nconst useSyncRbac = (collectionTypeUID, query, containerName = \"listView\") => {\n const [isLoading, setIsLoading] = React.useState(true);\n const dispatch = useTypedDispatch();\n const collectionTypesRelatedPermissions = useTypedSelector(\n (state) => state.rbacProvider.collectionTypesRelatedPermissions\n );\n const relatedPermissions = collectionTypesRelatedPermissions[collectionTypeUID];\n React.useEffect(() => {\n setIsLoading(true);\n if (relatedPermissions) {\n dispatch(\n setPermissions({\n permissions: relatedPermissions,\n __meta__: {\n plugins: query ? query.plugins : void 0,\n containerName\n }\n })\n );\n }\n setIsLoading(false);\n return () => {\n dispatch(resetPermissions());\n };\n }, [relatedPermissions, dispatch, query, containerName]);\n const permissions = useTypedSelector((state) => state[\"content-manager\"].rbac.permissions);\n const isPermissionMismatch = permissions && permissions.some((permission) => permission.subject !== collectionTypeUID) ? true : false;\n return {\n isLoading,\n isError: !isLoading && isPermissionMismatch,\n permissions\n };\n};\nexport {\n useSyncRbac as u\n};\n//# sourceMappingURL=useSyncRbac-83vFRiaG.mjs.map\n"],"names":["React","useTypedDispatch","useTypedSelector","setPermissions","resetPermissions"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAEK,MAAC,cAAc,CAAC,mBAAmB,OAAO,gBAAgB,eAAe;AAC5E,QAAM,CAAC,WAAW,YAAY,IAAIA,iBAAM,SAAS,IAAI;AACrD,QAAM,WAAWC,MAAAA;AACjB,QAAM,oCAAoCC,MAAgB;AAAA,IACxD,CAAC,UAAU,MAAM,aAAa;AAAA,EAClC;AACE,QAAM,qBAAqB,kCAAkC,iBAAiB;AAC9EF,mBAAM,UAAU,MAAM;AACpB,iBAAa,IAAI;AACjB,QAAI,oBAAoB;AACtB;AAAA,QACEG,qBAAe;AAAA,UACb,aAAa;AAAA,UACb,UAAU;AAAA,YACR,SAAS,QAAQ,MAAM,UAAU;AAAA,YACjC;AAAA,UACD;AAAA,QACX,CAAS;AAAA,MACT;AAAA,IACK;AACD,iBAAa,KAAK;AAClB,WAAO,MAAM;AACX,eAASC,MAAgB,iBAAA,CAAE;AAAA,IACjC;AAAA,EACG,GAAE,CAAC,oBAAoB,UAAU,OAAO,aAAa,CAAC;AACvD,QAAM,cAAcF,MAAgB,iBAAC,CAAC,UAAU,MAAM,iBAAiB,EAAE,KAAK,WAAW;AACzF,QAAM,uBAAuB,eAAe,YAAY,KAAK,CAAC,eAAe,WAAW,YAAY,iBAAiB,IAAI,OAAO;AAChI,SAAO;AAAA,IACL;AAAA,IACA,SAAS,CAAC,aAAa;AAAA,IACvB;AAAA,EACJ;AACA;;"}
@@ -0,0 +1,39 @@
1
+ import * as React from "react";
2
+ import { af as useTypedDispatch, a9 as useTypedSelector, ag as setPermissions, ah as resetPermissions } from "./index-lggLaJiY.mjs";
3
+ const useSyncRbac = (collectionTypeUID, query, containerName = "listView") => {
4
+ const [isLoading, setIsLoading] = React.useState(true);
5
+ const dispatch = useTypedDispatch();
6
+ const collectionTypesRelatedPermissions = useTypedSelector(
7
+ (state) => state.rbacProvider.collectionTypesRelatedPermissions
8
+ );
9
+ const relatedPermissions = collectionTypesRelatedPermissions[collectionTypeUID];
10
+ React.useEffect(() => {
11
+ setIsLoading(true);
12
+ if (relatedPermissions) {
13
+ dispatch(
14
+ setPermissions({
15
+ permissions: relatedPermissions,
16
+ __meta__: {
17
+ plugins: query ? query.plugins : void 0,
18
+ containerName
19
+ }
20
+ })
21
+ );
22
+ }
23
+ setIsLoading(false);
24
+ return () => {
25
+ dispatch(resetPermissions());
26
+ };
27
+ }, [relatedPermissions, dispatch, query, containerName]);
28
+ const permissions = useTypedSelector((state) => state["content-manager"].rbac.permissions);
29
+ const isPermissionMismatch = permissions && permissions.some((permission) => permission.subject !== collectionTypeUID) ? true : false;
30
+ return {
31
+ isLoading,
32
+ isError: !isLoading && isPermissionMismatch,
33
+ permissions
34
+ };
35
+ };
36
+ export {
37
+ useSyncRbac as u
38
+ };
39
+ //# sourceMappingURL=useSyncRbac-83vFRiaG-oJpvBKQE.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSyncRbac-83vFRiaG-oJpvBKQE.mjs","sources":["../../../../core/admin/dist/_chunks/useSyncRbac-83vFRiaG.mjs"],"sourcesContent":["import * as React from \"react\";\nimport { r as useTypedDispatch, q as useTypedSelector, aJ as setPermissions, aK as resetPermissions } from \"./index-YFPS5vYF.mjs\";\nconst useSyncRbac = (collectionTypeUID, query, containerName = \"listView\") => {\n const [isLoading, setIsLoading] = React.useState(true);\n const dispatch = useTypedDispatch();\n const collectionTypesRelatedPermissions = useTypedSelector(\n (state) => state.rbacProvider.collectionTypesRelatedPermissions\n );\n const relatedPermissions = collectionTypesRelatedPermissions[collectionTypeUID];\n React.useEffect(() => {\n setIsLoading(true);\n if (relatedPermissions) {\n dispatch(\n setPermissions({\n permissions: relatedPermissions,\n __meta__: {\n plugins: query ? query.plugins : void 0,\n containerName\n }\n })\n );\n }\n setIsLoading(false);\n return () => {\n dispatch(resetPermissions());\n };\n }, [relatedPermissions, dispatch, query, containerName]);\n const permissions = useTypedSelector((state) => state[\"content-manager\"].rbac.permissions);\n const isPermissionMismatch = permissions && permissions.some((permission) => permission.subject !== collectionTypeUID) ? true : false;\n return {\n isLoading,\n isError: !isLoading && isPermissionMismatch,\n permissions\n };\n};\nexport {\n useSyncRbac as u\n};\n//# sourceMappingURL=useSyncRbac-83vFRiaG.mjs.map\n"],"names":[],"mappings":";;AAEK,MAAC,cAAc,CAAC,mBAAmB,OAAO,gBAAgB,eAAe;AAC5E,QAAM,CAAC,WAAW,YAAY,IAAI,MAAM,SAAS,IAAI;AACrD,QAAM,WAAW;AACjB,QAAM,oCAAoC;AAAA,IACxC,CAAC,UAAU,MAAM,aAAa;AAAA,EAClC;AACE,QAAM,qBAAqB,kCAAkC,iBAAiB;AAC9E,QAAM,UAAU,MAAM;AACpB,iBAAa,IAAI;AACjB,QAAI,oBAAoB;AACtB;AAAA,QACE,eAAe;AAAA,UACb,aAAa;AAAA,UACb,UAAU;AAAA,YACR,SAAS,QAAQ,MAAM,UAAU;AAAA,YACjC;AAAA,UACD;AAAA,QACX,CAAS;AAAA,MACT;AAAA,IACK;AACD,iBAAa,KAAK;AAClB,WAAO,MAAM;AACX,eAAS,iBAAgB,CAAE;AAAA,IACjC;AAAA,EACG,GAAE,CAAC,oBAAoB,UAAU,OAAO,aAAa,CAAC;AACvD,QAAM,cAAc,iBAAiB,CAAC,UAAU,MAAM,iBAAiB,EAAE,KAAK,WAAW;AACzF,QAAM,uBAAuB,eAAe,YAAY,KAAK,CAAC,eAAe,WAAW,YAAY,iBAAiB,IAAI,OAAO;AAChI,SAAO;AAAA,IACL;AAAA,IACA,SAAS,CAAC,aAAa;AAAA,IACvB;AAAA,EACJ;AACA;"}
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
- const index = require("../_chunks/index-r8UM9pKc.js");
3
- require("@strapi/helper-plugin");
2
+ const index = require("../_chunks/index-ri1exVbc.js");
4
3
  require("@strapi/icons");
5
4
  module.exports = index.index;
6
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
@@ -1,5 +1,4 @@
1
- import { i } from "../_chunks/index-6c_gUVrM.mjs";
2
- import "@strapi/helper-plugin";
1
+ import { i } from "../_chunks/index-JM6LA3Oe.mjs";
3
2
  import "@strapi/icons";
4
3
  export {
5
4
  i as default
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
1
+ {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
package/dist/style.css ADDED
@@ -0,0 +1,84 @@
1
+ /*
2
+
3
+ Orginal Style from ethanschoonover.com/solarized (c) Jeremy Hull <sourdrums@gmail.com>
4
+
5
+ */
6
+
7
+ .hljs {
8
+ display: block;
9
+ overflow-x: auto;
10
+ padding: 0.5em;
11
+ background: #002b36;
12
+ color: #839496;
13
+ }
14
+
15
+ .hljs-comment,
16
+ .hljs-quote {
17
+ color: #586e75;
18
+ }
19
+
20
+ /* Solarized Green */
21
+ .hljs-keyword,
22
+ .hljs-selector-tag,
23
+ .hljs-addition {
24
+ color: #859900;
25
+ }
26
+
27
+ /* Solarized Cyan */
28
+ .hljs-number,
29
+ .hljs-string,
30
+ .hljs-meta .hljs-meta-string,
31
+ .hljs-literal,
32
+ .hljs-doctag,
33
+ .hljs-regexp {
34
+ color: #2aa198;
35
+ }
36
+
37
+ /* Solarized Blue */
38
+ .hljs-title,
39
+ .hljs-section,
40
+ .hljs-name,
41
+ .hljs-selector-id,
42
+ .hljs-selector-class {
43
+ color: #268bd2;
44
+ }
45
+
46
+ /* Solarized Yellow */
47
+ .hljs-attribute,
48
+ .hljs-attr,
49
+ .hljs-variable,
50
+ .hljs-template-variable,
51
+ .hljs-class .hljs-title,
52
+ .hljs-type {
53
+ color: #b58900;
54
+ }
55
+
56
+ /* Solarized Orange */
57
+ .hljs-symbol,
58
+ .hljs-bullet,
59
+ .hljs-subst,
60
+ .hljs-meta,
61
+ .hljs-meta .hljs-keyword,
62
+ .hljs-selector-attr,
63
+ .hljs-selector-pseudo,
64
+ .hljs-link {
65
+ color: #cb4b16;
66
+ }
67
+
68
+ /* Solarized Red */
69
+ .hljs-built_in,
70
+ .hljs-deletion {
71
+ color: #dc322f;
72
+ }
73
+
74
+ .hljs-formula {
75
+ background: #073642;
76
+ }
77
+
78
+ .hljs-emphasis {
79
+ font-style: italic;
80
+ }
81
+
82
+ .hljs-strong {
83
+ font-weight: bold;
84
+ }