strapi-plugin-magic-mark 3.4.0 → 4.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.
Files changed (48) hide show
  1. package/CHANGELOG.md +366 -0
  2. package/README.md +390 -619
  3. package/dist/admin/App-C9PsvW9C.mjs +580 -0
  4. package/dist/admin/App-KJvUCwN1.js +580 -0
  5. package/dist/admin/PinnedBookmarksWidget-ClskVR1i.mjs +55 -0
  6. package/dist/admin/PinnedBookmarksWidget-DlD8lDhq.js +55 -0
  7. package/dist/admin/de-BF0nCjGF.mjs +183 -0
  8. package/dist/admin/de-Cn90CcnC.js +183 -0
  9. package/dist/admin/en-D-EGHodf.mjs +183 -0
  10. package/dist/admin/en-GDfO_EfL.js +183 -0
  11. package/dist/admin/es-6o-_RABX.js +183 -0
  12. package/dist/admin/es-C33BufuB.mjs +183 -0
  13. package/dist/admin/fr-BOZS5mJT.js +183 -0
  14. package/dist/admin/fr-DJHTjkmb.mjs +183 -0
  15. package/dist/admin/index-CLjQOzqv.js +1770 -0
  16. package/dist/admin/index-X8I03cOT.mjs +1769 -0
  17. package/dist/admin/index.js +4 -2
  18. package/dist/admin/index.mjs +2 -1
  19. package/dist/admin/pt-D13SxuK2.js +183 -0
  20. package/dist/admin/pt-yoB1jrsq.mjs +183 -0
  21. package/dist/server/index.js +1129 -1542
  22. package/dist/server/index.mjs +1126 -1539
  23. package/package.json +90 -54
  24. package/strapi-admin.js +5 -0
  25. package/strapi-server.js +2 -1
  26. package/COPYRIGHT_NOTICE.txt +0 -20
  27. package/dist/_chunks/App-DNyxeldt.js +0 -1451
  28. package/dist/_chunks/App-D_Vllkur.mjs +0 -1449
  29. package/dist/_chunks/UpgradePage-DuyIskve.mjs +0 -351
  30. package/dist/_chunks/UpgradePage-SzlmS6po.js +0 -353
  31. package/dist/_chunks/de-Cs9dd3Mr.js +0 -138
  32. package/dist/_chunks/de-DOVki5VS.mjs +0 -138
  33. package/dist/_chunks/en-CE3r46Y2.js +0 -138
  34. package/dist/_chunks/en-Cf5-O03L.mjs +0 -138
  35. package/dist/_chunks/es-Ba6JcPIm.mjs +0 -138
  36. package/dist/_chunks/es-D4AOyJYJ.js +0 -138
  37. package/dist/_chunks/fr-CWSfoA8i.js +0 -138
  38. package/dist/_chunks/fr-CrMBXR3c.mjs +0 -138
  39. package/dist/_chunks/index-CBwb0AEf.js +0 -3618
  40. package/dist/_chunks/index-JirQF8zE.mjs +0 -328
  41. package/dist/_chunks/index-QkINaIgJ.mjs +0 -3614
  42. package/dist/_chunks/index-uUErgmi9.js +0 -330
  43. package/dist/_chunks/pt-BXxZ1Zym.mjs +0 -138
  44. package/dist/_chunks/pt-DW_6r_mP.js +0 -138
  45. package/pics/advancedFilters.png +0 -0
  46. package/pics/dashboard.png +0 -0
  47. package/pics/quickaccesinContentmanager.png +0 -0
  48. package/pics/saveAsMagicMark.png +0 -0
@@ -0,0 +1,580 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const admin = require("@strapi/strapi/admin");
5
+ const reactRouterDom = require("react-router-dom");
6
+ const index = require("./index-CLjQOzqv.js");
7
+ const designSystem = require("@strapi/design-system");
8
+ const icons = require("@strapi/icons");
9
+ const symbols = require("@strapi/icons/symbols");
10
+ const react = require("react");
11
+ const reactIntl = require("react-intl");
12
+ const styledComponents = require("styled-components");
13
+ const TRIGGER_WITHOUT_TOOLTIP = { withTooltip: false };
14
+ const BookmarkActions = ({
15
+ bookmark,
16
+ permissions,
17
+ busy,
18
+ onOpen,
19
+ onPin,
20
+ onEdit,
21
+ onDuplicate,
22
+ onCopyLink,
23
+ onDelete,
24
+ parts = "all"
25
+ }) => {
26
+ const { formatMessage } = reactIntl.useIntl();
27
+ const name = { name: bookmark.name };
28
+ const canEdit = permissions.canUpdate && bookmark.canEdit;
29
+ const canDelete = permissions.canDelete && bookmark.canEdit;
30
+ const [menuOpen, setMenuOpen] = react.useState(false);
31
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 1, justifyContent: "flex-end", children: [
32
+ parts !== "menu" ? /* @__PURE__ */ jsxRuntime.jsx(
33
+ designSystem.IconButton,
34
+ {
35
+ label: formatMessage(
36
+ bookmark.isPinned ? index.msg("actions.unpinNamed", "Unpin {name}") : index.msg("actions.pinNamed", "Pin {name}"),
37
+ name
38
+ ),
39
+ variant: bookmark.isPinned ? "secondary" : "ghost",
40
+ "aria-pressed": bookmark.isPinned,
41
+ disabled: busy,
42
+ onClick: onPin,
43
+ children: /* @__PURE__ */ jsxRuntime.jsx(icons.Pin, {})
44
+ }
45
+ ) : null,
46
+ parts !== "pin" ? /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Root, { open: menuOpen, onOpenChange: setMenuOpen, children: [
47
+ /* @__PURE__ */ jsxRuntime.jsx(
48
+ designSystem.Menu.Trigger,
49
+ {
50
+ tag: designSystem.IconButton,
51
+ icon: /* @__PURE__ */ jsxRuntime.jsx(icons.More, {}),
52
+ label: formatMessage(index.msg("actions.moreNamed", "More actions for {name}"), name),
53
+ variant: "ghost",
54
+ disabled: busy,
55
+ "data-bookmark-menu": bookmark.documentId,
56
+ ...TRIGGER_WITHOUT_TOOLTIP
57
+ }
58
+ ),
59
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Content, { popoverPlacement: "bottom-end", maxHeight: void 0, children: [
60
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.Item, { startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.ExternalLink, {}), onSelect: onOpen, disabled: !bookmark.path, children: formatMessage(index.msg("actions.open", "Open")) }),
61
+ canEdit ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.Item, { startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Pencil, {}), onSelect: onEdit, children: formatMessage(index.msg("actions.edit", "Edit")) }) : null,
62
+ permissions.canCreate ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.Item, { startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Duplicate, {}), onSelect: onDuplicate, disabled: !bookmark.path, children: formatMessage(index.msg("actions.duplicate", "Duplicate")) }) : null,
63
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.Item, { startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Link, {}), onSelect: onCopyLink, disabled: !bookmark.path, children: formatMessage(index.msg("actions.copyLink", "Copy link")) }),
64
+ canDelete ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.Item, { startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Trash, {}), variant: "danger", onSelect: onDelete, children: formatMessage(index.msg("actions.delete", "Delete")) }) : null
65
+ ] })
66
+ ] }) : null
67
+ ] });
68
+ };
69
+ const VISIBILITY_BADGE = {
70
+ private: {
71
+ backgroundColor: "neutral200",
72
+ textColor: "neutral700",
73
+ label: index.msg("visibility.private", "Only me")
74
+ },
75
+ shared: {
76
+ backgroundColor: "primary100",
77
+ textColor: "primary700",
78
+ label: index.msg("visibility.shared", "Shared")
79
+ },
80
+ public: {
81
+ backgroundColor: "secondary200",
82
+ textColor: "secondary700",
83
+ label: index.msg("visibility.public", "All admins")
84
+ }
85
+ };
86
+ const BookmarksPage = () => {
87
+ const { formatMessage } = reactIntl.useIntl();
88
+ const { toggleNotification } = admin.useNotification();
89
+ const api = index.useBookmarksApi();
90
+ const openBookmark = index.useOpenBookmark();
91
+ const { copy } = admin.useClipboard();
92
+ const showCards = !admin.useIsDesktop();
93
+ const theme = styledComponents.useTheme();
94
+ const isMobile = admin.useIsMobile();
95
+ const showPageSize = admin.useMediaQuery(theme.breakpoints.small);
96
+ const { names } = index.useContentTypeNames();
97
+ const { allowedActions } = admin.useRBAC(index.ALL_PERMISSIONS);
98
+ const [{ query }, setQuery] = admin.useQueryParams();
99
+ const page = Number(query.page) || 1;
100
+ const pageSize = Number(query.pageSize) || 25;
101
+ const scopes = allowedActions.canManage ? ["all", "mine", "shared", "pinned", "managed"] : ["all", "mine", "shared", "pinned"];
102
+ const scope = scopes.includes(query.scope) ? query.scope : "all";
103
+ const sort = query.sort === "name:desc" || query.sort === "updatedAt:desc" || query.sort === "updatedAt:asc" ? query.sort : "name:asc";
104
+ const [result, setResult] = react.useState(null);
105
+ const [status, setStatus] = react.useState("loading");
106
+ const [attempt, setAttempt] = react.useState(0);
107
+ const [busyId, setBusyId] = react.useState(null);
108
+ const [editId, setEditId] = react.useState(null);
109
+ const [toDelete, setToDelete] = react.useState(null);
110
+ const [deleting, setDeleting] = react.useState(false);
111
+ const focusMainAfterLoad = react.useRef(false);
112
+ react.useEffect(() => {
113
+ const controller = new AbortController();
114
+ api.list(
115
+ { page, pageSize, q: query._q, scope, sort, contentType: query.contentType },
116
+ controller.signal
117
+ ).then((data) => {
118
+ setResult(data);
119
+ setStatus("ready");
120
+ if (data.meta.pagination.pageCount > 0 && page > data.meta.pagination.pageCount) {
121
+ setQuery({ page: String(data.meta.pagination.pageCount) }, "push", true);
122
+ }
123
+ }).catch(() => {
124
+ if (!controller.signal.aborted) setStatus("error");
125
+ });
126
+ return () => controller.abort();
127
+ }, [api, page, pageSize, query._q, query.contentType, scope, sort, attempt, setQuery]);
128
+ const focusTarget = react.useRef(null);
129
+ const restoreFocus = react.useCallback(() => {
130
+ const id = focusTarget.current;
131
+ focusTarget.current = null;
132
+ window.setTimeout(() => {
133
+ if (document.activeElement && document.activeElement !== document.body) return;
134
+ const trigger = id ? document.querySelector(`[data-bookmark-menu="${CSS.escape(id)}"]`) : null;
135
+ (trigger ?? document.getElementById("main-content"))?.focus();
136
+ }, 50);
137
+ }, []);
138
+ react.useEffect(() => {
139
+ if (!focusMainAfterLoad.current || status !== "ready") return;
140
+ focusMainAfterLoad.current = false;
141
+ restoreFocus();
142
+ }, [result, status, restoreFocus]);
143
+ const reload = react.useCallback(() => setAttempt((n) => n + 1), []);
144
+ const retry = () => {
145
+ setStatus("loading");
146
+ reload();
147
+ };
148
+ const bookmarks = result?.data ?? [];
149
+ const pagination = result?.meta.pagination;
150
+ const canShare = result?.meta.permissions.canShare ?? !!allowedActions.canShare;
151
+ const isFiltered = !!query._q || scope !== "all" || !!query.contentType;
152
+ const permissions = {
153
+ canCreate: !!allowedActions.canCreate,
154
+ canUpdate: !!allowedActions.canUpdate,
155
+ canDelete: !!allowedActions.canDelete
156
+ };
157
+ const contentTypeOptions = react.useMemo(
158
+ () => [...names.entries()].sort((a, b) => a[1].localeCompare(b[1])),
159
+ [names]
160
+ );
161
+ const adminHref = reactRouterDom.useHref("/");
162
+ const setFilter = (patch) => setQuery({ ...patch, page: "1" }, "push", true);
163
+ const togglePin = async (bookmark) => {
164
+ setBusyId(bookmark.documentId);
165
+ try {
166
+ await api.pin(bookmark.documentId, !bookmark.isPinned);
167
+ toggleNotification({
168
+ type: "success",
169
+ message: formatMessage(
170
+ bookmark.isPinned ? index.msg("notification.unpinned", "Bookmark unpinned.") : index.msg("notification.pinned", "Bookmark pinned.")
171
+ )
172
+ });
173
+ reload();
174
+ } catch {
175
+ toggleNotification({
176
+ type: "danger",
177
+ message: formatMessage(index.msg("notification.pinError", "The bookmark could not be pinned."))
178
+ });
179
+ } finally {
180
+ setBusyId(null);
181
+ }
182
+ };
183
+ const duplicate = async (bookmark) => {
184
+ setBusyId(bookmark.documentId);
185
+ try {
186
+ await api.duplicate(
187
+ bookmark.documentId,
188
+ formatMessage(index.msg("actions.copyName", "{name} (copy)"), { name: bookmark.name }).slice(
189
+ 0,
190
+ 100
191
+ )
192
+ );
193
+ toggleNotification({
194
+ type: "success",
195
+ message: formatMessage(index.msg("notification.duplicated", "Bookmark duplicated."))
196
+ });
197
+ reload();
198
+ } catch {
199
+ toggleNotification({
200
+ type: "danger",
201
+ message: formatMessage(
202
+ index.msg("notification.duplicateError", "The bookmark could not be duplicated.")
203
+ )
204
+ });
205
+ } finally {
206
+ setBusyId(null);
207
+ }
208
+ };
209
+ const copyLink = async (bookmark) => {
210
+ const target = index.bookmarkLocation(bookmark);
211
+ if (!target) return;
212
+ const base = adminHref.endsWith("/") ? adminHref.slice(0, -1) : adminHref;
213
+ const url = new URL(
214
+ `${base}${target.pathname}${target.search}`,
215
+ window.location.origin
216
+ ).toString();
217
+ const copied = await copy(url);
218
+ toggleNotification({
219
+ type: copied ? "success" : "danger",
220
+ message: formatMessage(
221
+ copied ? index.msg("notification.linkCopied", "Link copied.") : index.msg("notification.linkCopyError", "The link could not be copied.")
222
+ )
223
+ });
224
+ };
225
+ const confirmDelete = async () => {
226
+ if (!toDelete) return;
227
+ setDeleting(true);
228
+ try {
229
+ await api.remove(toDelete.documentId);
230
+ toggleNotification({
231
+ type: "success",
232
+ message: formatMessage(index.msg("notification.deleted", "Bookmark deleted."))
233
+ });
234
+ setToDelete(null);
235
+ focusTarget.current = null;
236
+ focusMainAfterLoad.current = true;
237
+ reload();
238
+ } catch {
239
+ toggleNotification({
240
+ type: "danger",
241
+ message: formatMessage(
242
+ index.msg("notification.deleteError", "The bookmark could not be deleted.")
243
+ )
244
+ });
245
+ } finally {
246
+ setDeleting(false);
247
+ }
248
+ };
249
+ const ownerLabel = (bookmark) => {
250
+ if (bookmark.isOwner) return formatMessage(index.msg("owner.you", "You"));
251
+ if (!bookmark.owner || bookmark.owner.isDeleted)
252
+ return formatMessage(index.msg("owner.deleted", "Deleted user"));
253
+ return bookmark.owner.name ?? formatMessage(index.msg("owner.unnamed", "Unnamed user"));
254
+ };
255
+ const contentTypeLabel = (bookmark) => bookmark.contentType ? names.get(bookmark.contentType) ?? bookmark.contentType : "—";
256
+ const conditions = (bookmark) => index.countConditions(index.parseQuery(bookmark.query).filters);
257
+ const actionsFor = (bookmark, parts = "all") => /* @__PURE__ */ jsxRuntime.jsx(
258
+ BookmarkActions,
259
+ {
260
+ parts,
261
+ bookmark,
262
+ permissions,
263
+ busy: busyId === bookmark.documentId,
264
+ onOpen: () => openBookmark(bookmark),
265
+ onPin: () => togglePin(bookmark),
266
+ onEdit: () => {
267
+ focusTarget.current = bookmark.documentId;
268
+ setEditId(bookmark.documentId);
269
+ },
270
+ onDuplicate: () => duplicate(bookmark),
271
+ onCopyLink: () => copyLink(bookmark),
272
+ onDelete: () => {
273
+ focusTarget.current = bookmark.documentId;
274
+ setToDelete(bookmark);
275
+ }
276
+ }
277
+ );
278
+ const nameCell = (bookmark) => {
279
+ const Icon = index.getIcon(bookmark.icon);
280
+ const target = index.bookmarkLocation(bookmark);
281
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 3, alignItems: "flex-start", minWidth: 0, children: [
282
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingTop: 1, color: "neutral600", children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { "aria-hidden": true }) }),
283
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", minWidth: 0, children: [
284
+ target ? /* @__PURE__ */ jsxRuntime.jsx(
285
+ designSystem.Link,
286
+ {
287
+ tag: reactRouterDom.NavLink,
288
+ to: target,
289
+ ...index.LINK_TARGET,
290
+ onClick: (event) => {
291
+ if (event.metaKey || event.ctrlKey || event.shiftKey || event.button !== 0) return;
292
+ event.preventDefault();
293
+ openBookmark(bookmark);
294
+ },
295
+ children: bookmark.name
296
+ }
297
+ ) : /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "semiBold", children: bookmark.name }),
298
+ bookmark.description ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: bookmark.description }) : null
299
+ ] })
300
+ ] });
301
+ };
302
+ const sortHeader = (field, label) => {
303
+ const active = sort.startsWith(`${field}:`);
304
+ const ascending = sort.endsWith(":asc");
305
+ const next = active && ascending ? `${field}:desc` : `${field}:asc`;
306
+ return /* @__PURE__ */ jsxRuntime.jsx(
307
+ designSystem.Th,
308
+ {
309
+ action: /* @__PURE__ */ jsxRuntime.jsx(
310
+ designSystem.IconButton,
311
+ {
312
+ label: formatMessage(index.msg("table.sortBy", "Sort by {column}"), { column: label }),
313
+ variant: "ghost",
314
+ onClick: () => setFilter({ sort: next }),
315
+ children: active && !ascending ? /* @__PURE__ */ jsxRuntime.jsx(icons.CaretDown, {}) : /* @__PURE__ */ jsxRuntime.jsx(icons.CaretUp, {})
316
+ }
317
+ ),
318
+ children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: label })
319
+ }
320
+ );
321
+ };
322
+ const title = formatMessage(index.msg("page.title", "Magic Mark"));
323
+ if (status === "loading" && !result) {
324
+ return /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Loading, {});
325
+ }
326
+ return /* @__PURE__ */ jsxRuntime.jsxs(admin.Page.Main, { "aria-labelledby": "magic-mark-title", children: [
327
+ /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Title, { children: title }),
328
+ /* @__PURE__ */ jsxRuntime.jsx(
329
+ admin.Layouts.Header,
330
+ {
331
+ id: "magic-mark-title",
332
+ title,
333
+ subtitle: formatMessage(
334
+ index.msg("page.subtitle", "Saved Content Manager views. Open a bookmark to apply its filters.")
335
+ ),
336
+ primaryAction: /* @__PURE__ */ jsxRuntime.jsx(designSystem.LinkButton, { tag: reactRouterDom.NavLink, to: "/content-manager", variant: "secondary", children: formatMessage(index.msg("page.openContentManager", "Open Content Manager")) })
337
+ }
338
+ ),
339
+ /* @__PURE__ */ jsxRuntime.jsx(
340
+ admin.Layouts.Action,
341
+ {
342
+ startActions: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, wrap: "wrap", children: [
343
+ /* @__PURE__ */ jsxRuntime.jsx(admin.SearchInput, { label: formatMessage(index.msg("page.search", "Search bookmarks")) }),
344
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { minWidth: "16rem", children: /* @__PURE__ */ jsxRuntime.jsxs(
345
+ designSystem.SingleSelect,
346
+ {
347
+ size: "S",
348
+ "aria-label": formatMessage(index.msg("page.scope", "Show")),
349
+ value: scope,
350
+ onChange: (value) => setFilter({ scope: value }),
351
+ children: [
352
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "all", children: formatMessage(index.msg("scope.all", "All bookmarks")) }),
353
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "mine", children: formatMessage(index.msg("scope.mine", "Created by me")) }),
354
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "shared", children: formatMessage(index.msg("scope.shared", "Shared with me")) }),
355
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "pinned", children: formatMessage(index.msg("scope.pinned", "Pinned")) }),
356
+ allowedActions.canManage ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "managed", children: formatMessage(index.msg("scope.managed", "All shared bookmarks")) }) : null
357
+ ]
358
+ }
359
+ ) }),
360
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { minWidth: "20rem", children: /* @__PURE__ */ jsxRuntime.jsxs(
361
+ designSystem.SingleSelect,
362
+ {
363
+ size: "S",
364
+ "aria-label": formatMessage(index.msg("page.contentType", "Content type")),
365
+ value: query.contentType ?? "",
366
+ onChange: (value) => setFilter({ contentType: String(value) || void 0 }),
367
+ children: [
368
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "", children: formatMessage(index.msg("page.allContentTypes", "All content types")) }),
369
+ contentTypeOptions.map(([uid, name]) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: uid, children: name }, uid))
370
+ ]
371
+ }
372
+ ) })
373
+ ] })
374
+ }
375
+ ),
376
+ /* @__PURE__ */ jsxRuntime.jsx(admin.Layouts.Content, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 4, paddingBottom: 8, children: [
377
+ status === "error" ? /* @__PURE__ */ jsxRuntime.jsx(
378
+ admin.Page.Error,
379
+ {
380
+ content: formatMessage(index.msg("page.error", "Bookmarks could not be loaded.")),
381
+ action: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "secondary", onClick: retry, children: formatMessage(index.msg("state.retry", "Try again")) })
382
+ }
383
+ ) : bookmarks.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(
384
+ designSystem.EmptyStateLayout,
385
+ {
386
+ icon: /* @__PURE__ */ jsxRuntime.jsx(symbols.EmptyDocuments, { width: "16rem" }),
387
+ content: isFiltered ? formatMessage(
388
+ index.msg("page.noResults", "No bookmarks match your search or filter.")
389
+ ) : formatMessage(
390
+ index.msg(
391
+ "page.empty",
392
+ "No bookmarks yet. Filter a list in the Content Manager, then save the view."
393
+ )
394
+ ),
395
+ action: isFiltered ? /* @__PURE__ */ jsxRuntime.jsx(
396
+ designSystem.Button,
397
+ {
398
+ variant: "secondary",
399
+ onClick: () => setQuery(
400
+ { _q: void 0, scope: void 0, contentType: void 0, page: "1" },
401
+ "push",
402
+ true
403
+ ),
404
+ children: formatMessage(index.msg("page.clearFilters", "Clear filters"))
405
+ }
406
+ ) : /* @__PURE__ */ jsxRuntime.jsx(designSystem.LinkButton, { tag: reactRouterDom.NavLink, to: "/content-manager", variant: "secondary", children: formatMessage(index.msg("page.openContentManager", "Open Content Manager")) })
407
+ }
408
+ ) : showCards ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 3, tag: "ul", children: bookmarks.map((bookmark) => /* @__PURE__ */ jsxRuntime.jsx(
409
+ designSystem.Box,
410
+ {
411
+ tag: "li",
412
+ background: "neutral0",
413
+ hasRadius: true,
414
+ shadow: "tableShadow",
415
+ padding: 4,
416
+ children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 3, children: [
417
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", alignItems: "flex-start", gap: 2, children: [
418
+ nameCell(bookmark),
419
+ actionsFor(bookmark)
420
+ ] }),
421
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, wrap: "wrap", children: [
422
+ /* @__PURE__ */ jsxRuntime.jsx(
423
+ designSystem.Badge,
424
+ {
425
+ backgroundColor: VISIBILITY_BADGE[bookmark.visibility].backgroundColor,
426
+ textColor: VISIBILITY_BADGE[bookmark.visibility].textColor,
427
+ children: formatMessage(VISIBILITY_BADGE[bookmark.visibility].label)
428
+ }
429
+ ),
430
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: [
431
+ contentTypeLabel(bookmark),
432
+ " ·",
433
+ " ",
434
+ formatMessage(
435
+ index.msg(
436
+ "table.conditionCount",
437
+ "{count, plural, =0 {No filters} one {# filter} other {# filters}}"
438
+ ),
439
+ {
440
+ count: conditions(bookmark)
441
+ }
442
+ ),
443
+ " ",
444
+ "· ",
445
+ ownerLabel(bookmark)
446
+ ] })
447
+ ] })
448
+ ] })
449
+ },
450
+ bookmark.documentId
451
+ )) }) : /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Table, { colCount: 7, rowCount: bookmarks.length + 1, children: [
452
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Thead, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
453
+ sortHeader("name", formatMessage(index.msg("table.name", "Name"))),
454
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: formatMessage(index.msg("table.contentType", "Content type")) }) }),
455
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: formatMessage(index.msg("table.filters", "Filters")) }) }),
456
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: formatMessage(index.msg("table.visibility", "Visibility")) }) }),
457
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: formatMessage(index.msg("table.owner", "Owner")) }) }),
458
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { children: formatMessage(index.msg("scope.pinned", "Pinned")) }) }),
459
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { children: formatMessage(index.msg("table.actions", "Actions")) }) })
460
+ ] }) }),
461
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tbody, { children: bookmarks.map((bookmark) => /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
462
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { maxWidth: "40rem", children: nameCell(bookmark) }),
463
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral800", children: contentTypeLabel(bookmark) }) }),
464
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral800", children: formatMessage(
465
+ index.msg(
466
+ "table.conditionCount",
467
+ "{count, plural, =0 {No filters} one {# filter} other {# filters}}"
468
+ ),
469
+ {
470
+ count: conditions(bookmark)
471
+ }
472
+ ) }) }),
473
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(
474
+ designSystem.Badge,
475
+ {
476
+ backgroundColor: VISIBILITY_BADGE[bookmark.visibility].backgroundColor,
477
+ textColor: VISIBILITY_BADGE[bookmark.visibility].textColor,
478
+ children: formatMessage(VISIBILITY_BADGE[bookmark.visibility].label)
479
+ }
480
+ ) }),
481
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral800", children: ownerLabel(bookmark) }) }),
482
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: actionsFor(bookmark, "pin") }),
483
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: actionsFor(bookmark, "menu") })
484
+ ] }, bookmark.documentId)) })
485
+ ] }),
486
+ pagination && pagination.total > 0 ? /* @__PURE__ */ jsxRuntime.jsxs(
487
+ admin.Pagination.Root,
488
+ {
489
+ pageCount: pagination.pageCount,
490
+ total: pagination.total,
491
+ defaultPageSize: 25,
492
+ children: [
493
+ showPageSize ? /* @__PURE__ */ jsxRuntime.jsx(admin.Pagination.PageSize, {}) : null,
494
+ /* @__PURE__ */ jsxRuntime.jsx(admin.Pagination.Links, { siblingCount: isMobile ? 0 : 1 })
495
+ ]
496
+ }
497
+ ) : null
498
+ ] }) }),
499
+ editId ? /* @__PURE__ */ jsxRuntime.jsx(
500
+ index.BookmarkFormModal,
501
+ {
502
+ open: !!editId,
503
+ onOpenChange: (next) => {
504
+ if (next) return;
505
+ setEditId(null);
506
+ restoreFocus();
507
+ },
508
+ bookmarkId: editId,
509
+ canShare,
510
+ onSaved: () => {
511
+ setEditId(null);
512
+ reload();
513
+ restoreFocus();
514
+ }
515
+ }
516
+ ) : null,
517
+ /* @__PURE__ */ jsxRuntime.jsx(
518
+ designSystem.Dialog.Root,
519
+ {
520
+ open: !!toDelete,
521
+ onOpenChange: (next) => {
522
+ if (next || deleting) return;
523
+ setToDelete(null);
524
+ restoreFocus();
525
+ },
526
+ children: /* @__PURE__ */ jsxRuntime.jsx(
527
+ admin.ConfirmDialog,
528
+ {
529
+ title: formatMessage(index.msg("delete.title", "Delete bookmark?")),
530
+ endAction: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "danger", loading: deleting, onClick: confirmDelete, children: formatMessage(index.msg("delete.confirm", "Delete")) }),
531
+ children: formatMessage(
532
+ index.msg(
533
+ "delete.body",
534
+ '"{name}" will be deleted for everyone it is shared with. The entries in the Content Manager are not affected. This cannot be undone.'
535
+ ),
536
+ { name: toDelete?.name ?? "" }
537
+ )
538
+ }
539
+ )
540
+ }
541
+ )
542
+ ] });
543
+ };
544
+ const NotFoundPage = () => {
545
+ const { formatMessage } = reactIntl.useIntl();
546
+ const title = formatMessage(index.msg("notFound.title", "Page not found"));
547
+ return /* @__PURE__ */ jsxRuntime.jsxs(admin.Page.Main, { "aria-labelledby": "magic-mark-not-found-title", children: [
548
+ /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Title, { children: title }),
549
+ /* @__PURE__ */ jsxRuntime.jsx(admin.Layouts.Header, { id: "magic-mark-not-found-title", title }),
550
+ /* @__PURE__ */ jsxRuntime.jsx(admin.Layouts.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(
551
+ designSystem.EmptyStateLayout,
552
+ {
553
+ icon: /* @__PURE__ */ jsxRuntime.jsx(symbols.EmptyPictures, { width: "16rem" }),
554
+ content: formatMessage(
555
+ index.msg(
556
+ "notFound.content",
557
+ "This page does not exist. Your bookmarks are on the Magic Mark page."
558
+ )
559
+ ),
560
+ action: /* @__PURE__ */ jsxRuntime.jsx(
561
+ designSystem.LinkButton,
562
+ {
563
+ tag: reactRouterDom.NavLink,
564
+ to: `/plugins/${index.pluginId}`,
565
+ variant: "secondary",
566
+ endIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.ArrowRight, {}),
567
+ children: formatMessage(index.msg("notFound.back", "Go to Magic Mark"))
568
+ }
569
+ ),
570
+ hasRadius: true,
571
+ shadow: "tableShadow"
572
+ }
573
+ ) })
574
+ ] });
575
+ };
576
+ const App = () => /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Protect, { permissions: index.PERMISSIONS.read, children: /* @__PURE__ */ jsxRuntime.jsxs(reactRouterDom.Routes, { children: [
577
+ /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Route, { index: true, element: /* @__PURE__ */ jsxRuntime.jsx(BookmarksPage, {}) }),
578
+ /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Route, { path: "*", element: /* @__PURE__ */ jsxRuntime.jsx(NotFoundPage, {}) })
579
+ ] }) });
580
+ exports.default = App;
@@ -0,0 +1,55 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Flex, Box, Link, Typography } from "@strapi/design-system";
3
+ import { Widget } from "@strapi/strapi/admin";
4
+ import { useState, useEffect } from "react";
5
+ import { useIntl } from "react-intl";
6
+ import { NavLink } from "react-router-dom";
7
+ import { u as useBookmarksApi, a as useOpenBookmark, b as useContentTypeNames, m as msg, g as getIcon, c as bookmarkLocation, L as LINK_TARGET } from "./index-X8I03cOT.mjs";
8
+ const PinnedBookmarksWidget = () => {
9
+ const { formatMessage } = useIntl();
10
+ const api = useBookmarksApi();
11
+ const openBookmark = useOpenBookmark();
12
+ const { names } = useContentTypeNames();
13
+ const [items, setItems] = useState(null);
14
+ const [failed, setFailed] = useState(false);
15
+ useEffect(() => {
16
+ const controller = new AbortController();
17
+ api.list({ scope: "pinned", pageSize: 5, sort: "name:asc" }, controller.signal).then((result) => setItems(result.data)).catch(() => !controller.signal.aborted && setFailed(true));
18
+ return () => controller.abort();
19
+ }, [api]);
20
+ if (failed) {
21
+ return /* @__PURE__ */ jsx(Widget.Error, { children: formatMessage(msg("widget.error", "Pinned bookmarks could not be loaded.")) });
22
+ }
23
+ if (!items) return /* @__PURE__ */ jsx(Widget.Loading, {});
24
+ if (!items.length) {
25
+ return /* @__PURE__ */ jsx(Widget.NoData, { children: formatMessage(msg("widget.empty", "Pin bookmarks to see them here.")) });
26
+ }
27
+ return /* @__PURE__ */ jsx(Flex, { direction: "column", alignItems: "stretch", gap: 3, tag: "ul", children: items.map((bookmark) => {
28
+ const Icon = getIcon(bookmark.icon);
29
+ const target = bookmarkLocation(bookmark);
30
+ return /* @__PURE__ */ jsxs(Flex, { tag: "li", gap: 3, alignItems: "flex-start", minWidth: 0, children: [
31
+ /* @__PURE__ */ jsx(Box, { paddingTop: 1, color: "neutral600", children: /* @__PURE__ */ jsx(Icon, { "aria-hidden": true }) }),
32
+ /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "flex-start", minWidth: 0, children: [
33
+ target ? /* @__PURE__ */ jsx(
34
+ Link,
35
+ {
36
+ tag: NavLink,
37
+ to: target,
38
+ ...LINK_TARGET,
39
+ onClick: (event) => {
40
+ if (event.metaKey || event.ctrlKey || event.shiftKey || event.button !== 0)
41
+ return;
42
+ event.preventDefault();
43
+ openBookmark(bookmark);
44
+ },
45
+ children: bookmark.name
46
+ }
47
+ ) : /* @__PURE__ */ jsx(Typography, { children: bookmark.name }),
48
+ /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: bookmark.contentType ? names.get(bookmark.contentType) ?? bookmark.contentType : "" })
49
+ ] })
50
+ ] }, bookmark.documentId);
51
+ }) });
52
+ };
53
+ export {
54
+ PinnedBookmarksWidget as default
55
+ };