@antibusy/strapi-plugin-timeline 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 +177 -0
- package/dist/admin/App-CPDkCA45.js +559 -0
- package/dist/admin/App-CurSaj2g.mjs +559 -0
- package/dist/admin/SchedulePage-DP5ctM0i.mjs +166 -0
- package/dist/admin/SchedulePage-H3RD9IW_.js +166 -0
- package/dist/admin/SettingsPage-DjP5AHwT.mjs +259 -0
- package/dist/admin/SettingsPage-Dms3VBZi.js +259 -0
- package/dist/admin/en-B4KWt_jN.js +4 -0
- package/dist/admin/en-Byx4XI2L.mjs +4 -0
- package/dist/admin/index-BV3yQjEk.js +1078 -0
- package/dist/admin/index-D9_WggIU.mjs +1053 -0
- package/dist/admin/index.js +4 -0
- package/dist/admin/index.mjs +4 -0
- package/dist/admin/src/index.d.ts +11 -0
- package/dist/server/index.js +1041 -0
- package/dist/server/index.mjs +1041 -0
- package/dist/server/src/index.d.ts +271 -0
- package/package.json +113 -0
|
@@ -0,0 +1,259 @@
|
|
|
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 designSystem = require("@strapi/design-system");
|
|
6
|
+
const icons = require("@strapi/icons");
|
|
7
|
+
const admin = require("@strapi/strapi/admin");
|
|
8
|
+
const index = require("./index-BV3yQjEk.js");
|
|
9
|
+
const ALL_ACTIONS = ["create", "update", "delete", "publish"];
|
|
10
|
+
const DURATION_UNITS = [
|
|
11
|
+
{ value: "hours", label: "Hours" },
|
|
12
|
+
{ value: "days", label: "Days" },
|
|
13
|
+
{ value: "weeks", label: "Weeks" },
|
|
14
|
+
{ value: "months", label: "Months" }
|
|
15
|
+
];
|
|
16
|
+
const makeDefaultConfig = () => ({
|
|
17
|
+
enabled: true,
|
|
18
|
+
actions: [...ALL_ACTIONS],
|
|
19
|
+
entriesLimit: 0,
|
|
20
|
+
durationLimit: 0,
|
|
21
|
+
durationUnit: "days"
|
|
22
|
+
});
|
|
23
|
+
const SettingsPage = () => {
|
|
24
|
+
const { get, put } = admin.useFetchClient();
|
|
25
|
+
const { toggleNotification } = admin.useNotification();
|
|
26
|
+
const [contentTypes, setContentTypes] = React.useState([]);
|
|
27
|
+
const [configs, setConfigs] = React.useState({});
|
|
28
|
+
const [loading, setLoading] = React.useState(true);
|
|
29
|
+
const [saving, setSaving] = React.useState(false);
|
|
30
|
+
const [addingUid, setAddingUid] = React.useState("");
|
|
31
|
+
const [expandedItem, setExpandedItem] = React.useState("");
|
|
32
|
+
const [removeTarget, setRemoveTarget] = React.useState(null);
|
|
33
|
+
React.useEffect(() => {
|
|
34
|
+
loadData();
|
|
35
|
+
}, []);
|
|
36
|
+
const loadData = async () => {
|
|
37
|
+
try {
|
|
38
|
+
const [settingsRes, ctRes] = await Promise.all([
|
|
39
|
+
get(`/${index.PLUGIN_ID}/settings`),
|
|
40
|
+
get(`/${index.PLUGIN_ID}/content-types`)
|
|
41
|
+
]);
|
|
42
|
+
const raw = settingsRes.data.data || {};
|
|
43
|
+
setConfigs(raw.contentTypeConfigs || {});
|
|
44
|
+
setContentTypes(ctRes.data.data || []);
|
|
45
|
+
} catch {
|
|
46
|
+
toggleNotification({ type: "danger", message: "Failed to load settings." });
|
|
47
|
+
} finally {
|
|
48
|
+
setLoading(false);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
const handleSave = async () => {
|
|
52
|
+
setSaving(true);
|
|
53
|
+
try {
|
|
54
|
+
await put(`/${index.PLUGIN_ID}/settings`, { contentTypeConfigs: configs });
|
|
55
|
+
toggleNotification({ type: "success", message: "Settings saved successfully." });
|
|
56
|
+
} catch {
|
|
57
|
+
toggleNotification({ type: "danger", message: "Failed to save settings." });
|
|
58
|
+
} finally {
|
|
59
|
+
setSaving(false);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
const availableContentTypes = contentTypes.filter((ct) => !configs[ct.uid]);
|
|
63
|
+
const addContentType = () => {
|
|
64
|
+
if (!addingUid) return;
|
|
65
|
+
setConfigs((prev) => ({ ...prev, [addingUid]: makeDefaultConfig() }));
|
|
66
|
+
setExpandedItem(addingUid);
|
|
67
|
+
setAddingUid("");
|
|
68
|
+
};
|
|
69
|
+
const removeContentType = (uid) => {
|
|
70
|
+
setConfigs((prev) => {
|
|
71
|
+
const next = { ...prev };
|
|
72
|
+
delete next[uid];
|
|
73
|
+
return next;
|
|
74
|
+
});
|
|
75
|
+
setExpandedItem((prev) => prev === uid ? "" : prev);
|
|
76
|
+
};
|
|
77
|
+
const updateConfig = (uid, field, value) => {
|
|
78
|
+
setConfigs((prev) => ({
|
|
79
|
+
...prev,
|
|
80
|
+
[uid]: { ...prev[uid], [field]: value }
|
|
81
|
+
}));
|
|
82
|
+
};
|
|
83
|
+
const getDisplayName = (uid) => {
|
|
84
|
+
const ct = contentTypes.find((c) => c.uid === uid);
|
|
85
|
+
return ct?.displayName || uid;
|
|
86
|
+
};
|
|
87
|
+
const getKindLabel = (uid) => {
|
|
88
|
+
const ct = contentTypes.find((c) => c.uid === uid);
|
|
89
|
+
return ct?.kind === "singleType" ? "Single Type" : "Collection Type";
|
|
90
|
+
};
|
|
91
|
+
if (loading) {
|
|
92
|
+
return /* @__PURE__ */ jsxRuntime.jsx(admin.Layouts.Root, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Main, { padding: 8, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "alpha", children: "Loading…" }) }) });
|
|
93
|
+
}
|
|
94
|
+
const configuredUids = Object.keys(configs);
|
|
95
|
+
return /* @__PURE__ */ jsxRuntime.jsx(admin.Layouts.Root, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Main, { padding: 8, children: [
|
|
96
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingBottom: 6, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", alignItems: "center", children: [
|
|
97
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { children: [
|
|
98
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "alpha", tag: "h1", children: "Timeline Settings" }),
|
|
99
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "epsilon", textColor: "neutral600", children: "Configure which content types to track and how to manage their history." })
|
|
100
|
+
] }),
|
|
101
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Check, {}), onClick: handleSave, loading: saving, disabled: saving, children: "Save" })
|
|
102
|
+
] }) }),
|
|
103
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { background: "neutral0", shadow: "tableShadow", padding: 6, borderRadius: "4px", children: [
|
|
104
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { paddingBottom: 4, children: [
|
|
105
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "delta", tag: "h2", children: "Tracked Content Types" }),
|
|
106
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral600", children: "Add content types to track and configure actions, entry limits, and retention duration for each." })
|
|
107
|
+
] }),
|
|
108
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, paddingBottom: 4, alignItems: "flex-end", children: [
|
|
109
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { flex: "1", children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { width: "100%", children: [
|
|
110
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: "Add Content Type" }),
|
|
111
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
112
|
+
designSystem.SingleSelect,
|
|
113
|
+
{
|
|
114
|
+
value: addingUid,
|
|
115
|
+
onChange: (value) => setAddingUid(String(value)),
|
|
116
|
+
placeholder: "Select a content type to add...",
|
|
117
|
+
disabled: availableContentTypes.length === 0,
|
|
118
|
+
children: availableContentTypes.map((ct) => /* @__PURE__ */ jsxRuntime.jsxs(designSystem.SingleSelectOption, { value: ct.uid, children: [
|
|
119
|
+
ct.displayName,
|
|
120
|
+
" (",
|
|
121
|
+
ct.kind === "singleType" ? "Single" : "Collection",
|
|
122
|
+
")"
|
|
123
|
+
] }, ct.uid))
|
|
124
|
+
}
|
|
125
|
+
)
|
|
126
|
+
] }) }),
|
|
127
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
128
|
+
designSystem.Button,
|
|
129
|
+
{
|
|
130
|
+
startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Plus, {}),
|
|
131
|
+
size: "L",
|
|
132
|
+
onClick: addContentType,
|
|
133
|
+
variant: "secondary",
|
|
134
|
+
disabled: !addingUid,
|
|
135
|
+
children: "Add"
|
|
136
|
+
}
|
|
137
|
+
)
|
|
138
|
+
] }),
|
|
139
|
+
configuredUids.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 4, background: "neutral100", borderRadius: "4px", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral600", children: "No content types configured. Select one above to start tracking changes." }) }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
140
|
+
designSystem.Accordion.Root,
|
|
141
|
+
{
|
|
142
|
+
value: expandedItem,
|
|
143
|
+
onValueChange: (value) => setExpandedItem(value),
|
|
144
|
+
children: configuredUids.map((uid) => {
|
|
145
|
+
const config = configs[uid];
|
|
146
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Item, { value: uid, children: [
|
|
147
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Trigger, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "center", children: [
|
|
148
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", children: getDisplayName(uid) }),
|
|
149
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral500", children: getKindLabel(uid) }),
|
|
150
|
+
!config.enabled && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "danger600", children: "(disabled)" })
|
|
151
|
+
] }) }) }),
|
|
152
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Content, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { padding: 4, children: [
|
|
153
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", alignItems: "center", paddingBottom: 4, children: [
|
|
154
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
155
|
+
designSystem.Switch,
|
|
156
|
+
{
|
|
157
|
+
onCheckedChange: (checked) => updateConfig(uid, "enabled", checked),
|
|
158
|
+
checked: config.enabled,
|
|
159
|
+
visibleLabels: true
|
|
160
|
+
}
|
|
161
|
+
),
|
|
162
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
163
|
+
designSystem.IconButton,
|
|
164
|
+
{
|
|
165
|
+
onClick: () => setRemoveTarget(uid),
|
|
166
|
+
label: "Remove content type",
|
|
167
|
+
variant: "danger-light",
|
|
168
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(icons.Trash, {})
|
|
169
|
+
}
|
|
170
|
+
)
|
|
171
|
+
] }),
|
|
172
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Grid.Root, { gap: 4, gridCols: 2, children: [
|
|
173
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 2, s: 2, alignItems: "flex-start", children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { width: "100%", hint: "Which lifecycle actions to record. Empty = all actions.", children: [
|
|
174
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: "Tracked Actions" }),
|
|
175
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
176
|
+
designSystem.MultiSelect,
|
|
177
|
+
{
|
|
178
|
+
value: config.actions,
|
|
179
|
+
onChange: (values) => updateConfig(uid, "actions", values),
|
|
180
|
+
placeholder: "Select actions to track...",
|
|
181
|
+
withTags: true,
|
|
182
|
+
children: ALL_ACTIONS.map((action) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.MultiSelectOption, { value: action, children: action.charAt(0).toUpperCase() + action.slice(1) }, action))
|
|
183
|
+
}
|
|
184
|
+
),
|
|
185
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Hint, {})
|
|
186
|
+
] }) }),
|
|
187
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 1, s: 2, alignItems: "flex-start", children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { width: "100%", hint: "Max entries to keep per content type. 0 = unlimited.", children: [
|
|
188
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: "Entries Limit" }),
|
|
189
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
190
|
+
designSystem.NumberInput,
|
|
191
|
+
{
|
|
192
|
+
name: `${uid}-entriesLimit`,
|
|
193
|
+
value: config.entriesLimit,
|
|
194
|
+
onValueChange: (value) => updateConfig(uid, "entriesLimit", value ?? 0),
|
|
195
|
+
step: 10
|
|
196
|
+
}
|
|
197
|
+
),
|
|
198
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Hint, {})
|
|
199
|
+
] }) }),
|
|
200
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 1, s: 2, alignItems: "flex-start", children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { width: "100%", hint: "Entries older than this are cleaned up by the scheduled task. 0 = no limit.", children: [
|
|
201
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "flex-end", children: [
|
|
202
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { flex: "1", children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { width: "100%", children: [
|
|
203
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: "Retention Duration" }),
|
|
204
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
205
|
+
designSystem.NumberInput,
|
|
206
|
+
{
|
|
207
|
+
name: `${uid}-durationLimit`,
|
|
208
|
+
value: config.durationLimit,
|
|
209
|
+
onValueChange: (value) => updateConfig(uid, "durationLimit", value ?? 0),
|
|
210
|
+
step: 1
|
|
211
|
+
}
|
|
212
|
+
)
|
|
213
|
+
] }) }),
|
|
214
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { minWidth: "120px" }, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
215
|
+
designSystem.SingleSelect,
|
|
216
|
+
{
|
|
217
|
+
value: config.durationUnit,
|
|
218
|
+
onChange: (value) => updateConfig(uid, "durationUnit", String(value)),
|
|
219
|
+
children: DURATION_UNITS.map((u) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: u.value, children: u.label }, u.value))
|
|
220
|
+
}
|
|
221
|
+
) })
|
|
222
|
+
] }),
|
|
223
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Hint, {})
|
|
224
|
+
] }) })
|
|
225
|
+
] })
|
|
226
|
+
] }) })
|
|
227
|
+
] }, uid);
|
|
228
|
+
})
|
|
229
|
+
}
|
|
230
|
+
)
|
|
231
|
+
] }),
|
|
232
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Root, { open: !!removeTarget, onOpenChange: (open) => !open && setRemoveTarget(null), children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Content, { children: [
|
|
233
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Header, { children: "Remove content type from tracking" }),
|
|
234
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Body, { icon: /* @__PURE__ */ jsxRuntime.jsx(icons.Trash, {}), children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, children: [
|
|
235
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { children: [
|
|
236
|
+
"Are you sure you want to stop tracking ",
|
|
237
|
+
/* @__PURE__ */ jsxRuntime.jsx("strong", { children: removeTarget ? getDisplayName(removeTarget) : "" }),
|
|
238
|
+
"?"
|
|
239
|
+
] }),
|
|
240
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: "Existing timeline entries for this content type will not be deleted. You can re-add it later to resume tracking." })
|
|
241
|
+
] }) }),
|
|
242
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Footer, { children: [
|
|
243
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Cancel, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", children: "Cancel" }) }),
|
|
244
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Action, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
245
|
+
designSystem.Button,
|
|
246
|
+
{
|
|
247
|
+
variant: "danger",
|
|
248
|
+
onClick: () => {
|
|
249
|
+
if (removeTarget) removeContentType(removeTarget);
|
|
250
|
+
setRemoveTarget(null);
|
|
251
|
+
},
|
|
252
|
+
children: "Remove"
|
|
253
|
+
}
|
|
254
|
+
) })
|
|
255
|
+
] })
|
|
256
|
+
] }) })
|
|
257
|
+
] }) });
|
|
258
|
+
};
|
|
259
|
+
exports.SettingsPage = SettingsPage;
|