strapi-plugin-magic-mark 3.4.0 → 4.0.1

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