strapi-bulk-publish 1.0.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.
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const React = require("react");
5
+ const index = require("./index-DkTxsEqL.js");
6
+ const designSystem = require("@strapi/design-system");
7
+ const admin = require("@strapi/strapi/admin");
8
+ const index$1 = require("./index-BBZKQRB2.js");
9
+ const SettingsPage = () => {
10
+ const { formatMessage } = index.useIntl();
11
+ const { get, put } = admin.useFetchClient();
12
+ const { toggleNotification } = admin.useNotification();
13
+ const [webhookUrl, setWebhookUrl] = React.useState("");
14
+ const [initialUrl, setInitialUrl] = React.useState("");
15
+ const [loading, setLoading] = React.useState(true);
16
+ const [saving, setSaving] = React.useState(false);
17
+ const fetchSettings = React.useCallback(async () => {
18
+ try {
19
+ const { data } = await get(`/${index$1.PLUGIN_ID}/settings`);
20
+ const url = data.data?.webhookUrl || "";
21
+ setWebhookUrl(url);
22
+ setInitialUrl(url);
23
+ } catch {
24
+ toggleNotification({
25
+ type: "danger",
26
+ message: formatMessage({ id: `${index$1.PLUGIN_ID}.notification.settings.error` })
27
+ });
28
+ } finally {
29
+ setLoading(false);
30
+ }
31
+ }, [get, toggleNotification, formatMessage]);
32
+ React.useEffect(() => {
33
+ fetchSettings();
34
+ }, [fetchSettings]);
35
+ const handleSave = async () => {
36
+ try {
37
+ setSaving(true);
38
+ await put(`/${index$1.PLUGIN_ID}/settings`, { webhookUrl });
39
+ setInitialUrl(webhookUrl);
40
+ toggleNotification({
41
+ type: "success",
42
+ message: formatMessage({ id: `${index$1.PLUGIN_ID}.notification.settings.success` })
43
+ });
44
+ } catch {
45
+ toggleNotification({
46
+ type: "danger",
47
+ message: formatMessage({ id: `${index$1.PLUGIN_ID}.notification.settings.error` })
48
+ });
49
+ } finally {
50
+ setSaving(false);
51
+ }
52
+ };
53
+ const hasChanged = webhookUrl !== initialUrl;
54
+ return /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Protect, { permissions: index$1.pluginPermissions.settings, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Main, { children: loading ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", paddingTop: 8, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Loader, { children: formatMessage({ id: `${index$1.PLUGIN_ID}.loading.settings` }) }) }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
55
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingTop: 8, paddingBottom: 4, paddingLeft: 10, paddingRight: 10, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", alignItems: "center", children: [
56
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { children: [
57
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "alpha", tag: "h1", children: formatMessage({ id: `${index$1.PLUGIN_ID}.settings.title` }) }),
58
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "epsilon", textColor: "neutral600", children: formatMessage({ id: `${index$1.PLUGIN_ID}.settings.subtitle` }) })
59
+ ] }),
60
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: handleSave, disabled: !hasChanged || saving, loading: saving, children: formatMessage({ id: `${index$1.PLUGIN_ID}.button.save` }) })
61
+ ] }) }),
62
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingLeft: 10, paddingRight: 10, paddingBottom: 10, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { background: "neutral0", padding: 6, shadow: "tableShadow", hasRadius: true, children: /* @__PURE__ */ jsxRuntime.jsx(
63
+ designSystem.TextInput,
64
+ {
65
+ label: formatMessage({ id: `${index$1.PLUGIN_ID}.webhook.label` }),
66
+ placeholder: formatMessage({ id: `${index$1.PLUGIN_ID}.webhook.placeholder` }),
67
+ hint: formatMessage({ id: `${index$1.PLUGIN_ID}.webhook.hint` }),
68
+ name: "webhookUrl",
69
+ value: webhookUrl,
70
+ onChange: (e) => setWebhookUrl(e.target.value)
71
+ }
72
+ ) }) })
73
+ ] }) }) });
74
+ };
75
+ exports.SettingsPage = SettingsPage;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const en = {
4
+ "plugin.name": "Bulk Publish",
5
+ "settings.section-label": "Bulk Publish",
6
+ "settings.webhook": "Webhook",
7
+ "page.title": "Bulk Publish",
8
+ "page.subtitle": "Publish documents across all locales with a single action",
9
+ "settings.title": "Bulk Publish Settings",
10
+ "settings.subtitle": "Configure webhook for frontend rebuild",
11
+ "table.title": "Title",
12
+ "table.locales": "Locales",
13
+ "table.status": "Status",
14
+ "table.updated": "Updated {time}",
15
+ "button.publish": "Publish Selected ({count})",
16
+ "button.publishing": "Publishing...",
17
+ "button.save": "Save",
18
+ "button.cancel": "Cancel",
19
+ "button.confirm": "Publish",
20
+ "status.draft": "Draft",
21
+ "status.partial": "Partial",
22
+ "status.published": "Published",
23
+ "legend.draft": "Draft",
24
+ "legend.published": "Published",
25
+ "legend.missing": "Missing",
26
+ "empty.message": "No draft documents found. All documents are published!",
27
+ "loading.posts": "Loading posts...",
28
+ "loading.settings": "Loading settings...",
29
+ "confirm.title": "Confirm Publish",
30
+ "confirm.body": "You are about to publish {count} document(s) across all locales. This action cannot be undone.",
31
+ "notification.publish.success": "Published {count} post(s), {locales} locale(s).",
32
+ "notification.publish.webhook": "Webhook triggered.",
33
+ "notification.publish.webhook-error": "Webhook failed: {error}",
34
+ "notification.publish.errors": "{count} error(s).",
35
+ "notification.publish.error": "Failed to publish posts",
36
+ "notification.settings.success": "Settings saved successfully",
37
+ "notification.settings.error": "Failed to save settings",
38
+ "notification.load.error": "Failed to load posts",
39
+ "webhook.label": "Webhook URL",
40
+ "webhook.placeholder": "https://example.com/api/rebuild",
41
+ "webhook.hint": "POST request will be sent to this URL after publishing",
42
+ "time.just-now": "just now",
43
+ "time.minutes-ago": "{count}m ago",
44
+ "time.hours-ago": "{count}h ago",
45
+ "time.days-ago": "{count}d ago"
46
+ };
47
+ exports.default = en;
@@ -0,0 +1,47 @@
1
+ const en = {
2
+ "plugin.name": "Bulk Publish",
3
+ "settings.section-label": "Bulk Publish",
4
+ "settings.webhook": "Webhook",
5
+ "page.title": "Bulk Publish",
6
+ "page.subtitle": "Publish documents across all locales with a single action",
7
+ "settings.title": "Bulk Publish Settings",
8
+ "settings.subtitle": "Configure webhook for frontend rebuild",
9
+ "table.title": "Title",
10
+ "table.locales": "Locales",
11
+ "table.status": "Status",
12
+ "table.updated": "Updated {time}",
13
+ "button.publish": "Publish Selected ({count})",
14
+ "button.publishing": "Publishing...",
15
+ "button.save": "Save",
16
+ "button.cancel": "Cancel",
17
+ "button.confirm": "Publish",
18
+ "status.draft": "Draft",
19
+ "status.partial": "Partial",
20
+ "status.published": "Published",
21
+ "legend.draft": "Draft",
22
+ "legend.published": "Published",
23
+ "legend.missing": "Missing",
24
+ "empty.message": "No draft documents found. All documents are published!",
25
+ "loading.posts": "Loading posts...",
26
+ "loading.settings": "Loading settings...",
27
+ "confirm.title": "Confirm Publish",
28
+ "confirm.body": "You are about to publish {count} document(s) across all locales. This action cannot be undone.",
29
+ "notification.publish.success": "Published {count} post(s), {locales} locale(s).",
30
+ "notification.publish.webhook": "Webhook triggered.",
31
+ "notification.publish.webhook-error": "Webhook failed: {error}",
32
+ "notification.publish.errors": "{count} error(s).",
33
+ "notification.publish.error": "Failed to publish posts",
34
+ "notification.settings.success": "Settings saved successfully",
35
+ "notification.settings.error": "Failed to save settings",
36
+ "notification.load.error": "Failed to load posts",
37
+ "webhook.label": "Webhook URL",
38
+ "webhook.placeholder": "https://example.com/api/rebuild",
39
+ "webhook.hint": "POST request will be sent to this URL after publishing",
40
+ "time.just-now": "just now",
41
+ "time.minutes-ago": "{count}m ago",
42
+ "time.hours-ago": "{count}h ago",
43
+ "time.days-ago": "{count}d ago"
44
+ };
45
+ export {
46
+ en as default
47
+ };
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ const icons = require("@strapi/icons");
3
+ const __variableDynamicImportRuntimeHelper = (glob, path, segs) => {
4
+ const v = glob[path];
5
+ if (v) {
6
+ return typeof v === "function" ? v() : Promise.resolve(v);
7
+ }
8
+ return new Promise((_, reject) => {
9
+ (typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(
10
+ reject.bind(
11
+ null,
12
+ new Error(
13
+ "Unknown variable dynamic import: " + path + (path.split("/").length !== segs ? ". Note that variables only represent file names one level deep." : "")
14
+ )
15
+ )
16
+ );
17
+ });
18
+ };
19
+ const PLUGIN_ID = "bulk-publish";
20
+ const pluginPermissions = {
21
+ publish: [{ action: "plugin::bulk-publish.publish", subject: null }],
22
+ settings: [{ action: "plugin::bulk-publish.settings", subject: null }]
23
+ };
24
+ const index = {
25
+ register(app) {
26
+ app.addMenuLink({
27
+ to: `plugins/${PLUGIN_ID}`,
28
+ icon: icons.Stack,
29
+ intlLabel: {
30
+ id: `${PLUGIN_ID}.plugin.name`,
31
+ defaultMessage: "Bulk Publish"
32
+ },
33
+ Component: async () => {
34
+ const { HomePage } = await Promise.resolve().then(() => require("./HomePage-DBJToziQ.js"));
35
+ return HomePage;
36
+ },
37
+ permissions: pluginPermissions.publish,
38
+ position: 2
39
+ });
40
+ app.createSettingSection(
41
+ {
42
+ id: PLUGIN_ID,
43
+ intlLabel: {
44
+ id: `${PLUGIN_ID}.settings.section-label`,
45
+ defaultMessage: "Bulk Publish"
46
+ }
47
+ },
48
+ [
49
+ {
50
+ intlLabel: {
51
+ id: `${PLUGIN_ID}.settings.webhook`,
52
+ defaultMessage: "Webhook"
53
+ },
54
+ id: "webhook",
55
+ to: `${PLUGIN_ID}/webhook`,
56
+ Component: async () => {
57
+ const { SettingsPage } = await Promise.resolve().then(() => require("./SettingsPage-D6yyZjsD.js"));
58
+ return SettingsPage;
59
+ },
60
+ permissions: pluginPermissions.settings
61
+ }
62
+ ]
63
+ );
64
+ app.registerPlugin({
65
+ id: PLUGIN_ID,
66
+ name: PLUGIN_ID
67
+ });
68
+ },
69
+ async registerTrads({ locales }) {
70
+ return Promise.all(
71
+ locales.map(async (locale) => {
72
+ try {
73
+ const data = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/en.json": () => Promise.resolve().then(() => require("./en-BU8SCgAJ.js")) }), `./translations/${locale}.json`, 3);
74
+ return {
75
+ data: prefixPluginTranslations(data.default, PLUGIN_ID),
76
+ locale
77
+ };
78
+ } catch {
79
+ return { data: {}, locale };
80
+ }
81
+ })
82
+ );
83
+ }
84
+ };
85
+ function prefixPluginTranslations(trad, pluginId) {
86
+ return Object.keys(trad).reduce((acc, key) => {
87
+ acc[`${pluginId}.${key}`] = trad[key];
88
+ return acc;
89
+ }, {});
90
+ }
91
+ exports.PLUGIN_ID = PLUGIN_ID;
92
+ exports.index = index;
93
+ exports.pluginPermissions = pluginPermissions;
@@ -0,0 +1,94 @@
1
+ import { Stack } from "@strapi/icons";
2
+ const __variableDynamicImportRuntimeHelper = (glob, path, segs) => {
3
+ const v = glob[path];
4
+ if (v) {
5
+ return typeof v === "function" ? v() : Promise.resolve(v);
6
+ }
7
+ return new Promise((_, reject) => {
8
+ (typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(
9
+ reject.bind(
10
+ null,
11
+ new Error(
12
+ "Unknown variable dynamic import: " + path + (path.split("/").length !== segs ? ". Note that variables only represent file names one level deep." : "")
13
+ )
14
+ )
15
+ );
16
+ });
17
+ };
18
+ const PLUGIN_ID = "bulk-publish";
19
+ const pluginPermissions = {
20
+ publish: [{ action: "plugin::bulk-publish.publish", subject: null }],
21
+ settings: [{ action: "plugin::bulk-publish.settings", subject: null }]
22
+ };
23
+ const index = {
24
+ register(app) {
25
+ app.addMenuLink({
26
+ to: `plugins/${PLUGIN_ID}`,
27
+ icon: Stack,
28
+ intlLabel: {
29
+ id: `${PLUGIN_ID}.plugin.name`,
30
+ defaultMessage: "Bulk Publish"
31
+ },
32
+ Component: async () => {
33
+ const { HomePage } = await import("./HomePage-C-cyV6ij.mjs");
34
+ return HomePage;
35
+ },
36
+ permissions: pluginPermissions.publish,
37
+ position: 2
38
+ });
39
+ app.createSettingSection(
40
+ {
41
+ id: PLUGIN_ID,
42
+ intlLabel: {
43
+ id: `${PLUGIN_ID}.settings.section-label`,
44
+ defaultMessage: "Bulk Publish"
45
+ }
46
+ },
47
+ [
48
+ {
49
+ intlLabel: {
50
+ id: `${PLUGIN_ID}.settings.webhook`,
51
+ defaultMessage: "Webhook"
52
+ },
53
+ id: "webhook",
54
+ to: `${PLUGIN_ID}/webhook`,
55
+ Component: async () => {
56
+ const { SettingsPage } = await import("./SettingsPage-BpvQogmY.mjs");
57
+ return SettingsPage;
58
+ },
59
+ permissions: pluginPermissions.settings
60
+ }
61
+ ]
62
+ );
63
+ app.registerPlugin({
64
+ id: PLUGIN_ID,
65
+ name: PLUGIN_ID
66
+ });
67
+ },
68
+ async registerTrads({ locales }) {
69
+ return Promise.all(
70
+ locales.map(async (locale) => {
71
+ try {
72
+ const data = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/en.json": () => import("./en-ua_GGXUg.mjs") }), `./translations/${locale}.json`, 3);
73
+ return {
74
+ data: prefixPluginTranslations(data.default, PLUGIN_ID),
75
+ locale
76
+ };
77
+ } catch {
78
+ return { data: {}, locale };
79
+ }
80
+ })
81
+ );
82
+ }
83
+ };
84
+ function prefixPluginTranslations(trad, pluginId) {
85
+ return Object.keys(trad).reduce((acc, key) => {
86
+ acc[`${pluginId}.${key}`] = trad[key];
87
+ return acc;
88
+ }, {});
89
+ }
90
+ export {
91
+ PLUGIN_ID as P,
92
+ index as i,
93
+ pluginPermissions as p
94
+ };