strapi-plugin-magic-mark 4.0.2 → 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 +31 -0
- package/README.md +27 -4
- package/dist/admin/{App-DxALpMK_.js → App-BZiGgFPL.js} +1 -1
- package/dist/admin/{App-BIc-2qv8.mjs → App-BzKXIPZe.mjs} +1 -1
- package/dist/admin/{PinnedBookmarksWidget-VM6buexr.js → PinnedBookmarksWidget-BLphsESy.js} +1 -1
- package/dist/admin/{PinnedBookmarksWidget-BWiAKlnA.mjs → PinnedBookmarksWidget-BY7dtb-J.mjs} +1 -1
- package/dist/admin/{de-Cn90CcnC.js → de-D9BJ4u7r.js} +6 -0
- package/dist/admin/{de-BF0nCjGF.mjs → de-DFgWtRSV.mjs} +6 -0
- package/dist/admin/{en-GDfO_EfL.js → en-BIMTC0Id.js} +6 -0
- package/dist/admin/{en-D-EGHodf.mjs → en-fhVztOaB.mjs} +6 -0
- package/dist/admin/{es-C33BufuB.mjs → es-BYIWE02H.mjs} +6 -0
- package/dist/admin/{es-6o-_RABX.js → es-YRbu_LzT.js} +6 -0
- package/dist/admin/{fr-DJHTjkmb.mjs → fr-7clZM722.mjs} +6 -0
- package/dist/admin/{fr-BOZS5mJT.js → fr-b0q34Kvn.js} +6 -0
- package/dist/admin/{index-C9FMo0F_.js → index-Db5jW3WB.js} +191 -100
- package/dist/admin/{index-BJ8l6K7P.mjs → index-DqJBO_JD.mjs} +193 -102
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/admin/{pt-yoB1jrsq.mjs → pt-Chy7Dok7.mjs} +6 -0
- package/dist/admin/{pt-D13SxuK2.js → pt-DkmTAK17.js} +6 -0
- package/package.json +6 -3
|
@@ -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
|
-
import { Modal, Flex, Loader, Alert, Button, Field, SingleSelect, SingleSelectOption, Box, TextButton, Grid, Combobox, ComboboxOption, IconButton, MultiSelect, MultiSelectOption, TextInput,
|
|
4
|
-
import {
|
|
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 { 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 : [],
|
|
@@ -280,6 +279,9 @@ const ADMIN_QUERY_DEPTH = 5;
|
|
|
280
279
|
const NO_VALUE_OPERATORS = ["$null", "$notNull"];
|
|
281
280
|
const LIST_OPERATORS = ["$in", "$notIn"];
|
|
282
281
|
const RANGE_OPERATORS = ["$between"];
|
|
282
|
+
const MAX_LIST_ITEMS = 100;
|
|
283
|
+
const MAX_ALL_CONDITIONS = 20;
|
|
284
|
+
const maxConditions = (match) => match === "all" ? MAX_ALL_CONDITIONS : MAX_LIST_ITEMS;
|
|
283
285
|
const BASE$1 = ["$eq", "$ne", "$null", "$notNull"];
|
|
284
286
|
const NUMERIC = ["$gt", "$gte", "$lt", "$lte"];
|
|
285
287
|
const SENSITIVE = ["$eqi", "$nei"];
|
|
@@ -342,6 +344,7 @@ const inputToDatetime = (value) => {
|
|
|
342
344
|
return Number.isNaN(date.getTime()) ? value : date.toISOString();
|
|
343
345
|
};
|
|
344
346
|
const splitList = (value) => value.split(",").map((item) => item.trim()).filter(Boolean);
|
|
347
|
+
const hasTooManyValues = (row) => LIST_OPERATORS.includes(row.operator) && splitList(row.value).length > MAX_LIST_ITEMS;
|
|
345
348
|
const validateRow = (row, fields) => {
|
|
346
349
|
const field = fields.get(row.field);
|
|
347
350
|
if (!field) return "field";
|
|
@@ -350,7 +353,10 @@ const validateRow = (row, fields) => {
|
|
|
350
353
|
}
|
|
351
354
|
if (NO_VALUE_OPERATORS.includes(row.operator)) return null;
|
|
352
355
|
if (field.type === "boolean") return BOOLEAN_VALUES.includes(row.value) ? null : "value";
|
|
353
|
-
if (LIST_OPERATORS.includes(row.operator))
|
|
356
|
+
if (LIST_OPERATORS.includes(row.operator)) {
|
|
357
|
+
const count = splitList(row.value).length;
|
|
358
|
+
return count && count <= MAX_LIST_ITEMS ? null : "value";
|
|
359
|
+
}
|
|
354
360
|
if (!row.value.trim()) return "value";
|
|
355
361
|
if (RANGE_OPERATORS.includes(row.operator) && !(row.valueTo ?? "").trim()) return "valueTo";
|
|
356
362
|
return null;
|
|
@@ -461,6 +467,31 @@ const countConditions = (filters) => {
|
|
|
461
467
|
}
|
|
462
468
|
return count;
|
|
463
469
|
};
|
|
470
|
+
const INDEX_KEY = /^\d+$/;
|
|
471
|
+
const listLength = (value) => {
|
|
472
|
+
if (Array.isArray(value)) return value.length;
|
|
473
|
+
if (!value || typeof value !== "object") return 0;
|
|
474
|
+
const keys = Object.keys(value);
|
|
475
|
+
return keys.length && keys.every((key) => INDEX_KEY.test(key)) ? Math.max(...keys.map(Number)) + 1 : 0;
|
|
476
|
+
};
|
|
477
|
+
const exceedsItemLimit = (value) => {
|
|
478
|
+
if (Array.isArray(value)) {
|
|
479
|
+
return value.length > MAX_LIST_ITEMS || value.some(exceedsItemLimit);
|
|
480
|
+
}
|
|
481
|
+
if (!value || typeof value !== "object") return false;
|
|
482
|
+
const keys = Object.keys(value);
|
|
483
|
+
if (keys.length && keys.every((key) => INDEX_KEY.test(key))) {
|
|
484
|
+
if (keys.some((key) => Number(key) >= MAX_LIST_ITEMS)) return true;
|
|
485
|
+
}
|
|
486
|
+
return Object.values(value).some(exceedsItemLimit);
|
|
487
|
+
};
|
|
488
|
+
const exceedsListLimit = (value) => {
|
|
489
|
+
const filters = value?.filters;
|
|
490
|
+
if (filters && typeof filters === "object") {
|
|
491
|
+
if (listLength(filters.$and) > MAX_ALL_CONDITIONS) return true;
|
|
492
|
+
}
|
|
493
|
+
return exceedsItemLimit(value);
|
|
494
|
+
};
|
|
464
495
|
const FOCUSABLE = [
|
|
465
496
|
"a[href]",
|
|
466
497
|
"button:not([disabled])",
|
|
@@ -536,7 +567,10 @@ const AdvancedFiltersModal = ({ open, onOpenChange, uid }) => {
|
|
|
536
567
|
const updateRow = (id, patch) => setRows((prev) => prev.map((row) => row.id === id ? { ...row, ...patch } : row));
|
|
537
568
|
const activeRows = rows.filter((row) => row.field || row.value);
|
|
538
569
|
const rowErrors = new Map(activeRows.map((row) => [row.id, validateRow(row, fieldMap)]));
|
|
539
|
-
const
|
|
570
|
+
const rowLimit = maxConditions(match);
|
|
571
|
+
const tooManyRows = activeRows.length > rowLimit;
|
|
572
|
+
const atRowLimit = rows.length >= rowLimit;
|
|
573
|
+
const hasErrors = tooManyRows || [...rowErrors.values()].some(Boolean);
|
|
540
574
|
const apply = () => {
|
|
541
575
|
setShowErrors(true);
|
|
542
576
|
if (hasErrors) return;
|
|
@@ -564,13 +598,22 @@ const AdvancedFiltersModal = ({ open, onOpenChange, uid }) => {
|
|
|
564
598
|
onOpenChange(false);
|
|
565
599
|
};
|
|
566
600
|
const errorText = (row, part) => {
|
|
601
|
+
if (part === "value" && hasTooManyValues(row)) {
|
|
602
|
+
return formatMessage(
|
|
603
|
+
msg(
|
|
604
|
+
"filters.errorTooManyValues",
|
|
605
|
+
"Enter at most {max} values. Strapi does not accept longer lists."
|
|
606
|
+
),
|
|
607
|
+
{ max: MAX_LIST_ITEMS }
|
|
608
|
+
);
|
|
609
|
+
}
|
|
567
610
|
if (!showErrors || rowErrors.get(row.id) !== part) return void 0;
|
|
568
611
|
if (part === "field") return formatMessage(msg("filters.errorField", "Choose a field."));
|
|
569
612
|
if (part === "operator")
|
|
570
613
|
return formatMessage(msg("filters.errorOperator", "Choose a condition."));
|
|
571
614
|
return formatMessage(msg("filters.errorValue", "Enter a value."));
|
|
572
615
|
};
|
|
573
|
-
return /* @__PURE__ */ jsx(Modal.Root, { open, onOpenChange, children: /* @__PURE__ */ jsxs(Modal.Content, { onKeyDown: keepFocusInside, children: [
|
|
616
|
+
return /* @__PURE__ */ jsx(Modal.Root, { open, onOpenChange, children: /* @__PURE__ */ jsxs(Modal.Content, { onKeyDown: keepFocusInside, "aria-describedby": void 0, children: [
|
|
574
617
|
/* @__PURE__ */ jsx(Modal.Header, { closeLabel: formatMessage(msg("form.close", "Close")), children: /* @__PURE__ */ jsx(Modal.Title, { children: formatMessage(msg("filters.title", "Advanced filters")) }) }),
|
|
575
618
|
/* @__PURE__ */ jsx(Modal.Body, { children: isLoading ? /* @__PURE__ */ jsx(Flex, { justifyContent: "center", padding: 6, children: /* @__PURE__ */ jsx(Loader, { small: true, children: formatMessage(msg("state.loading", "Loading")) }) }) : error ? /* @__PURE__ */ jsx(
|
|
576
619
|
Alert,
|
|
@@ -650,15 +693,44 @@ const AdvancedFiltersModal = ({ open, onOpenChange, uid }) => {
|
|
|
650
693
|
) }, row.id))
|
|
651
694
|
}
|
|
652
695
|
),
|
|
653
|
-
/* @__PURE__ */
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
696
|
+
/* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "flex-start", gap: 2, children: [
|
|
697
|
+
/* @__PURE__ */ jsx(
|
|
698
|
+
TextButton,
|
|
699
|
+
{
|
|
700
|
+
startIcon: /* @__PURE__ */ jsx(Plus, {}),
|
|
701
|
+
...TEXT_BUTTON_TARGET,
|
|
702
|
+
disabled: atRowLimit,
|
|
703
|
+
"aria-describedby": atRowLimit ? "magic-mark-filters-row-limit" : void 0,
|
|
704
|
+
onClick: () => setRows((prev) => [...prev, emptyRow()]),
|
|
705
|
+
children: formatMessage(msg("filters.add", "Add condition"))
|
|
706
|
+
}
|
|
707
|
+
),
|
|
708
|
+
atRowLimit ? /* @__PURE__ */ jsx(
|
|
709
|
+
Typography,
|
|
710
|
+
{
|
|
711
|
+
id: "magic-mark-filters-row-limit",
|
|
712
|
+
variant: "pi",
|
|
713
|
+
textColor: tooManyRows ? "danger600" : "neutral600",
|
|
714
|
+
role: tooManyRows ? "alert" : void 0,
|
|
715
|
+
children: formatMessage(
|
|
716
|
+
match === "all" ? tooManyRows ? msg(
|
|
717
|
+
"filters.errorTooManyConditionsAll",
|
|
718
|
+
"With All conditions, keep at most {max} conditions: the Content Manager list does not open with more. Remove conditions or choose Any condition."
|
|
719
|
+
) : msg(
|
|
720
|
+
"filters.maxConditionsAll",
|
|
721
|
+
"With All conditions, a filter can have at most {max} conditions. The Content Manager list does not open with more."
|
|
722
|
+
) : tooManyRows ? msg(
|
|
723
|
+
"filters.errorTooManyConditions",
|
|
724
|
+
"Remove conditions until at most {max} are left. Strapi does not accept more."
|
|
725
|
+
) : msg(
|
|
726
|
+
"filters.maxConditions",
|
|
727
|
+
"A filter can have at most {max} conditions, the most Strapi accepts."
|
|
728
|
+
),
|
|
729
|
+
{ max: rowLimit }
|
|
730
|
+
)
|
|
731
|
+
}
|
|
732
|
+
) : null
|
|
733
|
+
] })
|
|
662
734
|
] }) }),
|
|
663
735
|
/* @__PURE__ */ jsxs(Modal.Footer, { children: [
|
|
664
736
|
/* @__PURE__ */ jsx(Button, { variant: "danger-light", onClick: clearAll, disabled: !query.filters, children: formatMessage(msg("filters.clear", "Clear all")) }),
|
|
@@ -971,7 +1043,6 @@ const normalizeSavedQuery = (query, init, uid) => {
|
|
|
971
1043
|
};
|
|
972
1044
|
const useOpenBookmark = () => {
|
|
973
1045
|
const navigate = useNavigate();
|
|
974
|
-
const { get } = useFetchClient();
|
|
975
1046
|
const { toggleNotification } = useNotification();
|
|
976
1047
|
const { formatMessage } = useIntl();
|
|
977
1048
|
return useCallback(
|
|
@@ -987,9 +1058,22 @@ const useOpenBookmark = () => {
|
|
|
987
1058
|
return;
|
|
988
1059
|
}
|
|
989
1060
|
const parsed = parseQuery(bookmark.query);
|
|
1061
|
+
if (exceedsListLimit(parsed)) {
|
|
1062
|
+
toggleNotification({
|
|
1063
|
+
type: "warning",
|
|
1064
|
+
timeout: 15e3,
|
|
1065
|
+
message: formatMessage(
|
|
1066
|
+
msg(
|
|
1067
|
+
"notification.listTooLong",
|
|
1068
|
+
"This bookmark was not opened: its filters have more values or conditions than Strapi accepts. Open the list, narrow the filters, then save the current view in this bookmark."
|
|
1069
|
+
)
|
|
1070
|
+
)
|
|
1071
|
+
});
|
|
1072
|
+
return;
|
|
1073
|
+
}
|
|
990
1074
|
let saved = parsed;
|
|
991
1075
|
try {
|
|
992
|
-
saved = normalizeSavedQuery(parsed, await loadInit(
|
|
1076
|
+
saved = normalizeSavedQuery(parsed, await loadInit(), location.uid);
|
|
993
1077
|
} catch {
|
|
994
1078
|
}
|
|
995
1079
|
const search = saved === parsed ? bookmark.query ?? "" : stringifyQuery(saved);
|
|
@@ -999,7 +1083,7 @@ const useOpenBookmark = () => {
|
|
|
999
1083
|
}
|
|
1000
1084
|
navigate({ pathname: location.path, search: search ? `?${search}` : "" });
|
|
1001
1085
|
},
|
|
1002
|
-
[
|
|
1086
|
+
[navigate, toggleNotification, formatMessage]
|
|
1003
1087
|
);
|
|
1004
1088
|
};
|
|
1005
1089
|
const errorBody = (error) => error?.response?.data?.error;
|
|
@@ -1412,83 +1496,90 @@ const BookmarkFormModal = ({
|
|
|
1412
1496
|
const contentType = view?.contentType ?? loaded?.contentType ?? null;
|
|
1413
1497
|
const query = view?.query ?? loaded?.query ?? "";
|
|
1414
1498
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1415
|
-
/* @__PURE__ */ jsx(Modal.Root, { open, onOpenChange: handleOpenChange, children: /* @__PURE__ */ jsxs(
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
"
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
onChange: (event) => setName(event.target.value),
|
|
1445
|
-
placeholder: formatMessage(
|
|
1446
|
-
msg("form.namePlaceholder", "e.g. Drafts waiting for review")
|
|
1447
|
-
)
|
|
1448
|
-
}
|
|
1449
|
-
),
|
|
1450
|
-
/* @__PURE__ */ jsx(Field.Error, {})
|
|
1451
|
-
] }),
|
|
1452
|
-
/* @__PURE__ */ jsxs(
|
|
1453
|
-
Field.Root,
|
|
1454
|
-
{
|
|
1455
|
-
name: "description",
|
|
1456
|
-
error: errors.description,
|
|
1457
|
-
hint: formatMessage(
|
|
1458
|
-
msg("form.descriptionHint", "Optional. Shown below the name.")
|
|
1459
|
-
),
|
|
1460
|
-
children: [
|
|
1461
|
-
/* @__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")) }),
|
|
1462
1528
|
/* @__PURE__ */ jsx(
|
|
1463
|
-
|
|
1529
|
+
TextInput,
|
|
1464
1530
|
{
|
|
1465
|
-
value:
|
|
1466
|
-
|
|
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
|
+
)
|
|
1467
1537
|
}
|
|
1468
1538
|
),
|
|
1469
|
-
/* @__PURE__ */ jsx(Field.Hint, {}),
|
|
1470
1539
|
/* @__PURE__ */ jsx(Field.Error, {})
|
|
1471
|
-
]
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
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
|
+
) }),
|
|
1492
1583
|
/* @__PURE__ */ jsx(Dialog.Root, { open: confirmDiscard, onOpenChange: setConfirmDiscard, children: /* @__PURE__ */ jsx(
|
|
1493
1584
|
ConfirmDialog,
|
|
1494
1585
|
{
|
|
@@ -1795,7 +1886,7 @@ const index = {
|
|
|
1795
1886
|
to: `plugins/${pluginId}`,
|
|
1796
1887
|
icon: PluginIcon,
|
|
1797
1888
|
intlLabel: { id: `${pluginId}.plugin.name`, defaultMessage: "Magic Mark" },
|
|
1798
|
-
Component: () => import("./App-
|
|
1889
|
+
Component: () => import("./App-BzKXIPZe.mjs"),
|
|
1799
1890
|
permissions: PERMISSIONS.read
|
|
1800
1891
|
});
|
|
1801
1892
|
app.registerPlugin({ id: pluginId, name: "Magic Mark" });
|
|
@@ -1810,7 +1901,7 @@ const index = {
|
|
|
1810
1901
|
label: { id: `${pluginId}.widget.link`, defaultMessage: "Manage bookmarks" },
|
|
1811
1902
|
href: `/plugins/${pluginId}`
|
|
1812
1903
|
},
|
|
1813
|
-
component: async () => (await import("./PinnedBookmarksWidget-
|
|
1904
|
+
component: async () => (await import("./PinnedBookmarksWidget-BY7dtb-J.mjs")).default,
|
|
1814
1905
|
permissions: PERMISSIONS.read
|
|
1815
1906
|
});
|
|
1816
1907
|
}
|
|
@@ -1826,7 +1917,7 @@ const index = {
|
|
|
1826
1917
|
return Promise.all(
|
|
1827
1918
|
locales.map(async (locale) => {
|
|
1828
1919
|
try {
|
|
1829
|
-
const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/de.json": () => import("./de-
|
|
1920
|
+
const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/de.json": () => import("./de-DFgWtRSV.mjs"), "./translations/en.json": () => import("./en-fhVztOaB.mjs"), "./translations/es.json": () => import("./es-BYIWE02H.mjs"), "./translations/fr.json": () => import("./fr-7clZM722.mjs"), "./translations/pt.json": () => import("./pt-Chy7Dok7.mjs") }), `./translations/${locale}.json`, 3);
|
|
1830
1921
|
return {
|
|
1831
1922
|
data: Object.fromEntries(
|
|
1832
1923
|
Object.entries(data).map(([key, value]) => [
|
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
|
@@ -18,6 +18,9 @@ const pt = {
|
|
|
18
18
|
"filters.conditions": "Condições",
|
|
19
19
|
"filters.errorField": "Escolha um campo.",
|
|
20
20
|
"filters.errorOperator": "Escolha uma condição.",
|
|
21
|
+
"filters.errorTooManyConditions": "Remova condições até restarem no máximo {max}. O Strapi não aceita mais.",
|
|
22
|
+
"filters.errorTooManyConditionsAll": 'Com "Todas as condições", use no máximo {max} condições: a lista do Content Manager não abre com mais. Remova condições ou escolha "Qualquer condição".',
|
|
23
|
+
"filters.errorTooManyValues": "Insira no máximo {max} valores. O Strapi não aceita listas mais longas.",
|
|
21
24
|
"filters.errorValue": "Informe um valor.",
|
|
22
25
|
"filters.false": "falso",
|
|
23
26
|
"filters.field": "Campo",
|
|
@@ -30,6 +33,8 @@ const pt = {
|
|
|
30
33
|
"filters.matchAll": "Todas as condições",
|
|
31
34
|
"filters.matchAny": "Qualquer condição",
|
|
32
35
|
"filters.matchAnyHint": "Estas condições não aparecem como etiquetas de filtro acima da lista.",
|
|
36
|
+
"filters.maxConditions": "Um filtro pode ter no máximo {max} condições, o máximo que o Strapi aceita.",
|
|
37
|
+
"filters.maxConditionsAll": 'Com "Todas as condições", um filtro pode ter no máximo {max} condições. A lista do Content Manager não abre com mais.',
|
|
33
38
|
"filters.noFields": "Nenhum campo correspondente",
|
|
34
39
|
"filters.operator": "Condição",
|
|
35
40
|
"filters.remove": "Remover a condição {number}",
|
|
@@ -106,6 +111,7 @@ const pt = {
|
|
|
106
111
|
"notification.invalidPath": "Este favorito não aponta para uma visualização de lista.",
|
|
107
112
|
"notification.linkCopied": "Link copiado.",
|
|
108
113
|
"notification.linkCopyError": "Não foi possível copiar o link.",
|
|
114
|
+
"notification.listTooLong": "Este favorito não foi aberto: os filtros têm mais valores ou condições do que o Strapi aceita. Abra a lista, restrinja os filtros e salve a visualização atual neste favorito.",
|
|
109
115
|
"notification.pinError": "Não foi possível fixar o favorito.",
|
|
110
116
|
"notification.pinned": "Favorito fixado.",
|
|
111
117
|
"notification.saveError": "Não foi possível salvar o favorito. Suas alterações continuam no formulário.",
|
|
@@ -20,6 +20,9 @@ const pt = {
|
|
|
20
20
|
"filters.conditions": "Condições",
|
|
21
21
|
"filters.errorField": "Escolha um campo.",
|
|
22
22
|
"filters.errorOperator": "Escolha uma condição.",
|
|
23
|
+
"filters.errorTooManyConditions": "Remova condições até restarem no máximo {max}. O Strapi não aceita mais.",
|
|
24
|
+
"filters.errorTooManyConditionsAll": 'Com "Todas as condições", use no máximo {max} condições: a lista do Content Manager não abre com mais. Remova condições ou escolha "Qualquer condição".',
|
|
25
|
+
"filters.errorTooManyValues": "Insira no máximo {max} valores. O Strapi não aceita listas mais longas.",
|
|
23
26
|
"filters.errorValue": "Informe um valor.",
|
|
24
27
|
"filters.false": "falso",
|
|
25
28
|
"filters.field": "Campo",
|
|
@@ -32,6 +35,8 @@ const pt = {
|
|
|
32
35
|
"filters.matchAll": "Todas as condições",
|
|
33
36
|
"filters.matchAny": "Qualquer condição",
|
|
34
37
|
"filters.matchAnyHint": "Estas condições não aparecem como etiquetas de filtro acima da lista.",
|
|
38
|
+
"filters.maxConditions": "Um filtro pode ter no máximo {max} condições, o máximo que o Strapi aceita.",
|
|
39
|
+
"filters.maxConditionsAll": 'Com "Todas as condições", um filtro pode ter no máximo {max} condições. A lista do Content Manager não abre com mais.',
|
|
35
40
|
"filters.noFields": "Nenhum campo correspondente",
|
|
36
41
|
"filters.operator": "Condição",
|
|
37
42
|
"filters.remove": "Remover a condição {number}",
|
|
@@ -108,6 +113,7 @@ const pt = {
|
|
|
108
113
|
"notification.invalidPath": "Este favorito não aponta para uma visualização de lista.",
|
|
109
114
|
"notification.linkCopied": "Link copiado.",
|
|
110
115
|
"notification.linkCopyError": "Não foi possível copiar o link.",
|
|
116
|
+
"notification.listTooLong": "Este favorito não foi aberto: os filtros têm mais valores ou condições do que o Strapi aceita. Abra a lista, restrinja os filtros e salve a visualização atual neste favorito.",
|
|
111
117
|
"notification.pinError": "Não foi possível fixar o favorito.",
|
|
112
118
|
"notification.pinned": "Favorito fixado.",
|
|
113
119
|
"notification.saveError": "Não foi possível salvar o favorito. Suas alterações continuam no formulário.",
|
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 .",
|
|
@@ -81,15 +82,17 @@
|
|
|
81
82
|
"@strapi/design-system": "^2.3.1",
|
|
82
83
|
"@strapi/icons": "^2.3.1",
|
|
83
84
|
"@strapi/sdk-plugin": "^6.1.1",
|
|
84
|
-
"@strapi/strapi": "^5.
|
|
85
|
-
"@strapi/typescript-utils": "^5.
|
|
85
|
+
"@strapi/strapi": "^5.63.0",
|
|
86
|
+
"@strapi/typescript-utils": "^5.63.0",
|
|
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",
|