@firecms/core 3.4.0-canary.63041d0 → 3.4.0-canary.9408c41
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 +4 -0
- package/dist/components/EntityCollectionTable/internal/popup_field/PopupFormField.d.ts +3 -1
- package/dist/components/EntityCollectionView/EntityCollectionBoardView.d.ts +3 -1
- package/dist/components/EntityCollectionView/EntityCollectionView.d.ts +3 -2
- package/dist/components/EntityCollectionView/EntityCollectionViewActions.d.ts +3 -1
- package/dist/components/EntityCollectionView/EntityCollectionViewStartActions.d.ts +3 -1
- package/dist/components/EntityCollectionView/useBoardDataController.d.ts +3 -1
- package/dist/components/ErrorBoundary.d.ts +1 -3
- package/dist/components/LicenseBanner.d.ts +23 -0
- package/dist/components/ReferenceTable/ReferenceSelectionTable.d.ts +10 -1
- package/dist/components/common/useDataSourceTableController.d.ts +4 -2
- package/dist/components/common/useTableSearchHelper.d.ts +3 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/contexts/LicenseStatusContext.d.ts +16 -0
- package/dist/core/EntityEditView.d.ts +2 -0
- package/dist/core/EntityEditViewFormActions.d.ts +1 -1
- package/dist/core/index.d.ts +1 -0
- package/dist/core/plugin_translations.d.ts +38 -0
- package/dist/core/pro_plugins.d.ts +40 -0
- package/dist/de-DMp6cIY1.js +702 -0
- package/dist/de-DMp6cIY1.js.map +1 -0
- package/dist/editor/extensions/Image.d.ts +11 -0
- package/dist/editor/index.d.ts +2 -1
- package/dist/editor/lazy_editor.d.ts +6 -0
- package/dist/editor-BSo_aS1I.js +4563 -0
- package/dist/editor-BSo_aS1I.js.map +1 -0
- package/dist/form/EntityForm.d.ts +8 -1
- package/dist/form/EntityFormActions.d.ts +2 -0
- package/dist/fr-Cckz4IkR.js +702 -0
- package/dist/fr-Cckz4IkR.js.map +1 -0
- package/dist/hi-CDCoIqbu.js +702 -0
- package/dist/hi-CDCoIqbu.js.map +1 -0
- package/dist/hooks/data/delete.d.ts +1 -1
- package/dist/hooks/data/useCollectionFetch.d.ts +7 -1
- package/dist/hooks/data/useEntityFetch.d.ts +4 -1
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/useLicenseStatus.d.ts +16 -0
- package/dist/hooks/useProjectLog.d.ts +11 -6
- package/dist/hooks/useTranslation.d.ts +1 -1
- package/dist/i18n/__tests__/FireCMSi18nProvider.test.d.ts +1 -0
- package/dist/i18n/__tests__/nested_provider_lifecycle.test.d.ts +1 -0
- package/dist/index.es.js +3113 -10785
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +7939 -6836
- package/dist/index.umd.js.map +1 -1
- package/dist/it-BJCUqixj.js +702 -0
- package/dist/it-BJCUqixj.js.map +1 -0
- package/dist/pl-DgT_joFf.js +704 -0
- package/dist/pl-DgT_joFf.js.map +1 -0
- package/dist/pt-B3dN3x0X.js +704 -0
- package/dist/pt-B3dN3x0X.js.map +1 -0
- package/dist/types/analytics.d.ts +1 -1
- package/dist/types/collections.d.ts +7 -0
- package/dist/types/datasource.d.ts +25 -4
- package/dist/types/entities.d.ts +21 -1
- package/dist/types/entity_actions.d.ts +6 -0
- package/dist/types/entity_callbacks.d.ts +21 -0
- package/dist/types/firecms.d.ts +18 -1
- package/dist/types/firecms_context.d.ts +8 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/license.d.ts +54 -0
- package/dist/types/navigation.d.ts +34 -5
- package/dist/types/plugins.d.ts +22 -1
- package/dist/types/side_entity_controller.d.ts +3 -2
- package/dist/types/translations.d.ts +35 -2
- package/dist/util/date_fns_locales.d.ts +18 -0
- package/dist/util/entity_cache.d.ts +11 -0
- package/dist/util/index.d.ts +1 -0
- package/dist/util/lazy_eager.d.ts +3 -3
- package/dist/util/navigation_utils.d.ts +84 -2
- package/dist/util/parent_references_from_path.d.ts +16 -0
- package/dist/util/paths.d.ts +28 -0
- package/dist/util/permissions.d.ts +10 -4
- package/package.json +5 -6
- package/src/app/Scaffold.tsx +7 -0
- package/src/components/DeleteEntityDialog.tsx +2 -0
- package/src/components/EntityCollectionTable/EntityCollectionRowActions.tsx +2 -2
- package/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +5 -1
- package/src/components/EntityCollectionView/EntityCollectionBoardView.tsx +12 -0
- package/src/components/EntityCollectionView/EntityCollectionView.tsx +49 -16
- package/src/components/EntityCollectionView/EntityCollectionViewActions.tsx +6 -2
- package/src/components/EntityCollectionView/EntityCollectionViewStartActions.tsx +4 -0
- package/src/components/EntityCollectionView/useBoardDataController.tsx +17 -1
- package/src/components/EntityPreview.tsx +4 -1
- package/src/components/ErrorBoundary.tsx +12 -18
- package/src/components/LicenseBanner.tsx +209 -0
- package/src/components/ReferenceTable/ReferenceSelectionTable.tsx +19 -2
- package/src/components/common/default_entity_actions.tsx +22 -2
- package/src/components/common/useDataSourceTableController.tsx +32 -8
- package/src/components/common/useTableSearchHelper.ts +5 -0
- package/src/components/index.tsx +1 -0
- package/src/contexts/LicenseStatusContext.tsx +50 -0
- package/src/core/DefaultAppBar.tsx +28 -16
- package/src/core/EntityEditView.tsx +11 -12
- package/src/core/EntityEditViewFormActions.tsx +3 -2
- package/src/core/EntitySidePanel.tsx +6 -4
- package/src/core/FireCMS.tsx +73 -47
- package/src/core/SideDialogs.tsx +44 -1
- package/src/core/index.tsx +1 -0
- package/src/core/plugin_translations.ts +87 -0
- package/src/core/pro_plugins.ts +79 -0
- package/src/editor/components/SlashCommandMenu.tsx +4 -1
- package/src/editor/extensions/Image.ts +17 -1
- package/src/editor/hooks/useProseMirror.ts +5 -0
- package/src/editor/index.ts +11 -1
- package/src/editor/lazy_editor.tsx +33 -0
- package/src/form/EntityForm.tsx +30 -9
- package/src/form/EntityFormActions.tsx +2 -0
- package/src/hooks/data/delete.ts +8 -0
- package/src/hooks/data/save.ts +5 -2
- package/src/hooks/data/useCollectionFetch.tsx +21 -1
- package/src/hooks/data/useEntityFetch.tsx +28 -6
- package/src/hooks/index.tsx +2 -0
- package/src/hooks/useBuildNavigationController.tsx +70 -15
- package/src/hooks/useFireCMSContext.tsx +7 -3
- package/src/hooks/useLicenseStatus.tsx +32 -0
- package/src/hooks/useProjectLog.tsx +27 -9
- package/src/hooks/useResolvedNavigationFrom.tsx +3 -1
- package/src/hooks/useTranslation.ts +3 -1
- package/src/i18n/FireCMSi18nProvider.tsx +199 -25
- package/src/i18n/__tests__/FireCMSi18nProvider.test.tsx +91 -0
- package/src/i18n/__tests__/nested_provider_lifecycle.test.tsx +67 -0
- package/src/internal/useBuildDataSource.ts +26 -15
- package/src/internal/useBuildSideEntityController.tsx +13 -5
- package/src/locales/de.ts +18 -2
- package/src/locales/en.ts +21 -3
- package/src/locales/es.ts +18 -2
- package/src/locales/fr.ts +18 -2
- package/src/locales/hi.ts +18 -2
- package/src/locales/it.ts +18 -2
- package/src/locales/pl.ts +18 -2
- package/src/locales/pt.ts +18 -2
- package/src/preview/components/DatePreview.tsx +2 -4
- package/src/preview/components/ReferencePreview.tsx +7 -3
- package/src/routes/FireCMSRoute.tsx +9 -4
- package/src/types/analytics.ts +3 -0
- package/src/types/collections.ts +8 -0
- package/src/types/datasource.ts +25 -4
- package/src/types/entities.ts +24 -1
- package/src/types/entity_actions.tsx +6 -0
- package/src/types/entity_callbacks.ts +24 -0
- package/src/types/firecms.tsx +19 -1
- package/src/types/firecms_context.tsx +9 -0
- package/src/types/index.ts +1 -0
- package/src/types/license.ts +62 -0
- package/src/types/navigation.ts +35 -5
- package/src/types/plugins.tsx +23 -1
- package/src/types/side_entity_controller.tsx +3 -2
- package/src/types/translations.ts +35 -2
- package/src/util/date_fns_locales.ts +168 -0
- package/src/util/entities.ts +3 -1
- package/src/util/entity_cache.ts +18 -0
- package/src/util/index.ts +1 -0
- package/src/util/lazy_eager.tsx +30 -8
- package/src/util/navigation_from_path.ts +6 -1
- package/src/util/navigation_utils.ts +210 -3
- package/src/util/parent_references_from_path.ts +42 -3
- package/src/util/paths.ts +40 -3
- package/src/util/permissions.ts +22 -10
- package/src/util/useStorageUploadController.tsx +6 -1
package/src/util/permissions.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AuthController, Entity, EntityCollection, Permissions, User } from "../types";
|
|
2
|
-
import { fullPathToCollectionSegments } from "./paths";
|
|
2
|
+
import { collectionSegmentsFrom, fullPathToCollectionSegments } from "./paths";
|
|
3
3
|
|
|
4
4
|
const DEFAULT_PERMISSIONS = {
|
|
5
5
|
read: true,
|
|
@@ -8,11 +8,18 @@ const DEFAULT_PERMISSIONS = {
|
|
|
8
8
|
delete: true
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* `pathSegments` is `path` split at its real segment boundaries. It is forwarded so the
|
|
13
|
+
* collection chain handed to a permissions builder stays correct when an entity id contains
|
|
14
|
+
* "/" — splitting `path` positionally would keep the wrong elements. Optional everywhere:
|
|
15
|
+
* omitted, behaviour is exactly as before.
|
|
16
|
+
*/
|
|
11
17
|
export function resolvePermissions<M extends Record<string, any>, USER extends User>
|
|
12
18
|
(collection: EntityCollection<M>,
|
|
13
19
|
authController: AuthController<USER>,
|
|
14
20
|
path: string,
|
|
15
|
-
entity: Entity<M> | null
|
|
21
|
+
entity: Entity<M> | null,
|
|
22
|
+
pathSegments?: string[]): Permissions | undefined {
|
|
16
23
|
|
|
17
24
|
const permission = collection.permissions;
|
|
18
25
|
if (permission === undefined) {
|
|
@@ -20,14 +27,16 @@ export function resolvePermissions<M extends Record<string, any>, USER extends U
|
|
|
20
27
|
} else if (typeof permission === "object") {
|
|
21
28
|
return permission as Permissions;
|
|
22
29
|
} else if (typeof permission === "function") {
|
|
23
|
-
const
|
|
30
|
+
const collectionSegments = pathSegments
|
|
31
|
+
? collectionSegmentsFrom(pathSegments)
|
|
32
|
+
: fullPathToCollectionSegments(path);
|
|
24
33
|
return permission({
|
|
25
34
|
entity,
|
|
26
35
|
path,
|
|
27
36
|
user: authController.user,
|
|
28
37
|
authController,
|
|
29
38
|
collection,
|
|
30
|
-
pathSegments
|
|
39
|
+
pathSegments: collectionSegments
|
|
31
40
|
});
|
|
32
41
|
}
|
|
33
42
|
console.error("Permissions:", permission);
|
|
@@ -39,8 +48,9 @@ export function canEditEntity<M extends Record<string, any>, USER extends User>
|
|
|
39
48
|
collection: EntityCollection<M>,
|
|
40
49
|
authController: AuthController<USER>,
|
|
41
50
|
path: string,
|
|
42
|
-
entity: Entity<M> | null
|
|
43
|
-
|
|
51
|
+
entity: Entity<M> | null,
|
|
52
|
+
pathSegments?: string[]): boolean {
|
|
53
|
+
return resolvePermissions(collection, authController, path, entity, pathSegments)?.edit ?? DEFAULT_PERMISSIONS.edit;
|
|
44
54
|
}
|
|
45
55
|
|
|
46
56
|
export function canCreateEntity<M extends Record<string, any>, USER extends User>
|
|
@@ -48,9 +58,10 @@ export function canCreateEntity<M extends Record<string, any>, USER extends User
|
|
|
48
58
|
collection: EntityCollection<M>,
|
|
49
59
|
authController: AuthController<USER>,
|
|
50
60
|
path: string,
|
|
51
|
-
entity: Entity<M> | null
|
|
61
|
+
entity: Entity<M> | null,
|
|
62
|
+
pathSegments?: string[]): boolean {
|
|
52
63
|
if (collection.collectionGroup) return false;
|
|
53
|
-
return resolvePermissions(collection, authController, path, entity)?.create ?? DEFAULT_PERMISSIONS.create;
|
|
64
|
+
return resolvePermissions(collection, authController, path, entity, pathSegments)?.create ?? DEFAULT_PERMISSIONS.create;
|
|
54
65
|
}
|
|
55
66
|
|
|
56
67
|
export function canDeleteEntity<M extends Record<string, any>, USER extends User>
|
|
@@ -58,8 +69,9 @@ export function canDeleteEntity<M extends Record<string, any>, USER extends User
|
|
|
58
69
|
collection: EntityCollection<M>,
|
|
59
70
|
authController: AuthController<USER>,
|
|
60
71
|
path: string,
|
|
61
|
-
entity: Entity<M> | null
|
|
62
|
-
|
|
72
|
+
entity: Entity<M> | null,
|
|
73
|
+
pathSegments?: string[]): boolean {
|
|
74
|
+
return resolvePermissions(collection, authController, path, entity, pathSegments)?.delete ?? DEFAULT_PERMISSIONS.delete;
|
|
63
75
|
}
|
|
64
76
|
|
|
65
77
|
// export function resolveCollectionsPermissions(roles: Role[]): Record<string, Permissions> {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type CompressorType from "compressorjs";
|
|
2
2
|
import equal from "react-fast-compare";
|
|
3
3
|
|
|
4
4
|
import {
|
|
@@ -321,6 +321,11 @@ export async function resizeImage(
|
|
|
321
321
|
mimeType = `image/${imageResize.format}`;
|
|
322
322
|
}
|
|
323
323
|
|
|
324
|
+
// Loaded here rather than imported: compressing an image is something a
|
|
325
|
+
// small fraction of sessions ever does, and a static import put the library
|
|
326
|
+
// in `@firecms/core` for everyone.
|
|
327
|
+
const Compressor: typeof CompressorType = (await import("compressorjs")).default;
|
|
328
|
+
|
|
324
329
|
return new Promise<File>((resolve, reject) => {
|
|
325
330
|
new Compressor(file, {
|
|
326
331
|
quality,
|