strapi-plugin-magic-mark 3.3.2 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/CHANGELOG.md +366 -0
  2. package/README.md +390 -619
  3. package/dist/admin/App-C9PsvW9C.mjs +580 -0
  4. package/dist/admin/App-KJvUCwN1.js +580 -0
  5. package/dist/admin/PinnedBookmarksWidget-ClskVR1i.mjs +55 -0
  6. package/dist/admin/PinnedBookmarksWidget-DlD8lDhq.js +55 -0
  7. package/dist/admin/de-BF0nCjGF.mjs +183 -0
  8. package/dist/admin/de-Cn90CcnC.js +183 -0
  9. package/dist/admin/en-D-EGHodf.mjs +183 -0
  10. package/dist/admin/en-GDfO_EfL.js +183 -0
  11. package/dist/admin/es-6o-_RABX.js +183 -0
  12. package/dist/admin/es-C33BufuB.mjs +183 -0
  13. package/dist/admin/fr-BOZS5mJT.js +183 -0
  14. package/dist/admin/fr-DJHTjkmb.mjs +183 -0
  15. package/dist/admin/index-CLjQOzqv.js +1770 -0
  16. package/dist/admin/index-X8I03cOT.mjs +1769 -0
  17. package/dist/admin/index.js +4 -2
  18. package/dist/admin/index.mjs +2 -1
  19. package/dist/admin/pt-D13SxuK2.js +183 -0
  20. package/dist/admin/pt-yoB1jrsq.mjs +183 -0
  21. package/dist/server/index.js +1129 -1542
  22. package/dist/server/index.mjs +1126 -1539
  23. package/package.json +90 -54
  24. package/strapi-admin.js +5 -0
  25. package/strapi-server.js +2 -1
  26. package/COPYRIGHT_NOTICE.txt +0 -20
  27. package/dist/_chunks/App-CozIqdTt.mjs +0 -1509
  28. package/dist/_chunks/App-DFDDcq8K.js +0 -1511
  29. package/dist/_chunks/UpgradePage-9godO_5E.mjs +0 -351
  30. package/dist/_chunks/UpgradePage-CwYDN8bT.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-DCsuhvUc.js +0 -2698
  40. package/dist/_chunks/index-DNoxLWi0.mjs +0 -2694
  41. package/dist/_chunks/index-JirQF8zE.mjs +0 -328
  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
@@ -1,1511 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const jsxRuntime = require("react/jsx-runtime");
4
- const React = require("react");
5
- const reactIntl = require("react-intl");
6
- const reactRouterDom = require("react-router-dom");
7
- const styled = require("styled-components");
8
- const designSystem = require("@strapi/design-system");
9
- const icons = require("@strapi/icons");
10
- const outline = require("@heroicons/react/24/outline");
11
- const admin = require("@strapi/strapi/admin");
12
- const index = require("./index-DCsuhvUc.js");
13
- const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
14
- const styled__default = /* @__PURE__ */ _interopDefault(styled);
15
- const FEATURES = {
16
- // Free tier features
17
- basicBookmarks: { tier: "free", limit: 10 },
18
- basicFilters: { tier: "free" },
19
- // Premium tier features
20
- extendedBookmarks: { tier: "premium", limit: 50 },
21
- queryHistory: { tier: "premium" },
22
- exportBookmarks: { tier: "premium" },
23
- sharedBookmarks: { tier: "premium" },
24
- // Advanced tier features
25
- unlimitedBookmarks: { tier: "advanced", limit: -1 },
26
- advancedFilters: { tier: "advanced" },
27
- subGroups: { tier: "advanced" },
28
- bulkOperations: { tier: "advanced" },
29
- analytics: { tier: "advanced" },
30
- customIntegrations: { tier: "advanced" }
31
- };
32
- const useLicenseInfo = () => {
33
- const { get } = admin.useFetchClient();
34
- const [limits, setLimits] = React.useState(null);
35
- const [isLoading, setIsLoading] = React.useState(true);
36
- React.useEffect(() => {
37
- const fetchLimits = async () => {
38
- try {
39
- console.log("[useLicenseInfo] Fetching license limits...");
40
- const response = await get("/magic-mark/license/limits");
41
- console.log("[useLicenseInfo] Raw API response:", response);
42
- console.log("[useLicenseInfo] Response data:", response.data);
43
- if (response.data?.success) {
44
- console.log("[useLicenseInfo] Setting limits:", response.data.data);
45
- setLimits(response.data.data);
46
- } else {
47
- console.warn("[useLicenseInfo] API returned success=false or missing data");
48
- }
49
- } catch (error) {
50
- console.error("[useLicenseInfo] Error fetching license limits:", error);
51
- } finally {
52
- setIsLoading(false);
53
- }
54
- };
55
- fetchLimits();
56
- }, []);
57
- const tier = limits?.tier || "free";
58
- const isPremium = tier === "premium" || tier === "advanced";
59
- const isAdvanced = tier === "advanced";
60
- console.log("[useLicenseInfo] Computed values:", { tier, isPremium, isAdvanced, limits });
61
- return {
62
- isLoading,
63
- limits,
64
- tier,
65
- isFree: tier === "free",
66
- isPremium,
67
- isAdvanced,
68
- canUseFeature: (feature) => {
69
- const featureConfig = FEATURES[feature];
70
- const tierOrder = { free: 0, premium: 1, advanced: 2 };
71
- return tierOrder[tier] >= tierOrder[featureConfig.tier];
72
- }
73
- };
74
- };
75
- const theme = {
76
- colors: {
77
- primary: {
78
- 50: "#F0F9FF",
79
- 100: "#E0F2FE",
80
- 500: "#0EA5E9",
81
- 600: "#0284C7",
82
- 700: "#0369A1"
83
- },
84
- secondary: {
85
- 600: "#9333EA"
86
- },
87
- success: {
88
- 100: "#DCFCE7",
89
- 500: "#22C55E",
90
- 600: "#16A34A"
91
- },
92
- warning: {
93
- 100: "#FEF3C7",
94
- 500: "#F59E0B",
95
- 600: "#D97706"
96
- },
97
- danger: {
98
- 100: "#FEE2E2",
99
- 500: "#EF4444",
100
- 600: "#DC2626"
101
- },
102
- neutral: {
103
- 0: "#FFFFFF",
104
- 100: "#F3F4F6",
105
- 600: "#4B5563"
106
- }
107
- },
108
- shadows: {
109
- sm: "0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1)",
110
- xl: "0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1)"
111
- },
112
- transitions: {
113
- fast: "150ms cubic-bezier(0.4, 0, 0.2, 1)",
114
- normal: "300ms cubic-bezier(0.4, 0, 0.2, 1)",
115
- slow: "500ms cubic-bezier(0.4, 0, 0.2, 1)"
116
- },
117
- spacing: {
118
- xs: "4px",
119
- sm: "8px",
120
- md: "16px",
121
- lg: "24px",
122
- xl: "32px",
123
- "2xl": "48px"
124
- },
125
- borderRadius: {
126
- md: "8px",
127
- lg: "12px",
128
- xl: "16px"
129
- }
130
- };
131
- const fadeIn$1 = styled.keyframes`
132
- from { opacity: 0; transform: translateY(10px); }
133
- to { opacity: 1; transform: translateY(0); }
134
- `;
135
- styled.keyframes`
136
- from { opacity: 0; transform: translateX(-10px); }
137
- to { opacity: 1; transform: translateX(0); }
138
- `;
139
- const shimmer = styled.keyframes`
140
- 0% { background-position: -200% 0; }
141
- 100% { background-position: 200% 0; }
142
- `;
143
- const float = styled.keyframes`
144
- 0%, 100% { transform: translateY(0px); }
145
- 50% { transform: translateY(-5px); }
146
- `;
147
- const breakpoints = {
148
- mobile: "768px"
149
- };
150
- const Container = styled__default.default(designSystem.Box)`
151
- animation: ${fadeIn$1} ${theme.transitions.slow};
152
- min-height: 100vh;
153
- max-width: 1440px;
154
- margin: 0 auto;
155
- padding: ${theme.spacing.xl} ${theme.spacing.lg} 0;
156
-
157
- @media screen and (max-width: ${breakpoints.mobile}) {
158
- padding: ${theme.spacing.md} ${theme.spacing.sm} 0;
159
- }
160
- `;
161
- const Header = styled__default.default(designSystem.Box)`
162
- background: linear-gradient(135deg,
163
- ${theme.colors.primary[600]} 0%,
164
- ${theme.colors.secondary[600]} 100%
165
- );
166
- border-radius: ${theme.borderRadius.xl};
167
- padding: ${theme.spacing.xl} ${theme.spacing["2xl"]};
168
- margin-bottom: ${theme.spacing.xl};
169
- position: relative;
170
- overflow: hidden;
171
- box-shadow: ${theme.shadows.xl};
172
-
173
- @media screen and (max-width: ${breakpoints.mobile}) {
174
- padding: ${theme.spacing.lg} ${theme.spacing.md} !important;
175
- border-radius: ${theme.borderRadius.lg} !important;
176
- }
177
-
178
- &::before {
179
- content: '';
180
- position: absolute;
181
- top: 0;
182
- left: -100%;
183
- width: 200%;
184
- height: 100%;
185
- background: linear-gradient(
186
- 90deg,
187
- transparent,
188
- rgba(255, 255, 255, 0.1),
189
- transparent
190
- );
191
- animation: ${shimmer} 3s infinite;
192
- }
193
-
194
- &::after {
195
- content: '';
196
- position: absolute;
197
- top: 0;
198
- right: 0;
199
- width: 100%;
200
- height: 100%;
201
- background-image: radial-gradient(circle at 20% 80%, transparent 50%, rgba(255, 255, 255, 0.1) 50%);
202
- background-size: 15px 15px;
203
- opacity: 0.3;
204
- }
205
- `;
206
- const HeaderContent = styled__default.default(designSystem.Flex)`
207
- position: relative;
208
- z-index: 1;
209
- `;
210
- const Title = styled__default.default(designSystem.Typography)`
211
- color: ${theme.colors.neutral[0]};
212
- font-size: 2rem;
213
- font-weight: 700;
214
- letter-spacing: -0.025em;
215
- text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
216
- display: flex;
217
- align-items: center;
218
- gap: ${theme.spacing.sm};
219
-
220
- svg {
221
- width: 28px;
222
- height: 28px;
223
- animation: ${float} 3s ease-in-out infinite;
224
- }
225
- `;
226
- const Subtitle = styled__default.default(designSystem.Typography)`
227
- color: rgba(255, 255, 255, 0.9);
228
- font-size: 0.95rem;
229
- font-weight: 400;
230
- margin-top: ${theme.spacing.xs};
231
- letter-spacing: 0.01em;
232
- `;
233
- const StatsGrid = styled__default.default.div`
234
- margin-bottom: ${theme.spacing.xl};
235
- display: grid;
236
- grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
237
- gap: ${theme.spacing.md};
238
- justify-content: center;
239
- max-width: 1200px;
240
- margin-left: auto;
241
- margin-right: auto;
242
-
243
- @media screen and (max-width: ${breakpoints.mobile}) {
244
- grid-template-columns: repeat(2, 1fr) !important;
245
- gap: 12px !important;
246
- margin-bottom: 24px !important;
247
- }
248
- `;
249
- const StatCard = styled__default.default(designSystem.Box)`
250
- background: ${(p) => p.theme.colors.neutral0};
251
- border-radius: ${theme.borderRadius.lg};
252
- padding: ${theme.spacing.lg};
253
- position: relative;
254
- overflow: hidden;
255
- transition: all ${theme.transitions.normal};
256
- animation: ${fadeIn$1} ${theme.transitions.slow} backwards;
257
- animation-delay: ${(props) => props.$delay || "0s"};
258
- box-shadow: ${theme.shadows.sm};
259
- border: 1px solid rgba(128, 128, 128, 0.2);
260
- min-width: 200px;
261
- flex: 1;
262
- text-align: center;
263
- display: flex;
264
- flex-direction: column;
265
- align-items: center;
266
- justify-content: center;
267
-
268
- &:hover {
269
- transform: translateY(-4px);
270
- box-shadow: ${theme.shadows.xl};
271
- border-color: ${(props) => props.$color || theme.colors.primary[500]};
272
-
273
- .stat-icon {
274
- transform: scale(1.1);
275
- }
276
-
277
- .stat-value {
278
- transform: scale(1.05);
279
- }
280
- }
281
-
282
- @media screen and (max-width: ${breakpoints.mobile}) {
283
- min-width: unset !important;
284
- padding: ${theme.spacing.md} !important;
285
-
286
- &:hover {
287
- transform: none !important;
288
- }
289
- }
290
- `;
291
- const StatIcon = styled__default.default(designSystem.Box)`
292
- width: 64px;
293
- height: 64px;
294
- border-radius: ${theme.borderRadius.md};
295
- display: flex;
296
- align-items: center;
297
- justify-content: center;
298
- background: ${(props) => props.$bg || theme.colors.primary[100]};
299
- transition: all ${theme.transitions.normal};
300
- margin-bottom: ${theme.spacing.md};
301
-
302
- svg {
303
- width: 32px;
304
- height: 32px;
305
- color: ${(props) => props.$color || theme.colors.primary[600]};
306
- }
307
- `;
308
- const StatValue = styled__default.default(designSystem.Typography)`
309
- font-size: 2.5rem;
310
- font-weight: 700;
311
- color: ${(p) => p.theme.colors.neutral800};
312
- line-height: 1;
313
- margin-bottom: ${theme.spacing.xs};
314
- transition: transform ${theme.transitions.normal};
315
- `;
316
- const StatLabel = styled__default.default(designSystem.Typography)`
317
- font-size: 0.875rem;
318
- color: ${(p) => p.theme.colors.neutral600};
319
- font-weight: 500;
320
- letter-spacing: 0.025em;
321
- text-transform: capitalize;
322
- `;
323
- const DataTable = styled__default.default(designSystem.Box)`
324
- background: ${(p) => p.theme.colors.neutral0};
325
- border-radius: ${theme.borderRadius.lg};
326
- overflow: hidden;
327
- box-shadow: ${theme.shadows.sm};
328
- border: 1px solid rgba(128, 128, 128, 0.2);
329
- margin-bottom: ${theme.spacing.xl};
330
- `;
331
- const StyledTable = styled__default.default(designSystem.Table)`
332
- thead {
333
- background: ${(p) => p.theme.colors.neutral0};
334
- border-bottom: 2px solid rgba(128, 128, 128, 0.15);
335
-
336
- th {
337
- font-weight: 600;
338
- color: ${(p) => p.theme.colors.neutral700};
339
- font-size: 0.875rem;
340
- text-transform: uppercase;
341
- letter-spacing: 0.025em;
342
- padding: ${theme.spacing.lg} ${theme.spacing.lg};
343
- }
344
- }
345
-
346
- tbody tr {
347
- transition: all ${theme.transitions.fast};
348
- border-bottom: 1px solid rgba(128, 128, 128, 0.1);
349
-
350
- &:last-child {
351
- border-bottom: none;
352
- }
353
-
354
- &:hover {
355
- background: ${(p) => p.theme.colors.neutral100};
356
-
357
- .action-buttons {
358
- opacity: 1;
359
- }
360
- }
361
-
362
- td {
363
- padding: ${theme.spacing.lg} ${theme.spacing.lg};
364
- color: ${(p) => p.theme.colors.neutral700};
365
- vertical-align: middle;
366
- }
367
- }
368
- `;
369
- styled__default.default(designSystem.Box)`
370
- width: 4px;
371
- height: 40px;
372
- background: ${(props) => props.$isPinned ? theme.colors.warning[500] : "transparent"};
373
- border-radius: 2px;
374
- transition: all ${theme.transitions.normal};
375
- `;
376
- const BookmarkIconWrapper = styled__default.default.div`
377
- display: flex;
378
- align-items: center;
379
- justify-content: center;
380
- width: 40px;
381
- height: 40px;
382
- background: linear-gradient(135deg, ${theme.colors.primary[100]} 0%, #E0E7FF 100%);
383
- border-radius: 8px;
384
- flex-shrink: 0;
385
-
386
- svg {
387
- width: 20px;
388
- height: 20px;
389
- color: ${theme.colors.primary[600]};
390
- }
391
- `;
392
- const ActionButtons = styled__default.default(designSystem.Flex)`
393
- opacity: 1;
394
- transition: all ${theme.transitions.fast};
395
- gap: ${theme.spacing.xs};
396
- justify-content: flex-end;
397
- `;
398
- const FloatingIcon = styled__default.default.div`
399
- position: absolute;
400
- bottom: 40px;
401
- right: 40px;
402
- opacity: 0.08;
403
- animation: ${float} 4s ease-in-out infinite;
404
-
405
- svg {
406
- width: 72px;
407
- height: 72px;
408
- color: ${theme.colors.warning[500]};
409
- }
410
- `;
411
- const FilterBar = styled__default.default(designSystem.Flex)`
412
- background: ${(p) => p.theme.colors.neutral0};
413
- padding: ${theme.spacing.md} ${theme.spacing.lg};
414
- border-radius: ${theme.borderRadius.lg};
415
- margin-bottom: ${theme.spacing.lg};
416
- box-shadow: ${theme.shadows.sm};
417
- border: 1px solid rgba(128, 128, 128, 0.2);
418
- gap: ${theme.spacing.md};
419
- align-items: center;
420
- `;
421
- const FilterSelect = styled__default.default(designSystem.Box)`
422
- min-width: 120px;
423
- `;
424
- const SearchInputWrapper = styled__default.default.div`
425
- position: relative;
426
- width: 100%;
427
- display: flex;
428
- align-items: center;
429
- `;
430
- const SearchIconStyled = styled__default.default(outline.MagnifyingGlassIcon)`
431
- position: absolute;
432
- left: 12px;
433
- width: 16px;
434
- height: 16px;
435
- color: ${(p) => p.theme.colors.neutral600};
436
- pointer-events: none;
437
- `;
438
- const StyledSearchInput = styled__default.default.input`
439
- width: 100%;
440
- padding: ${theme.spacing.sm} ${theme.spacing.sm} ${theme.spacing.sm} 36px;
441
- border: 1px solid rgba(128, 128, 128, 0.2);
442
- border-radius: ${theme.borderRadius.md};
443
- font-size: 0.875rem;
444
- transition: all ${theme.transitions.fast};
445
- background: ${(p) => p.theme.colors.neutral0};
446
- color: ${(p) => p.theme.colors.neutral800};
447
-
448
- &:focus {
449
- outline: none;
450
- border-color: ${theme.colors.primary[500]};
451
- box-shadow: 0 0 0 3px ${theme.colors.primary[100]};
452
- }
453
-
454
- &::placeholder {
455
- color: ${(p) => p.theme.colors.neutral600};
456
- }
457
- `;
458
- const HomePageModern = () => {
459
- const { formatMessage } = reactIntl.useIntl();
460
- const navigate = reactRouterDom.useNavigate();
461
- const { get, post, del } = admin.useFetchClient();
462
- useLicenseInfo();
463
- const [currentUser, setCurrentUser] = React.useState(null);
464
- const [bookmarks, setBookmarks] = React.useState([]);
465
- const [loading, setLoading] = React.useState(false);
466
- const [showModal, setShowModal] = React.useState(false);
467
- const [editingBookmark, setEditingBookmark] = React.useState(null);
468
- const [searchQuery, setSearchQuery] = React.useState("");
469
- const [filterType, setFilterType] = React.useState("all");
470
- const [entriesPerPage, setEntriesPerPage] = React.useState("10");
471
- const [availableRoles, setAvailableRoles] = React.useState([]);
472
- const [availableUsers, setAvailableUsers] = React.useState([]);
473
- const [licenseLimits, setLicenseLimits] = React.useState({
474
- maxBookmarks: 10,
475
- currentBookmarks: 0,
476
- canCreate: true,
477
- tier: "free",
478
- features: {}
479
- });
480
- React.useEffect(() => {
481
- fetchBookmarks();
482
- fetchCurrentUser();
483
- fetchRoles();
484
- fetchUsers();
485
- fetchLicenseLimits();
486
- }, []);
487
- const fetchRoles = async () => {
488
- try {
489
- const response = await get(`/${index.pluginId}/roles`);
490
- const roles = response.data?.data?.data || response.data?.data || [];
491
- console.log("[Magic-Mark] Available roles in HomePage:", roles);
492
- setAvailableRoles(roles);
493
- } catch (error) {
494
- console.error("[Magic-Mark] Error fetching roles:", error);
495
- }
496
- };
497
- const fetchUsers = async () => {
498
- try {
499
- const response = await get("/admin/users?pageSize=100&page=1&sort=firstname");
500
- console.log("[Magic-Mark] Admin users API response:", response);
501
- const allUsers = response.data?.data?.results || response.data?.results || [];
502
- console.log("[Magic-Mark] All users from API in HomePage:", allUsers);
503
- const users = currentUser && Array.isArray(allUsers) ? allUsers.filter((u) => u.id !== currentUser.id) : allUsers;
504
- console.log("[Magic-Mark] Available users in HomePage:", users);
505
- setAvailableUsers(users);
506
- } catch (error) {
507
- console.error("[Magic-Mark] Error fetching users from admin API:", error);
508
- try {
509
- const response = await get(`/${index.pluginId}/users`);
510
- const users = response.data?.data?.data || response.data?.data || [];
511
- setAvailableUsers(users);
512
- } catch (fallbackError) {
513
- console.warn("[Magic-Mark] Both user endpoints failed");
514
- setAvailableUsers([]);
515
- }
516
- }
517
- };
518
- const fetchCurrentUser = async () => {
519
- try {
520
- const response = await get("/admin/users/me");
521
- console.log("[Magic-Mark] Current user response:", response);
522
- const userData = response.data?.data || response.data || response;
523
- setCurrentUser(userData);
524
- console.log("[Magic-Mark] Current user set to:", userData);
525
- } catch (error) {
526
- console.error("[Magic-Mark] Error fetching current user:", error);
527
- }
528
- };
529
- const isCurrentUserOwner = (bookmark) => {
530
- if (!bookmark.createdBy || !currentUser) return false;
531
- if (bookmark.createdBy.documentId && currentUser.documentId) {
532
- return bookmark.createdBy.documentId === currentUser.documentId;
533
- }
534
- if (bookmark.createdBy.id && currentUser.id) {
535
- return String(bookmark.createdBy.id) === String(currentUser.id);
536
- }
537
- if (bookmark.createdBy.id && currentUser.documentId) {
538
- return String(bookmark.createdBy.id) === String(currentUser.documentId);
539
- }
540
- return false;
541
- };
542
- const fetchLicenseLimits = async () => {
543
- try {
544
- const response = await get(`/${index.pluginId}/license/limits`);
545
- if (response.data?.success) {
546
- setLicenseLimits(response.data.data);
547
- console.log("[Magic-Mark] License limits loaded:", response.data.data);
548
- }
549
- } catch (error) {
550
- console.error("[Magic-Mark] Error fetching license limits:", error);
551
- }
552
- };
553
- const fetchBookmarks = async () => {
554
- setLoading(true);
555
- try {
556
- const { data } = await get(`/${index.pluginId}/bookmarks`);
557
- console.log("[Magic-Mark HomePage] Bookmarks loaded:", data);
558
- console.log("[Magic-Mark HomePage] Current user state:", currentUser);
559
- setBookmarks(data.data || []);
560
- } catch (error) {
561
- console.error("[Magic-Mark HomePage] Error fetching bookmarks:", error);
562
- } finally {
563
- setLoading(false);
564
- }
565
- };
566
- const handleDelete = async (bookmark) => {
567
- if (!confirm(formatMessage({
568
- id: `${index.pluginId}.confirm.delete`,
569
- defaultMessage: "Are you sure you want to delete this bookmark?"
570
- }))) {
571
- return;
572
- }
573
- const deleteId = bookmark.documentId || bookmark.id;
574
- try {
575
- await del(`/${index.pluginId}/bookmarks/${deleteId}`);
576
- console.log("[Magic-Mark HomePage] Bookmark deleted:", deleteId);
577
- fetchBookmarks();
578
- } catch (error) {
579
- console.error("[Magic-Mark HomePage] Error deleting bookmark:", error);
580
- }
581
- };
582
- const handlePin = async (bookmark) => {
583
- const pinId = bookmark.documentId || bookmark.id;
584
- try {
585
- await post(`/${index.pluginId}/bookmarks/${pinId}/pin`, {
586
- isPinned: !bookmark.isPinned
587
- });
588
- console.log("[Magic-Mark HomePage] Bookmark pinned:", pinId);
589
- fetchBookmarks();
590
- } catch (error) {
591
- console.error("[Magic-Mark HomePage] Error pinning bookmark:", error);
592
- }
593
- };
594
- const handleEdit = (bookmark) => {
595
- setEditingBookmark(bookmark);
596
- setShowModal(true);
597
- };
598
- const handleModalClose = () => {
599
- setShowModal(false);
600
- setEditingBookmark(null);
601
- };
602
- const handleModalSuccess = () => {
603
- setShowModal(false);
604
- setEditingBookmark(null);
605
- fetchBookmarks();
606
- fetchLicenseLimits();
607
- };
608
- const handleBookmarkClick = (bookmark) => {
609
- if (bookmark.path) {
610
- let path = bookmark.path;
611
- if (path.startsWith("/admin/")) {
612
- path = path.substring(6);
613
- }
614
- const url = bookmark.query ? `${path}?${bookmark.query}` : path;
615
- console.log("[HomePage] Navigating to:", url);
616
- navigate(url);
617
- }
618
- };
619
- const filteredBookmarks = bookmarks.filter((bookmark) => {
620
- if (filterType === "pinned" && !bookmark.isPinned) return false;
621
- if (filterType === "unpinned" && bookmark.isPinned) return false;
622
- if (!searchQuery) return true;
623
- const query = searchQuery.toLowerCase();
624
- return bookmark.name.toLowerCase().includes(query) || bookmark.description && bookmark.description.toLowerCase().includes(query) || bookmark.path.toLowerCase().includes(query);
625
- }).slice(0, parseInt(entriesPerPage));
626
- const pinnedBookmarks = bookmarks.filter((b) => b.isPinned);
627
- const myBookmarks = bookmarks.filter((b) => isCurrentUserOwner(b));
628
- const sharedWithMe = bookmarks.filter((b) => !isCurrentUserOwner(b) && b.createdBy);
629
- return /* @__PURE__ */ jsxRuntime.jsxs(Container, { padding: 8, children: [
630
- /* @__PURE__ */ jsxRuntime.jsx(Header, { children: /* @__PURE__ */ jsxRuntime.jsxs(HeaderContent, { direction: "column", alignItems: "flex-start", gap: 2, children: [
631
- /* @__PURE__ */ jsxRuntime.jsxs(Title, { children: [
632
- /* @__PURE__ */ jsxRuntime.jsx(outline.BookOpenIcon, {}),
633
- " MagicMark"
634
- ] }),
635
- /* @__PURE__ */ jsxRuntime.jsx(Subtitle, { children: "Save filtered views and navigate with one click" })
636
- ] }) }),
637
- /* @__PURE__ */ jsxRuntime.jsxs(StatsGrid, { children: [
638
- /* @__PURE__ */ jsxRuntime.jsxs(StatCard, { $delay: "0.1s", $color: theme.colors.primary[500], children: [
639
- /* @__PURE__ */ jsxRuntime.jsx(StatIcon, { className: "stat-icon", $bg: theme.colors.primary[100], $color: theme.colors.primary[600], children: /* @__PURE__ */ jsxRuntime.jsx(outline.UserIcon, {}) }),
640
- /* @__PURE__ */ jsxRuntime.jsx(StatValue, { className: "stat-value", children: myBookmarks.length }),
641
- /* @__PURE__ */ jsxRuntime.jsx(StatLabel, { children: "My Bookmarks" })
642
- ] }),
643
- /* @__PURE__ */ jsxRuntime.jsxs(StatCard, { $delay: "0.2s", $color: theme.colors.success[500], children: [
644
- /* @__PURE__ */ jsxRuntime.jsx(StatIcon, { className: "stat-icon", $bg: theme.colors.success[100], $color: theme.colors.success[600], children: /* @__PURE__ */ jsxRuntime.jsx(outline.SparklesIcon, {}) }),
645
- /* @__PURE__ */ jsxRuntime.jsx(StatValue, { className: "stat-value", children: sharedWithMe.length }),
646
- /* @__PURE__ */ jsxRuntime.jsx(StatLabel, { children: formatMessage({ id: `${index.pluginId}.stats.shared`, defaultMessage: "Shared with Me" }) })
647
- ] }),
648
- /* @__PURE__ */ jsxRuntime.jsxs(StatCard, { $delay: "0.3s", $color: theme.colors.warning[500], children: [
649
- /* @__PURE__ */ jsxRuntime.jsx(StatIcon, { className: "stat-icon", $bg: theme.colors.warning[100], $color: theme.colors.warning[600], children: /* @__PURE__ */ jsxRuntime.jsx(icons.Pin, {}) }),
650
- /* @__PURE__ */ jsxRuntime.jsx(StatValue, { className: "stat-value", children: pinnedBookmarks.length }),
651
- /* @__PURE__ */ jsxRuntime.jsx(StatLabel, { children: formatMessage({ id: `${index.pluginId}.stats.pinned`, defaultMessage: "Pinned" }) })
652
- ] }),
653
- /* @__PURE__ */ jsxRuntime.jsxs(
654
- StatCard,
655
- {
656
- $delay: "0.4s",
657
- $color: licenseLimits.canCreate ? theme.colors.neutral[600] : theme.colors.danger[500],
658
- onClick: () => !licenseLimits.canCreate && navigate(`/settings/${index.pluginId}/upgrade`),
659
- style: { cursor: !licenseLimits.canCreate ? "pointer" : "default" },
660
- children: [
661
- /* @__PURE__ */ jsxRuntime.jsx(
662
- StatIcon,
663
- {
664
- className: "stat-icon",
665
- $bg: licenseLimits.canCreate ? theme.colors.neutral[100] : theme.colors.danger[100],
666
- $color: licenseLimits.canCreate ? theme.colors.neutral[600] : theme.colors.danger[600],
667
- children: /* @__PURE__ */ jsxRuntime.jsx(outline.LinkIcon, {})
668
- }
669
- ),
670
- /* @__PURE__ */ jsxRuntime.jsxs(StatValue, { className: "stat-value", children: [
671
- licenseLimits.currentBookmarks,
672
- "/",
673
- licenseLimits.maxBookmarks === -1 ? "∞" : licenseLimits.maxBookmarks
674
- ] }),
675
- /* @__PURE__ */ jsxRuntime.jsx(StatLabel, { children: licenseLimits.canCreate ? formatMessage({ id: `${index.pluginId}.stats.limit`, defaultMessage: "Bookmark Limit" }) : formatMessage({ id: `${index.pluginId}.stats.limitReached`, defaultMessage: "Limit Reached - Upgrade" }) })
676
- ]
677
- }
678
- )
679
- ] }),
680
- loading && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", padding: 8, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Loader, { children: formatMessage({ id: `${index.pluginId}.loading`, defaultMessage: "Loading bookmarks..." }) }) }),
681
- !loading && sharedWithMe.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { marginBottom: 4, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { style: {
682
- padding: theme.spacing.lg,
683
- background: theme.colors.primary[50],
684
- borderRadius: theme.borderRadius.lg,
685
- border: `1px solid ${theme.colors.primary[200]}`
686
- }, children: [
687
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "beta", style: { marginBottom: theme.spacing.sm, color: theme.colors.primary[700] }, children: formatMessage({ id: `${index.pluginId}.shared.title`, defaultMessage: "🤝 Shared with You" }) }),
688
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", style: { color: theme.colors.primary[600] }, children: sharedWithMe.length > 1 ? formatMessage({ id: `${index.pluginId}.shared.countPlural`, defaultMessage: "{count} bookmarks have been shared with you" }, { count: sharedWithMe.length }) : formatMessage({ id: `${index.pluginId}.shared.count`, defaultMessage: "{count} bookmark has been shared with you" }, { count: sharedWithMe.length }) }),
689
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { marginTop: 2, children: [...new Map(sharedWithMe.map((b) => [b.createdBy?.id, b.createdBy])).values()].map((creator) => {
690
- const creatorBookmarks = sharedWithMe.filter((b) => b.createdBy?.id === creator?.id);
691
- return creator && /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { alignItems: "center", marginTop: 1, children: [
692
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "pi", fontWeight: "semiBold", children: [
693
- creator.firstname || formatMessage({ id: `${index.pluginId}.bookmark.unknown`, defaultMessage: "Unknown" }),
694
- " ",
695
- creator.lastname || "",
696
- ":"
697
- ] }),
698
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", marginLeft: 1, children: creatorBookmarks.length > 1 ? formatMessage({ id: `${index.pluginId}.shared.byCreatorPlural`, defaultMessage: "{count} bookmarks" }, { count: creatorBookmarks.length }) : formatMessage({ id: `${index.pluginId}.shared.byCreator`, defaultMessage: "{count} bookmark" }, { count: creatorBookmarks.length }) })
699
- ] }, creator.id);
700
- }) })
701
- ] }) }),
702
- !loading && bookmarks.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { children: [
703
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { marginBottom: theme.spacing.md }, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "delta", style: { marginBottom: theme.spacing.md, color: "var(--colors-neutral700, #374151)" }, children: formatMessage({ id: `${index.pluginId}.allBookmarks.title`, defaultMessage: "🔖 All Available Bookmarks" }) }) }),
704
- /* @__PURE__ */ jsxRuntime.jsxs(FilterBar, { children: [
705
- /* @__PURE__ */ jsxRuntime.jsxs(SearchInputWrapper, { style: { flex: 1 }, children: [
706
- /* @__PURE__ */ jsxRuntime.jsx(SearchIconStyled, {}),
707
- /* @__PURE__ */ jsxRuntime.jsx(
708
- StyledSearchInput,
709
- {
710
- value: searchQuery,
711
- onChange: (e) => setSearchQuery(e.target.value),
712
- placeholder: formatMessage({ id: `${index.pluginId}.search.placeholder`, defaultMessage: "Search by name, description..." }),
713
- type: "text"
714
- }
715
- )
716
- ] }),
717
- /* @__PURE__ */ jsxRuntime.jsx(FilterSelect, { children: /* @__PURE__ */ jsxRuntime.jsxs(
718
- designSystem.SingleSelect,
719
- {
720
- value: filterType,
721
- onChange: setFilterType,
722
- placeholder: formatMessage({ id: `${index.pluginId}.filter.placeholder`, defaultMessage: "Filter" }),
723
- size: "S",
724
- children: [
725
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "all", children: formatMessage({ id: `${index.pluginId}.filter.all`, defaultMessage: "Show All" }) }),
726
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "pinned", children: formatMessage({ id: `${index.pluginId}.filter.pinned`, defaultMessage: "Pinned Only" }) }),
727
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "unpinned", children: formatMessage({ id: `${index.pluginId}.filter.unpinned`, defaultMessage: "Unpinned Only" }) })
728
- ]
729
- }
730
- ) }),
731
- /* @__PURE__ */ jsxRuntime.jsx(FilterSelect, { children: /* @__PURE__ */ jsxRuntime.jsxs(
732
- designSystem.SingleSelect,
733
- {
734
- value: entriesPerPage,
735
- onChange: setEntriesPerPage,
736
- placeholder: formatMessage({ id: `${index.pluginId}.entries.placeholder`, defaultMessage: "Entries" }),
737
- size: "S",
738
- children: [
739
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "10", children: formatMessage({ id: `${index.pluginId}.entries.10`, defaultMessage: "10 entries" }) }),
740
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "25", children: formatMessage({ id: `${index.pluginId}.entries.25`, defaultMessage: "25 entries" }) }),
741
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "50", children: formatMessage({ id: `${index.pluginId}.entries.50`, defaultMessage: "50 entries" }) }),
742
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "100", children: formatMessage({ id: `${index.pluginId}.entries.100`, defaultMessage: "100 entries" }) })
743
- ]
744
- }
745
- ) })
746
- ] }),
747
- /* @__PURE__ */ jsxRuntime.jsx(DataTable, { children: /* @__PURE__ */ jsxRuntime.jsxs(StyledTable, { children: [
748
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Thead, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
749
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: formatMessage({
750
- id: `${index.pluginId}.table.name`,
751
- defaultMessage: "Name"
752
- }) }),
753
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: formatMessage({
754
- id: `${index.pluginId}.table.description`,
755
- defaultMessage: "Description"
756
- }) }),
757
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { children: "Actions" }) })
758
- ] }) }),
759
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tbody, { children: filteredBookmarks.map((bookmark) => /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { style: {
760
- background: bookmark.isPinned ? theme.colors.warning[50] : "transparent"
761
- }, children: [
762
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { onClick: () => handleBookmarkClick(bookmark), style: { cursor: "pointer" }, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { alignItems: "center", gap: 3, children: [
763
- /* @__PURE__ */ jsxRuntime.jsx(BookmarkIconWrapper, { children: (() => {
764
- const IconComponent = index.getIconById(bookmark.icon || bookmark.emoji || "bookmark");
765
- return /* @__PURE__ */ jsxRuntime.jsx(IconComponent, {});
766
- })() }),
767
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", gap: 0, children: [
768
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "semiBold", ellipsis: true, style: { fontSize: "1.125rem", lineHeight: "1.4" }, children: bookmark.name }),
769
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 1, alignItems: "center", children: [
770
- isCurrentUserOwner(bookmark) ? /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "pi", style: { fontSize: "0.75rem", color: theme.colors.primary[600], fontWeight: 500 }, children: [
771
- "• ",
772
- formatMessage({ id: `${index.pluginId}.bookmark.myBookmark`, defaultMessage: "My Bookmark" })
773
- ] }) : /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "pi", style: { fontSize: "0.75rem", color: "var(--colors-neutral600, #4B5563)" }, children: [
774
- "• ",
775
- formatMessage({ id: `${index.pluginId}.bookmark.sharedBy`, defaultMessage: "Shared by {name}" }, { name: bookmark.createdBy?.firstname || formatMessage({ id: `${index.pluginId}.bookmark.unknown`, defaultMessage: "Unknown" }) })
776
- ] }),
777
- bookmark.isPublic && /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "pi", style: { fontSize: "0.75rem", color: theme.colors.success[600], marginLeft: "8px" }, children: [
778
- "• ",
779
- formatMessage({ id: `${index.pluginId}.bookmark.public`, defaultMessage: "Public" })
780
- ] }),
781
- bookmark.sharedWithRoles && bookmark.sharedWithRoles.length > 0 && !bookmark.isPublic && /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "pi", style: { fontSize: "0.75rem", color: theme.colors.warning[600], marginLeft: "8px" }, children: [
782
- "• Roles: ",
783
- bookmark.sharedWithRoles.map((roleId) => {
784
- const role = availableRoles.find((r) => r.id === roleId);
785
- return role?.name || `Role ${roleId}`;
786
- }).join(", ")
787
- ] }),
788
- bookmark.sharedWithUsers && bookmark.sharedWithUsers.length > 0 && !bookmark.isPublic && /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "pi", style: { fontSize: "0.75rem", color: theme.colors.primary[600], marginLeft: "8px" }, children: [
789
- "• Users: ",
790
- bookmark.sharedWithUsers.map((userId) => {
791
- const user = availableUsers.find((u) => u.id === userId);
792
- return user ? `${user.firstname} ${user.lastname}` : `User ${userId}`;
793
- }).join(", ")
794
- ] })
795
- ] })
796
- ] })
797
- ] }) }),
798
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { onClick: () => handleBookmarkClick(bookmark), style: { cursor: "pointer" }, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", ellipsis: true, style: { fontSize: "1rem", lineHeight: "1.6", fontWeight: 400 }, children: bookmark.description || "-" }) }),
799
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsxs(
800
- ActionButtons,
801
- {
802
- className: "action-buttons",
803
- children: [
804
- /* @__PURE__ */ jsxRuntime.jsx(
805
- designSystem.Button,
806
- {
807
- variant: bookmark.isPinned ? "secondary" : "ghost",
808
- size: "S",
809
- onClick: (e) => {
810
- e.stopPropagation();
811
- handlePin(bookmark);
812
- },
813
- style: {
814
- color: bookmark.isPinned ? theme.colors.warning[600] : "inherit",
815
- background: bookmark.isPinned ? theme.colors.warning[100] : "transparent"
816
- },
817
- children: /* @__PURE__ */ jsxRuntime.jsx(icons.Pin, {})
818
- }
819
- ),
820
- /* @__PURE__ */ jsxRuntime.jsx(
821
- designSystem.Button,
822
- {
823
- variant: "ghost",
824
- size: "S",
825
- onClick: (e) => {
826
- e.stopPropagation();
827
- handleBookmarkClick(bookmark);
828
- },
829
- children: /* @__PURE__ */ jsxRuntime.jsx(icons.Eye, {})
830
- }
831
- ),
832
- /* @__PURE__ */ jsxRuntime.jsx(
833
- designSystem.Button,
834
- {
835
- variant: "ghost",
836
- size: "S",
837
- onClick: (e) => {
838
- e.stopPropagation();
839
- handleEdit(bookmark);
840
- },
841
- disabled: !isCurrentUserOwner(bookmark),
842
- children: /* @__PURE__ */ jsxRuntime.jsx(icons.Pencil, {})
843
- }
844
- ),
845
- isCurrentUserOwner(bookmark) && /* @__PURE__ */ jsxRuntime.jsx(
846
- designSystem.Button,
847
- {
848
- variant: "ghost",
849
- size: "S",
850
- onClick: (e) => {
851
- e.stopPropagation();
852
- handleDelete(bookmark);
853
- },
854
- children: /* @__PURE__ */ jsxRuntime.jsx(icons.Trash, {})
855
- }
856
- )
857
- ]
858
- }
859
- ) })
860
- ] }, bookmark.id)) })
861
- ] }) })
862
- ] }),
863
- !loading && bookmarks.length === 0 && /* @__PURE__ */ jsxRuntime.jsxs(
864
- designSystem.Box,
865
- {
866
- style: {
867
- background: "transparent",
868
- borderRadius: theme.borderRadius.xl,
869
- border: "2px dashed rgba(128, 128, 128, 0.2)",
870
- padding: theme.spacing["3xl"],
871
- textAlign: "center",
872
- position: "relative",
873
- overflow: "hidden",
874
- minHeight: "400px",
875
- display: "flex",
876
- alignItems: "center",
877
- justifyContent: "center"
878
- },
879
- children: [
880
- /* @__PURE__ */ jsxRuntime.jsx(
881
- designSystem.Box,
882
- {
883
- style: {
884
- content: "",
885
- position: "absolute",
886
- top: 0,
887
- left: 0,
888
- right: 0,
889
- bottom: 0,
890
- background: `linear-gradient(135deg, ${theme.colors.primary[50]} 0%, ${theme.colors.secondary[50]} 100%)`,
891
- opacity: 0.3,
892
- zIndex: 0
893
- }
894
- }
895
- ),
896
- /* @__PURE__ */ jsxRuntime.jsx(FloatingIcon, { children: /* @__PURE__ */ jsxRuntime.jsx(outline.SparklesIcon, {}) }),
897
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "center", gap: 6, style: { position: "relative", zIndex: 1 }, children: [
898
- /* @__PURE__ */ jsxRuntime.jsx(
899
- designSystem.Box,
900
- {
901
- style: {
902
- width: "120px",
903
- height: "120px",
904
- borderRadius: "50%",
905
- background: `linear-gradient(135deg, ${theme.colors.primary[100]} 0%, ${theme.colors.secondary[100]} 100%)`,
906
- display: "flex",
907
- alignItems: "center",
908
- justifyContent: "center",
909
- boxShadow: theme.shadows.xl
910
- },
911
- children: /* @__PURE__ */ jsxRuntime.jsx(outline.SparklesIcon, { style: { width: "60px", height: "60px", color: theme.colors.primary[600] } })
912
- }
913
- ),
914
- /* @__PURE__ */ jsxRuntime.jsx(
915
- designSystem.Typography,
916
- {
917
- variant: "alpha",
918
- style: {
919
- fontSize: "1.75rem",
920
- fontWeight: "700",
921
- color: "var(--colors-neutral800, #1F2937)",
922
- marginBottom: "8px"
923
- },
924
- children: formatMessage({ id: `${index.pluginId}.empty.title`, defaultMessage: "No bookmarks yet" })
925
- }
926
- ),
927
- /* @__PURE__ */ jsxRuntime.jsx(
928
- designSystem.Typography,
929
- {
930
- variant: "omega",
931
- textColor: "neutral600",
932
- style: {
933
- fontSize: "1rem",
934
- maxWidth: "500px",
935
- lineHeight: "1.6"
936
- },
937
- children: formatMessage({ id: `${index.pluginId}.empty.description`, defaultMessage: 'Navigate to any Content Manager view, apply filters, and click "Save Bookmark" to create quick access shortcuts' })
938
- }
939
- )
940
- ] })
941
- ]
942
- }
943
- ),
944
- showModal && /* @__PURE__ */ jsxRuntime.jsx(
945
- index.CreateEditModal,
946
- {
947
- bookmark: editingBookmark,
948
- pluginId: index.pluginId,
949
- onClose: handleModalClose,
950
- onSuccess: handleModalSuccess,
951
- currentPath: "",
952
- currentQuery: ""
953
- }
954
- )
955
- ] });
956
- };
957
- const fadeIn = styled.keyframes`
958
- from { opacity: 0; }
959
- to { opacity: 1; }
960
- `;
961
- const slideUp = styled.keyframes`
962
- from {
963
- opacity: 0;
964
- transform: translateY(30px);
965
- }
966
- to {
967
- opacity: 1;
968
- transform: translateY(0);
969
- }
970
- `;
971
- const ModalOverlay = styled__default.default.div`
972
- position: fixed;
973
- top: 0;
974
- left: 0;
975
- right: 0;
976
- bottom: 0;
977
- background: rgba(4, 28, 47, 0.85);
978
- backdrop-filter: blur(8px);
979
- z-index: 9999;
980
- display: flex;
981
- align-items: center;
982
- justify-content: center;
983
- animation: ${fadeIn} 0.3s ease-out;
984
- padding: 20px;
985
- `;
986
- const ModalContent = styled__default.default(designSystem.Box)`
987
- background: ${(p) => p.theme.colors.neutral0};
988
- border-radius: 16px;
989
- width: 100%;
990
- max-width: 580px;
991
- box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
992
- animation: ${slideUp} 0.4s cubic-bezier(0.4, 0, 0.2, 1);
993
- overflow: hidden;
994
- `;
995
- const GradientHeader = styled__default.default(designSystem.Box)`
996
- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
997
- padding: 32px 40px;
998
- position: relative;
999
- overflow: hidden;
1000
-
1001
- &::before {
1002
- content: '';
1003
- position: absolute;
1004
- top: -50%;
1005
- right: -50%;
1006
- width: 200%;
1007
- height: 200%;
1008
- background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
1009
- }
1010
- `;
1011
- const IconWrapper = styled__default.default.div`
1012
- width: 72px;
1013
- height: 72px;
1014
- border-radius: 50%;
1015
- background: rgba(255, 255, 255, 0.2);
1016
- display: flex;
1017
- align-items: center;
1018
- justify-content: center;
1019
- margin: 0 auto 16px;
1020
- backdrop-filter: blur(10px);
1021
- border: 2px solid rgba(255, 255, 255, 0.3);
1022
-
1023
- svg {
1024
- width: 36px;
1025
- height: 36px;
1026
- color: white;
1027
- }
1028
- `;
1029
- const CloseButton = styled__default.default.button`
1030
- position: absolute;
1031
- top: 16px;
1032
- right: 16px;
1033
- background: rgba(255, 255, 255, 0.2);
1034
- border: 2px solid rgba(255, 255, 255, 0.3);
1035
- border-radius: 50%;
1036
- width: 36px;
1037
- height: 36px;
1038
- display: flex;
1039
- align-items: center;
1040
- justify-content: center;
1041
- cursor: pointer;
1042
- transition: all 0.2s;
1043
- z-index: 10;
1044
-
1045
- svg {
1046
- width: 20px;
1047
- height: 20px;
1048
- color: white;
1049
- }
1050
-
1051
- &:hover {
1052
- background: rgba(255, 255, 255, 0.3);
1053
- transform: scale(1.1);
1054
- }
1055
-
1056
- &:active {
1057
- transform: scale(0.95);
1058
- }
1059
- `;
1060
- const ToggleButton = styled__default.default.button`
1061
- background: none;
1062
- border: none;
1063
- color: #667eea;
1064
- font-size: 13px;
1065
- font-weight: 600;
1066
- cursor: pointer;
1067
- padding: 8px 0;
1068
- text-decoration: underline;
1069
- transition: color 0.2s;
1070
-
1071
- &:hover {
1072
- color: #764ba2;
1073
- }
1074
- `;
1075
- const LicenseGuard = ({ children }) => {
1076
- const { get, post } = admin.useFetchClient();
1077
- const { toggleNotification } = admin.useNotification();
1078
- const navigate = reactRouterDom.useNavigate();
1079
- const [isChecking, setIsChecking] = React.useState(true);
1080
- const [needsLicense, setNeedsLicense] = React.useState(false);
1081
- const [isCreating, setIsCreating] = React.useState(false);
1082
- const [useExistingKey, setUseExistingKey] = React.useState(false);
1083
- const [useAutoCreate, setUseAutoCreate] = React.useState(true);
1084
- const [existingLicenseKey, setExistingLicenseKey] = React.useState("");
1085
- const [existingEmail, setExistingEmail] = React.useState("");
1086
- const [adminUser, setAdminUser] = React.useState(null);
1087
- const [formData, setFormData] = React.useState({
1088
- email: "",
1089
- firstName: "",
1090
- lastName: ""
1091
- });
1092
- React.useEffect(() => {
1093
- checkLicenseStatus();
1094
- fetchAdminUser();
1095
- }, []);
1096
- const fetchAdminUser = async () => {
1097
- try {
1098
- const response = await get("/admin/users/me");
1099
- console.log("Admin user response:", response);
1100
- const userData = response.data?.data || response.data;
1101
- console.log("User data extracted:", userData);
1102
- if (userData) {
1103
- setAdminUser(userData);
1104
- setFormData({
1105
- email: userData.email || "",
1106
- firstName: userData.firstname || "",
1107
- lastName: userData.lastname || ""
1108
- });
1109
- console.log("Admin user set:", {
1110
- email: userData.email,
1111
- firstname: userData.firstname,
1112
- lastname: userData.lastname
1113
- });
1114
- }
1115
- } catch (error) {
1116
- console.error("Error fetching admin user:", error);
1117
- }
1118
- };
1119
- const checkLicenseStatus = async () => {
1120
- setIsChecking(true);
1121
- try {
1122
- const response = await get("/magic-mark/license/status");
1123
- if (response.data.valid) {
1124
- setNeedsLicense(false);
1125
- } else {
1126
- setNeedsLicense(true);
1127
- }
1128
- } catch (error) {
1129
- console.error("Error checking license:", error);
1130
- setNeedsLicense(true);
1131
- } finally {
1132
- setIsChecking(false);
1133
- }
1134
- };
1135
- const handleAutoCreateLicense = async (e) => {
1136
- e.preventDefault();
1137
- setIsCreating(true);
1138
- try {
1139
- console.log("Auto-creating license with admin user data...");
1140
- const response = await post("/magic-mark/license/auto-create", {});
1141
- if (response.data && response.data.success) {
1142
- toggleNotification({
1143
- type: "success",
1144
- message: `License automatically created! Reloading...`
1145
- });
1146
- setNeedsLicense(false);
1147
- setTimeout(() => {
1148
- window.location.reload();
1149
- }, 500);
1150
- } else {
1151
- throw new Error("Failed to auto-create license");
1152
- }
1153
- } catch (error) {
1154
- console.error("Error auto-creating license:", error);
1155
- toggleNotification({
1156
- type: "danger",
1157
- message: error?.response?.data?.error?.message || "Failed to auto-create license. Try manual creation."
1158
- });
1159
- setIsCreating(false);
1160
- setUseAutoCreate(false);
1161
- }
1162
- };
1163
- const handleCreateLicense = async (e) => {
1164
- e.preventDefault();
1165
- if (!formData.email || !formData.firstName || !formData.lastName) {
1166
- toggleNotification({
1167
- type: "warning",
1168
- message: "Please fill in all fields"
1169
- });
1170
- return;
1171
- }
1172
- setIsCreating(true);
1173
- try {
1174
- console.log("Creating license with data:", formData);
1175
- const response = await post("/magic-mark/license/create", formData);
1176
- console.log("License creation response:", response);
1177
- if (response.data && response.data.success) {
1178
- toggleNotification({
1179
- type: "success",
1180
- message: `License created successfully! Reloading...`
1181
- });
1182
- setNeedsLicense(false);
1183
- setTimeout(() => {
1184
- window.location.reload();
1185
- }, 500);
1186
- } else {
1187
- throw new Error("Failed to create license");
1188
- }
1189
- } catch (error) {
1190
- console.error("Error creating license:", error);
1191
- toggleNotification({
1192
- type: "danger",
1193
- message: error?.response?.data?.error?.message || "Failed to create license. Please try again."
1194
- });
1195
- setIsCreating(false);
1196
- }
1197
- };
1198
- const handleValidateExistingKey = async (e) => {
1199
- e.preventDefault();
1200
- if (!existingLicenseKey.trim() || !existingEmail.trim()) {
1201
- toggleNotification({
1202
- type: "warning",
1203
- message: "Please enter both license key and email address"
1204
- });
1205
- return;
1206
- }
1207
- setIsCreating(true);
1208
- try {
1209
- console.log("Validating existing license key...");
1210
- const pluginStore = await post("/magic-mark/license/store-key", {
1211
- licenseKey: existingLicenseKey.trim(),
1212
- email: existingEmail.trim()
1213
- });
1214
- if (pluginStore.data && pluginStore.data.success) {
1215
- toggleNotification({
1216
- type: "success",
1217
- message: "License key validated successfully! Reloading..."
1218
- });
1219
- setNeedsLicense(false);
1220
- setTimeout(() => {
1221
- window.location.reload();
1222
- }, 500);
1223
- } else {
1224
- throw new Error("Invalid license key or email");
1225
- }
1226
- } catch (error) {
1227
- console.error("Error validating license key:", error);
1228
- toggleNotification({
1229
- type: "danger",
1230
- message: error?.response?.data?.error?.message || "Invalid license key or email address. Please check and try again."
1231
- });
1232
- setIsCreating(false);
1233
- }
1234
- };
1235
- const handleClose = () => {
1236
- navigate("/content-manager");
1237
- };
1238
- if (isChecking) {
1239
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 8, style: { textAlign: "center" }, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Loader, { children: "Checking license..." }) });
1240
- }
1241
- if (needsLicense) {
1242
- return /* @__PURE__ */ jsxRuntime.jsx(ModalOverlay, { children: /* @__PURE__ */ jsxRuntime.jsxs(ModalContent, { children: [
1243
- /* @__PURE__ */ jsxRuntime.jsxs(GradientHeader, { children: [
1244
- /* @__PURE__ */ jsxRuntime.jsx(CloseButton, { onClick: handleClose, type: "button", children: /* @__PURE__ */ jsxRuntime.jsx(icons.Cross, {}) }),
1245
- /* @__PURE__ */ jsxRuntime.jsx(IconWrapper, { children: /* @__PURE__ */ jsxRuntime.jsx(icons.Key, {}) }),
1246
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { style: { textAlign: "center", position: "relative" }, children: [
1247
- /* @__PURE__ */ jsxRuntime.jsx(
1248
- designSystem.Typography,
1249
- {
1250
- variant: "alpha",
1251
- style: {
1252
- color: "white",
1253
- fontSize: "24px",
1254
- fontWeight: "700",
1255
- marginBottom: "12px",
1256
- display: "block"
1257
- },
1258
- children: "Activate MagicMark Plugin"
1259
- }
1260
- ),
1261
- /* @__PURE__ */ jsxRuntime.jsx(
1262
- designSystem.Typography,
1263
- {
1264
- variant: "epsilon",
1265
- style: {
1266
- color: "rgba(255, 255, 255, 0.9)",
1267
- fontSize: "14px",
1268
- display: "block"
1269
- },
1270
- children: useExistingKey ? "Enter your existing license key" : "Create a license to start using the plugin"
1271
- }
1272
- )
1273
- ] })
1274
- ] }),
1275
- /* @__PURE__ */ jsxRuntime.jsx("form", { onSubmit: useExistingKey ? handleValidateExistingKey : useAutoCreate ? handleAutoCreateLicense : handleCreateLicense, children: /* @__PURE__ */ jsxRuntime.jsx(
1276
- designSystem.Box,
1277
- {
1278
- padding: 6,
1279
- paddingLeft: 8,
1280
- paddingRight: 8,
1281
- children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 5, style: { width: "100%" }, children: [
1282
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { style: { textAlign: "center", width: "100%" }, children: [
1283
- !useExistingKey && /* @__PURE__ */ jsxRuntime.jsx(
1284
- ToggleButton,
1285
- {
1286
- type: "button",
1287
- onClick: () => setUseAutoCreate(!useAutoCreate),
1288
- disabled: isCreating,
1289
- style: { marginBottom: "8px", display: "block", margin: "0 auto" },
1290
- children: useAutoCreate ? "→ Manual entry" : "← Auto-create with my account"
1291
- }
1292
- ),
1293
- /* @__PURE__ */ jsxRuntime.jsx(
1294
- ToggleButton,
1295
- {
1296
- type: "button",
1297
- onClick: () => {
1298
- setUseExistingKey(!useExistingKey);
1299
- if (!useExistingKey) setUseAutoCreate(false);
1300
- },
1301
- disabled: isCreating,
1302
- children: useExistingKey ? "← Create new license" : "Have a license key? →"
1303
- }
1304
- )
1305
- ] }),
1306
- /* @__PURE__ */ jsxRuntime.jsx(
1307
- designSystem.Box,
1308
- {
1309
- background: "primary100",
1310
- padding: 4,
1311
- style: {
1312
- borderRadius: "8px",
1313
- border: "2px solid rgba(14, 165, 233, 0.3)",
1314
- width: "100%"
1315
- },
1316
- children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", style: { fontSize: "13px", lineHeight: "1.6" }, children: useExistingKey ? "Enter your email and license key to activate." : useAutoCreate && adminUser && adminUser.email ? `Click "Activate" to auto-create a license with your account (${adminUser.email})` : useAutoCreate ? 'Click "Activate" to auto-create a license with your admin account' : "A license will be created with the details below." })
1317
- }
1318
- ),
1319
- useExistingKey ? (
1320
- // Existing License Key Input
1321
- /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1322
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { style: { width: "100%" }, children: [
1323
- /* @__PURE__ */ jsxRuntime.jsx(
1324
- designSystem.Typography,
1325
- {
1326
- variant: "pi",
1327
- fontWeight: "bold",
1328
- style: { marginBottom: "8px", display: "block" },
1329
- children: "Email Address *"
1330
- }
1331
- ),
1332
- /* @__PURE__ */ jsxRuntime.jsx(
1333
- designSystem.TextInput,
1334
- {
1335
- placeholder: "admin@example.com",
1336
- type: "email",
1337
- value: existingEmail,
1338
- onChange: (e) => setExistingEmail(e.target.value),
1339
- required: true,
1340
- disabled: isCreating
1341
- }
1342
- ),
1343
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral600", style: { fontSize: "11px", marginTop: "4px" }, children: "Enter the email address associated with this license" })
1344
- ] }),
1345
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { style: { width: "100%" }, children: [
1346
- /* @__PURE__ */ jsxRuntime.jsx(
1347
- designSystem.Typography,
1348
- {
1349
- variant: "pi",
1350
- fontWeight: "bold",
1351
- style: { marginBottom: "8px", display: "block" },
1352
- children: "License Key *"
1353
- }
1354
- ),
1355
- /* @__PURE__ */ jsxRuntime.jsx(
1356
- designSystem.TextInput,
1357
- {
1358
- placeholder: "67C5-40D2-7695-718C",
1359
- value: existingLicenseKey,
1360
- onChange: (e) => setExistingLicenseKey(e.target.value),
1361
- required: true,
1362
- disabled: isCreating
1363
- }
1364
- ),
1365
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral600", style: { fontSize: "11px", marginTop: "4px" }, children: "Enter the license key in the format: XXXX-XXXX-XXXX-XXXX" })
1366
- ] })
1367
- ] })
1368
- ) : useAutoCreate && adminUser ? (
1369
- // Auto-create mode - Show user info
1370
- /* @__PURE__ */ jsxRuntime.jsxs(
1371
- designSystem.Box,
1372
- {
1373
- background: "success100",
1374
- padding: 5,
1375
- style: {
1376
- borderRadius: "8px",
1377
- border: "2px solid rgba(34, 197, 94, 0.15)",
1378
- textAlign: "center"
1379
- },
1380
- children: [
1381
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", fontWeight: "bold", style: { marginBottom: "12px", display: "block" }, children: "Ready to activate with your account:" }),
1382
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { alignItems: "center", gap: 2, style: { marginBottom: "4px" }, children: [
1383
- /* @__PURE__ */ jsxRuntime.jsx(icons.User, { fill: "neutral700", width: "14px", height: "14px" }),
1384
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "pi", children: [
1385
- adminUser.firstname || "Admin",
1386
- " ",
1387
- adminUser.lastname || "User"
1388
- ] })
1389
- ] }),
1390
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { alignItems: "center", gap: 2, children: [
1391
- /* @__PURE__ */ jsxRuntime.jsx(icons.Mail, { fill: "neutral600", width: "14px", height: "14px" }),
1392
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: adminUser.email || "Loading..." })
1393
- ] })
1394
- ]
1395
- }
1396
- )
1397
- ) : (
1398
- // Manual Create License Fields
1399
- /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1400
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { style: { width: "100%" }, children: [
1401
- /* @__PURE__ */ jsxRuntime.jsx(
1402
- designSystem.Typography,
1403
- {
1404
- variant: "pi",
1405
- fontWeight: "bold",
1406
- style: { marginBottom: "8px", display: "block" },
1407
- children: "Email Address *"
1408
- }
1409
- ),
1410
- /* @__PURE__ */ jsxRuntime.jsx(
1411
- designSystem.TextInput,
1412
- {
1413
- placeholder: "admin@example.com",
1414
- type: "email",
1415
- value: formData.email,
1416
- onChange: (e) => setFormData({ ...formData, email: e.target.value }),
1417
- required: true,
1418
- disabled: isCreating
1419
- }
1420
- )
1421
- ] }),
1422
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { style: { width: "100%" }, children: [
1423
- /* @__PURE__ */ jsxRuntime.jsx(
1424
- designSystem.Typography,
1425
- {
1426
- variant: "pi",
1427
- fontWeight: "bold",
1428
- style: { marginBottom: "8px", display: "block" },
1429
- children: "First Name *"
1430
- }
1431
- ),
1432
- /* @__PURE__ */ jsxRuntime.jsx(
1433
- designSystem.TextInput,
1434
- {
1435
- placeholder: "John",
1436
- value: formData.firstName,
1437
- onChange: (e) => setFormData({ ...formData, firstName: e.target.value }),
1438
- required: true,
1439
- disabled: isCreating
1440
- }
1441
- )
1442
- ] }),
1443
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { style: { width: "100%" }, children: [
1444
- /* @__PURE__ */ jsxRuntime.jsx(
1445
- designSystem.Typography,
1446
- {
1447
- variant: "pi",
1448
- fontWeight: "bold",
1449
- style: { marginBottom: "8px", display: "block" },
1450
- children: "Last Name *"
1451
- }
1452
- ),
1453
- /* @__PURE__ */ jsxRuntime.jsx(
1454
- designSystem.TextInput,
1455
- {
1456
- placeholder: "Doe",
1457
- value: formData.lastName,
1458
- onChange: (e) => setFormData({ ...formData, lastName: e.target.value }),
1459
- required: true,
1460
- disabled: isCreating
1461
- }
1462
- )
1463
- ] })
1464
- ] })
1465
- ),
1466
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { gap: 3, justifyContent: "center", style: { marginTop: "16px" }, children: useExistingKey ? /* @__PURE__ */ jsxRuntime.jsx(
1467
- designSystem.Button,
1468
- {
1469
- type: "submit",
1470
- size: "L",
1471
- startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Check, {}),
1472
- loading: isCreating,
1473
- disabled: isCreating || !existingLicenseKey.trim() || !existingEmail.trim(),
1474
- style: {
1475
- background: "linear-gradient(135deg, #667eea 0%, #764ba2 100%)",
1476
- color: "white",
1477
- fontWeight: "600",
1478
- border: "none",
1479
- boxShadow: "0 4px 12px rgba(102, 126, 234, 0.4)"
1480
- },
1481
- children: "Validate License"
1482
- }
1483
- ) : /* @__PURE__ */ jsxRuntime.jsx(
1484
- designSystem.Button,
1485
- {
1486
- type: "submit",
1487
- size: "L",
1488
- startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Check, {}),
1489
- loading: isCreating,
1490
- disabled: isCreating || !useAutoCreate && (!formData.email || !formData.firstName || !formData.lastName),
1491
- style: {
1492
- background: "linear-gradient(135deg, #667eea 0%, #764ba2 100%)",
1493
- color: "white",
1494
- fontWeight: "600",
1495
- border: "none",
1496
- boxShadow: "0 4px 12px rgba(102, 126, 234, 0.4)"
1497
- },
1498
- children: useAutoCreate ? "Activate License" : "Create License"
1499
- }
1500
- ) })
1501
- ] })
1502
- }
1503
- ) })
1504
- ] }) });
1505
- }
1506
- return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
1507
- };
1508
- const App = () => {
1509
- return /* @__PURE__ */ jsxRuntime.jsx(LicenseGuard, { children: /* @__PURE__ */ jsxRuntime.jsx(HomePageModern, {}) });
1510
- };
1511
- exports.default = App;