strapi-cache 1.6.2-rc.2 → 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 -17
- package/dist/_chunks/de-Dihl3Ias.mjs +0 -17
- package/dist/_chunks/en-CLhkAQFN.mjs +0 -17
- package/dist/_chunks/en-DYulQU0k.js +0 -17
- package/dist/_chunks/index-7Lm6jbM0.js +0 -50
- package/dist/_chunks/index-BJj5EZfj.js +0 -341
- package/dist/_chunks/index-BS9N2eCV.mjs +0 -50
- package/dist/_chunks/index-dynpWXaG.mjs +0 -342
- package/dist/admin/index.js +0 -3
- package/dist/admin/index.mjs +0 -4
- package/dist/server/index.js +0 -842
- package/dist/server/index.mjs +0 -840
- 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 -3
- 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,17 +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;
|
|
@@ -1,17 +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
|
-
};
|
|
@@ -1,17 +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
|
-
};
|
|
@@ -1,17 +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;
|
|
@@ -1,50 +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;
|
|
@@ -1,341 +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;
|
|
@@ -1,50 +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
|
-
};
|