@kontainer/strapi-plugin 0.1.0
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/LICENSE +21 -0
- package/README.md +129 -0
- package/dist/admin/KontainerMediaInput-C6wPHxqb.js +148 -0
- package/dist/admin/KontainerMediaInput-DmEdEpue.mjs +130 -0
- package/dist/admin/Settings-fZTH8z6T.js +152 -0
- package/dist/admin/Settings-tNEBWX1o.mjs +134 -0
- package/dist/admin/da-Be8uFPrt.js +28 -0
- package/dist/admin/da-WHaTm2Cy.mjs +28 -0
- package/dist/admin/en-B3JWZj1Z.mjs +28 -0
- package/dist/admin/en-B7EZhOY4.js +28 -0
- package/dist/admin/index-CMAfPTry.js +121 -0
- package/dist/admin/index-hpPTiq45.mjs +122 -0
- package/dist/admin/index.js +4 -0
- package/dist/admin/index.mjs +4 -0
- package/dist/admin/src/components/Initializer.d.ts +5 -0
- package/dist/admin/src/components/KontainerMediaInput.d.ts +3 -0
- package/dist/admin/src/components/PluginIcon.d.ts +2 -0
- package/dist/admin/src/index.d.ts +3 -0
- package/dist/admin/src/pages/Settings.d.ts +3 -0
- package/dist/admin/src/pluginId.d.ts +1 -0
- package/dist/admin/src/utils/getTranslation.d.ts +2 -0
- package/dist/server/index.js +356 -0
- package/dist/server/index.mjs +356 -0
- package/dist/server/src/bootstrap.d.ts +5 -0
- package/dist/server/src/config/index.d.ts +9 -0
- package/dist/server/src/content-types/index.d.ts +2 -0
- package/dist/server/src/controllers/controller.d.ts +11 -0
- package/dist/server/src/controllers/index.d.ts +12 -0
- package/dist/server/src/destroy.d.ts +5 -0
- package/dist/server/src/index.d.ts +108 -0
- package/dist/server/src/middlewares/index.d.ts +2 -0
- package/dist/server/src/policies/index.d.ts +2 -0
- package/dist/server/src/register.d.ts +5 -0
- package/dist/server/src/routes/admin/index.d.ts +12 -0
- package/dist/server/src/routes/content-api/index.d.ts +12 -0
- package/dist/server/src/routes/index.d.ts +25 -0
- package/dist/server/src/services/index.d.ts +51 -0
- package/dist/server/src/services/service.d.ts +57 -0
- package/package.json +91 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { Box, Flex, Typography, Field, TextInput, Button } from "@strapi/design-system";
|
|
4
|
+
import { Check } from "@strapi/icons";
|
|
5
|
+
import { useFetchClient, useNotification } from "@strapi/strapi/admin";
|
|
6
|
+
import { useIntl } from "react-intl";
|
|
7
|
+
import { g as getTranslation } from "./index-hpPTiq45.mjs";
|
|
8
|
+
const VALIDATION_DEBOUNCE_MS = 500;
|
|
9
|
+
const Settings = () => {
|
|
10
|
+
const { formatMessage } = useIntl();
|
|
11
|
+
const { get, put } = useFetchClient();
|
|
12
|
+
const { toggleNotification } = useNotification();
|
|
13
|
+
const [url, setUrl] = React.useState("");
|
|
14
|
+
const [fileUrl, setFileUrl] = React.useState("");
|
|
15
|
+
const [loading, setLoading] = React.useState(true);
|
|
16
|
+
const [saving, setSaving] = React.useState(false);
|
|
17
|
+
const [validation, setValidation] = React.useState({ status: "idle" });
|
|
18
|
+
const validationSeq = React.useRef(0);
|
|
19
|
+
React.useEffect(() => {
|
|
20
|
+
get("/kontainer/settings").then(({ data }) => {
|
|
21
|
+
setUrl(data.url);
|
|
22
|
+
setFileUrl(data.fileUrl);
|
|
23
|
+
}).catch(() => {
|
|
24
|
+
}).finally(() => setLoading(false));
|
|
25
|
+
}, [get]);
|
|
26
|
+
React.useEffect(() => {
|
|
27
|
+
if (loading) return;
|
|
28
|
+
const seq = ++validationSeq.current;
|
|
29
|
+
const trimmed = url.trim();
|
|
30
|
+
if (!trimmed) {
|
|
31
|
+
setValidation({ status: "idle" });
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
setValidation({ status: "checking" });
|
|
35
|
+
const timer = setTimeout(() => {
|
|
36
|
+
get("/kontainer/settings/validate", { params: { url: trimmed } }).then(({ data }) => {
|
|
37
|
+
if (seq !== validationSeq.current) return;
|
|
38
|
+
setValidation(
|
|
39
|
+
data.valid ? { status: "valid" } : { status: "invalid", reason: data.reason ?? "invalid-url" }
|
|
40
|
+
);
|
|
41
|
+
}).catch(() => {
|
|
42
|
+
if (seq !== validationSeq.current) return;
|
|
43
|
+
setValidation({ status: "invalid", reason: "unreachable" });
|
|
44
|
+
});
|
|
45
|
+
}, VALIDATION_DEBOUNCE_MS);
|
|
46
|
+
return () => clearTimeout(timer);
|
|
47
|
+
}, [url, loading, get]);
|
|
48
|
+
const save = async () => {
|
|
49
|
+
setSaving(true);
|
|
50
|
+
try {
|
|
51
|
+
await put("/kontainer/settings", { url: url.trim() });
|
|
52
|
+
toggleNotification({
|
|
53
|
+
type: "success",
|
|
54
|
+
message: formatMessage({
|
|
55
|
+
id: getTranslation("settings.saved"),
|
|
56
|
+
defaultMessage: "Kontainer settings saved"
|
|
57
|
+
})
|
|
58
|
+
});
|
|
59
|
+
} catch {
|
|
60
|
+
toggleNotification({
|
|
61
|
+
type: "danger",
|
|
62
|
+
message: formatMessage({
|
|
63
|
+
id: getTranslation("settings.save-error"),
|
|
64
|
+
defaultMessage: "Could not save — enter a valid http(s) URL"
|
|
65
|
+
})
|
|
66
|
+
});
|
|
67
|
+
} finally {
|
|
68
|
+
setSaving(false);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
const invalidMessage = (reason) => formatMessage({
|
|
72
|
+
id: getTranslation(`settings.validation.${reason}`),
|
|
73
|
+
defaultMessage: reason === "not-kontainer" ? "This URL does not appear to be a Kontainer instance" : reason === "unreachable" ? "The Strapi server could not reach this URL" : "Not a valid URL"
|
|
74
|
+
});
|
|
75
|
+
return /* @__PURE__ */ jsx(Box, { padding: 10, children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "flex-start", gap: 6, maxWidth: "60rem", children: [
|
|
76
|
+
/* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "flex-start", gap: 1, children: [
|
|
77
|
+
/* @__PURE__ */ jsx(Typography, { variant: "alpha", tag: "h1", children: "Kontainer" }),
|
|
78
|
+
/* @__PURE__ */ jsx(Typography, { variant: "epsilon", textColor: "neutral600", children: formatMessage({
|
|
79
|
+
id: getTranslation("settings.subtitle"),
|
|
80
|
+
defaultMessage: "Connect Strapi to your Kontainer DAM. Editors pick files from this Kontainer in the content editor."
|
|
81
|
+
}) })
|
|
82
|
+
] }),
|
|
83
|
+
/* @__PURE__ */ jsxs(
|
|
84
|
+
Field.Root,
|
|
85
|
+
{
|
|
86
|
+
name: "kontainer-url",
|
|
87
|
+
error: validation.status === "invalid" ? invalidMessage(validation.reason) : void 0,
|
|
88
|
+
hint: fileUrl ? formatMessage(
|
|
89
|
+
{
|
|
90
|
+
id: getTranslation("settings.url.hint-fallback"),
|
|
91
|
+
defaultMessage: "Leave empty to use the value from config/plugins: {fileUrl}"
|
|
92
|
+
},
|
|
93
|
+
{ fileUrl }
|
|
94
|
+
) : formatMessage({
|
|
95
|
+
id: getTranslation("settings.url.hint"),
|
|
96
|
+
defaultMessage: "Example: https://yourcompany.kontainer.com"
|
|
97
|
+
}),
|
|
98
|
+
style: { width: "100%" },
|
|
99
|
+
children: [
|
|
100
|
+
/* @__PURE__ */ jsx(Field.Label, { children: formatMessage({
|
|
101
|
+
id: getTranslation("settings.url.label"),
|
|
102
|
+
defaultMessage: "Kontainer URL"
|
|
103
|
+
}) }),
|
|
104
|
+
/* @__PURE__ */ jsx(
|
|
105
|
+
TextInput,
|
|
106
|
+
{
|
|
107
|
+
placeholder: "https://yourcompany.kontainer.com",
|
|
108
|
+
value: url,
|
|
109
|
+
disabled: loading,
|
|
110
|
+
onChange: (e) => setUrl(e.target.value)
|
|
111
|
+
}
|
|
112
|
+
),
|
|
113
|
+
validation.status === "checking" && /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: formatMessage({
|
|
114
|
+
id: getTranslation("settings.validation.checking"),
|
|
115
|
+
defaultMessage: "Checking…"
|
|
116
|
+
}) }),
|
|
117
|
+
validation.status === "valid" && /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "success600", children: formatMessage({
|
|
118
|
+
id: getTranslation("settings.validation.valid"),
|
|
119
|
+
defaultMessage: "Kontainer instance detected"
|
|
120
|
+
}) }),
|
|
121
|
+
/* @__PURE__ */ jsx(Field.Hint, {}),
|
|
122
|
+
/* @__PURE__ */ jsx(Field.Error, {})
|
|
123
|
+
]
|
|
124
|
+
}
|
|
125
|
+
),
|
|
126
|
+
/* @__PURE__ */ jsx(Button, { onClick: save, loading: saving, disabled: loading, startIcon: /* @__PURE__ */ jsx(Check, {}), children: formatMessage({
|
|
127
|
+
id: getTranslation("settings.save"),
|
|
128
|
+
defaultMessage: "Save"
|
|
129
|
+
}) })
|
|
130
|
+
] }) });
|
|
131
|
+
};
|
|
132
|
+
export {
|
|
133
|
+
Settings as default
|
|
134
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const da = {
|
|
4
|
+
"plugin.name": "Kontainer",
|
|
5
|
+
"field.label": "Kontainer medie",
|
|
6
|
+
"field.description": "Vælg en fil fra Kontainer",
|
|
7
|
+
"field.options.required": "Obligatorisk felt",
|
|
8
|
+
"field.options.required.description": "Du kan ikke gemme et indlæg, hvis dette felt er tomt",
|
|
9
|
+
"input.choose": "Vælg fra Kontainer",
|
|
10
|
+
"input.replace": "Erstat",
|
|
11
|
+
"input.remove": "Fjern",
|
|
12
|
+
"input.not-configured": "Kontainer-URL er ikke konfigureret. Sæt den under Indstillinger → Kontainer.",
|
|
13
|
+
"settings.section": "Kontainer",
|
|
14
|
+
"settings.link": "Konfiguration",
|
|
15
|
+
"settings.subtitle": "Forbind Strapi til din Kontainer DAM. Redaktører vælger filer fra denne Kontainer i editoren.",
|
|
16
|
+
"settings.url.label": "Kontainer-URL",
|
|
17
|
+
"settings.url.hint": "Eksempel: https://ditfirma.kontainer.com",
|
|
18
|
+
"settings.url.hint-fallback": "Lad stå tomt for at bruge værdien fra config/plugins: {fileUrl}",
|
|
19
|
+
"settings.save": "Gem",
|
|
20
|
+
"settings.saved": "Kontainer-indstillinger gemt",
|
|
21
|
+
"settings.save-error": "Kunne ikke gemme — angiv en gyldig http(s)-URL",
|
|
22
|
+
"settings.validation.checking": "Kontrollerer…",
|
|
23
|
+
"settings.validation.valid": "Kontainer-instans fundet",
|
|
24
|
+
"settings.validation.invalid-url": "Ikke en gyldig URL",
|
|
25
|
+
"settings.validation.not-kontainer": "URL’en ser ikke ud til at være en Kontainer-instans",
|
|
26
|
+
"settings.validation.unreachable": "Strapi-serveren kunne ikke nå denne URL"
|
|
27
|
+
};
|
|
28
|
+
exports.default = da;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const da = {
|
|
2
|
+
"plugin.name": "Kontainer",
|
|
3
|
+
"field.label": "Kontainer medie",
|
|
4
|
+
"field.description": "Vælg en fil fra Kontainer",
|
|
5
|
+
"field.options.required": "Obligatorisk felt",
|
|
6
|
+
"field.options.required.description": "Du kan ikke gemme et indlæg, hvis dette felt er tomt",
|
|
7
|
+
"input.choose": "Vælg fra Kontainer",
|
|
8
|
+
"input.replace": "Erstat",
|
|
9
|
+
"input.remove": "Fjern",
|
|
10
|
+
"input.not-configured": "Kontainer-URL er ikke konfigureret. Sæt den under Indstillinger → Kontainer.",
|
|
11
|
+
"settings.section": "Kontainer",
|
|
12
|
+
"settings.link": "Konfiguration",
|
|
13
|
+
"settings.subtitle": "Forbind Strapi til din Kontainer DAM. Redaktører vælger filer fra denne Kontainer i editoren.",
|
|
14
|
+
"settings.url.label": "Kontainer-URL",
|
|
15
|
+
"settings.url.hint": "Eksempel: https://ditfirma.kontainer.com",
|
|
16
|
+
"settings.url.hint-fallback": "Lad stå tomt for at bruge værdien fra config/plugins: {fileUrl}",
|
|
17
|
+
"settings.save": "Gem",
|
|
18
|
+
"settings.saved": "Kontainer-indstillinger gemt",
|
|
19
|
+
"settings.save-error": "Kunne ikke gemme — angiv en gyldig http(s)-URL",
|
|
20
|
+
"settings.validation.checking": "Kontrollerer…",
|
|
21
|
+
"settings.validation.valid": "Kontainer-instans fundet",
|
|
22
|
+
"settings.validation.invalid-url": "Ikke en gyldig URL",
|
|
23
|
+
"settings.validation.not-kontainer": "URL’en ser ikke ud til at være en Kontainer-instans",
|
|
24
|
+
"settings.validation.unreachable": "Strapi-serveren kunne ikke nå denne URL"
|
|
25
|
+
};
|
|
26
|
+
export {
|
|
27
|
+
da as default
|
|
28
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const en = {
|
|
2
|
+
"plugin.name": "Kontainer",
|
|
3
|
+
"field.label": "Kontainer media",
|
|
4
|
+
"field.description": "Pick a file from Kontainer",
|
|
5
|
+
"field.options.required": "Required field",
|
|
6
|
+
"field.options.required.description": "You won't be able to save an entry if this field is empty",
|
|
7
|
+
"input.choose": "Choose from Kontainer",
|
|
8
|
+
"input.replace": "Replace",
|
|
9
|
+
"input.remove": "Remove",
|
|
10
|
+
"input.not-configured": "Kontainer URL is not configured. Set it under Settings → Kontainer.",
|
|
11
|
+
"settings.section": "Kontainer",
|
|
12
|
+
"settings.link": "Configuration",
|
|
13
|
+
"settings.subtitle": "Connect Strapi to your Kontainer DAM. Editors pick files from this Kontainer in the content editor.",
|
|
14
|
+
"settings.url.label": "Kontainer URL",
|
|
15
|
+
"settings.url.hint": "Example: https://yourcompany.kontainer.com",
|
|
16
|
+
"settings.url.hint-fallback": "Leave empty to use the value from config/plugins: {fileUrl}",
|
|
17
|
+
"settings.save": "Save",
|
|
18
|
+
"settings.saved": "Kontainer settings saved",
|
|
19
|
+
"settings.save-error": "Could not save — enter a valid http(s) URL",
|
|
20
|
+
"settings.validation.checking": "Checking…",
|
|
21
|
+
"settings.validation.valid": "Kontainer instance detected",
|
|
22
|
+
"settings.validation.invalid-url": "Not a valid URL",
|
|
23
|
+
"settings.validation.not-kontainer": "This URL does not appear to be a Kontainer instance",
|
|
24
|
+
"settings.validation.unreachable": "The Strapi server could not reach this URL"
|
|
25
|
+
};
|
|
26
|
+
export {
|
|
27
|
+
en as default
|
|
28
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const en = {
|
|
4
|
+
"plugin.name": "Kontainer",
|
|
5
|
+
"field.label": "Kontainer media",
|
|
6
|
+
"field.description": "Pick a file from Kontainer",
|
|
7
|
+
"field.options.required": "Required field",
|
|
8
|
+
"field.options.required.description": "You won't be able to save an entry if this field is empty",
|
|
9
|
+
"input.choose": "Choose from Kontainer",
|
|
10
|
+
"input.replace": "Replace",
|
|
11
|
+
"input.remove": "Remove",
|
|
12
|
+
"input.not-configured": "Kontainer URL is not configured. Set it under Settings → Kontainer.",
|
|
13
|
+
"settings.section": "Kontainer",
|
|
14
|
+
"settings.link": "Configuration",
|
|
15
|
+
"settings.subtitle": "Connect Strapi to your Kontainer DAM. Editors pick files from this Kontainer in the content editor.",
|
|
16
|
+
"settings.url.label": "Kontainer URL",
|
|
17
|
+
"settings.url.hint": "Example: https://yourcompany.kontainer.com",
|
|
18
|
+
"settings.url.hint-fallback": "Leave empty to use the value from config/plugins: {fileUrl}",
|
|
19
|
+
"settings.save": "Save",
|
|
20
|
+
"settings.saved": "Kontainer settings saved",
|
|
21
|
+
"settings.save-error": "Could not save — enter a valid http(s) URL",
|
|
22
|
+
"settings.validation.checking": "Checking…",
|
|
23
|
+
"settings.validation.valid": "Kontainer instance detected",
|
|
24
|
+
"settings.validation.invalid-url": "Not a valid URL",
|
|
25
|
+
"settings.validation.not-kontainer": "This URL does not appear to be a Kontainer instance",
|
|
26
|
+
"settings.validation.unreachable": "The Strapi server could not reach this URL"
|
|
27
|
+
};
|
|
28
|
+
exports.default = en;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const React = require("react");
|
|
3
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
+
const icons = require("@strapi/icons");
|
|
5
|
+
const __variableDynamicImportRuntimeHelper = (glob, path, segs) => {
|
|
6
|
+
const v = glob[path];
|
|
7
|
+
if (v) {
|
|
8
|
+
return typeof v === "function" ? v() : Promise.resolve(v);
|
|
9
|
+
}
|
|
10
|
+
return new Promise((_, reject) => {
|
|
11
|
+
(typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(
|
|
12
|
+
reject.bind(
|
|
13
|
+
null,
|
|
14
|
+
new Error(
|
|
15
|
+
"Unknown variable dynamic import: " + path + (path.split("/").length !== segs ? ". Note that variables only represent file names one level deep." : "")
|
|
16
|
+
)
|
|
17
|
+
)
|
|
18
|
+
);
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
const PLUGIN_ID = "kontainer";
|
|
22
|
+
const getTranslation = (id) => `${PLUGIN_ID}.${id}`;
|
|
23
|
+
const Initializer = ({ setPlugin }) => {
|
|
24
|
+
const ref = React.useRef(setPlugin);
|
|
25
|
+
React.useEffect(() => {
|
|
26
|
+
ref.current(PLUGIN_ID);
|
|
27
|
+
}, []);
|
|
28
|
+
return null;
|
|
29
|
+
};
|
|
30
|
+
const PluginIcon = () => /* @__PURE__ */ jsxRuntime.jsx(icons.PuzzlePiece, {});
|
|
31
|
+
const plugin = {
|
|
32
|
+
register(app) {
|
|
33
|
+
app.customFields.register({
|
|
34
|
+
name: "media",
|
|
35
|
+
pluginId: PLUGIN_ID,
|
|
36
|
+
type: "json",
|
|
37
|
+
icon: PluginIcon,
|
|
38
|
+
intlLabel: {
|
|
39
|
+
id: getTranslation("field.label"),
|
|
40
|
+
defaultMessage: "Kontainer media"
|
|
41
|
+
},
|
|
42
|
+
intlDescription: {
|
|
43
|
+
id: getTranslation("field.description"),
|
|
44
|
+
defaultMessage: "Pick a file from Kontainer"
|
|
45
|
+
},
|
|
46
|
+
components: {
|
|
47
|
+
Input: async () => Promise.resolve().then(() => require("./KontainerMediaInput-C6wPHxqb.js"))
|
|
48
|
+
},
|
|
49
|
+
options: {
|
|
50
|
+
advanced: [
|
|
51
|
+
{
|
|
52
|
+
sectionTitle: {
|
|
53
|
+
id: "global.settings",
|
|
54
|
+
defaultMessage: "Settings"
|
|
55
|
+
},
|
|
56
|
+
items: [
|
|
57
|
+
{
|
|
58
|
+
name: "required",
|
|
59
|
+
type: "checkbox",
|
|
60
|
+
intlLabel: {
|
|
61
|
+
id: getTranslation("field.options.required"),
|
|
62
|
+
defaultMessage: "Required field"
|
|
63
|
+
},
|
|
64
|
+
description: {
|
|
65
|
+
id: getTranslation("field.options.required.description"),
|
|
66
|
+
defaultMessage: "You won't be able to save an entry if this field is empty"
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
]
|
|
70
|
+
}
|
|
71
|
+
]
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
app.createSettingSection(
|
|
75
|
+
{
|
|
76
|
+
id: PLUGIN_ID,
|
|
77
|
+
intlLabel: {
|
|
78
|
+
id: getTranslation("settings.section"),
|
|
79
|
+
defaultMessage: "Kontainer"
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
[
|
|
83
|
+
{
|
|
84
|
+
intlLabel: {
|
|
85
|
+
id: getTranslation("settings.link"),
|
|
86
|
+
defaultMessage: "Configuration"
|
|
87
|
+
},
|
|
88
|
+
id: `${PLUGIN_ID}-settings`,
|
|
89
|
+
to: `plugins/${PLUGIN_ID}`,
|
|
90
|
+
Component: () => Promise.resolve().then(() => require("./Settings-fZTH8z6T.js")),
|
|
91
|
+
permissions: []
|
|
92
|
+
}
|
|
93
|
+
]
|
|
94
|
+
);
|
|
95
|
+
app.registerPlugin({
|
|
96
|
+
id: PLUGIN_ID,
|
|
97
|
+
initializer: Initializer,
|
|
98
|
+
isReady: false,
|
|
99
|
+
name: PLUGIN_ID
|
|
100
|
+
});
|
|
101
|
+
},
|
|
102
|
+
registerTrads({ locales }) {
|
|
103
|
+
return Promise.all(
|
|
104
|
+
locales.map(async (locale) => {
|
|
105
|
+
try {
|
|
106
|
+
const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/da.json": () => Promise.resolve().then(() => require("./da-Be8uFPrt.js")), "./translations/en.json": () => Promise.resolve().then(() => require("./en-B7EZhOY4.js")) }), `./translations/${locale}.json`, 3);
|
|
107
|
+
const newData = {};
|
|
108
|
+
const keys = Object.keys(data);
|
|
109
|
+
for (const key of keys) {
|
|
110
|
+
newData[getTranslation(key)] = data[key];
|
|
111
|
+
}
|
|
112
|
+
return { data: newData, locale };
|
|
113
|
+
} catch {
|
|
114
|
+
return { data: {}, locale };
|
|
115
|
+
}
|
|
116
|
+
})
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
exports.getTranslation = getTranslation;
|
|
121
|
+
exports.plugin = plugin;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { useRef, useEffect } from "react";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { PuzzlePiece } from "@strapi/icons";
|
|
4
|
+
const __variableDynamicImportRuntimeHelper = (glob, path, segs) => {
|
|
5
|
+
const v = glob[path];
|
|
6
|
+
if (v) {
|
|
7
|
+
return typeof v === "function" ? v() : Promise.resolve(v);
|
|
8
|
+
}
|
|
9
|
+
return new Promise((_, reject) => {
|
|
10
|
+
(typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(
|
|
11
|
+
reject.bind(
|
|
12
|
+
null,
|
|
13
|
+
new Error(
|
|
14
|
+
"Unknown variable dynamic import: " + path + (path.split("/").length !== segs ? ". Note that variables only represent file names one level deep." : "")
|
|
15
|
+
)
|
|
16
|
+
)
|
|
17
|
+
);
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
const PLUGIN_ID = "kontainer";
|
|
21
|
+
const getTranslation = (id) => `${PLUGIN_ID}.${id}`;
|
|
22
|
+
const Initializer = ({ setPlugin }) => {
|
|
23
|
+
const ref = useRef(setPlugin);
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
ref.current(PLUGIN_ID);
|
|
26
|
+
}, []);
|
|
27
|
+
return null;
|
|
28
|
+
};
|
|
29
|
+
const PluginIcon = () => /* @__PURE__ */ jsx(PuzzlePiece, {});
|
|
30
|
+
const plugin = {
|
|
31
|
+
register(app) {
|
|
32
|
+
app.customFields.register({
|
|
33
|
+
name: "media",
|
|
34
|
+
pluginId: PLUGIN_ID,
|
|
35
|
+
type: "json",
|
|
36
|
+
icon: PluginIcon,
|
|
37
|
+
intlLabel: {
|
|
38
|
+
id: getTranslation("field.label"),
|
|
39
|
+
defaultMessage: "Kontainer media"
|
|
40
|
+
},
|
|
41
|
+
intlDescription: {
|
|
42
|
+
id: getTranslation("field.description"),
|
|
43
|
+
defaultMessage: "Pick a file from Kontainer"
|
|
44
|
+
},
|
|
45
|
+
components: {
|
|
46
|
+
Input: async () => import("./KontainerMediaInput-DmEdEpue.mjs")
|
|
47
|
+
},
|
|
48
|
+
options: {
|
|
49
|
+
advanced: [
|
|
50
|
+
{
|
|
51
|
+
sectionTitle: {
|
|
52
|
+
id: "global.settings",
|
|
53
|
+
defaultMessage: "Settings"
|
|
54
|
+
},
|
|
55
|
+
items: [
|
|
56
|
+
{
|
|
57
|
+
name: "required",
|
|
58
|
+
type: "checkbox",
|
|
59
|
+
intlLabel: {
|
|
60
|
+
id: getTranslation("field.options.required"),
|
|
61
|
+
defaultMessage: "Required field"
|
|
62
|
+
},
|
|
63
|
+
description: {
|
|
64
|
+
id: getTranslation("field.options.required.description"),
|
|
65
|
+
defaultMessage: "You won't be able to save an entry if this field is empty"
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
]
|
|
69
|
+
}
|
|
70
|
+
]
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
app.createSettingSection(
|
|
74
|
+
{
|
|
75
|
+
id: PLUGIN_ID,
|
|
76
|
+
intlLabel: {
|
|
77
|
+
id: getTranslation("settings.section"),
|
|
78
|
+
defaultMessage: "Kontainer"
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
[
|
|
82
|
+
{
|
|
83
|
+
intlLabel: {
|
|
84
|
+
id: getTranslation("settings.link"),
|
|
85
|
+
defaultMessage: "Configuration"
|
|
86
|
+
},
|
|
87
|
+
id: `${PLUGIN_ID}-settings`,
|
|
88
|
+
to: `plugins/${PLUGIN_ID}`,
|
|
89
|
+
Component: () => import("./Settings-tNEBWX1o.mjs"),
|
|
90
|
+
permissions: []
|
|
91
|
+
}
|
|
92
|
+
]
|
|
93
|
+
);
|
|
94
|
+
app.registerPlugin({
|
|
95
|
+
id: PLUGIN_ID,
|
|
96
|
+
initializer: Initializer,
|
|
97
|
+
isReady: false,
|
|
98
|
+
name: PLUGIN_ID
|
|
99
|
+
});
|
|
100
|
+
},
|
|
101
|
+
registerTrads({ locales }) {
|
|
102
|
+
return Promise.all(
|
|
103
|
+
locales.map(async (locale) => {
|
|
104
|
+
try {
|
|
105
|
+
const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/da.json": () => import("./da-WHaTm2Cy.mjs"), "./translations/en.json": () => import("./en-B3JWZj1Z.mjs") }), `./translations/${locale}.json`, 3);
|
|
106
|
+
const newData = {};
|
|
107
|
+
const keys = Object.keys(data);
|
|
108
|
+
for (const key of keys) {
|
|
109
|
+
newData[getTranslation(key)] = data[key];
|
|
110
|
+
}
|
|
111
|
+
return { data: newData, locale };
|
|
112
|
+
} catch {
|
|
113
|
+
return { data: {}, locale };
|
|
114
|
+
}
|
|
115
|
+
})
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
export {
|
|
120
|
+
getTranslation as g,
|
|
121
|
+
plugin as p
|
|
122
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const PLUGIN_ID = "kontainer";
|