strapi-plugin-magic-mark 4.0.3 → 4.0.4
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/CHANGELOG.md +17 -0
- package/README.md +9 -0
- package/dist/admin/{App-uN9SP52K.js → App-BZiGgFPL.js} +1 -1
- package/dist/admin/{App-CsSuEj9M.mjs → App-BzKXIPZe.mjs} +1 -1
- package/dist/admin/{PinnedBookmarksWidget-BpJ0pz5_.js → PinnedBookmarksWidget-BLphsESy.js} +1 -1
- package/dist/admin/{PinnedBookmarksWidget-hj8PkIR8.mjs → PinnedBookmarksWidget-BY7dtb-J.mjs} +1 -1
- package/dist/admin/{index-CcVZyEc_.js → index-Db5jW3WB.js} +92 -87
- package/dist/admin/{index-JMvoPs_C.mjs → index-DqJBO_JD.mjs} +93 -88
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/package.json +4 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
## [4.0.4](https://github.com/Schero94/Magicmark/compare/v4.0.3...v4.0.4) (2026-11-18)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **admin:** keep the shared schema cache alive across StrictMode remounts ([#14](https://github.com/Schero94/Magicmark/issues/14)) ([494ba2c](https://github.com/Schero94/Magicmark/commit/494ba2c4a2f3d699c233182f5b539206dd9bc8ba))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
* Content type names and filter fields load again after a component that started loading them unmounts. The schema cache (`/content-manager/init` and the list view configuration) is shared by the list view toolbar, the bookmark popover, the homepage widget and the bookmark page, but its requests ran on the abort signal of the first component; when that component unmounted (React StrictMode does this once on every mount), every other component got the aborted request and showed raw content type ids or "Fields could not be loaded". The cache now uses a fetch client that is not bound to one component.
|
|
12
|
+
* The bookmark dialog no longer logs the Radix "Missing `Description`" warning: its title is its only label (`aria-describedby={undefined}`), as in the Advanced filters dialog since 4.0.3.
|
|
13
|
+
|
|
14
|
+
### Tests
|
|
15
|
+
|
|
16
|
+
* `npm run test:admin`: StrictMode tests for every admin entry point (no duplicate requests, no leaked timers, listeners, connections or observers after unmount, no console errors or warnings), also run against React 19 in an informational CI job.
|
|
17
|
+
|
|
1
18
|
## [4.0.3](https://github.com/Schero94/Magicmark/compare/v4.0.2...v4.0.3) (2026-11-18)
|
|
2
19
|
|
|
3
20
|
|
package/README.md
CHANGED
|
@@ -413,6 +413,7 @@ npm ci --legacy-peer-deps
|
|
|
413
413
|
npm run lint
|
|
414
414
|
npm run format:check
|
|
415
415
|
npm test
|
|
416
|
+
npm run test:admin
|
|
416
417
|
npm run test:ts:front
|
|
417
418
|
npm run test:ts:back
|
|
418
419
|
npm run build
|
|
@@ -427,6 +428,14 @@ view helpers, translation completeness and package rules. CI runs every command
|
|
|
427
428
|
and 24, and type-checks, tests and builds once more against the lowest supported Strapi version
|
|
428
429
|
(5.57.0).
|
|
429
430
|
|
|
431
|
+
`npm run test:admin` renders every admin entry point (the bookmark page, the homepage widget, the
|
|
432
|
+
list view toolbar with its popover and filter dialog, the bookmark dialog) inside
|
|
433
|
+
`React.StrictMode` with the providers of the Strapi admin, in jsdom with a fake network. It fails
|
|
434
|
+
on a mutation sent twice, a read repeated without aborting the first one, an interval, listener,
|
|
435
|
+
connection or observer left after unmount, and any console error or warning. A separate CI job
|
|
436
|
+
runs the same tests against React 19 for information only: the plugin's peer range is React 18,
|
|
437
|
+
like the Strapi 5 admin.
|
|
438
|
+
|
|
430
439
|
## Contributing and support
|
|
431
440
|
|
|
432
441
|
- Bugs and feature requests: [open an issue](https://github.com/Schero94/Magicmark/issues/new/choose).
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const jsxRuntime = require("react/jsx-runtime");
|
|
4
4
|
const admin = require("@strapi/strapi/admin");
|
|
5
5
|
const reactRouterDom = require("react-router-dom");
|
|
6
|
-
const index = require("./index-
|
|
6
|
+
const index = require("./index-Db5jW3WB.js");
|
|
7
7
|
const designSystem = require("@strapi/design-system");
|
|
8
8
|
const icons = require("@strapi/icons");
|
|
9
9
|
const symbols = require("@strapi/icons/symbols");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useNotification, useClipboard, useIsDesktop, useIsMobile, useMediaQuery, useRBAC, useQueryParams, Page, Layouts, SearchInput, Pagination, ConfirmDialog } from "@strapi/strapi/admin";
|
|
3
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-
|
|
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-DqJBO_JD.mjs";
|
|
5
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
6
|
import { Pin, More, ExternalLink, Pencil, Duplicate, Link, Trash, CaretDown, CaretUp, ArrowRight } from "@strapi/icons";
|
|
7
7
|
import { EmptyDocuments, EmptyPictures } from "@strapi/icons/symbols";
|
|
@@ -6,7 +6,7 @@ const admin = require("@strapi/strapi/admin");
|
|
|
6
6
|
const react = require("react");
|
|
7
7
|
const reactIntl = require("react-intl");
|
|
8
8
|
const reactRouterDom = require("react-router-dom");
|
|
9
|
-
const index = require("./index-
|
|
9
|
+
const index = require("./index-Db5jW3WB.js");
|
|
10
10
|
const PinnedBookmarksWidget = () => {
|
|
11
11
|
const { formatMessage } = reactIntl.useIntl();
|
|
12
12
|
const api = index.useBookmarksApi();
|
package/dist/admin/{PinnedBookmarksWidget-hj8PkIR8.mjs → PinnedBookmarksWidget-BY7dtb-J.mjs}
RENAMED
|
@@ -4,7 +4,7 @@ import { Widget } from "@strapi/strapi/admin";
|
|
|
4
4
|
import { useState, useEffect } from "react";
|
|
5
5
|
import { useIntl } from "react-intl";
|
|
6
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-
|
|
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-DqJBO_JD.mjs";
|
|
8
8
|
const PinnedBookmarksWidget = () => {
|
|
9
9
|
const { formatMessage } = useIntl();
|
|
10
10
|
const api = useBookmarksApi();
|
|
@@ -197,19 +197,20 @@ const buildFieldOptions = (uid, init, metadatas, readable) => {
|
|
|
197
197
|
};
|
|
198
198
|
let initCache = null;
|
|
199
199
|
const configCache = /* @__PURE__ */ new Map();
|
|
200
|
-
const
|
|
200
|
+
const sessionGet = (url) => admin.getFetchClient().get(url);
|
|
201
|
+
const loadInit = () => {
|
|
201
202
|
if (!initCache) {
|
|
202
|
-
initCache =
|
|
203
|
+
initCache = sessionGet("/content-manager/init").then(({ data }) => data.data).catch((error) => {
|
|
203
204
|
initCache = null;
|
|
204
205
|
throw error;
|
|
205
206
|
});
|
|
206
207
|
}
|
|
207
208
|
return initCache;
|
|
208
209
|
};
|
|
209
|
-
const loadMetadatas = (
|
|
210
|
+
const loadMetadatas = (uid) => {
|
|
210
211
|
let promise = configCache.get(uid);
|
|
211
212
|
if (!promise) {
|
|
212
|
-
promise =
|
|
213
|
+
promise = sessionGet(
|
|
213
214
|
`/content-manager/content-types/${uid}/configuration`
|
|
214
215
|
).then(({ data }) => data.data.contentType.metadatas ?? {}).catch((error) => {
|
|
215
216
|
configCache.delete(uid);
|
|
@@ -220,7 +221,6 @@ const loadMetadatas = (get, uid) => {
|
|
|
220
221
|
return promise;
|
|
221
222
|
};
|
|
222
223
|
const useContentTypeNames = () => {
|
|
223
|
-
const { get } = admin.useFetchClient();
|
|
224
224
|
const [state, setState] = react.useState({
|
|
225
225
|
names: /* @__PURE__ */ new Map(),
|
|
226
226
|
isLoading: true,
|
|
@@ -228,7 +228,7 @@ const useContentTypeNames = () => {
|
|
|
228
228
|
});
|
|
229
229
|
react.useEffect(() => {
|
|
230
230
|
let active = true;
|
|
231
|
-
loadInit(
|
|
231
|
+
loadInit().then((init) => {
|
|
232
232
|
if (!active) return;
|
|
233
233
|
setState({
|
|
234
234
|
names: new Map(init.contentTypes.map((ct) => [ct.uid, ct.info?.displayName ?? ct.uid])),
|
|
@@ -239,11 +239,10 @@ const useContentTypeNames = () => {
|
|
|
239
239
|
return () => {
|
|
240
240
|
active = false;
|
|
241
241
|
};
|
|
242
|
-
}, [
|
|
242
|
+
}, []);
|
|
243
243
|
return state;
|
|
244
244
|
};
|
|
245
245
|
const useFilterFields = (uid) => {
|
|
246
|
-
const { get } = admin.useFetchClient();
|
|
247
246
|
const permissions = admin.useAuth("MagicMarkFilters", (state2) => state2.permissions);
|
|
248
247
|
const [attempt, setAttempt] = react.useState(0);
|
|
249
248
|
const [state, setState] = react.useState({
|
|
@@ -262,7 +261,7 @@ const useFilterFields = (uid) => {
|
|
|
262
261
|
react.useEffect(() => {
|
|
263
262
|
if (!uid) return void 0;
|
|
264
263
|
let active = true;
|
|
265
|
-
Promise.all([loadInit(
|
|
264
|
+
Promise.all([loadInit(), loadMetadatas(uid)]).then(([init, metadatas]) => {
|
|
266
265
|
if (active) {
|
|
267
266
|
setState({ key, fields: buildFieldOptions(uid, init, metadatas, readable), error: null });
|
|
268
267
|
}
|
|
@@ -270,7 +269,7 @@ const useFilterFields = (uid) => {
|
|
|
270
269
|
return () => {
|
|
271
270
|
active = false;
|
|
272
271
|
};
|
|
273
|
-
}, [
|
|
272
|
+
}, [uid, readable, key]);
|
|
274
273
|
const current = state.key === key;
|
|
275
274
|
return {
|
|
276
275
|
fields: current ? state.fields : [],
|
|
@@ -1047,7 +1046,6 @@ const normalizeSavedQuery = (query, init, uid) => {
|
|
|
1047
1046
|
};
|
|
1048
1047
|
const useOpenBookmark = () => {
|
|
1049
1048
|
const navigate = reactRouterDom.useNavigate();
|
|
1050
|
-
const { get } = admin.useFetchClient();
|
|
1051
1049
|
const { toggleNotification } = admin.useNotification();
|
|
1052
1050
|
const { formatMessage } = reactIntl.useIntl();
|
|
1053
1051
|
return react.useCallback(
|
|
@@ -1078,7 +1076,7 @@ const useOpenBookmark = () => {
|
|
|
1078
1076
|
}
|
|
1079
1077
|
let saved = parsed;
|
|
1080
1078
|
try {
|
|
1081
|
-
saved = normalizeSavedQuery(parsed, await loadInit(
|
|
1079
|
+
saved = normalizeSavedQuery(parsed, await loadInit(), location.uid);
|
|
1082
1080
|
} catch {
|
|
1083
1081
|
}
|
|
1084
1082
|
const search = saved === parsed ? bookmark.query ?? "" : stringifyQuery(saved);
|
|
@@ -1088,7 +1086,7 @@ const useOpenBookmark = () => {
|
|
|
1088
1086
|
}
|
|
1089
1087
|
navigate({ pathname: location.path, search: search ? `?${search}` : "" });
|
|
1090
1088
|
},
|
|
1091
|
-
[
|
|
1089
|
+
[navigate, toggleNotification, formatMessage]
|
|
1092
1090
|
);
|
|
1093
1091
|
};
|
|
1094
1092
|
const errorBody = (error) => error?.response?.data?.error;
|
|
@@ -1501,83 +1499,90 @@ const BookmarkFormModal = ({
|
|
|
1501
1499
|
const contentType = view?.contentType ?? loaded?.contentType ?? null;
|
|
1502
1500
|
const query = view?.query ?? loaded?.query ?? "";
|
|
1503
1501
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1504
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Root, { open, onOpenChange: handleOpenChange, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
"
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
onChange: (event) => setName(event.target.value),
|
|
1534
|
-
placeholder: formatMessage(
|
|
1535
|
-
msg("form.namePlaceholder", "e.g. Drafts waiting for review")
|
|
1536
|
-
)
|
|
1537
|
-
}
|
|
1538
|
-
),
|
|
1539
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Error, {})
|
|
1540
|
-
] }),
|
|
1541
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1542
|
-
designSystem.Field.Root,
|
|
1543
|
-
{
|
|
1544
|
-
name: "description",
|
|
1545
|
-
error: errors.description,
|
|
1546
|
-
hint: formatMessage(
|
|
1547
|
-
msg("form.descriptionHint", "Optional. Shown below the name.")
|
|
1548
|
-
),
|
|
1549
|
-
children: [
|
|
1550
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: formatMessage(msg("form.description", "Description")) }),
|
|
1502
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Root, { open, onOpenChange: handleOpenChange, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1503
|
+
designSystem.Modal.Content,
|
|
1504
|
+
{
|
|
1505
|
+
onKeyDown: keepFocusInside,
|
|
1506
|
+
"aria-describedby": void 0,
|
|
1507
|
+
children: [
|
|
1508
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Header, { closeLabel: formatMessage(msg("form.close", "Close")), children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Title, { children: title }) }),
|
|
1509
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Body, { children: loading ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", padding: 6, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Loader, { small: true, children: formatMessage(msg("state.loading", "Loading")) }) }) : loadFailed ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "danger600", children: formatMessage(msg("form.loadError", "The bookmark could not be loaded.")) }) : /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
|
|
1510
|
+
queryRejected ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1511
|
+
designSystem.Alert,
|
|
1512
|
+
{
|
|
1513
|
+
variant: "danger",
|
|
1514
|
+
closeLabel: formatMessage(msg("form.close", "Close")),
|
|
1515
|
+
onClose: () => setQueryRejected(false),
|
|
1516
|
+
children: formatMessage(
|
|
1517
|
+
msg(
|
|
1518
|
+
"form.queryTooLong",
|
|
1519
|
+
"This view cannot be saved: the search text or a filter value is too long. Shorten it in the list and try again."
|
|
1520
|
+
)
|
|
1521
|
+
)
|
|
1522
|
+
}
|
|
1523
|
+
) : null,
|
|
1524
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { background: "neutral100", hasRadius: true, padding: 4, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
|
1525
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", tag: "h3", children: formatMessage(msg("form.savedView", "Saved view")) }),
|
|
1526
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "semiBold", children: view?.contentTypeName ?? (contentType ? names.get(contentType) ?? contentType : "") }),
|
|
1527
|
+
/* @__PURE__ */ jsxRuntime.jsx(FilterSummary, { contentType, query })
|
|
1528
|
+
] }) }),
|
|
1529
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { name: "name", error: errors.name, required: true, children: [
|
|
1530
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: formatMessage(msg("form.name", "Name")) }),
|
|
1551
1531
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1552
|
-
designSystem.
|
|
1532
|
+
designSystem.TextInput,
|
|
1553
1533
|
{
|
|
1554
|
-
value:
|
|
1555
|
-
|
|
1534
|
+
value: name,
|
|
1535
|
+
maxLength: NAME_MAX,
|
|
1536
|
+
onChange: (event) => setName(event.target.value),
|
|
1537
|
+
placeholder: formatMessage(
|
|
1538
|
+
msg("form.namePlaceholder", "e.g. Drafts waiting for review")
|
|
1539
|
+
)
|
|
1556
1540
|
}
|
|
1557
1541
|
),
|
|
1558
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Hint, {}),
|
|
1559
1542
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Error, {})
|
|
1560
|
-
]
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1543
|
+
] }),
|
|
1544
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1545
|
+
designSystem.Field.Root,
|
|
1546
|
+
{
|
|
1547
|
+
name: "description",
|
|
1548
|
+
error: errors.description,
|
|
1549
|
+
hint: formatMessage(
|
|
1550
|
+
msg("form.descriptionHint", "Optional. Shown below the name.")
|
|
1551
|
+
),
|
|
1552
|
+
children: [
|
|
1553
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: formatMessage(msg("form.description", "Description")) }),
|
|
1554
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1555
|
+
designSystem.Textarea,
|
|
1556
|
+
{
|
|
1557
|
+
value: description,
|
|
1558
|
+
onChange: (event) => setDescription(event.target.value)
|
|
1559
|
+
}
|
|
1560
|
+
),
|
|
1561
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Hint, {}),
|
|
1562
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Error, {})
|
|
1563
|
+
]
|
|
1564
|
+
}
|
|
1565
|
+
),
|
|
1566
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { name: "icon", children: [
|
|
1567
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: formatMessage(msg("form.icon", "Icon")) }),
|
|
1568
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1569
|
+
designSystem.SingleSelect,
|
|
1570
|
+
{
|
|
1571
|
+
value: icon,
|
|
1572
|
+
onChange: (value) => setIcon(String(value)),
|
|
1573
|
+
children: ICON_OPTIONS.map(({ key, Icon }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: key, startIcon: /* @__PURE__ */ jsxRuntime.jsx(Icon, { "aria-hidden": true }), children: formatMessage(ICON_LABELS[key]) }, key))
|
|
1574
|
+
}
|
|
1575
|
+
)
|
|
1576
|
+
] }),
|
|
1577
|
+
canShare ? /* @__PURE__ */ jsxRuntime.jsx(SharingFields, { value: sharing, onChange: setSharing, error: errors.roles }) : null
|
|
1578
|
+
] }) }),
|
|
1579
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Footer, { children: [
|
|
1580
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Close, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", children: formatMessage(msg("form.cancel", "Cancel")) }) }),
|
|
1581
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: submit, loading: saving, disabled: loading || loadFailed, children: formatMessage(msg("form.save", "Save")) })
|
|
1582
|
+
] })
|
|
1583
|
+
]
|
|
1584
|
+
}
|
|
1585
|
+
) }),
|
|
1581
1586
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Root, { open: confirmDiscard, onOpenChange: setConfirmDiscard, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1582
1587
|
admin.ConfirmDialog,
|
|
1583
1588
|
{
|
|
@@ -1884,7 +1889,7 @@ const index = {
|
|
|
1884
1889
|
to: `plugins/${pluginId}`,
|
|
1885
1890
|
icon: PluginIcon,
|
|
1886
1891
|
intlLabel: { id: `${pluginId}.plugin.name`, defaultMessage: "Magic Mark" },
|
|
1887
|
-
Component: () => Promise.resolve().then(() => require("./App-
|
|
1892
|
+
Component: () => Promise.resolve().then(() => require("./App-BZiGgFPL.js")),
|
|
1888
1893
|
permissions: PERMISSIONS.read
|
|
1889
1894
|
});
|
|
1890
1895
|
app.registerPlugin({ id: pluginId, name: "Magic Mark" });
|
|
@@ -1899,7 +1904,7 @@ const index = {
|
|
|
1899
1904
|
label: { id: `${pluginId}.widget.link`, defaultMessage: "Manage bookmarks" },
|
|
1900
1905
|
href: `/plugins/${pluginId}`
|
|
1901
1906
|
},
|
|
1902
|
-
component: async () => (await Promise.resolve().then(() => require("./PinnedBookmarksWidget-
|
|
1907
|
+
component: async () => (await Promise.resolve().then(() => require("./PinnedBookmarksWidget-BLphsESy.js"))).default,
|
|
1903
1908
|
permissions: PERMISSIONS.read
|
|
1904
1909
|
});
|
|
1905
1910
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Plus, Trash, Book, Star, Heart, Lightning, Rocket, Sparkle, Pencil, File, Folder, Image, Link, PriceTag, Filter, Search, Calendar, Clock, Bell, CheckCircle, Mail, User, Briefcase, Gift, Globe, House, Feather, TrendUp, Stack, Cog, PuzzlePiece, Code, ChartPie, Cross, ArrowClockwise, Pin, SlidersHorizontal } from "@strapi/icons";
|
|
2
2
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { Modal, Flex, Loader, Alert, Button, Field, SingleSelect, SingleSelectOption, Box, TextButton, Typography, Grid, Combobox, ComboboxOption, IconButton, MultiSelect, MultiSelectOption, TextInput, Radio, Tag, Textarea, Dialog, Popover, Divider, Link as Link$1 } from "@strapi/design-system";
|
|
4
|
-
import {
|
|
4
|
+
import { useAuth, getFetchClient, useQueryParams, withEncodedUserParams, deepEncodeQueryValues, useFetchClient, useNotification, ConfirmDialog, useRBAC } from "@strapi/strapi/admin";
|
|
5
5
|
import { useState, useEffect, useMemo, useCallback, useRef } from "react";
|
|
6
6
|
import { useIntl } from "react-intl";
|
|
7
7
|
import { useNavigate, NavLink, useLocation } from "react-router-dom";
|
|
@@ -194,19 +194,20 @@ const buildFieldOptions = (uid, init, metadatas, readable) => {
|
|
|
194
194
|
};
|
|
195
195
|
let initCache = null;
|
|
196
196
|
const configCache = /* @__PURE__ */ new Map();
|
|
197
|
-
const
|
|
197
|
+
const sessionGet = (url) => getFetchClient().get(url);
|
|
198
|
+
const loadInit = () => {
|
|
198
199
|
if (!initCache) {
|
|
199
|
-
initCache =
|
|
200
|
+
initCache = sessionGet("/content-manager/init").then(({ data }) => data.data).catch((error) => {
|
|
200
201
|
initCache = null;
|
|
201
202
|
throw error;
|
|
202
203
|
});
|
|
203
204
|
}
|
|
204
205
|
return initCache;
|
|
205
206
|
};
|
|
206
|
-
const loadMetadatas = (
|
|
207
|
+
const loadMetadatas = (uid) => {
|
|
207
208
|
let promise = configCache.get(uid);
|
|
208
209
|
if (!promise) {
|
|
209
|
-
promise =
|
|
210
|
+
promise = sessionGet(
|
|
210
211
|
`/content-manager/content-types/${uid}/configuration`
|
|
211
212
|
).then(({ data }) => data.data.contentType.metadatas ?? {}).catch((error) => {
|
|
212
213
|
configCache.delete(uid);
|
|
@@ -217,7 +218,6 @@ const loadMetadatas = (get, uid) => {
|
|
|
217
218
|
return promise;
|
|
218
219
|
};
|
|
219
220
|
const useContentTypeNames = () => {
|
|
220
|
-
const { get } = useFetchClient();
|
|
221
221
|
const [state, setState] = useState({
|
|
222
222
|
names: /* @__PURE__ */ new Map(),
|
|
223
223
|
isLoading: true,
|
|
@@ -225,7 +225,7 @@ const useContentTypeNames = () => {
|
|
|
225
225
|
});
|
|
226
226
|
useEffect(() => {
|
|
227
227
|
let active = true;
|
|
228
|
-
loadInit(
|
|
228
|
+
loadInit().then((init) => {
|
|
229
229
|
if (!active) return;
|
|
230
230
|
setState({
|
|
231
231
|
names: new Map(init.contentTypes.map((ct) => [ct.uid, ct.info?.displayName ?? ct.uid])),
|
|
@@ -236,11 +236,10 @@ const useContentTypeNames = () => {
|
|
|
236
236
|
return () => {
|
|
237
237
|
active = false;
|
|
238
238
|
};
|
|
239
|
-
}, [
|
|
239
|
+
}, []);
|
|
240
240
|
return state;
|
|
241
241
|
};
|
|
242
242
|
const useFilterFields = (uid) => {
|
|
243
|
-
const { get } = useFetchClient();
|
|
244
243
|
const permissions = useAuth("MagicMarkFilters", (state2) => state2.permissions);
|
|
245
244
|
const [attempt, setAttempt] = useState(0);
|
|
246
245
|
const [state, setState] = useState({
|
|
@@ -259,7 +258,7 @@ const useFilterFields = (uid) => {
|
|
|
259
258
|
useEffect(() => {
|
|
260
259
|
if (!uid) return void 0;
|
|
261
260
|
let active = true;
|
|
262
|
-
Promise.all([loadInit(
|
|
261
|
+
Promise.all([loadInit(), loadMetadatas(uid)]).then(([init, metadatas]) => {
|
|
263
262
|
if (active) {
|
|
264
263
|
setState({ key, fields: buildFieldOptions(uid, init, metadatas, readable), error: null });
|
|
265
264
|
}
|
|
@@ -267,7 +266,7 @@ const useFilterFields = (uid) => {
|
|
|
267
266
|
return () => {
|
|
268
267
|
active = false;
|
|
269
268
|
};
|
|
270
|
-
}, [
|
|
269
|
+
}, [uid, readable, key]);
|
|
271
270
|
const current = state.key === key;
|
|
272
271
|
return {
|
|
273
272
|
fields: current ? state.fields : [],
|
|
@@ -1044,7 +1043,6 @@ const normalizeSavedQuery = (query, init, uid) => {
|
|
|
1044
1043
|
};
|
|
1045
1044
|
const useOpenBookmark = () => {
|
|
1046
1045
|
const navigate = useNavigate();
|
|
1047
|
-
const { get } = useFetchClient();
|
|
1048
1046
|
const { toggleNotification } = useNotification();
|
|
1049
1047
|
const { formatMessage } = useIntl();
|
|
1050
1048
|
return useCallback(
|
|
@@ -1075,7 +1073,7 @@ const useOpenBookmark = () => {
|
|
|
1075
1073
|
}
|
|
1076
1074
|
let saved = parsed;
|
|
1077
1075
|
try {
|
|
1078
|
-
saved = normalizeSavedQuery(parsed, await loadInit(
|
|
1076
|
+
saved = normalizeSavedQuery(parsed, await loadInit(), location.uid);
|
|
1079
1077
|
} catch {
|
|
1080
1078
|
}
|
|
1081
1079
|
const search = saved === parsed ? bookmark.query ?? "" : stringifyQuery(saved);
|
|
@@ -1085,7 +1083,7 @@ const useOpenBookmark = () => {
|
|
|
1085
1083
|
}
|
|
1086
1084
|
navigate({ pathname: location.path, search: search ? `?${search}` : "" });
|
|
1087
1085
|
},
|
|
1088
|
-
[
|
|
1086
|
+
[navigate, toggleNotification, formatMessage]
|
|
1089
1087
|
);
|
|
1090
1088
|
};
|
|
1091
1089
|
const errorBody = (error) => error?.response?.data?.error;
|
|
@@ -1498,83 +1496,90 @@ const BookmarkFormModal = ({
|
|
|
1498
1496
|
const contentType = view?.contentType ?? loaded?.contentType ?? null;
|
|
1499
1497
|
const query = view?.query ?? loaded?.query ?? "";
|
|
1500
1498
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1501
|
-
/* @__PURE__ */ jsx(Modal.Root, { open, onOpenChange: handleOpenChange, children: /* @__PURE__ */ jsxs(
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
"
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
onChange: (event) => setName(event.target.value),
|
|
1531
|
-
placeholder: formatMessage(
|
|
1532
|
-
msg("form.namePlaceholder", "e.g. Drafts waiting for review")
|
|
1533
|
-
)
|
|
1534
|
-
}
|
|
1535
|
-
),
|
|
1536
|
-
/* @__PURE__ */ jsx(Field.Error, {})
|
|
1537
|
-
] }),
|
|
1538
|
-
/* @__PURE__ */ jsxs(
|
|
1539
|
-
Field.Root,
|
|
1540
|
-
{
|
|
1541
|
-
name: "description",
|
|
1542
|
-
error: errors.description,
|
|
1543
|
-
hint: formatMessage(
|
|
1544
|
-
msg("form.descriptionHint", "Optional. Shown below the name.")
|
|
1545
|
-
),
|
|
1546
|
-
children: [
|
|
1547
|
-
/* @__PURE__ */ jsx(Field.Label, { children: formatMessage(msg("form.description", "Description")) }),
|
|
1499
|
+
/* @__PURE__ */ jsx(Modal.Root, { open, onOpenChange: handleOpenChange, children: /* @__PURE__ */ jsxs(
|
|
1500
|
+
Modal.Content,
|
|
1501
|
+
{
|
|
1502
|
+
onKeyDown: keepFocusInside,
|
|
1503
|
+
"aria-describedby": void 0,
|
|
1504
|
+
children: [
|
|
1505
|
+
/* @__PURE__ */ jsx(Modal.Header, { closeLabel: formatMessage(msg("form.close", "Close")), children: /* @__PURE__ */ jsx(Modal.Title, { children: title }) }),
|
|
1506
|
+
/* @__PURE__ */ jsx(Modal.Body, { children: loading ? /* @__PURE__ */ jsx(Flex, { justifyContent: "center", padding: 6, children: /* @__PURE__ */ jsx(Loader, { small: true, children: formatMessage(msg("state.loading", "Loading")) }) }) : loadFailed ? /* @__PURE__ */ jsx(Typography, { textColor: "danger600", children: formatMessage(msg("form.loadError", "The bookmark could not be loaded.")) }) : /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
|
|
1507
|
+
queryRejected ? /* @__PURE__ */ jsx(
|
|
1508
|
+
Alert,
|
|
1509
|
+
{
|
|
1510
|
+
variant: "danger",
|
|
1511
|
+
closeLabel: formatMessage(msg("form.close", "Close")),
|
|
1512
|
+
onClose: () => setQueryRejected(false),
|
|
1513
|
+
children: formatMessage(
|
|
1514
|
+
msg(
|
|
1515
|
+
"form.queryTooLong",
|
|
1516
|
+
"This view cannot be saved: the search text or a filter value is too long. Shorten it in the list and try again."
|
|
1517
|
+
)
|
|
1518
|
+
)
|
|
1519
|
+
}
|
|
1520
|
+
) : null,
|
|
1521
|
+
/* @__PURE__ */ jsx(Box, { background: "neutral100", hasRadius: true, padding: 4, children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
|
1522
|
+
/* @__PURE__ */ jsx(Typography, { variant: "sigma", textColor: "neutral600", tag: "h3", children: formatMessage(msg("form.savedView", "Saved view")) }),
|
|
1523
|
+
/* @__PURE__ */ jsx(Typography, { fontWeight: "semiBold", children: view?.contentTypeName ?? (contentType ? names.get(contentType) ?? contentType : "") }),
|
|
1524
|
+
/* @__PURE__ */ jsx(FilterSummary, { contentType, query })
|
|
1525
|
+
] }) }),
|
|
1526
|
+
/* @__PURE__ */ jsxs(Field.Root, { name: "name", error: errors.name, required: true, children: [
|
|
1527
|
+
/* @__PURE__ */ jsx(Field.Label, { children: formatMessage(msg("form.name", "Name")) }),
|
|
1548
1528
|
/* @__PURE__ */ jsx(
|
|
1549
|
-
|
|
1529
|
+
TextInput,
|
|
1550
1530
|
{
|
|
1551
|
-
value:
|
|
1552
|
-
|
|
1531
|
+
value: name,
|
|
1532
|
+
maxLength: NAME_MAX,
|
|
1533
|
+
onChange: (event) => setName(event.target.value),
|
|
1534
|
+
placeholder: formatMessage(
|
|
1535
|
+
msg("form.namePlaceholder", "e.g. Drafts waiting for review")
|
|
1536
|
+
)
|
|
1553
1537
|
}
|
|
1554
1538
|
),
|
|
1555
|
-
/* @__PURE__ */ jsx(Field.Hint, {}),
|
|
1556
1539
|
/* @__PURE__ */ jsx(Field.Error, {})
|
|
1557
|
-
]
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1540
|
+
] }),
|
|
1541
|
+
/* @__PURE__ */ jsxs(
|
|
1542
|
+
Field.Root,
|
|
1543
|
+
{
|
|
1544
|
+
name: "description",
|
|
1545
|
+
error: errors.description,
|
|
1546
|
+
hint: formatMessage(
|
|
1547
|
+
msg("form.descriptionHint", "Optional. Shown below the name.")
|
|
1548
|
+
),
|
|
1549
|
+
children: [
|
|
1550
|
+
/* @__PURE__ */ jsx(Field.Label, { children: formatMessage(msg("form.description", "Description")) }),
|
|
1551
|
+
/* @__PURE__ */ jsx(
|
|
1552
|
+
Textarea,
|
|
1553
|
+
{
|
|
1554
|
+
value: description,
|
|
1555
|
+
onChange: (event) => setDescription(event.target.value)
|
|
1556
|
+
}
|
|
1557
|
+
),
|
|
1558
|
+
/* @__PURE__ */ jsx(Field.Hint, {}),
|
|
1559
|
+
/* @__PURE__ */ jsx(Field.Error, {})
|
|
1560
|
+
]
|
|
1561
|
+
}
|
|
1562
|
+
),
|
|
1563
|
+
/* @__PURE__ */ jsxs(Field.Root, { name: "icon", children: [
|
|
1564
|
+
/* @__PURE__ */ jsx(Field.Label, { children: formatMessage(msg("form.icon", "Icon")) }),
|
|
1565
|
+
/* @__PURE__ */ jsx(
|
|
1566
|
+
SingleSelect,
|
|
1567
|
+
{
|
|
1568
|
+
value: icon,
|
|
1569
|
+
onChange: (value) => setIcon(String(value)),
|
|
1570
|
+
children: ICON_OPTIONS.map(({ key, Icon }) => /* @__PURE__ */ jsx(SingleSelectOption, { value: key, startIcon: /* @__PURE__ */ jsx(Icon, { "aria-hidden": true }), children: formatMessage(ICON_LABELS[key]) }, key))
|
|
1571
|
+
}
|
|
1572
|
+
)
|
|
1573
|
+
] }),
|
|
1574
|
+
canShare ? /* @__PURE__ */ jsx(SharingFields, { value: sharing, onChange: setSharing, error: errors.roles }) : null
|
|
1575
|
+
] }) }),
|
|
1576
|
+
/* @__PURE__ */ jsxs(Modal.Footer, { children: [
|
|
1577
|
+
/* @__PURE__ */ jsx(Modal.Close, { children: /* @__PURE__ */ jsx(Button, { variant: "tertiary", children: formatMessage(msg("form.cancel", "Cancel")) }) }),
|
|
1578
|
+
/* @__PURE__ */ jsx(Button, { onClick: submit, loading: saving, disabled: loading || loadFailed, children: formatMessage(msg("form.save", "Save")) })
|
|
1579
|
+
] })
|
|
1580
|
+
]
|
|
1581
|
+
}
|
|
1582
|
+
) }),
|
|
1578
1583
|
/* @__PURE__ */ jsx(Dialog.Root, { open: confirmDiscard, onOpenChange: setConfirmDiscard, children: /* @__PURE__ */ jsx(
|
|
1579
1584
|
ConfirmDialog,
|
|
1580
1585
|
{
|
|
@@ -1881,7 +1886,7 @@ const index = {
|
|
|
1881
1886
|
to: `plugins/${pluginId}`,
|
|
1882
1887
|
icon: PluginIcon,
|
|
1883
1888
|
intlLabel: { id: `${pluginId}.plugin.name`, defaultMessage: "Magic Mark" },
|
|
1884
|
-
Component: () => import("./App-
|
|
1889
|
+
Component: () => import("./App-BzKXIPZe.mjs"),
|
|
1885
1890
|
permissions: PERMISSIONS.read
|
|
1886
1891
|
});
|
|
1887
1892
|
app.registerPlugin({ id: pluginId, name: "Magic Mark" });
|
|
@@ -1896,7 +1901,7 @@ const index = {
|
|
|
1896
1901
|
label: { id: `${pluginId}.widget.link`, defaultMessage: "Manage bookmarks" },
|
|
1897
1902
|
href: `/plugins/${pluginId}`
|
|
1898
1903
|
},
|
|
1899
|
-
component: async () => (await import("./PinnedBookmarksWidget-
|
|
1904
|
+
component: async () => (await import("./PinnedBookmarksWidget-BY7dtb-J.mjs")).default,
|
|
1900
1905
|
permissions: PERMISSIONS.read
|
|
1901
1906
|
});
|
|
1902
1907
|
}
|
package/dist/admin/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
-
const index = require("./index-
|
|
3
|
+
const index = require("./index-Db5jW3WB.js");
|
|
4
4
|
require("@strapi/icons");
|
|
5
5
|
exports.default = index.index;
|
package/dist/admin/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "strapi-plugin-magic-mark",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.4",
|
|
4
4
|
"description": "Bookmarks for the Strapi 5 Content Manager: save list views with their filters, sort order, search and locale, pin them and share them with roles or admin users.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"strapi",
|
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
"scripts": {
|
|
53
53
|
"clean": "node -e \"require('fs').rmSync('dist', { recursive: true, force: true })\"",
|
|
54
54
|
"test": "node --test tests/*.test.cjs",
|
|
55
|
+
"test:admin": "node --import ./tests/admin/harness/setup.mjs --test \"tests/admin/*.test.jsx\"",
|
|
55
56
|
"test:ts:front": "tsc --noEmit -p admin/tsconfig.json",
|
|
56
57
|
"test:ts:back": "tsc --noEmit -p server/tsconfig.json",
|
|
57
58
|
"lint": "eslint .",
|
|
@@ -86,10 +87,12 @@
|
|
|
86
87
|
"@types/qs": "^6.15.1",
|
|
87
88
|
"@types/react": "^18.3.31",
|
|
88
89
|
"@types/react-dom": "^18.3.7",
|
|
90
|
+
"esbuild": "^0.28.2",
|
|
89
91
|
"eslint": "^10.14.0",
|
|
90
92
|
"eslint-config-prettier": "^10.1.8",
|
|
91
93
|
"eslint-plugin-react-hooks": "^7.1.1",
|
|
92
94
|
"globals": "^17.14.0",
|
|
95
|
+
"jsdom": "^31.0.1",
|
|
93
96
|
"prettier": "^3.9.10",
|
|
94
97
|
"react": "^18.3.1",
|
|
95
98
|
"react-dom": "^18.3.1",
|