strapi-cache 1.6.2-rc.3 → 1.6.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.
- package/package.json +1 -1
- package/dist/_chunks/de-BABI25Ju.js +0 -18
- package/dist/_chunks/de-BABI25Ju.js.map +0 -1
- package/dist/_chunks/de-Dihl3Ias.mjs +0 -18
- package/dist/_chunks/de-Dihl3Ias.mjs.map +0 -1
- package/dist/_chunks/en-CLhkAQFN.mjs +0 -18
- package/dist/_chunks/en-CLhkAQFN.mjs.map +0 -1
- package/dist/_chunks/en-DYulQU0k.js +0 -18
- package/dist/_chunks/en-DYulQU0k.js.map +0 -1
- package/dist/_chunks/index-7Lm6jbM0.js +0 -51
- package/dist/_chunks/index-7Lm6jbM0.js.map +0 -1
- package/dist/_chunks/index-BJj5EZfj.js +0 -342
- package/dist/_chunks/index-BJj5EZfj.js.map +0 -1
- package/dist/_chunks/index-BS9N2eCV.mjs +0 -51
- package/dist/_chunks/index-BS9N2eCV.mjs.map +0 -1
- package/dist/_chunks/index-dynpWXaG.mjs +0 -343
- package/dist/_chunks/index-dynpWXaG.mjs.map +0 -1
- package/dist/admin/index.js +0 -4
- package/dist/admin/index.js.map +0 -1
- package/dist/admin/index.mjs +0 -5
- package/dist/admin/index.mjs.map +0 -1
- package/dist/server/index.js +0 -846
- package/dist/server/index.js.map +0 -1
- package/dist/server/index.mjs +0 -844
- package/dist/server/index.mjs.map +0 -1
- package/dist/server/src/bootstrap.d.ts +0 -5
- package/dist/server/src/config/index.d.ts +0 -27
- package/dist/server/src/content-types/index.d.ts +0 -2
- package/dist/server/src/controllers/controller.d.ts +0 -10
- package/dist/server/src/controllers/index.d.ts +0 -11
- package/dist/server/src/index.d.ts +0 -75
- package/dist/server/src/middlewares/cache.d.ts +0 -3
- package/dist/server/src/middlewares/graphql.d.ts +0 -2
- package/dist/server/src/middlewares/index.d.ts +0 -6
- package/dist/server/src/permissions.d.ts +0 -6
- package/dist/server/src/policies/index.d.ts +0 -2
- package/dist/server/src/register.d.ts +0 -5
- package/dist/server/src/routes/index.d.ts +0 -19
- package/dist/server/src/routes/purge.d.ts +0 -14
- package/dist/server/src/services/index.d.ts +0 -8
- package/dist/server/src/services/memory/provider.d.ts +0 -17
- package/dist/server/src/services/memory/service.d.ts +0 -6
- package/dist/server/src/services/redis/provider.d.ts +0 -18
- package/dist/server/src/services/redis/service.d.ts +0 -6
- package/dist/server/src/services/resolver.d.ts +0 -3
- package/dist/server/src/types/cache.types.d.ts +0 -18
- package/dist/server/src/utils/body.d.ts +0 -7
- package/dist/server/src/utils/header.d.ts +0 -10
- package/dist/server/src/utils/invalidateCache.d.ts +0 -4
- package/dist/server/src/utils/key.d.ts +0 -4
- package/dist/server/src/utils/log.d.ts +0 -5
- package/dist/server/src/utils/withTimeout.d.ts +0 -1
package/package.json
CHANGED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const de = {
|
|
4
|
-
"strapi-cache.name": "Strapi-Cache",
|
|
5
|
-
"strapi-cache.cache.purge": "Cache leeren",
|
|
6
|
-
"strapi-cache.cache.purge.entity": "Entity-Cache leeren",
|
|
7
|
-
"strapi-cache.cache.cancel": "Nein, abbrechen",
|
|
8
|
-
"strapi-cache.cache.confirm": "Ja, leeren",
|
|
9
|
-
"strapi-cache.cache.purge.confirmation": "Dies löscht alle Schlüssel, bei denen {key} Teil des Schlüssels ist. Sind Sie sicher, dass Sie den Cache leeren möchten?",
|
|
10
|
-
"strapi-cache.cache.purge.success": "Cache erfolgreich für {key} geleert",
|
|
11
|
-
"strapi-cache.cache.purge.error": "Fehler beim Leeren des Caches für {key}",
|
|
12
|
-
"strapi-cache.cache.purge.no-content-type": "Kein Inhaltstyp gefunden",
|
|
13
|
-
"strapi-cache.cache.routes.fetch-error": "Cacheable-Routen konnten nicht abgerufen werden. Die Cache-Löschung funktioniert möglicherweise nicht korrekt.",
|
|
14
|
-
"strapi-cache.settings.description": "Geben Sie unten einen Cache-Schlüssel ein und klicken Sie auf 'Cache leeren', um bestimmte gecachte Inhalte zu löschen.",
|
|
15
|
-
"strapi-cache.settings.key-placeholder": "Cache-Schlüssel zum Leeren eingeben"
|
|
16
|
-
};
|
|
17
|
-
exports.default = de;
|
|
18
|
-
//# sourceMappingURL=de-BABI25Ju.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"de-BABI25Ju.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
const de = {
|
|
2
|
-
"strapi-cache.name": "Strapi-Cache",
|
|
3
|
-
"strapi-cache.cache.purge": "Cache leeren",
|
|
4
|
-
"strapi-cache.cache.purge.entity": "Entity-Cache leeren",
|
|
5
|
-
"strapi-cache.cache.cancel": "Nein, abbrechen",
|
|
6
|
-
"strapi-cache.cache.confirm": "Ja, leeren",
|
|
7
|
-
"strapi-cache.cache.purge.confirmation": "Dies löscht alle Schlüssel, bei denen {key} Teil des Schlüssels ist. Sind Sie sicher, dass Sie den Cache leeren möchten?",
|
|
8
|
-
"strapi-cache.cache.purge.success": "Cache erfolgreich für {key} geleert",
|
|
9
|
-
"strapi-cache.cache.purge.error": "Fehler beim Leeren des Caches für {key}",
|
|
10
|
-
"strapi-cache.cache.purge.no-content-type": "Kein Inhaltstyp gefunden",
|
|
11
|
-
"strapi-cache.cache.routes.fetch-error": "Cacheable-Routen konnten nicht abgerufen werden. Die Cache-Löschung funktioniert möglicherweise nicht korrekt.",
|
|
12
|
-
"strapi-cache.settings.description": "Geben Sie unten einen Cache-Schlüssel ein und klicken Sie auf 'Cache leeren', um bestimmte gecachte Inhalte zu löschen.",
|
|
13
|
-
"strapi-cache.settings.key-placeholder": "Cache-Schlüssel zum Leeren eingeben"
|
|
14
|
-
};
|
|
15
|
-
export {
|
|
16
|
-
de as default
|
|
17
|
-
};
|
|
18
|
-
//# sourceMappingURL=de-Dihl3Ias.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"de-Dihl3Ias.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
const en = {
|
|
2
|
-
"strapi-cache.name": "Strapi-Cache",
|
|
3
|
-
"strapi-cache.cache.purge": "Purge Cache",
|
|
4
|
-
"strapi-cache.cache.purge.entity": "Purge Entity Cache",
|
|
5
|
-
"strapi-cache.cache.cancel": "No, cancel",
|
|
6
|
-
"strapi-cache.cache.confirm": "Yes, purge",
|
|
7
|
-
"strapi-cache.cache.purge.confirmation": "This purges all keys where {key} is part of the key. Are you sure you want to purge the cache?",
|
|
8
|
-
"strapi-cache.cache.purge.success": "Cache purged successfully for {key}",
|
|
9
|
-
"strapi-cache.cache.purge.error": "Error purging cache for {key}",
|
|
10
|
-
"strapi-cache.cache.purge.no-content-type": "No content type found",
|
|
11
|
-
"strapi-cache.cache.routes.fetch-error": "Unable to fetch cacheable routes. Cache purge may not work correctly.",
|
|
12
|
-
"strapi-cache.settings.description": "Enter a cache key below and click 'Purge Cache' to clear specific cached content.",
|
|
13
|
-
"strapi-cache.settings.key-placeholder": "Enter cache key to purge"
|
|
14
|
-
};
|
|
15
|
-
export {
|
|
16
|
-
en as default
|
|
17
|
-
};
|
|
18
|
-
//# sourceMappingURL=en-CLhkAQFN.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"en-CLhkAQFN.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const en = {
|
|
4
|
-
"strapi-cache.name": "Strapi-Cache",
|
|
5
|
-
"strapi-cache.cache.purge": "Purge Cache",
|
|
6
|
-
"strapi-cache.cache.purge.entity": "Purge Entity Cache",
|
|
7
|
-
"strapi-cache.cache.cancel": "No, cancel",
|
|
8
|
-
"strapi-cache.cache.confirm": "Yes, purge",
|
|
9
|
-
"strapi-cache.cache.purge.confirmation": "This purges all keys where {key} is part of the key. Are you sure you want to purge the cache?",
|
|
10
|
-
"strapi-cache.cache.purge.success": "Cache purged successfully for {key}",
|
|
11
|
-
"strapi-cache.cache.purge.error": "Error purging cache for {key}",
|
|
12
|
-
"strapi-cache.cache.purge.no-content-type": "No content type found",
|
|
13
|
-
"strapi-cache.cache.routes.fetch-error": "Unable to fetch cacheable routes. Cache purge may not work correctly.",
|
|
14
|
-
"strapi-cache.settings.description": "Enter a cache key below and click 'Purge Cache' to clear specific cached content.",
|
|
15
|
-
"strapi-cache.settings.key-placeholder": "Enter cache key to purge"
|
|
16
|
-
};
|
|
17
|
-
exports.default = en;
|
|
18
|
-
//# sourceMappingURL=en-DYulQU0k.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"en-DYulQU0k.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;"}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
-
const designSystem = require("@strapi/design-system");
|
|
5
|
-
const reactIntl = require("react-intl");
|
|
6
|
-
const index = require("./index-BJj5EZfj.js");
|
|
7
|
-
const react = require("react");
|
|
8
|
-
const SettingsPage = () => {
|
|
9
|
-
const { formatMessage } = reactIntl.useIntl();
|
|
10
|
-
const [keyToUse, setKeyToUse] = react.useState("");
|
|
11
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { padding: "20px" }, children: [
|
|
12
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "alpha", as: "h1", children: formatMessage({
|
|
13
|
-
id: "strapi-cache.name",
|
|
14
|
-
defaultMessage: "Strapi Cache Settings"
|
|
15
|
-
}) }),
|
|
16
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { marginTop: "16px", marginBottom: "24px" }, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", children: formatMessage({
|
|
17
|
-
id: "strapi-cache.settings.description",
|
|
18
|
-
defaultMessage: 'Enter a cache key below and click "Purge Cache" to clear specific cached content.'
|
|
19
|
-
}) }) }),
|
|
20
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
21
|
-
"div",
|
|
22
|
-
{
|
|
23
|
-
style: {
|
|
24
|
-
display: "flex",
|
|
25
|
-
justifyContent: "center",
|
|
26
|
-
alignItems: "center",
|
|
27
|
-
gap: "12px",
|
|
28
|
-
maxWidth: "400px"
|
|
29
|
-
},
|
|
30
|
-
children: [
|
|
31
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { flex: 1 }, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
32
|
-
designSystem.TextInput,
|
|
33
|
-
{
|
|
34
|
-
placeholder: formatMessage({
|
|
35
|
-
id: "strapi-cache.settings.key-placeholder",
|
|
36
|
-
defaultMessage: "Enter cache key to purge"
|
|
37
|
-
}),
|
|
38
|
-
size: "M",
|
|
39
|
-
type: "text",
|
|
40
|
-
value: keyToUse,
|
|
41
|
-
onChange: (e) => setKeyToUse(e.target.value)
|
|
42
|
-
}
|
|
43
|
-
) }),
|
|
44
|
-
/* @__PURE__ */ jsxRuntime.jsx(index.PurgeModal, { buttonText: "Purge Cache", keyToUse, isSettingsPage: true })
|
|
45
|
-
]
|
|
46
|
-
}
|
|
47
|
-
)
|
|
48
|
-
] });
|
|
49
|
-
};
|
|
50
|
-
exports.default = SettingsPage;
|
|
51
|
-
//# sourceMappingURL=index-7Lm6jbM0.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-7Lm6jbM0.js","sources":["../../admin/src/components/SettingsPage/index.tsx"],"sourcesContent":["import { TextInput, Typography } from '@strapi/design-system';\nimport { useIntl } from 'react-intl';\nimport PurgeModal from '../PurgeModal';\nimport { useState } from 'react';\n\nconst SettingsPage = () => {\n const { formatMessage } = useIntl();\n const [keyToUse, setKeyToUse] = useState<string>('');\n\n return (\n <div style={{ padding: '20px' }}>\n <Typography variant=\"alpha\" as=\"h1\">\n {formatMessage({\n id: 'strapi-cache.name',\n defaultMessage: 'Strapi Cache Settings',\n })}\n </Typography>\n\n <div style={{ marginTop: '16px', marginBottom: '24px' }}>\n <Typography variant=\"omega\">\n {formatMessage({\n id: 'strapi-cache.settings.description',\n defaultMessage:\n 'Enter a cache key below and click \"Purge Cache\" to clear specific cached content.',\n })}\n </Typography>\n </div>\n\n <div\n style={{\n display: 'flex',\n justifyContent: 'center',\n alignItems: 'center',\n gap: '12px',\n maxWidth: '400px',\n }}\n >\n <div style={{ flex: 1 }}>\n <TextInput\n placeholder={formatMessage({\n id: 'strapi-cache.settings.key-placeholder',\n defaultMessage: 'Enter cache key to purge',\n })}\n size=\"M\"\n type=\"text\"\n value={keyToUse}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => setKeyToUse(e.target.value)}\n />\n </div>\n <PurgeModal buttonText=\"Purge Cache\" keyToUse={keyToUse} isSettingsPage />\n </div>\n </div>\n );\n};\n\nexport default SettingsPage;\n"],"names":["useIntl","useState","jsx","Typography","jsxs","TextInput","PurgeModal"],"mappings":";;;;;;;AAKA,MAAM,eAAe,MAAM;AACnB,QAAA,EAAE,cAAc,IAAIA,kBAAQ;AAClC,QAAM,CAAC,UAAU,WAAW,IAAIC,MAAAA,SAAiB,EAAE;AAEnD,yCACG,OAAI,EAAA,OAAO,EAAE,SAAS,OACrB,GAAA,UAAA;AAAA,IAAAC,+BAACC,aAAAA,YAAW,EAAA,SAAQ,SAAQ,IAAG,MAC5B,UAAc,cAAA;AAAA,MACb,IAAI;AAAA,MACJ,gBAAgB;AAAA,IACjB,CAAA,GACH;AAAA,IAECD,2BAAA,IAAA,OAAA,EAAI,OAAO,EAAE,WAAW,QAAQ,cAAc,OAC7C,GAAA,UAAAA,2BAAA,IAACC,yBAAW,EAAA,SAAQ,SACjB,UAAc,cAAA;AAAA,MACb,IAAI;AAAA,MACJ,gBACE;AAAA,IAAA,CACH,GACH,EACF,CAAA;AAAA,IAEAC,2BAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,OAAO;AAAA,UACL,SAAS;AAAA,UACT,gBAAgB;AAAA,UAChB,YAAY;AAAA,UACZ,KAAK;AAAA,UACL,UAAU;AAAA,QACZ;AAAA,QAEA,UAAA;AAAA,UAAAF,2BAAA,IAAC,OAAI,EAAA,OAAO,EAAE,MAAM,KAClB,UAAAA,2BAAA;AAAA,YAACG,aAAA;AAAA,YAAA;AAAA,cACC,aAAa,cAAc;AAAA,gBACzB,IAAI;AAAA,gBACJ,gBAAgB;AAAA,cAAA,CACjB;AAAA,cACD,MAAK;AAAA,cACL,MAAK;AAAA,cACL,OAAO;AAAA,cACP,UAAU,CAAC,MAA2C,YAAY,EAAE,OAAO,KAAK;AAAA,YAAA;AAAA,UAAA,GAEpF;AAAA,yCACCC,MAAW,YAAA,EAAA,YAAW,eAAc,UAAoB,gBAAc,KAAC,CAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAC1E,GACF;AAEJ;;"}
|
|
@@ -1,342 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const react = require("react");
|
|
3
|
-
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
-
const admin = require("@strapi/strapi/admin");
|
|
5
|
-
const reactIntl = require("react-intl");
|
|
6
|
-
const icons = require("@strapi/icons");
|
|
7
|
-
const designSystem = require("@strapi/design-system");
|
|
8
|
-
const __variableDynamicImportRuntimeHelper = (glob, path, segs) => {
|
|
9
|
-
const v = glob[path];
|
|
10
|
-
if (v) {
|
|
11
|
-
return typeof v === "function" ? v() : Promise.resolve(v);
|
|
12
|
-
}
|
|
13
|
-
return new Promise((_, reject) => {
|
|
14
|
-
(typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(
|
|
15
|
-
reject.bind(
|
|
16
|
-
null,
|
|
17
|
-
new Error(
|
|
18
|
-
"Unknown variable dynamic import: " + path + (path.split("/").length !== segs ? ". Note that variables only represent file names one level deep." : "")
|
|
19
|
-
)
|
|
20
|
-
)
|
|
21
|
-
);
|
|
22
|
-
});
|
|
23
|
-
};
|
|
24
|
-
const PLUGIN_ID = "strapi-cache";
|
|
25
|
-
const Initializer = ({ setPlugin }) => {
|
|
26
|
-
const ref = react.useRef(setPlugin);
|
|
27
|
-
react.useEffect(() => {
|
|
28
|
-
ref.current(PLUGIN_ID);
|
|
29
|
-
}, []);
|
|
30
|
-
return null;
|
|
31
|
-
};
|
|
32
|
-
const useCacheConfig = (enabled = true) => {
|
|
33
|
-
const [config, setConfig] = react.useState();
|
|
34
|
-
const [isLoading, setIsLoading] = react.useState(false);
|
|
35
|
-
const [error, setError] = react.useState(null);
|
|
36
|
-
const { get } = admin.useFetchClient();
|
|
37
|
-
react.useEffect(() => {
|
|
38
|
-
if (!enabled) {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
const fetchConfig = async () => {
|
|
42
|
-
setIsLoading(true);
|
|
43
|
-
setError(null);
|
|
44
|
-
try {
|
|
45
|
-
const { data } = await get("/strapi-cache/config");
|
|
46
|
-
setConfig(data);
|
|
47
|
-
} catch (error2) {
|
|
48
|
-
setError(error2);
|
|
49
|
-
} finally {
|
|
50
|
-
setIsLoading(false);
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
fetchConfig();
|
|
54
|
-
}, [enabled, get]);
|
|
55
|
-
return {
|
|
56
|
-
config,
|
|
57
|
-
isLoading,
|
|
58
|
-
error,
|
|
59
|
-
refetch: () => {
|
|
60
|
-
const fetchConfig = async () => {
|
|
61
|
-
setIsLoading(true);
|
|
62
|
-
setError(null);
|
|
63
|
-
try {
|
|
64
|
-
const { data } = await get("/strapi-cache/config");
|
|
65
|
-
setConfig(data);
|
|
66
|
-
} catch (error2) {
|
|
67
|
-
setError(error2);
|
|
68
|
-
} finally {
|
|
69
|
-
setIsLoading(false);
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
fetchConfig();
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
};
|
|
76
|
-
const pluginPermissions = {
|
|
77
|
-
purge: [{ action: "plugin::strapi-cache.purge-cache", subject: null }]
|
|
78
|
-
};
|
|
79
|
-
const useCachePermissions = () => {
|
|
80
|
-
const { allowedActions } = admin.useRBAC(pluginPermissions);
|
|
81
|
-
return {
|
|
82
|
-
canPurgeCache: allowedActions.canPurgeCache,
|
|
83
|
-
allowedActions
|
|
84
|
-
};
|
|
85
|
-
};
|
|
86
|
-
const useCacheOperations = () => {
|
|
87
|
-
const { post } = admin.useFetchClient();
|
|
88
|
-
const isCacheableRoute = (keyToUse, contentTypeName, config) => {
|
|
89
|
-
if (!keyToUse || !config) {
|
|
90
|
-
return false;
|
|
91
|
-
}
|
|
92
|
-
const { cacheableRoutes } = config;
|
|
93
|
-
return cacheableRoutes.length === 0 || cacheableRoutes.some((route) => {
|
|
94
|
-
return route.includes(keyToUse) || contentTypeName && route.includes(contentTypeName);
|
|
95
|
-
});
|
|
96
|
-
};
|
|
97
|
-
const clearCache = async (keyToUse) => {
|
|
98
|
-
if (!keyToUse) {
|
|
99
|
-
return {
|
|
100
|
-
success: false,
|
|
101
|
-
message: "No content type found"
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
try {
|
|
105
|
-
await post(
|
|
106
|
-
`/strapi-cache/purge-cache/key`,
|
|
107
|
-
{ key: keyToUse },
|
|
108
|
-
{
|
|
109
|
-
headers: {
|
|
110
|
-
"Content-Type": "application/json"
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
);
|
|
114
|
-
return {
|
|
115
|
-
success: true,
|
|
116
|
-
message: `Cache purged successfully for key: "${keyToUse}"`
|
|
117
|
-
};
|
|
118
|
-
} catch (error) {
|
|
119
|
-
return {
|
|
120
|
-
success: false,
|
|
121
|
-
message: `Error purging cache for key: "${keyToUse}"`,
|
|
122
|
-
error
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
return {
|
|
127
|
-
isCacheableRoute,
|
|
128
|
-
clearCache
|
|
129
|
-
};
|
|
130
|
-
};
|
|
131
|
-
const useCacheNotifications = (config) => {
|
|
132
|
-
const formatMessage = reactIntl.useIntl().formatMessage;
|
|
133
|
-
const { toggleNotification } = admin.useNotification();
|
|
134
|
-
const showConfigFetchError = (error) => {
|
|
135
|
-
const isPermissionError = error?.response?.status === 403 || error?.response?.status === 401;
|
|
136
|
-
if (!isPermissionError && !config?.disableAdminPopups) {
|
|
137
|
-
toggleNotification({
|
|
138
|
-
type: "warning",
|
|
139
|
-
message: formatMessage({
|
|
140
|
-
id: "strapi-cache.cache.routes.fetch-error",
|
|
141
|
-
defaultMessage: "Unable to fetch cache config. Cache purge may not work correctly."
|
|
142
|
-
})
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
};
|
|
146
|
-
const showPurgeSuccess = (key) => {
|
|
147
|
-
if (!config?.disableAdminPopups) {
|
|
148
|
-
toggleNotification({
|
|
149
|
-
type: "success",
|
|
150
|
-
message: formatMessage(
|
|
151
|
-
{
|
|
152
|
-
id: "strapi-cache.cache.purge.success",
|
|
153
|
-
defaultMessage: "Cache purged successfully"
|
|
154
|
-
},
|
|
155
|
-
{
|
|
156
|
-
key: `"${key}"`
|
|
157
|
-
}
|
|
158
|
-
)
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
};
|
|
162
|
-
const showPurgeError = (key) => {
|
|
163
|
-
if (!config?.disableAdminPopups) {
|
|
164
|
-
toggleNotification({
|
|
165
|
-
type: "danger",
|
|
166
|
-
message: formatMessage(
|
|
167
|
-
{
|
|
168
|
-
id: "strapi-cache.cache.purge.error",
|
|
169
|
-
defaultMessage: "Error purging cache"
|
|
170
|
-
},
|
|
171
|
-
{
|
|
172
|
-
key: `"${key}"`
|
|
173
|
-
}
|
|
174
|
-
)
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
};
|
|
178
|
-
const showNoContentTypeWarning = () => {
|
|
179
|
-
if (!config?.disableAdminPopups) {
|
|
180
|
-
toggleNotification({
|
|
181
|
-
type: "warning",
|
|
182
|
-
message: formatMessage({
|
|
183
|
-
id: "strapi-cache.cache.purge.no-content-type",
|
|
184
|
-
defaultMessage: "No content type found"
|
|
185
|
-
})
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
};
|
|
189
|
-
return {
|
|
190
|
-
showConfigFetchError,
|
|
191
|
-
showPurgeSuccess,
|
|
192
|
-
showPurgeError,
|
|
193
|
-
showNoContentTypeWarning
|
|
194
|
-
};
|
|
195
|
-
};
|
|
196
|
-
function PurgeModal({
|
|
197
|
-
buttonText,
|
|
198
|
-
keyToUse,
|
|
199
|
-
buttonWidth,
|
|
200
|
-
contentTypeName,
|
|
201
|
-
isSettingsPage
|
|
202
|
-
}) {
|
|
203
|
-
const { canPurgeCache } = useCachePermissions();
|
|
204
|
-
const { config, error: configError } = useCacheConfig(canPurgeCache);
|
|
205
|
-
const { isCacheableRoute, clearCache } = useCacheOperations();
|
|
206
|
-
const { showConfigFetchError, showPurgeSuccess, showPurgeError, showNoContentTypeWarning } = useCacheNotifications(config);
|
|
207
|
-
const formatMessage = reactIntl.useIntl().formatMessage;
|
|
208
|
-
react.useEffect(() => {
|
|
209
|
-
if (configError) {
|
|
210
|
-
showConfigFetchError(configError);
|
|
211
|
-
}
|
|
212
|
-
}, [configError, showConfigFetchError]);
|
|
213
|
-
const handleClearCache = async () => {
|
|
214
|
-
if (!keyToUse) {
|
|
215
|
-
showNoContentTypeWarning();
|
|
216
|
-
return;
|
|
217
|
-
}
|
|
218
|
-
const result = await clearCache(keyToUse);
|
|
219
|
-
if (result.success) {
|
|
220
|
-
showPurgeSuccess(keyToUse);
|
|
221
|
-
} else {
|
|
222
|
-
showPurgeError(keyToUse);
|
|
223
|
-
}
|
|
224
|
-
};
|
|
225
|
-
if (!canPurgeCache || !isSettingsPage && !isCacheableRoute(keyToUse, contentTypeName, config)) {
|
|
226
|
-
return null;
|
|
227
|
-
}
|
|
228
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Root, { children: [
|
|
229
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Trigger, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { width: buttonWidth, disabled: !keyToUse, startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Archive, {}), variant: "danger", children: buttonText }) }),
|
|
230
|
-
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Content, { children: [
|
|
231
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Title, { children: buttonText }) }),
|
|
232
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Body, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", children: formatMessage(
|
|
233
|
-
{
|
|
234
|
-
id: "strapi-cache.cache.purge.confirmation",
|
|
235
|
-
defaultMessage: "Are you sure you want to purge the cache?"
|
|
236
|
-
},
|
|
237
|
-
{ key: `"${keyToUse}"` }
|
|
238
|
-
) }) }),
|
|
239
|
-
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Footer, { children: [
|
|
240
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Close, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", children: formatMessage({
|
|
241
|
-
id: "strapi-cache.cache.cancel",
|
|
242
|
-
defaultMessage: "No, cancel"
|
|
243
|
-
}) }) }),
|
|
244
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Close, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: handleClearCache, children: formatMessage({
|
|
245
|
-
id: "strapi-cache.cache.confirm",
|
|
246
|
-
defaultMessage: "Yes, confirm"
|
|
247
|
-
}) }) })
|
|
248
|
-
] })
|
|
249
|
-
] })
|
|
250
|
-
] });
|
|
251
|
-
}
|
|
252
|
-
function PurgeCacheButton() {
|
|
253
|
-
const { contentType } = admin.unstable_useContentManagerContext();
|
|
254
|
-
const { formatMessage } = reactIntl.useIntl();
|
|
255
|
-
const keyToUse = contentType?.info.pluralName;
|
|
256
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
257
|
-
PurgeModal,
|
|
258
|
-
{
|
|
259
|
-
buttonText: formatMessage({
|
|
260
|
-
id: "strapi-cache.cache.purge",
|
|
261
|
-
defaultMessage: "Purge Cache"
|
|
262
|
-
}),
|
|
263
|
-
keyToUse
|
|
264
|
-
}
|
|
265
|
-
);
|
|
266
|
-
}
|
|
267
|
-
function PurgeEntityButton() {
|
|
268
|
-
const { formatMessage } = reactIntl.useIntl();
|
|
269
|
-
const { id, isSingleType, contentType } = admin.unstable_useContentManagerContext();
|
|
270
|
-
const apiPath = isSingleType ? contentType?.info.singularName : id;
|
|
271
|
-
if (!apiPath) {
|
|
272
|
-
return null;
|
|
273
|
-
}
|
|
274
|
-
const keyToUse = encodeURIComponent(apiPath);
|
|
275
|
-
const contentTypeName = isSingleType ? contentType?.info.singularName : contentType?.info.pluralName;
|
|
276
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
277
|
-
PurgeModal,
|
|
278
|
-
{
|
|
279
|
-
buttonWidth: "100%",
|
|
280
|
-
buttonText: formatMessage({
|
|
281
|
-
id: "strapi-cache.cache.purge.entity",
|
|
282
|
-
defaultMessage: "Purge Entity Cache"
|
|
283
|
-
}),
|
|
284
|
-
keyToUse,
|
|
285
|
-
contentTypeName
|
|
286
|
-
}
|
|
287
|
-
);
|
|
288
|
-
}
|
|
289
|
-
const index = {
|
|
290
|
-
register(app) {
|
|
291
|
-
app.registerPlugin({
|
|
292
|
-
id: PLUGIN_ID,
|
|
293
|
-
initializer: Initializer,
|
|
294
|
-
isReady: false,
|
|
295
|
-
name: PLUGIN_ID
|
|
296
|
-
});
|
|
297
|
-
app.getPlugin("content-manager").injectComponent("listView", "actions", {
|
|
298
|
-
name: PurgeCacheButton,
|
|
299
|
-
Component: PurgeCacheButton
|
|
300
|
-
});
|
|
301
|
-
app.getPlugin("content-manager").injectComponent("editView", "right-links", {
|
|
302
|
-
name: PurgeEntityButton,
|
|
303
|
-
Component: PurgeEntityButton
|
|
304
|
-
});
|
|
305
|
-
app.createSettingSection(
|
|
306
|
-
{
|
|
307
|
-
id: PLUGIN_ID,
|
|
308
|
-
intlLabel: {
|
|
309
|
-
id: "strapi-cache.settings.link",
|
|
310
|
-
defaultMessage: "Strapi Cache"
|
|
311
|
-
}
|
|
312
|
-
},
|
|
313
|
-
[
|
|
314
|
-
{
|
|
315
|
-
intlLabel: {
|
|
316
|
-
id: "strapi-cache.settings.link",
|
|
317
|
-
defaultMessage: "Strapi Cache"
|
|
318
|
-
},
|
|
319
|
-
id: "settings",
|
|
320
|
-
to: `${PLUGIN_ID}/settings`,
|
|
321
|
-
Component: () => Promise.resolve().then(() => require("./index-7Lm6jbM0.js")),
|
|
322
|
-
permissions: []
|
|
323
|
-
}
|
|
324
|
-
]
|
|
325
|
-
);
|
|
326
|
-
},
|
|
327
|
-
async registerTrads({ locales }) {
|
|
328
|
-
return Promise.all(
|
|
329
|
-
locales.map(async (locale) => {
|
|
330
|
-
try {
|
|
331
|
-
const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/de.json": () => Promise.resolve().then(() => require("./de-BABI25Ju.js")), "./translations/en.json": () => Promise.resolve().then(() => require("./en-DYulQU0k.js")) }), `./translations/${locale}.json`, 3);
|
|
332
|
-
return { data, locale };
|
|
333
|
-
} catch {
|
|
334
|
-
return { data: {}, locale };
|
|
335
|
-
}
|
|
336
|
-
})
|
|
337
|
-
);
|
|
338
|
-
}
|
|
339
|
-
};
|
|
340
|
-
exports.PurgeModal = PurgeModal;
|
|
341
|
-
exports.index = index;
|
|
342
|
-
//# sourceMappingURL=index-BJj5EZfj.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-BJj5EZfj.js","sources":["../../admin/src/pluginId.ts","../../admin/src/components/Initializer.tsx","../../admin/src/hooks/useCacheConfig.ts","../../admin/src/permission.ts","../../admin/src/hooks/useCachePermissions.ts","../../admin/src/hooks/useCacheOperations.ts","../../admin/src/hooks/useCacheNotifications.ts","../../admin/src/components/PurgeModal/index.tsx","../../admin/src/components/PurgeCacheButton/index.tsx","../../admin/src/components/PurgeEntityButton/index.tsx","../../admin/src/index.ts"],"sourcesContent":["export const PLUGIN_ID = 'strapi-cache';\n","import { useEffect, useRef } from 'react';\n\nimport { PLUGIN_ID } from '../pluginId';\n\ntype InitializerProps = {\n setPlugin: (id: string) => void;\n};\n\nconst Initializer = ({ setPlugin }: InitializerProps) => {\n const ref = useRef(setPlugin);\n\n useEffect(() => {\n ref.current(PLUGIN_ID);\n }, []);\n\n return null;\n};\n\nexport { Initializer };\n","import { useState, useEffect } from 'react';\nimport { useFetchClient } from '@strapi/strapi/admin';\n\nexport type CacheConfig = {\n cacheableRoutes: string[];\n disableAdminPopups: boolean;\n};\n\nexport const useCacheConfig = (enabled: boolean = true) => {\n const [config, setConfig] = useState<CacheConfig>();\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const { get } = useFetchClient();\n\n useEffect(() => {\n if (!enabled) {\n return;\n }\n\n const fetchConfig = async () => {\n setIsLoading(true);\n setError(null);\n\n try {\n const { data } = await get('/strapi-cache/config');\n setConfig(data);\n } catch (error: any) {\n setError(error);\n } finally {\n setIsLoading(false);\n }\n };\n\n fetchConfig();\n }, [enabled, get]);\n\n return {\n config,\n isLoading,\n error,\n refetch: () => {\n const fetchConfig = async () => {\n setIsLoading(true);\n setError(null);\n\n try {\n const { data } = await get('/strapi-cache/config');\n setConfig(data);\n } catch (error: any) {\n setError(error);\n } finally {\n setIsLoading(false);\n }\n };\n fetchConfig();\n },\n };\n};\n","export const pluginPermissions = {\n purge: [{ action: 'plugin::strapi-cache.purge-cache', subject: null }],\n};\n","import { useRBAC } from '@strapi/strapi/admin';\nimport { pluginPermissions } from '../permission';\n\nexport const useCachePermissions = () => {\n const { allowedActions } = useRBAC(pluginPermissions);\n\n return {\n canPurgeCache: allowedActions.canPurgeCache,\n allowedActions,\n };\n};\n","import { useFetchClient } from '@strapi/strapi/admin';\nimport { CacheConfig } from './useCacheConfig';\n\nexport type CacheOperationResult = {\n success: boolean;\n message?: string;\n error?: Error;\n};\n\nexport const useCacheOperations = () => {\n const { post } = useFetchClient();\n\n const isCacheableRoute = (\n keyToUse?: string,\n contentTypeName?: string,\n config?: CacheConfig\n ): boolean => {\n if (!keyToUse || !config) {\n return false;\n }\n\n const { cacheableRoutes } = config;\n return (\n cacheableRoutes.length === 0 ||\n cacheableRoutes.some((route) => {\n return route.includes(keyToUse) || (contentTypeName && route.includes(contentTypeName));\n })\n );\n };\n\n const clearCache = async (keyToUse?: string): Promise<CacheOperationResult> => {\n if (!keyToUse) {\n return {\n success: false,\n message: 'No content type found',\n };\n }\n\n try {\n await post(\n `/strapi-cache/purge-cache/key`,\n { key: keyToUse },\n {\n headers: {\n 'Content-Type': 'application/json',\n },\n }\n );\n\n return {\n success: true,\n message: `Cache purged successfully for key: \"${keyToUse}\"`,\n };\n } catch (error: any) {\n return {\n success: false,\n message: `Error purging cache for key: \"${keyToUse}\"`,\n error,\n };\n }\n };\n\n return {\n isCacheableRoute,\n clearCache,\n };\n};\n","import { useIntl } from 'react-intl';\nimport { useNotification } from '@strapi/strapi/admin';\nimport { CacheConfig } from './useCacheConfig';\n\nexport const useCacheNotifications = (config?: CacheConfig) => {\n const formatMessage = useIntl().formatMessage;\n const { toggleNotification } = useNotification();\n\n const showConfigFetchError = (error: Error) => {\n // only show error notification if its not a permissions error and popups are not disabled\n const isPermissionError =\n (error as any)?.response?.status === 403 || (error as any)?.response?.status === 401;\n\n if (!isPermissionError && !config?.disableAdminPopups) {\n toggleNotification({\n type: 'warning',\n message: formatMessage({\n id: 'strapi-cache.cache.routes.fetch-error',\n defaultMessage: 'Unable to fetch cache config. Cache purge may not work correctly.',\n }),\n });\n }\n };\n\n const showPurgeSuccess = (key: string) => {\n if (!config?.disableAdminPopups) {\n toggleNotification({\n type: 'success',\n message: formatMessage(\n {\n id: 'strapi-cache.cache.purge.success',\n defaultMessage: 'Cache purged successfully',\n },\n {\n key: `\"${key}\"`,\n }\n ),\n });\n }\n };\n\n const showPurgeError = (key: string) => {\n if (!config?.disableAdminPopups) {\n toggleNotification({\n type: 'danger',\n message: formatMessage(\n {\n id: 'strapi-cache.cache.purge.error',\n defaultMessage: 'Error purging cache',\n },\n {\n key: `\"${key}\"`,\n }\n ),\n });\n }\n };\n\n const showNoContentTypeWarning = () => {\n if (!config?.disableAdminPopups) {\n toggleNotification({\n type: 'warning',\n message: formatMessage({\n id: 'strapi-cache.cache.purge.no-content-type',\n defaultMessage: 'No content type found',\n }),\n });\n }\n };\n\n return {\n showConfigFetchError,\n showPurgeSuccess,\n showPurgeError,\n showNoContentTypeWarning,\n };\n};\n","import { useIntl } from 'react-intl';\nimport { Archive } from '@strapi/icons';\nimport { Button, Modal } from '@strapi/design-system';\nimport { Typography } from '@strapi/design-system';\nimport { useEffect } from 'react';\nimport {\n useCacheConfig,\n useCachePermissions,\n useCacheOperations,\n useCacheNotifications,\n} from '../../hooks';\n\nexport type PurgeProps = {\n buttonText: string;\n buttonWidth?: string;\n keyToUse?: string;\n contentTypeName?: string;\n isSettingsPage?: boolean;\n};\n\nfunction PurgeModal({\n buttonText,\n keyToUse,\n buttonWidth,\n contentTypeName,\n isSettingsPage,\n}: PurgeProps) {\n const { canPurgeCache } = useCachePermissions();\n const { config, error: configError } = useCacheConfig(canPurgeCache);\n const { isCacheableRoute, clearCache } = useCacheOperations();\n const { showConfigFetchError, showPurgeSuccess, showPurgeError, showNoContentTypeWarning } =\n useCacheNotifications(config);\n const formatMessage = useIntl().formatMessage;\n\n useEffect(() => {\n if (configError) {\n showConfigFetchError(configError);\n }\n }, [configError, showConfigFetchError]);\n\n const handleClearCache = async () => {\n if (!keyToUse) {\n showNoContentTypeWarning();\n return;\n }\n\n const result = await clearCache(keyToUse);\n\n if (result.success) {\n showPurgeSuccess(keyToUse);\n } else {\n showPurgeError(keyToUse);\n }\n };\n\n if (!canPurgeCache || (!isSettingsPage && !isCacheableRoute(keyToUse, contentTypeName, config))) {\n return null;\n }\n\n return (\n <Modal.Root>\n <Modal.Trigger>\n <Button width={buttonWidth} disabled={!keyToUse} startIcon={<Archive />} variant=\"danger\">\n {buttonText}\n </Button>\n </Modal.Trigger>\n <Modal.Content>\n <Modal.Header>\n <Modal.Title>{buttonText}</Modal.Title>\n </Modal.Header>\n <Modal.Body>\n <Typography variant=\"omega\">\n {formatMessage(\n {\n id: 'strapi-cache.cache.purge.confirmation',\n defaultMessage: 'Are you sure you want to purge the cache?',\n },\n { key: `\"${keyToUse}\"` }\n )}\n </Typography>\n </Modal.Body>\n <Modal.Footer>\n <Modal.Close>\n <Button variant=\"tertiary\">\n {formatMessage({\n id: 'strapi-cache.cache.cancel',\n defaultMessage: 'No, cancel',\n })}\n </Button>\n </Modal.Close>\n <Modal.Close>\n <Button onClick={handleClearCache}>\n {formatMessage({\n id: 'strapi-cache.cache.confirm',\n defaultMessage: 'Yes, confirm',\n })}\n </Button>\n </Modal.Close>\n </Modal.Footer>\n </Modal.Content>\n </Modal.Root>\n );\n}\n\nexport default PurgeModal;\n","import { unstable_useContentManagerContext as useContentManagerContext } from '@strapi/strapi/admin';\nimport PurgeModal from '../PurgeModal';\nimport { useIntl } from 'react-intl';\n\nfunction PurgeCacheButton() {\n const { contentType } = useContentManagerContext();\n const { formatMessage } = useIntl();\n const keyToUse = contentType?.info.pluralName;\n\n return (\n <PurgeModal\n buttonText={formatMessage({\n id: 'strapi-cache.cache.purge',\n defaultMessage: 'Purge Cache',\n })}\n keyToUse={keyToUse}\n ></PurgeModal>\n );\n}\n\nexport default PurgeCacheButton;\n","import { unstable_useContentManagerContext as useContentManagerContext } from '@strapi/strapi/admin';\nimport PurgeModal from '../PurgeModal';\nimport { useIntl } from 'react-intl';\n\nfunction PurgeEntityButton() {\n const { formatMessage } = useIntl();\n const { id, isSingleType, contentType } = useContentManagerContext();\n const apiPath = isSingleType ? contentType?.info.singularName : id;\n\n if (!apiPath) {\n return null;\n }\n\n const keyToUse = encodeURIComponent(apiPath);\n const contentTypeName = isSingleType\n ? contentType?.info.singularName\n : contentType?.info.pluralName;\n\n return (\n <PurgeModal\n buttonWidth=\"100%\"\n buttonText={formatMessage({\n id: 'strapi-cache.cache.purge.entity',\n defaultMessage: 'Purge Entity Cache',\n })}\n keyToUse={keyToUse}\n contentTypeName={contentTypeName}\n ></PurgeModal>\n );\n}\n\nexport default PurgeEntityButton;\n","import { PLUGIN_ID } from './pluginId';\nimport { Initializer } from './components/Initializer';\nimport PurgeCacheButton from './components/PurgeCacheButton';\nimport PurgeEntityButton from './components/PurgeEntityButton';\n\nexport default {\n register(app: any) {\n app.registerPlugin({\n id: PLUGIN_ID,\n initializer: Initializer,\n isReady: false,\n name: PLUGIN_ID,\n });\n\n app.getPlugin('content-manager').injectComponent('listView', 'actions', {\n name: PurgeCacheButton,\n Component: PurgeCacheButton,\n });\n\n app.getPlugin('content-manager').injectComponent('editView', 'right-links', {\n name: PurgeEntityButton,\n Component: PurgeEntityButton,\n });\n\n app.createSettingSection(\n {\n id: PLUGIN_ID,\n intlLabel: {\n id: 'strapi-cache.settings.link',\n defaultMessage: 'Strapi Cache',\n },\n },\n [\n {\n intlLabel: {\n id: 'strapi-cache.settings.link',\n defaultMessage: 'Strapi Cache',\n },\n id: 'settings',\n to: `${PLUGIN_ID}/settings`,\n Component: () => import('./components/SettingsPage'),\n permissions: [],\n },\n ]\n );\n },\n\n async registerTrads({ locales }: { locales: string[] }) {\n return Promise.all(\n locales.map(async (locale) => {\n try {\n const { default: data } = await import(`./translations/${locale}.json`);\n\n return { data, locale };\n } catch {\n return { data: {}, locale };\n }\n })\n );\n },\n};\n"],"names":["useRef","useEffect","useState","useFetchClient","error","useRBAC","useIntl","useNotification","jsxs","Modal","jsx","Button","Archive","Typography","useContentManagerContext"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAO,MAAM,YAAY;ACQzB,MAAM,cAAc,CAAC,EAAE,gBAAkC;AACjD,QAAA,MAAMA,aAAO,SAAS;AAE5BC,QAAAA,UAAU,MAAM;AACd,QAAI,QAAQ,SAAS;AAAA,EACvB,GAAG,EAAE;AAEE,SAAA;AACT;ACRa,MAAA,iBAAiB,CAAC,UAAmB,SAAS;AACzD,QAAM,CAAC,QAAQ,SAAS,IAAIC,eAAsB;AAClD,QAAM,CAAC,WAAW,YAAY,IAAIA,MAAAA,SAAS,KAAK;AAChD,QAAM,CAAC,OAAO,QAAQ,IAAIA,MAAAA,SAAuB,IAAI;AAC/C,QAAA,EAAE,IAAI,IAAIC,qBAAe;AAE/BF,QAAAA,UAAU,MAAM;AACd,QAAI,CAAC,SAAS;AACZ;AAAA,IAAA;AAGF,UAAM,cAAc,YAAY;AAC9B,mBAAa,IAAI;AACjB,eAAS,IAAI;AAET,UAAA;AACF,cAAM,EAAE,KAAA,IAAS,MAAM,IAAI,sBAAsB;AACjD,kBAAU,IAAI;AAAA,eACPG,QAAY;AACnB,iBAASA,MAAK;AAAA,MAAA,UACd;AACA,qBAAa,KAAK;AAAA,MAAA;AAAA,IAEtB;AAEY,gBAAA;AAAA,EAAA,GACX,CAAC,SAAS,GAAG,CAAC;AAEV,SAAA;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS,MAAM;AACb,YAAM,cAAc,YAAY;AAC9B,qBAAa,IAAI;AACjB,iBAAS,IAAI;AAET,YAAA;AACF,gBAAM,EAAE,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AAA,QAAA,EAAA,KAAA,MAAA,QAAA,kBAAA,CAAA,GAAA,0BAAA,MAAA,qCAAA,kBAAA,CAAA,EAAA,CAAA,GAAA,kBAAA,MAAA,SAAA,CAAA;AAEzB,iBAAA,EAAE,MAAM,OAAO;AAAA,QAAA,QAChB;AACN,iBAAO,EAAE,MAAM,CAAC,GAAG,OAAO;AAAA,QAAA;AAAA,MAE7B,CAAA;AAAA,IACH;AAAA,EAAA;AAEJ;;;"}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Typography, TextInput } from "@strapi/design-system";
|
|
3
|
-
import { useIntl } from "react-intl";
|
|
4
|
-
import { P as PurgeModal } from "./index-dynpWXaG.mjs";
|
|
5
|
-
import { useState } from "react";
|
|
6
|
-
const SettingsPage = () => {
|
|
7
|
-
const { formatMessage } = useIntl();
|
|
8
|
-
const [keyToUse, setKeyToUse] = useState("");
|
|
9
|
-
return /* @__PURE__ */ jsxs("div", { style: { padding: "20px" }, children: [
|
|
10
|
-
/* @__PURE__ */ jsx(Typography, { variant: "alpha", as: "h1", children: formatMessage({
|
|
11
|
-
id: "strapi-cache.name",
|
|
12
|
-
defaultMessage: "Strapi Cache Settings"
|
|
13
|
-
}) }),
|
|
14
|
-
/* @__PURE__ */ jsx("div", { style: { marginTop: "16px", marginBottom: "24px" }, children: /* @__PURE__ */ jsx(Typography, { variant: "omega", children: formatMessage({
|
|
15
|
-
id: "strapi-cache.settings.description",
|
|
16
|
-
defaultMessage: 'Enter a cache key below and click "Purge Cache" to clear specific cached content.'
|
|
17
|
-
}) }) }),
|
|
18
|
-
/* @__PURE__ */ jsxs(
|
|
19
|
-
"div",
|
|
20
|
-
{
|
|
21
|
-
style: {
|
|
22
|
-
display: "flex",
|
|
23
|
-
justifyContent: "center",
|
|
24
|
-
alignItems: "center",
|
|
25
|
-
gap: "12px",
|
|
26
|
-
maxWidth: "400px"
|
|
27
|
-
},
|
|
28
|
-
children: [
|
|
29
|
-
/* @__PURE__ */ jsx("div", { style: { flex: 1 }, children: /* @__PURE__ */ jsx(
|
|
30
|
-
TextInput,
|
|
31
|
-
{
|
|
32
|
-
placeholder: formatMessage({
|
|
33
|
-
id: "strapi-cache.settings.key-placeholder",
|
|
34
|
-
defaultMessage: "Enter cache key to purge"
|
|
35
|
-
}),
|
|
36
|
-
size: "M",
|
|
37
|
-
type: "text",
|
|
38
|
-
value: keyToUse,
|
|
39
|
-
onChange: (e) => setKeyToUse(e.target.value)
|
|
40
|
-
}
|
|
41
|
-
) }),
|
|
42
|
-
/* @__PURE__ */ jsx(PurgeModal, { buttonText: "Purge Cache", keyToUse, isSettingsPage: true })
|
|
43
|
-
]
|
|
44
|
-
}
|
|
45
|
-
)
|
|
46
|
-
] });
|
|
47
|
-
};
|
|
48
|
-
export {
|
|
49
|
-
SettingsPage as default
|
|
50
|
-
};
|
|
51
|
-
//# sourceMappingURL=index-BS9N2eCV.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-BS9N2eCV.mjs","sources":["../../admin/src/components/SettingsPage/index.tsx"],"sourcesContent":["import { TextInput, Typography } from '@strapi/design-system';\nimport { useIntl } from 'react-intl';\nimport PurgeModal from '../PurgeModal';\nimport { useState } from 'react';\n\nconst SettingsPage = () => {\n const { formatMessage } = useIntl();\n const [keyToUse, setKeyToUse] = useState<string>('');\n\n return (\n <div style={{ padding: '20px' }}>\n <Typography variant=\"alpha\" as=\"h1\">\n {formatMessage({\n id: 'strapi-cache.name',\n defaultMessage: 'Strapi Cache Settings',\n })}\n </Typography>\n\n <div style={{ marginTop: '16px', marginBottom: '24px' }}>\n <Typography variant=\"omega\">\n {formatMessage({\n id: 'strapi-cache.settings.description',\n defaultMessage:\n 'Enter a cache key below and click \"Purge Cache\" to clear specific cached content.',\n })}\n </Typography>\n </div>\n\n <div\n style={{\n display: 'flex',\n justifyContent: 'center',\n alignItems: 'center',\n gap: '12px',\n maxWidth: '400px',\n }}\n >\n <div style={{ flex: 1 }}>\n <TextInput\n placeholder={formatMessage({\n id: 'strapi-cache.settings.key-placeholder',\n defaultMessage: 'Enter cache key to purge',\n })}\n size=\"M\"\n type=\"text\"\n value={keyToUse}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => setKeyToUse(e.target.value)}\n />\n </div>\n <PurgeModal buttonText=\"Purge Cache\" keyToUse={keyToUse} isSettingsPage />\n </div>\n </div>\n );\n};\n\nexport default SettingsPage;\n"],"names":[],"mappings":";;;;;AAKA,MAAM,eAAe,MAAM;AACnB,QAAA,EAAE,cAAc,IAAI,QAAQ;AAClC,QAAM,CAAC,UAAU,WAAW,IAAI,SAAiB,EAAE;AAEnD,8BACG,OAAI,EAAA,OAAO,EAAE,SAAS,OACrB,GAAA,UAAA;AAAA,IAAA,oBAAC,YAAW,EAAA,SAAQ,SAAQ,IAAG,MAC5B,UAAc,cAAA;AAAA,MACb,IAAI;AAAA,MACJ,gBAAgB;AAAA,IACjB,CAAA,GACH;AAAA,IAEC,oBAAA,OAAA,EAAI,OAAO,EAAE,WAAW,QAAQ,cAAc,OAC7C,GAAA,UAAA,oBAAC,YAAW,EAAA,SAAQ,SACjB,UAAc,cAAA;AAAA,MACb,IAAI;AAAA,MACJ,gBACE;AAAA,IAAA,CACH,GACH,EACF,CAAA;AAAA,IAEA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,OAAO;AAAA,UACL,SAAS;AAAA,UACT,gBAAgB;AAAA,UAChB,YAAY;AAAA,UACZ,KAAK;AAAA,UACL,UAAU;AAAA,QACZ;AAAA,QAEA,UAAA;AAAA,UAAA,oBAAC,OAAI,EAAA,OAAO,EAAE,MAAM,KAClB,UAAA;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,aAAa,cAAc;AAAA,gBACzB,IAAI;AAAA,gBACJ,gBAAgB;AAAA,cAAA,CACjB;AAAA,cACD,MAAK;AAAA,cACL,MAAK;AAAA,cACL,OAAO;AAAA,cACP,UAAU,CAAC,MAA2C,YAAY,EAAE,OAAO,KAAK;AAAA,YAAA;AAAA,UAAA,GAEpF;AAAA,8BACC,YAAW,EAAA,YAAW,eAAc,UAAoB,gBAAc,KAAC,CAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAC1E,GACF;AAEJ;"}
|