@questpie/admin 3.0.3 → 3.0.5
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/README.md +34 -5
- package/dist/client/blocks/block-renderer.d.mts +2 -2
- package/dist/client/blocks/block-renderer.mjs +4 -1
- package/dist/client/builder/types/action-types.d.mts +31 -3
- package/dist/client/builder/types/collection-types.d.mts +140 -0
- package/dist/client/builder/types/ui-config.d.mts +16 -2
- package/dist/client/builder/types/views.d.mts +57 -0
- package/dist/client/builder/types/widget-types.d.mts +5 -0
- package/dist/client/components/actions/action-button.mjs +137 -199
- package/dist/client/components/actions/action-dialog.mjs +198 -156
- package/dist/client/components/actions/confirmation-dialog.mjs +2 -2
- package/dist/client/components/actions/header-actions.mjs +52 -53
- package/dist/client/components/admin-link.d.mts +2 -2
- package/dist/client/components/auth/auth-loading.mjs +41 -18
- package/dist/client/components/blocks/block-editor-layout.mjs +2 -2
- package/dist/client/components/blocks/block-fields-renderer.mjs +64 -28
- package/dist/client/components/blocks/block-insert-button.mjs +4 -4
- package/dist/client/components/blocks/block-item.mjs +2 -2
- package/dist/client/components/blocks/block-library-sidebar.mjs +91 -63
- package/dist/client/components/component-renderer.mjs +1 -1
- package/dist/client/components/fields/array-field.mjs +14 -14
- package/dist/client/components/fields/asset-preview-field.mjs +1 -1
- package/dist/client/components/fields/blocks-field/blocks-field.mjs +84 -104
- package/dist/client/components/fields/json-field.mjs +2 -2
- package/dist/client/components/fields/object-array-field.mjs +22 -22
- package/dist/client/components/fields/object-field.mjs +5 -5
- package/dist/client/components/fields/relation/displays/cards-display.mjs +16 -9
- package/dist/client/components/fields/relation/displays/chips-display.mjs +15 -12
- package/dist/client/components/fields/relation/displays/grid-display.mjs +15 -11
- package/dist/client/components/fields/relation/displays/list-display.mjs +33 -20
- package/dist/client/components/fields/relation/displays/table-display.mjs +62 -93
- package/dist/client/components/fields/relation/relation-items-display.mjs +1 -1
- package/dist/client/components/fields/relation-picker.mjs +7 -6
- package/dist/client/components/fields/relation-select.mjs +71 -47
- package/dist/client/components/fields/rich-text-editor/bubble-menu.mjs +392 -82
- package/dist/client/components/fields/rich-text-editor/extensions.mjs +54 -23
- package/dist/client/components/fields/rich-text-editor/image-popover.mjs +24 -50
- package/dist/client/components/fields/rich-text-editor/image-upload.mjs +66 -0
- package/dist/client/components/fields/rich-text-editor/index.d.mts +38 -0
- package/dist/client/components/fields/rich-text-editor/index.mjs +637 -376
- package/dist/client/components/fields/rich-text-editor/link-utils.mjs +26 -0
- package/dist/client/components/fields/rich-text-editor/presets.d.mts +10 -0
- package/dist/client/components/fields/rich-text-editor/slash-commands.mjs +27 -6
- package/dist/client/components/fields/rich-text-editor/toolbar.mjs +464 -346
- package/dist/client/components/fields/rich-text-editor/types.d.mts +77 -0
- package/dist/client/components/fields/upload-field.mjs +45 -49
- package/dist/client/components/filter-builder/columns-tab.mjs +69 -62
- package/dist/client/components/filter-builder/filter-builder-sheet.mjs +473 -308
- package/dist/client/components/filter-builder/filters-tab.mjs +109 -82
- package/dist/client/components/filter-builder/saved-views-tab.mjs +300 -198
- package/dist/client/components/history-sidebar.mjs +850 -340
- package/dist/client/components/layout/field-layout-renderer.mjs +6 -5
- package/dist/client/components/locale-switcher.mjs +8 -8
- package/dist/client/components/media/media-grid.mjs +106 -86
- package/dist/client/components/media/media-picker-dialog.mjs +242 -230
- package/dist/client/components/preview/live-preview-mode.mjs +1 -1
- package/dist/client/components/primitives/asset-preview.mjs +37 -22
- package/dist/client/components/primitives/date-input.mjs +212 -249
- package/dist/client/components/primitives/dropzone.mjs +192 -159
- package/dist/client/components/primitives/field-select-control.mjs +93 -0
- package/dist/client/components/primitives/select-multi.mjs +406 -365
- package/dist/client/components/primitives/select-single.mjs +391 -323
- package/dist/client/components/primitives/time-input.mjs +2 -2
- package/dist/client/components/sheets/resource-sheet.mjs +2 -0
- package/dist/client/components/ui/accordion.mjs +4 -4
- package/dist/client/components/ui/alert.mjs +3 -3
- package/dist/client/components/ui/badge.mjs +4 -4
- package/dist/client/components/ui/button.mjs +47 -37
- package/dist/client/components/ui/card.mjs +2 -2
- package/dist/client/components/ui/checkbox.mjs +1 -1
- package/dist/client/components/ui/command.mjs +5 -5
- package/dist/client/components/ui/dialog.mjs +3 -3
- package/dist/client/components/ui/drawer.mjs +1 -1
- package/dist/client/components/ui/dropdown-menu.mjs +157 -15
- package/dist/client/components/ui/empty-state.mjs +88 -59
- package/dist/client/components/ui/field.mjs +2 -2
- package/dist/client/components/ui/input-group.mjs +3 -3
- package/dist/client/components/ui/input.mjs +1 -1
- package/dist/client/components/ui/kbd.mjs +1 -1
- package/dist/client/components/ui/label.mjs +1 -1
- package/dist/client/components/ui/popover.mjs +19 -11
- package/dist/client/components/ui/scroll-fade.mjs +170 -0
- package/dist/client/components/ui/search-input.mjs +1 -1
- package/dist/client/components/ui/select.mjs +129 -27
- package/dist/client/components/ui/sheet.mjs +54 -34
- package/dist/client/components/ui/sidebar.mjs +15 -14
- package/dist/client/components/ui/skeleton.mjs +28 -12
- package/dist/client/components/ui/switch.mjs +2 -2
- package/dist/client/components/ui/table.mjs +82 -74
- package/dist/client/components/ui/tabs.mjs +26 -31
- package/dist/client/components/ui/textarea.mjs +1 -1
- package/dist/client/components/ui/tooltip.mjs +1 -1
- package/dist/client/components/widgets/chart-widget.mjs +154 -100
- package/dist/client/components/widgets/progress-widget.mjs +63 -36
- package/dist/client/components/widgets/quick-actions-widget.mjs +207 -115
- package/dist/client/components/widgets/recent-items-widget.mjs +147 -103
- package/dist/client/components/widgets/stats-widget.mjs +91 -72
- package/dist/client/components/widgets/table-widget.mjs +161 -247
- package/dist/client/components/widgets/timeline-widget.mjs +119 -78
- package/dist/client/components/widgets/value-widget.mjs +286 -157
- package/dist/client/components/widgets/widget-empty-state.mjs +88 -0
- package/dist/client/components/widgets/widget-skeletons.mjs +53 -20
- package/dist/client/contexts/focus-context.d.mts +2 -2
- package/dist/client/hooks/use-action.mjs +63 -55
- package/dist/client/hooks/use-audit-history.mjs +1 -65
- package/dist/client/hooks/use-collection-validation.mjs +36 -23
- package/dist/client/hooks/use-collection.mjs +96 -1
- package/dist/client/hooks/use-saved-views.mjs +70 -49
- package/dist/client/hooks/use-server-actions.mjs +70 -46
- package/dist/client/hooks/use-server-validation.mjs +156 -41
- package/dist/client/hooks/use-server-widget-data.mjs +1 -1
- package/dist/client/hooks/use-setup-status.d.mts +3 -3
- package/dist/client/hooks/use-setup-status.mjs +2 -2
- package/dist/client/hooks/use-transition-stage.mjs +2 -10
- package/dist/client/hooks/use-validation-error-map.mjs +31 -13
- package/dist/client/hooks/use-view-state.mjs +238 -174
- package/dist/client/i18n/date-locale.mjs +33 -0
- package/dist/client/i18n/hooks.mjs +17 -1
- package/dist/client/lib/utils.mjs +3 -2
- package/dist/client/preview/block-scope-context.d.mts +2 -2
- package/dist/client/preview/preview-banner.d.mts +2 -2
- package/dist/client/preview/preview-banner.mjs +75 -46
- package/dist/client/preview/preview-field.d.mts +4 -4
- package/dist/client/preview/preview-field.mjs +2 -2
- package/dist/client/runtime/provider.mjs +8 -1
- package/dist/client/runtime/translations-provider.mjs +1 -1
- package/dist/client/scope/picker.d.mts +2 -2
- package/dist/client/scope/provider.d.mts +2 -2
- package/dist/client/styles/base.css +1022 -0
- package/dist/client/styles/index.css +3 -589
- package/dist/client/utils/auto-expand-fields.mjs +4 -2
- package/dist/client/utils/keyboard-shortcuts.mjs +26 -0
- package/dist/client/utils/use-lazy-component.mjs +80 -0
- package/dist/client/views/auth/accept-invite-form.d.mts +2 -2
- package/dist/client/views/auth/auth-layout.d.mts +17 -10
- package/dist/client/views/auth/auth-layout.mjs +291 -80
- package/dist/client/views/auth/forgot-password-form.d.mts +2 -2
- package/dist/client/views/auth/forgot-password-form.mjs +2 -2
- package/dist/client/views/auth/login-form.d.mts +2 -2
- package/dist/client/views/auth/login-form.mjs +1 -1
- package/dist/client/views/auth/reset-password-form.d.mts +2 -2
- package/dist/client/views/auth/reset-password-form.mjs +2 -2
- package/dist/client/views/auth/setup-form.d.mts +2 -2
- package/dist/client/views/collection/auto-form-fields.mjs +11 -9
- package/dist/client/views/collection/bulk-action-toolbar.mjs +173 -138
- package/dist/client/views/collection/cells/complex-cells.mjs +22 -22
- package/dist/client/views/collection/cells/primitive-cells.mjs +1 -1
- package/dist/client/views/collection/cells/relation-cells.mjs +147 -129
- package/dist/client/views/collection/cells/shared/asset-thumbnail.mjs +224 -278
- package/dist/client/views/collection/cells/shared/relation-chip.mjs +64 -36
- package/dist/client/views/collection/cells/upload-cells.mjs +199 -9
- package/dist/client/views/collection/columns/build-columns.mjs +29 -9
- package/dist/client/views/collection/columns/column-defaults.mjs +2 -2
- package/dist/client/views/collection/field-renderer.mjs +50 -89
- package/dist/client/views/collection/form-view.mjs +237 -227
- package/dist/client/views/collection/table-view.mjs +1167 -234
- package/dist/client/views/collection/view-skeletons.mjs +222 -79
- package/dist/client/views/common/global-search.mjs +29 -18
- package/dist/client/views/dashboard/dashboard-grid.mjs +678 -501
- package/dist/client/views/dashboard/dashboard-widget.mjs +6 -3
- package/dist/client/views/dashboard/widget-card.mjs +23 -14
- package/dist/client/views/globals/global-form-view.mjs +634 -589
- package/dist/client/views/layout/admin-layout-provider.mjs +67 -70
- package/dist/client/views/layout/admin-layout.d.mts +3 -6
- package/dist/client/views/layout/admin-layout.mjs +152 -155
- package/dist/client/views/layout/admin-router.mjs +936 -616
- package/dist/client/views/layout/admin-sidebar.d.mts +38 -1
- package/dist/client/views/layout/admin-sidebar.mjs +762 -592
- package/dist/client/views/layout/admin-theme.d.mts +10 -0
- package/dist/client/views/layout/admin-theme.mjs +84 -0
- package/dist/client/views/layout/admin-view-layout.mjs +161 -0
- package/dist/client/views/pages/accept-invite-page.d.mts +2 -2
- package/dist/client/views/pages/accept-invite-page.mjs +49 -26
- package/dist/client/views/pages/dashboard-page.d.mts +2 -2
- package/dist/client/views/pages/forgot-password-page.d.mts +2 -2
- package/dist/client/views/pages/forgot-password-page.mjs +2 -19
- package/dist/client/views/pages/invite-page.d.mts +2 -2
- package/dist/client/views/pages/invite-page.mjs +2 -19
- package/dist/client/views/pages/login-page.d.mts +3 -3
- package/dist/client/views/pages/login-page.mjs +4 -21
- package/dist/client/views/pages/reset-password-page.d.mts +2 -2
- package/dist/client/views/pages/reset-password-page.mjs +3 -20
- package/dist/client/views/pages/setup-page.d.mts +2 -2
- package/dist/client/views/pages/setup-page.mjs +70 -71
- package/dist/client.d.mts +6 -2
- package/dist/client.mjs +2 -1
- package/dist/components/rich-text/rich-text-renderer.d.mts +2 -2
- package/dist/index.d.mts +6 -2
- package/dist/index.mjs +2 -1
- package/dist/server/augmentation/dashboard.d.mts +67 -3
- package/dist/server/augmentation/form-layout.d.mts +21 -0
- package/dist/server/augmentation/index.d.mts +1 -1
- package/dist/server/codegen/admin-client-template.mjs +4 -0
- package/dist/server/fields/blocks.d.mts +1 -1
- package/dist/server/fields/blocks.mjs +12 -0
- package/dist/server/fields/rich-text.d.mts +1 -1
- package/dist/server/fields/rich-text.mjs +8 -0
- package/dist/server/i18n/index.mjs +29 -7
- package/dist/server/i18n/messages/cs.mjs +414 -1
- package/dist/server/i18n/messages/de.mjs +412 -1
- package/dist/server/i18n/messages/en.mjs +166 -1
- package/dist/server/i18n/messages/es.mjs +412 -1
- package/dist/server/i18n/messages/fr.mjs +412 -1
- package/dist/server/i18n/messages/pl.mjs +416 -1
- package/dist/server/i18n/messages/pt.mjs +409 -1
- package/dist/server/i18n/messages/sk.mjs +216 -2
- package/dist/server/modules/admin/block/introspection.mjs +4 -1
- package/dist/server/modules/admin/block/prefetch.mjs +12 -2
- package/dist/server/modules/admin/collections/account.d.mts +2 -2
- package/dist/server/modules/admin/collections/admin-locks.d.mts +2 -2
- package/dist/server/modules/admin/collections/admin-preferences.d.mts +39 -39
- package/dist/server/modules/admin/collections/admin-saved-views.d.mts +47 -47
- package/dist/server/modules/admin/collections/apikey.d.mts +42 -42
- package/dist/server/modules/admin/collections/assets.d.mts +20 -20
- package/dist/server/modules/admin/collections/assets.mjs +0 -1
- package/dist/server/modules/admin/collections/session.d.mts +42 -42
- package/dist/server/modules/admin/collections/user.d.mts +40 -28
- package/dist/server/modules/admin/collections/user.mjs +40 -9
- package/dist/server/modules/admin/collections/verification.d.mts +36 -36
- package/dist/server/modules/admin/dto/admin-config.dto.mjs +2 -0
- package/dist/server/modules/admin/factories.mjs +7 -18
- package/dist/server/modules/admin/index.d.mts +1 -1
- package/dist/server/modules/admin/routes/admin-config.d.mts +2 -2
- package/dist/server/modules/admin/routes/admin-config.mjs +34 -16
- package/dist/server/modules/admin/routes/execute-action.d.mts +9 -9
- package/dist/server/modules/admin/routes/execute-action.mjs +67 -28
- package/dist/server/modules/admin/routes/i18n-helpers.mjs +34 -0
- package/dist/server/modules/admin/routes/locales.d.mts +2 -2
- package/dist/server/modules/admin/routes/preview.mjs +25 -17
- package/dist/server/modules/admin/routes/reactive.d.mts +9 -9
- package/dist/server/modules/admin/routes/route-helpers.mjs +1 -1
- package/dist/server/modules/admin/routes/setup.d.mts +10 -10
- package/dist/server/modules/admin/routes/setup.mjs +16 -13
- package/dist/server/modules/admin/routes/translations.d.mts +4 -4
- package/dist/server/modules/admin/routes/translations.mjs +5 -1
- package/dist/server/modules/admin-preferences/collections/admin-preferences.mjs +1 -1
- package/dist/server/modules/admin-preferences/collections/saved-views.d.mts +2 -2
- package/dist/server/modules/audit/.generated/module.d.mts +1 -1
- package/dist/server/modules/audit/.generated/module.mjs +1 -1
- package/dist/server/modules/audit/collections/audit-log.d.mts +2 -2
- package/dist/server/modules/audit/collections/audit-log.mjs +1 -1
- package/dist/server/modules/audit/config/app.mjs +99 -42
- package/dist/server/modules/audit/jobs/audit-cleanup.mjs +1 -1
- package/dist/server/plugin.mjs +4 -2
- package/dist/server/proxy-factories.d.mts +4 -3
- package/dist/server/proxy-factories.mjs +34 -8
- package/dist/shared/types/saved-views.types.d.mts +2 -0
- package/package.json +6 -4
- package/dist/client/components/fields/rich-text-editor/link-popover.mjs +0 -85
- package/dist/client/components/ui/spinner.mjs +0 -52
- package/dist/client/components/ui/toolbar.mjs +0 -136
- package/dist/client/contexts/breadcrumb-context.mjs +0 -60
- package/dist/client/views/layout/admin-topbar.mjs +0 -236
|
@@ -9,39 +9,49 @@ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
|
9
9
|
* Note: This hook requires the `adminModule` to be used in your app setup.
|
|
10
10
|
* If admin_saved_views collection is not available, returns empty array.
|
|
11
11
|
*/
|
|
12
|
-
function useSavedViews(collectionName) {
|
|
13
|
-
const $ = c(
|
|
12
|
+
function useSavedViews(collectionName, userId) {
|
|
13
|
+
const $ = c(11);
|
|
14
14
|
const client = useAdminStore(_temp);
|
|
15
15
|
let t0;
|
|
16
|
-
if ($[0] !== collectionName) {
|
|
17
|
-
t0 = [
|
|
16
|
+
if ($[0] !== collectionName || $[1] !== userId) {
|
|
17
|
+
t0 = [
|
|
18
|
+
"admin_saved_views",
|
|
19
|
+
collectionName,
|
|
20
|
+
userId
|
|
21
|
+
];
|
|
18
22
|
$[0] = collectionName;
|
|
19
|
-
$[1] =
|
|
20
|
-
|
|
23
|
+
$[1] = userId;
|
|
24
|
+
$[2] = t0;
|
|
25
|
+
} else t0 = $[2];
|
|
21
26
|
let t1;
|
|
22
|
-
if ($[
|
|
27
|
+
if ($[3] !== client?.collections || $[4] !== collectionName || $[5] !== userId) {
|
|
23
28
|
t1 = async () => {
|
|
24
29
|
const collections = client?.collections;
|
|
25
30
|
if (!collections?.admin_saved_views) return { docs: [] };
|
|
26
|
-
|
|
31
|
+
const where = userId ? {
|
|
32
|
+
collectionName,
|
|
33
|
+
userId
|
|
34
|
+
} : { collectionName };
|
|
35
|
+
return { docs: (await collections.admin_saved_views.find({ where }))?.docs ?? [] };
|
|
27
36
|
};
|
|
28
|
-
$[
|
|
29
|
-
$[
|
|
30
|
-
$[
|
|
31
|
-
|
|
37
|
+
$[3] = client?.collections;
|
|
38
|
+
$[4] = collectionName;
|
|
39
|
+
$[5] = userId;
|
|
40
|
+
$[6] = t1;
|
|
41
|
+
} else t1 = $[6];
|
|
32
42
|
const t2 = !!client;
|
|
33
43
|
let t3;
|
|
34
|
-
if ($[
|
|
44
|
+
if ($[7] !== t0 || $[8] !== t1 || $[9] !== t2) {
|
|
35
45
|
t3 = {
|
|
36
46
|
queryKey: t0,
|
|
37
47
|
queryFn: t1,
|
|
38
48
|
enabled: t2
|
|
39
49
|
};
|
|
40
|
-
$[
|
|
41
|
-
$[
|
|
42
|
-
$[
|
|
43
|
-
$[
|
|
44
|
-
} else t3 = $[
|
|
50
|
+
$[7] = t0;
|
|
51
|
+
$[8] = t1;
|
|
52
|
+
$[9] = t2;
|
|
53
|
+
$[10] = t3;
|
|
54
|
+
} else t3 = $[10];
|
|
45
55
|
return useQuery(t3);
|
|
46
56
|
}
|
|
47
57
|
/**
|
|
@@ -50,56 +60,62 @@ function useSavedViews(collectionName) {
|
|
|
50
60
|
function _temp(s) {
|
|
51
61
|
return s.client;
|
|
52
62
|
}
|
|
53
|
-
function useSaveView(collectionName) {
|
|
54
|
-
const $ = c(
|
|
63
|
+
function useSaveView(collectionName, userId) {
|
|
64
|
+
const $ = c(11);
|
|
55
65
|
const client = useAdminStore(_temp2);
|
|
56
66
|
const queryClient = useQueryClient();
|
|
57
67
|
let t0;
|
|
58
|
-
if ($[0] !== client?.collections || $[1] !== collectionName) {
|
|
68
|
+
if ($[0] !== client?.collections || $[1] !== collectionName || $[2] !== userId) {
|
|
59
69
|
t0 = async (data) => {
|
|
60
70
|
const collections = client?.collections;
|
|
61
71
|
if (!collections?.admin_saved_views) throw new Error("admin_saved_views collection not available. Make sure to use the adminModule in your app setup.");
|
|
62
72
|
return collections.admin_saved_views.create({
|
|
63
73
|
...data,
|
|
64
74
|
collectionName,
|
|
65
|
-
userId: data.userId || "anonymous",
|
|
75
|
+
userId: data.userId || userId || "anonymous",
|
|
66
76
|
isDefault: false
|
|
67
77
|
});
|
|
68
78
|
};
|
|
69
79
|
$[0] = client?.collections;
|
|
70
80
|
$[1] = collectionName;
|
|
71
|
-
$[2] =
|
|
72
|
-
|
|
81
|
+
$[2] = userId;
|
|
82
|
+
$[3] = t0;
|
|
83
|
+
} else t0 = $[3];
|
|
73
84
|
let t1;
|
|
74
|
-
if ($[
|
|
85
|
+
if ($[4] !== collectionName || $[5] !== queryClient || $[6] !== userId) {
|
|
75
86
|
t1 = () => {
|
|
76
|
-
queryClient.invalidateQueries({ queryKey: [
|
|
87
|
+
queryClient.invalidateQueries({ queryKey: [
|
|
88
|
+
"admin_saved_views",
|
|
89
|
+
collectionName,
|
|
90
|
+
userId
|
|
91
|
+
] });
|
|
77
92
|
};
|
|
78
|
-
$[
|
|
79
|
-
$[
|
|
80
|
-
$[
|
|
81
|
-
|
|
93
|
+
$[4] = collectionName;
|
|
94
|
+
$[5] = queryClient;
|
|
95
|
+
$[6] = userId;
|
|
96
|
+
$[7] = t1;
|
|
97
|
+
} else t1 = $[7];
|
|
82
98
|
let t2;
|
|
83
|
-
if ($[
|
|
99
|
+
if ($[8] !== t0 || $[9] !== t1) {
|
|
84
100
|
t2 = {
|
|
85
101
|
mutationFn: t0,
|
|
86
102
|
onSuccess: t1
|
|
87
103
|
};
|
|
88
|
-
$[
|
|
89
|
-
$[
|
|
90
|
-
$[
|
|
91
|
-
} else t2 = $[
|
|
104
|
+
$[8] = t0;
|
|
105
|
+
$[9] = t1;
|
|
106
|
+
$[10] = t2;
|
|
107
|
+
} else t2 = $[10];
|
|
92
108
|
return useMutation(t2);
|
|
93
109
|
}
|
|
94
110
|
/**
|
|
95
|
-
* Hook to
|
|
111
|
+
* Hook to delete a view
|
|
96
112
|
*/
|
|
97
113
|
function _temp2(s) {
|
|
98
114
|
return s.client;
|
|
99
115
|
}
|
|
100
|
-
function useDeleteSavedView(collectionName) {
|
|
101
|
-
const $ = c(
|
|
102
|
-
const client = useAdminStore(
|
|
116
|
+
function useDeleteSavedView(collectionName, userId) {
|
|
117
|
+
const $ = c(9);
|
|
118
|
+
const client = useAdminStore(_temp3);
|
|
103
119
|
const queryClient = useQueryClient();
|
|
104
120
|
let t0;
|
|
105
121
|
if ($[0] !== client?.collections) {
|
|
@@ -112,27 +128,32 @@ function useDeleteSavedView(collectionName) {
|
|
|
112
128
|
$[1] = t0;
|
|
113
129
|
} else t0 = $[1];
|
|
114
130
|
let t1;
|
|
115
|
-
if ($[2] !== collectionName || $[3] !== queryClient) {
|
|
131
|
+
if ($[2] !== collectionName || $[3] !== queryClient || $[4] !== userId) {
|
|
116
132
|
t1 = () => {
|
|
117
|
-
queryClient.invalidateQueries({ queryKey: [
|
|
133
|
+
queryClient.invalidateQueries({ queryKey: [
|
|
134
|
+
"admin_saved_views",
|
|
135
|
+
collectionName,
|
|
136
|
+
userId
|
|
137
|
+
] });
|
|
118
138
|
};
|
|
119
139
|
$[2] = collectionName;
|
|
120
140
|
$[3] = queryClient;
|
|
121
|
-
$[4] =
|
|
122
|
-
|
|
141
|
+
$[4] = userId;
|
|
142
|
+
$[5] = t1;
|
|
143
|
+
} else t1 = $[5];
|
|
123
144
|
let t2;
|
|
124
|
-
if ($[
|
|
145
|
+
if ($[6] !== t0 || $[7] !== t1) {
|
|
125
146
|
t2 = {
|
|
126
147
|
mutationFn: t0,
|
|
127
148
|
onSuccess: t1
|
|
128
149
|
};
|
|
129
|
-
$[
|
|
130
|
-
$[
|
|
131
|
-
$[
|
|
132
|
-
} else t2 = $[
|
|
150
|
+
$[6] = t0;
|
|
151
|
+
$[7] = t1;
|
|
152
|
+
$[8] = t2;
|
|
153
|
+
} else t2 = $[8];
|
|
133
154
|
return useMutation(t2);
|
|
134
155
|
}
|
|
135
|
-
function
|
|
156
|
+
function _temp3(s) {
|
|
136
157
|
return s.client;
|
|
137
158
|
}
|
|
138
159
|
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
+
import { useTranslation } from "../i18n/hooks.mjs";
|
|
3
4
|
import { selectAdmin, selectClient, useAdminStore } from "../runtime/provider.mjs";
|
|
5
|
+
import { configureField } from "../builder/field/field.mjs";
|
|
4
6
|
import { useCollectionSchema } from "./use-collection-schema.mjs";
|
|
5
7
|
import { c } from "react/compiler-runtime";
|
|
6
8
|
|
|
@@ -12,10 +14,10 @@ import { c } from "react/compiler-runtime";
|
|
|
12
14
|
* Server actions have their handlers stripped during serialization; this hook
|
|
13
15
|
* creates client-side wrappers that execute actions via the server API.
|
|
14
16
|
*/
|
|
15
|
-
function getActionErrorMessage(response) {
|
|
17
|
+
function getActionErrorMessage(response, t) {
|
|
16
18
|
if (response.error) return response.error;
|
|
17
19
|
if (response.result?.toast?.message) return response.result.toast.message;
|
|
18
|
-
return "
|
|
20
|
+
return t("action.executionFailed");
|
|
19
21
|
}
|
|
20
22
|
async function applyServerActionEffects(result, ctx) {
|
|
21
23
|
if (!result) return;
|
|
@@ -28,28 +30,32 @@ function buildServerFormFields(rawFields, fieldRegistry) {
|
|
|
28
30
|
if (!rawFields || !fieldRegistry) return {};
|
|
29
31
|
const result = {};
|
|
30
32
|
for (const [fieldName, fieldConfig] of Object.entries(rawFields)) {
|
|
31
|
-
|
|
32
|
-
if (
|
|
33
|
+
if (!fieldConfig || typeof fieldConfig !== "object") continue;
|
|
34
|
+
if ("name" in fieldConfig && "component" in fieldConfig && "~options" in fieldConfig) {
|
|
33
35
|
result[fieldName] = fieldConfig;
|
|
34
36
|
continue;
|
|
35
37
|
}
|
|
38
|
+
const fc = fieldConfig;
|
|
36
39
|
const fieldBuilder = fieldRegistry[typeof fc.type === "string" && fc.type.length > 0 ? fc.type : "text"] ?? fieldRegistry.text ?? null;
|
|
37
|
-
if (!fieldBuilder
|
|
38
|
-
const options = {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if (fc.
|
|
45
|
-
|
|
40
|
+
if (!fieldBuilder) continue;
|
|
41
|
+
const options = { ...fc };
|
|
42
|
+
delete options.type;
|
|
43
|
+
delete options.options;
|
|
44
|
+
delete options.admin;
|
|
45
|
+
delete options.default;
|
|
46
|
+
if (fc.default !== void 0) options.defaultValue = fc.default;
|
|
47
|
+
else if (fc.defaultValue !== void 0) options.defaultValue = fc.defaultValue;
|
|
48
|
+
if (Array.isArray(fc.options)) options.options = fc.options;
|
|
49
|
+
else if (fc.options && typeof fc.options === "object") Object.assign(options, fc.options);
|
|
50
|
+
if (fc.admin && typeof fc.admin === "object") Object.assign(options, fc.admin);
|
|
51
|
+
result[fieldName] = configureField(fieldBuilder, options);
|
|
46
52
|
}
|
|
47
53
|
return result;
|
|
48
54
|
}
|
|
49
55
|
/**
|
|
50
56
|
* Map a server action definition (from collection schema) to a client ActionDefinition
|
|
51
57
|
*/
|
|
52
|
-
function mapServerAction(serverAction, collection, fieldRegistry, client) {
|
|
58
|
+
function mapServerAction(serverAction, collection, fieldRegistry, client, locale, t) {
|
|
53
59
|
const action = {
|
|
54
60
|
id: serverAction.id,
|
|
55
61
|
label: serverAction.label,
|
|
@@ -86,7 +92,7 @@ function mapServerAction(serverAction, collection, fieldRegistry, client) {
|
|
|
86
92
|
width: form.width,
|
|
87
93
|
onSubmit: async (data, ctx) => {
|
|
88
94
|
const routes = client?.routes;
|
|
89
|
-
if (!routes?.executeAction) throw new Error("
|
|
95
|
+
if (!routes?.executeAction) throw new Error(t("error.serverActionFailed"));
|
|
90
96
|
const itemId = ctx.item && !Array.isArray(ctx.item) ? ctx.item.id : void 0;
|
|
91
97
|
const idsFromItems = Array.isArray(ctx.items) ? ctx.items.map((it) => it?.id).filter(Boolean) : [];
|
|
92
98
|
const idsFromItemArray = Array.isArray(ctx.item) ? ctx.item.map((it) => it?.id).filter(Boolean) : [];
|
|
@@ -96,9 +102,10 @@ function mapServerAction(serverAction, collection, fieldRegistry, client) {
|
|
|
96
102
|
actionId: serverAction.id,
|
|
97
103
|
itemId,
|
|
98
104
|
itemIds,
|
|
99
|
-
data
|
|
105
|
+
data,
|
|
106
|
+
locale
|
|
100
107
|
});
|
|
101
|
-
if (!response.success || response.result?.type === "error") throw new Error(getActionErrorMessage(response));
|
|
108
|
+
if (!response.success || response.result?.type === "error") throw new Error(getActionErrorMessage(response, t));
|
|
102
109
|
await applyServerActionEffects(response.result, ctx);
|
|
103
110
|
}
|
|
104
111
|
}
|
|
@@ -117,48 +124,60 @@ function mapServerAction(serverAction, collection, fieldRegistry, client) {
|
|
|
117
124
|
* ```
|
|
118
125
|
*/
|
|
119
126
|
function useServerActions(t0) {
|
|
120
|
-
const $ = c(
|
|
121
|
-
const { collection } = t0;
|
|
127
|
+
const $ = c(13);
|
|
128
|
+
const { collection, schema: schemaOverride } = t0;
|
|
122
129
|
const admin = useAdminStore(selectAdmin);
|
|
123
130
|
const client = useAdminStore(selectClient);
|
|
124
|
-
const {
|
|
131
|
+
const { t, locale } = useTranslation();
|
|
132
|
+
const t1 = !schemaOverride;
|
|
133
|
+
let t2;
|
|
134
|
+
if ($[0] !== t1) {
|
|
135
|
+
t2 = { enabled: t1 };
|
|
136
|
+
$[0] = t1;
|
|
137
|
+
$[1] = t2;
|
|
138
|
+
} else t2 = $[1];
|
|
139
|
+
const { data: queriedSchema, isPending: isSchemaPending } = useCollectionSchema(collection, t2);
|
|
140
|
+
const schema = schemaOverride ?? queriedSchema;
|
|
141
|
+
const isPending = schemaOverride ? false : isSchemaPending;
|
|
125
142
|
schema?.admin?.actions;
|
|
126
|
-
let
|
|
143
|
+
let t3;
|
|
127
144
|
bb0: {
|
|
128
145
|
const actionsConfig = schema?.admin?.actions;
|
|
129
146
|
if (!actionsConfig?.custom?.length) {
|
|
130
|
-
let
|
|
131
|
-
if ($[
|
|
132
|
-
|
|
133
|
-
$[
|
|
134
|
-
} else
|
|
135
|
-
|
|
147
|
+
let t4$2;
|
|
148
|
+
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
149
|
+
t4$2 = [];
|
|
150
|
+
$[2] = t4$2;
|
|
151
|
+
} else t4$2 = $[2];
|
|
152
|
+
t3 = t4$2;
|
|
136
153
|
break bb0;
|
|
137
154
|
}
|
|
138
|
-
let
|
|
139
|
-
if ($[
|
|
155
|
+
let t4$1;
|
|
156
|
+
if ($[3] !== actionsConfig.custom || $[4] !== admin || $[5] !== client || $[6] !== collection || $[7] !== locale || $[8] !== t) {
|
|
140
157
|
const fieldRegistry = admin?.getFields?.() ?? null;
|
|
141
|
-
|
|
142
|
-
$[
|
|
143
|
-
$[
|
|
144
|
-
$[
|
|
145
|
-
$[
|
|
146
|
-
$[
|
|
147
|
-
|
|
148
|
-
|
|
158
|
+
t4$1 = actionsConfig.custom.map((serverAction) => mapServerAction(serverAction, collection, fieldRegistry, client, locale, t));
|
|
159
|
+
$[3] = actionsConfig.custom;
|
|
160
|
+
$[4] = admin;
|
|
161
|
+
$[5] = client;
|
|
162
|
+
$[6] = collection;
|
|
163
|
+
$[7] = locale;
|
|
164
|
+
$[8] = t;
|
|
165
|
+
$[9] = t4$1;
|
|
166
|
+
} else t4$1 = $[9];
|
|
167
|
+
t3 = t4$1;
|
|
149
168
|
}
|
|
150
|
-
const serverActions =
|
|
151
|
-
let
|
|
152
|
-
if ($[
|
|
153
|
-
|
|
169
|
+
const serverActions = t3;
|
|
170
|
+
let t4;
|
|
171
|
+
if ($[10] !== isPending || $[11] !== serverActions) {
|
|
172
|
+
t4 = {
|
|
154
173
|
serverActions,
|
|
155
174
|
isLoading: isPending
|
|
156
175
|
};
|
|
157
|
-
$[
|
|
158
|
-
$[
|
|
159
|
-
$[
|
|
160
|
-
} else
|
|
161
|
-
return
|
|
176
|
+
$[10] = isPending;
|
|
177
|
+
$[11] = serverActions;
|
|
178
|
+
$[12] = t4;
|
|
179
|
+
} else t4 = $[12];
|
|
180
|
+
return t4;
|
|
162
181
|
}
|
|
163
182
|
/**
|
|
164
183
|
* Merge server actions with local actions config.
|
|
@@ -168,11 +187,15 @@ function mergeServerActions(localActions, serverActions) {
|
|
|
168
187
|
if (!serverActions.length) return localActions;
|
|
169
188
|
const headerActions = [...localActions.header?.primary ?? []];
|
|
170
189
|
const headerSecondary = [...localActions.header?.secondary ?? []];
|
|
190
|
+
const rowActions = [...localActions.row ?? []];
|
|
171
191
|
const bulkActions = [...localActions.bulk ?? []];
|
|
172
192
|
for (const action of serverActions) switch (action.scope) {
|
|
173
193
|
case "bulk":
|
|
174
194
|
bulkActions.push(action);
|
|
175
195
|
break;
|
|
196
|
+
case "row":
|
|
197
|
+
rowActions.push(action);
|
|
198
|
+
break;
|
|
176
199
|
case "header":
|
|
177
200
|
headerActions.push(action);
|
|
178
201
|
break;
|
|
@@ -183,6 +206,7 @@ function mergeServerActions(localActions, serverActions) {
|
|
|
183
206
|
primary: headerActions,
|
|
184
207
|
secondary: headerSecondary
|
|
185
208
|
},
|
|
209
|
+
row: rowActions,
|
|
186
210
|
bulk: bulkActions
|
|
187
211
|
};
|
|
188
212
|
}
|