@firecms/core 3.0.0-canary.5 → 3.0.0-canary.50
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 +2 -2
- package/dist/components/ClearFilterSortButton.d.ts +5 -0
- package/dist/components/EntityCollectionTable/EntityCollectionRowActions.d.ts +11 -11
- package/dist/components/EntityCollectionTable/EntityCollectionTable.d.ts +2 -2
- package/dist/components/EntityCollectionTable/EntityCollectionTableProps.d.ts +5 -3
- package/dist/components/EntityCollectionTable/PropertyTableCell.d.ts +3 -2
- package/dist/components/EntityCollectionTable/column_utils.d.ts +1 -2
- package/dist/components/EntityCollectionTable/internal/CollectionTableToolbar.d.ts +1 -4
- package/dist/components/EntityCollectionTable/internal/popup_field/PopupFormField.d.ts +1 -1
- package/dist/components/EntityCollectionView/EntityCollectionView.d.ts +12 -3
- package/dist/components/EntityCollectionView/EntityCollectionViewStartActions.d.ts +11 -0
- package/dist/components/EntityCollectionView/useSelectionController.d.ts +2 -0
- package/dist/components/EntityPreview.d.ts +25 -7
- package/dist/components/EntityView.d.ts +11 -0
- package/dist/components/FieldCaption.d.ts +5 -0
- package/dist/components/FireCMSAppBar.d.ts +3 -2
- package/dist/components/HomePage/NavigationCard.d.ts +8 -0
- package/dist/components/HomePage/{NavigationCollectionCard.d.ts → NavigationCardBinding.d.ts} +2 -2
- package/dist/components/HomePage/SmallNavigationCard.d.ts +6 -0
- package/dist/components/HomePage/index.d.ts +3 -1
- package/dist/components/SelectableTable/SelectableTable.d.ts +1 -1
- package/dist/components/VirtualTable/VirtualTableProps.d.ts +1 -1
- package/dist/components/common/types.d.ts +4 -6
- package/dist/components/common/useDataSourceEntityCollectionTableController.d.ts +3 -0
- package/dist/components/index.d.ts +4 -2
- package/dist/contexts/AuthControllerContext.d.ts +1 -1
- package/dist/core/{EntityView.d.ts → EntityEditView.d.ts} +2 -2
- package/dist/core/NavigationRoutes.d.ts +1 -1
- package/dist/core/Scaffold.d.ts +1 -1
- package/dist/form/EntityForm.d.ts +1 -1
- package/dist/form/components/ErrorFocus.d.ts +1 -1
- package/dist/form/components/StorageItemPreview.d.ts +3 -2
- package/dist/form/components/StorageUploadProgress.d.ts +1 -1
- package/dist/form/field_bindings/KeyValueFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/MapFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/StorageUploadFieldBinding.d.ts +4 -3
- package/dist/form/field_bindings/TextFieldBinding.d.ts +2 -2
- package/dist/form/validation.d.ts +1 -1
- package/dist/hooks/data/delete.d.ts +2 -2
- package/dist/hooks/data/save.d.ts +2 -3
- package/dist/hooks/data/useDataSource.d.ts +2 -2
- package/dist/hooks/data/useEntityFetch.d.ts +3 -3
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/useBuildNavigationController.d.ts +6 -4
- package/dist/hooks/useProjectLog.d.ts +6 -2
- package/dist/hooks/useStorageSource.d.ts +2 -2
- package/dist/hooks/useValidateAuthenticator.d.ts +21 -0
- package/dist/index.es.js +10402 -9898
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +5 -5
- package/dist/index.umd.js.map +1 -1
- package/dist/internal/useBuildDataSource.d.ts +1 -12
- package/dist/preview/PropertyPreview.d.ts +1 -1
- package/dist/preview/PropertyPreviewProps.d.ts +1 -4
- package/dist/preview/components/BooleanPreview.d.ts +5 -1
- package/dist/preview/components/EnumValuesChip.d.ts +1 -1
- package/dist/preview/components/ReferencePreview.d.ts +1 -7
- package/dist/types/analytics.d.ts +1 -1
- package/dist/types/auth.d.ts +37 -1
- package/dist/types/collections.d.ts +29 -5
- package/dist/types/datasource.d.ts +3 -6
- package/dist/types/entities.d.ts +5 -1
- package/dist/types/entity_actions.d.ts +14 -0
- package/dist/types/entity_callbacks.d.ts +2 -2
- package/dist/types/entity_overrides.d.ts +6 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/navigation.d.ts +14 -13
- package/dist/types/permissions.d.ts +5 -1
- package/dist/types/plugins.d.ts +20 -20
- package/dist/types/properties.d.ts +4 -4
- package/dist/types/property_config.d.ts +2 -2
- package/dist/types/roles.d.ts +31 -0
- package/dist/types/storage.d.ts +11 -3
- package/dist/types/user.d.ts +5 -0
- package/dist/util/collections.d.ts +9 -1
- package/dist/util/entities.d.ts +1 -1
- package/dist/util/icon_synonyms.d.ts +1 -4
- package/dist/util/icons.d.ts +8 -2
- package/dist/util/navigation_utils.d.ts +2 -2
- package/dist/util/permissions.d.ts +4 -4
- package/dist/util/references.d.ts +4 -2
- package/dist/util/resolutions.d.ts +9 -13
- package/dist/util/useTraceUpdate.d.ts +1 -0
- package/package.json +139 -119
- package/src/components/ClearFilterSortButton.tsx +41 -0
- package/src/components/DeleteEntityDialog.tsx +4 -4
- package/src/components/EntityCollectionTable/EntityCollectionRowActions.tsx +2 -2
- package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +275 -278
- package/src/components/EntityCollectionTable/EntityCollectionTableProps.tsx +9 -5
- package/src/components/EntityCollectionTable/PropertyTableCell.tsx +44 -44
- package/src/components/EntityCollectionTable/column_utils.tsx +3 -3
- package/src/components/EntityCollectionTable/fields/TableReferenceField.tsx +9 -16
- package/src/components/EntityCollectionTable/fields/TableStorageUpload.tsx +3 -3
- package/src/components/EntityCollectionTable/internal/CollectionTableToolbar.tsx +27 -32
- package/src/components/EntityCollectionTable/internal/EntityTableCell.tsx +11 -6
- package/src/components/EntityCollectionTable/internal/default_entity_actions.tsx +9 -5
- package/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +2 -4
- package/src/components/EntityCollectionView/EntityCollectionView.tsx +69 -64
- package/src/components/EntityCollectionView/EntityCollectionViewActions.tsx +5 -6
- package/src/components/EntityCollectionView/EntityCollectionViewStartActions.tsx +68 -0
- package/src/components/EntityCollectionView/useSelectionController.tsx +30 -0
- package/src/components/EntityPreview.tsx +207 -70
- package/src/components/EntityView.tsx +84 -0
- package/src/components/FieldCaption.tsx +14 -0
- package/src/components/FireCMSAppBar.tsx +33 -11
- package/src/components/HomePage/DefaultHomePage.tsx +15 -11
- package/src/components/HomePage/NavigationCard.tsx +69 -0
- package/src/components/HomePage/NavigationCardBinding.tsx +116 -0
- package/src/components/HomePage/SmallNavigationCard.tsx +45 -0
- package/src/components/HomePage/index.tsx +3 -1
- package/src/components/ReferenceTable/ReferenceSelectionTable.tsx +4 -4
- package/src/components/ReferenceWidget.tsx +4 -4
- package/src/components/SearchIconsView.tsx +4 -4
- package/src/components/SelectableTable/SelectableTable.tsx +1 -1
- package/src/components/SelectableTable/filters/BooleanFilterField.tsx +2 -3
- package/src/components/SelectableTable/filters/DateTimeFilterField.tsx +23 -8
- package/src/components/SelectableTable/filters/ReferenceFilterField.tsx +35 -24
- package/src/components/SelectableTable/filters/StringNumberFilterField.tsx +35 -15
- package/src/components/VirtualTable/VirtualTable.tsx +28 -20
- package/src/components/VirtualTable/VirtualTableProps.tsx +1 -1
- package/src/components/VirtualTable/fields/VirtualTableDateField.tsx +1 -1
- package/src/components/common/types.tsx +4 -6
- package/src/components/common/useDataSourceEntityCollectionTableController.tsx +12 -1
- package/src/components/index.tsx +4 -2
- package/src/contexts/AuthControllerContext.tsx +1 -1
- package/src/core/Drawer.tsx +66 -39
- package/src/core/{EntityView.tsx → EntityEditView.tsx} +21 -40
- package/src/core/EntitySidePanel.tsx +2 -2
- package/src/core/FireCMS.tsx +18 -3
- package/src/core/NavigationRoutes.tsx +11 -4
- package/src/core/Scaffold.tsx +5 -4
- package/src/core/field_configs.tsx +1 -2
- package/src/form/EntityForm.tsx +40 -21
- package/src/form/PropertyFieldBinding.tsx +0 -2
- package/src/form/components/StorageItemPreview.tsx +5 -3
- package/src/form/components/StorageUploadProgress.tsx +7 -6
- package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +8 -12
- package/src/form/field_bindings/DateTimeFieldBinding.tsx +1 -1
- package/src/form/field_bindings/KeyValueFieldBinding.tsx +15 -15
- package/src/form/field_bindings/MapFieldBinding.tsx +15 -15
- package/src/form/field_bindings/ReadOnlyFieldBinding.tsx +1 -1
- package/src/form/field_bindings/ReferenceFieldBinding.tsx +1 -0
- package/src/form/field_bindings/StorageUploadFieldBinding.tsx +14 -5
- package/src/form/field_bindings/TextFieldBinding.tsx +7 -5
- package/src/form/validation.ts +3 -4
- package/src/hooks/data/delete.ts +3 -3
- package/src/hooks/data/save.ts +2 -2
- package/src/hooks/data/useCollectionFetch.tsx +1 -1
- package/src/hooks/data/useDataSource.tsx +8 -3
- package/src/hooks/data/useEntityFetch.tsx +4 -4
- package/src/hooks/index.tsx +2 -0
- package/src/hooks/useBuildLocalConfigurationPersistence.tsx +9 -10
- package/src/hooks/useBuildModeController.tsx +11 -5
- package/src/hooks/useBuildNavigationController.tsx +199 -81
- package/src/hooks/useProjectLog.tsx +17 -7
- package/src/hooks/useReferenceDialog.tsx +2 -2
- package/src/hooks/useStorageSource.tsx +7 -2
- package/src/hooks/useValidateAuthenticator.tsx +115 -0
- package/src/internal/useBuildDataSource.ts +42 -44
- package/src/internal/useBuildSideEntityController.tsx +86 -20
- package/src/preview/PropertyPreview.tsx +3 -14
- package/src/preview/PropertyPreviewProps.tsx +1 -11
- package/src/preview/components/BooleanPreview.tsx +19 -4
- package/src/preview/components/EnumValuesChip.tsx +1 -1
- package/src/preview/components/ReferencePreview.tsx +55 -147
- package/src/preview/property_previews/ArrayOfMapsPreview.tsx +0 -1
- package/src/preview/property_previews/ArrayOfReferencesPreview.tsx +0 -1
- package/src/preview/property_previews/ArrayOfStorageComponentsPreview.tsx +0 -1
- package/src/preview/property_previews/ArrayOfStringsPreview.tsx +0 -1
- package/src/preview/property_previews/ArrayOneOfPreview.tsx +0 -1
- package/src/preview/property_previews/ArrayPropertyPreview.tsx +0 -1
- package/src/preview/property_previews/StringPropertyPreview.tsx +8 -7
- package/src/types/analytics.ts +1 -0
- package/src/types/auth.tsx +50 -1
- package/src/types/collections.ts +33 -5
- package/src/types/datasource.ts +8 -5
- package/src/types/entities.ts +9 -1
- package/src/types/entity_actions.tsx +17 -0
- package/src/types/entity_callbacks.ts +2 -2
- package/src/types/entity_overrides.tsx +7 -0
- package/src/types/firecms.tsx +0 -1
- package/src/types/index.ts +2 -1
- package/src/types/navigation.ts +17 -16
- package/src/types/permissions.ts +6 -1
- package/src/types/plugins.tsx +26 -28
- package/src/types/properties.ts +8 -6
- package/src/types/property_config.tsx +2 -2
- package/src/types/roles.ts +41 -0
- package/src/types/side_entity_controller.tsx +1 -0
- package/src/types/storage.ts +12 -3
- package/src/types/user.ts +7 -0
- package/src/util/collections.ts +22 -0
- package/src/util/entities.ts +1 -1
- package/src/util/icon_list.ts +2 -2
- package/src/util/icon_synonyms.ts +1 -4
- package/src/util/icons.tsx +11 -3
- package/src/util/navigation_utils.ts +6 -6
- package/src/util/objects.ts +0 -14
- package/src/util/permissions.ts +11 -8
- package/src/util/references.ts +36 -5
- package/src/util/resolutions.ts +6 -24
- package/src/util/strings.ts +2 -2
- package/src/util/useTraceUpdate.tsx +2 -1
- package/dist/core/SideEntityView.d.ts +0 -7
- package/dist/internal/useLocaleConfig.d.ts +0 -1
- package/dist/types/appcheck.d.ts +0 -26
- package/src/components/HomePage/NavigationCollectionCard.tsx +0 -146
- package/src/core/SideEntityView.tsx +0 -38
- package/src/internal/useLocaleConfig.tsx +0 -18
- package/src/types/appcheck.ts +0 -29
|
@@ -5,9 +5,25 @@ import { EntityCollection, SelectionController } from "./collections";
|
|
|
5
5
|
import { User } from "./user";
|
|
6
6
|
import { SideEntityController } from "./side_entity_controller";
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* An entity action is a custom action that can be performed on an entity.
|
|
10
|
+
* They are displayed in the entity view and in the collection view.
|
|
11
|
+
*/
|
|
8
12
|
export type EntityAction<M extends object = any, UserType extends User = User> = {
|
|
13
|
+
/**
|
|
14
|
+
* Title of the action
|
|
15
|
+
*/
|
|
9
16
|
name: string;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Icon of the action
|
|
20
|
+
*/
|
|
10
21
|
icon?: React.ReactElement;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Callback when the action is clicked
|
|
25
|
+
* @param props
|
|
26
|
+
*/
|
|
11
27
|
onClick: (props: EntityActionClickProps<M, UserType>) => Promise<void> | void;
|
|
12
28
|
|
|
13
29
|
/**
|
|
@@ -21,6 +37,7 @@ export type EntityAction<M extends object = any, UserType extends User = User> =
|
|
|
21
37
|
* Show this action in the form, defaults to true
|
|
22
38
|
*/
|
|
23
39
|
includeInForm?: boolean;
|
|
40
|
+
|
|
24
41
|
}
|
|
25
42
|
|
|
26
43
|
export type EntityActionClickProps<M extends object, UserType extends User = User> = {
|
|
@@ -78,7 +78,7 @@ export interface EntityOnFetchProps<M extends Record<string, any> = any, UserTyp
|
|
|
78
78
|
/**
|
|
79
79
|
* Collection of the entity
|
|
80
80
|
*/
|
|
81
|
-
collection: EntityCollection<M>;
|
|
81
|
+
collection: EntityCollection<M, UserType>;
|
|
82
82
|
|
|
83
83
|
/**
|
|
84
84
|
* Full path of the CMS where this collection is being fetched.
|
|
@@ -193,7 +193,7 @@ export interface EntityOnDeleteProps<M extends Record<string, any> = any, UserTy
|
|
|
193
193
|
/**
|
|
194
194
|
* Context of the app status
|
|
195
195
|
*/
|
|
196
|
-
context: FireCMSContext
|
|
196
|
+
context: FireCMSContext<UserType>;
|
|
197
197
|
}
|
|
198
198
|
|
|
199
199
|
/**
|
package/src/types/firecms.tsx
CHANGED
package/src/types/index.ts
CHANGED
|
@@ -17,11 +17,12 @@ export * from "./side_entity_controller";
|
|
|
17
17
|
export * from "./side_dialogs_controller";
|
|
18
18
|
export * from "./firecms_context";
|
|
19
19
|
export * from "./entity_callbacks";
|
|
20
|
+
export * from "./entity_overrides";
|
|
20
21
|
export * from "./local_config_persistence";
|
|
21
22
|
export * from "./plugins";
|
|
22
23
|
export * from "./analytics";
|
|
23
24
|
export * from "./firecms";
|
|
24
|
-
export * from "./
|
|
25
|
+
export * from "./roles";
|
|
25
26
|
export * from "./export_import";
|
|
26
27
|
export * from "./modify_collections";
|
|
27
28
|
export * from "./analytics_controller";
|
package/src/types/navigation.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import React from "react";
|
|
1
2
|
import { EntityCollection } from "./collections";
|
|
2
3
|
import { EntityReference } from "./entities";
|
|
3
4
|
|
|
@@ -6,7 +7,7 @@ import { EntityReference } from "./entities";
|
|
|
6
7
|
* attributes.
|
|
7
8
|
* @group Models
|
|
8
9
|
*/
|
|
9
|
-
export type NavigationController = {
|
|
10
|
+
export type NavigationController<EC extends EntityCollection = EntityCollection<any>> = {
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* List of the mapped collections in the CMS.
|
|
@@ -22,6 +23,12 @@ export type NavigationController = {
|
|
|
22
23
|
*/
|
|
23
24
|
views?: CMSView[];
|
|
24
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Custom additional views created by the developer, added to the admin
|
|
28
|
+
* navigation
|
|
29
|
+
*/
|
|
30
|
+
adminViews?: CMSView[];
|
|
31
|
+
|
|
25
32
|
/**
|
|
26
33
|
* Configuration for the views that should be displayed at the top
|
|
27
34
|
* level of the navigation (e.g. in the home page or the navigation
|
|
@@ -49,18 +56,18 @@ export type NavigationController = {
|
|
|
49
56
|
* Get the collection configuration for a given path.
|
|
50
57
|
* The collection is resolved from the given path or alias.
|
|
51
58
|
*/
|
|
52
|
-
getCollection:
|
|
53
|
-
|
|
54
|
-
|
|
59
|
+
getCollection: (pathOrId: string,
|
|
60
|
+
entityId?: string,
|
|
61
|
+
includeUserOverride?: boolean) => EC | undefined;
|
|
55
62
|
/**
|
|
56
63
|
* Get the collection configuration from its parent path segments.
|
|
57
64
|
*/
|
|
58
|
-
getCollectionFromIds:
|
|
65
|
+
getCollectionFromIds: (ids: string[]) => EC | undefined;
|
|
59
66
|
|
|
60
67
|
/**
|
|
61
68
|
* Get the collection configuration from its parent path segments.
|
|
62
69
|
*/
|
|
63
|
-
getCollectionFromPaths:
|
|
70
|
+
getCollectionFromPaths: (pathSegments: string[]) => EC | undefined;
|
|
64
71
|
|
|
65
72
|
/**
|
|
66
73
|
* Default path under the navigation routes of the CMS will be created
|
|
@@ -116,13 +123,6 @@ export type NavigationController = {
|
|
|
116
123
|
*/
|
|
117
124
|
resolveAliasesFrom: (pathWithAliases: string) => string;
|
|
118
125
|
|
|
119
|
-
/**
|
|
120
|
-
* Location used as the base for routes.
|
|
121
|
-
* This is the location that will be used underneath, when the url changes while
|
|
122
|
-
* opening a side dialog
|
|
123
|
-
*/
|
|
124
|
-
baseLocation: string;
|
|
125
|
-
|
|
126
126
|
/**
|
|
127
127
|
* Call this method to recalculate the navigation
|
|
128
128
|
*/
|
|
@@ -192,6 +192,7 @@ export interface CMSView {
|
|
|
192
192
|
/**
|
|
193
193
|
* Optional field used to group top level navigation entries under a
|
|
194
194
|
* navigation view.
|
|
195
|
+
* This prop is ignored for admin views.
|
|
195
196
|
*/
|
|
196
197
|
group?: string;
|
|
197
198
|
|
|
@@ -201,11 +202,11 @@ export interface TopNavigationEntry {
|
|
|
201
202
|
url: string;
|
|
202
203
|
name: string;
|
|
203
204
|
path: string;
|
|
204
|
-
type: "collection" | "view";
|
|
205
|
+
type: "collection" | "view" | "admin";
|
|
205
206
|
collection?: EntityCollection;
|
|
206
|
-
view
|
|
207
|
+
view?: CMSView;
|
|
207
208
|
description?: string;
|
|
208
|
-
group
|
|
209
|
+
group: string;
|
|
209
210
|
}
|
|
210
211
|
|
|
211
212
|
export type TopNavigationResult = {
|
package/src/types/permissions.ts
CHANGED
|
@@ -41,6 +41,11 @@ export interface PermissionsBuilderProps<EC extends EntityCollection = EntityCol
|
|
|
41
41
|
*/
|
|
42
42
|
entity: Entity<M> | null;
|
|
43
43
|
|
|
44
|
+
/**
|
|
45
|
+
* Path of the collection e.g. 'products/12345/locales'
|
|
46
|
+
*/
|
|
47
|
+
path: string;
|
|
48
|
+
|
|
44
49
|
/**
|
|
45
50
|
* Path segments of the collection e.g. ['products', 'locales']
|
|
46
51
|
*/
|
|
@@ -73,4 +78,4 @@ export type PermissionsBuilder<EC extends EntityCollection = EntityCollection, U
|
|
|
73
78
|
user,
|
|
74
79
|
collection,
|
|
75
80
|
authController
|
|
76
|
-
}: PermissionsBuilderProps<EC, UserType, M>) => Permissions);
|
|
81
|
+
}: PermissionsBuilderProps<EC, UserType, M>) => Permissions | undefined);
|
package/src/types/plugins.tsx
CHANGED
|
@@ -13,12 +13,12 @@ import { ResolvedProperty } from "./resolved_entities";
|
|
|
13
13
|
* NOTE: This is a work in progress and the API is not stable yet.
|
|
14
14
|
* @group Core
|
|
15
15
|
*/
|
|
16
|
-
export type FireCMSPlugin<PROPS = any, FORM_PROPS = any, EC extends EntityCollection = EntityCollection, COL_ACTIONS_PROPS = any> = {
|
|
16
|
+
export type FireCMSPlugin<PROPS = any, FORM_PROPS = any, EC extends EntityCollection = EntityCollection, COL_ACTIONS_PROPS = any, COL_ACTIONS_START__PROPS = any> = {
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
19
|
+
* Key of the plugin. This is used to identify the plugin in the CMS.
|
|
20
20
|
*/
|
|
21
|
-
|
|
21
|
+
key: string;
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* If this flag is set to true, no content will be shown in the CMS
|
|
@@ -26,31 +26,6 @@ export type FireCMSPlugin<PROPS = any, FORM_PROPS = any, EC extends EntityCollec
|
|
|
26
26
|
*/
|
|
27
27
|
loading?: boolean;
|
|
28
28
|
|
|
29
|
-
collections?: {
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Use this component to add custom actions to the entity collections
|
|
33
|
-
* toolbar.
|
|
34
|
-
*/
|
|
35
|
-
CollectionActions?: React.ComponentType<CollectionActionsProps<any, any, EC> & COL_ACTIONS_PROPS> | React.ComponentType<CollectionActionsProps<any, any, EC> & COL_ACTIONS_PROPS>[];
|
|
36
|
-
|
|
37
|
-
collectionActionsProps?: COL_ACTIONS_PROPS;
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
form?: {
|
|
42
|
-
provider?: {
|
|
43
|
-
Component: React.ComponentType<PropsWithChildren<FORM_PROPS & PluginFormActionProps<any, EC>>>;
|
|
44
|
-
props?: FORM_PROPS;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
Actions?: React.ComponentType<PluginFormActionProps<any, EC>>;
|
|
48
|
-
|
|
49
|
-
fieldBuilder?: <T extends CMSType = CMSType>(props: PluginFieldBuilderParams<T, any, EC>) => React.ComponentType<FieldProps<T>> | null;
|
|
50
|
-
|
|
51
|
-
fieldBuilderEnabled?: <T extends CMSType = CMSType>(props: PluginFieldBuilderParams<T>) => boolean;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
29
|
/**
|
|
55
30
|
* You can use this prop to add higher order components to the CMS.
|
|
56
31
|
* The components will be added to the root of the CMS, so any component
|
|
@@ -113,6 +88,16 @@ export type FireCMSPlugin<PROPS = any, FORM_PROPS = any, EC extends EntityCollec
|
|
|
113
88
|
|
|
114
89
|
collectionView?: {
|
|
115
90
|
|
|
91
|
+
/**
|
|
92
|
+
* Use this component to add custom actions to the entity collections
|
|
93
|
+
* toolbar.
|
|
94
|
+
*/
|
|
95
|
+
CollectionActions?: React.ComponentType<CollectionActionsProps<any, any, EC> & COL_ACTIONS_PROPS> | React.ComponentType<CollectionActionsProps<any, any, EC> & COL_ACTIONS_PROPS>[];
|
|
96
|
+
collectionActionsProps?: COL_ACTIONS_PROPS;
|
|
97
|
+
|
|
98
|
+
CollectionActionsStart?: React.ComponentType<CollectionActionsProps<any, any, EC> & COL_ACTIONS_START__PROPS> | React.ComponentType<CollectionActionsProps<any, any, EC> & COL_ACTIONS_START__PROPS>[];
|
|
99
|
+
collectionActionsStartProps?: COL_ACTIONS_START__PROPS;
|
|
100
|
+
|
|
116
101
|
showTextSearchBar?: (props: {
|
|
117
102
|
context: FireCMSContext,
|
|
118
103
|
path: string,
|
|
@@ -151,6 +136,19 @@ export type FireCMSPlugin<PROPS = any, FORM_PROPS = any, EC extends EntityCollec
|
|
|
151
136
|
}>;
|
|
152
137
|
}
|
|
153
138
|
|
|
139
|
+
form?: {
|
|
140
|
+
provider?: {
|
|
141
|
+
Component: React.ComponentType<PropsWithChildren<FORM_PROPS & PluginFormActionProps<any, EC>>>;
|
|
142
|
+
props?: FORM_PROPS;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
Actions?: React.ComponentType<PluginFormActionProps<any, EC>>;
|
|
146
|
+
|
|
147
|
+
fieldBuilder?: <T extends CMSType = CMSType>(props: PluginFieldBuilderParams<T, any, EC>) => React.ComponentType<FieldProps<T>> | null;
|
|
148
|
+
|
|
149
|
+
fieldBuilderEnabled?: <T extends CMSType = CMSType>(props: PluginFieldBuilderParams<T>) => boolean;
|
|
150
|
+
}
|
|
151
|
+
|
|
154
152
|
}
|
|
155
153
|
|
|
156
154
|
/**
|
package/src/types/properties.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { FieldProps } from "./fields";
|
|
3
3
|
import { PropertyPreviewProps } from "../preview";
|
|
4
|
-
import { EntityReference, EntityValues, GeoPoint } from "./entities";
|
|
4
|
+
import { EntityReference, EntityValues, GeoPoint, Vector } from "./entities";
|
|
5
5
|
import { ResolvedArrayProperty, ResolvedStringProperty } from "./resolved_entities";
|
|
6
6
|
import { FilterValues } from "./collections";
|
|
7
7
|
import { ChipColorKey, ChipColorScheme } from "@firecms/ui";
|
|
@@ -15,9 +15,10 @@ export type DataType<T extends CMSType = CMSType> =
|
|
|
15
15
|
T extends boolean ? "boolean" :
|
|
16
16
|
T extends Date ? "date" :
|
|
17
17
|
T extends GeoPoint ? "geopoint" :
|
|
18
|
-
T extends
|
|
19
|
-
T extends
|
|
20
|
-
T extends
|
|
18
|
+
T extends Vector ? "vector" :
|
|
19
|
+
T extends EntityReference ? "reference" :
|
|
20
|
+
T extends Array<CMSType> ? "array" :
|
|
21
|
+
T extends Record<string, any> ? "map" : never;
|
|
21
22
|
|
|
22
23
|
/**
|
|
23
24
|
* @group Entity properties
|
|
@@ -695,7 +696,7 @@ export interface ArrayPropertyValidationSchema extends PropertyValidationSchema
|
|
|
695
696
|
* Additional configuration related to Storage related fields
|
|
696
697
|
* @group Entity properties
|
|
697
698
|
*/
|
|
698
|
-
export
|
|
699
|
+
export type StorageConfig = {
|
|
699
700
|
|
|
700
701
|
/**
|
|
701
702
|
* File MIME types that can be uploaded to this reference. Don't specify for
|
|
@@ -770,7 +771,8 @@ export interface StorageConfig {
|
|
|
770
771
|
* Postprocess the saved value (storage path or URL)
|
|
771
772
|
* after it has been resolved.
|
|
772
773
|
*/
|
|
773
|
-
postProcess?: (pathOrUrl: string) => Promise<string
|
|
774
|
+
postProcess?: (pathOrUrl: string) => Promise<string>;
|
|
775
|
+
|
|
774
776
|
}
|
|
775
777
|
|
|
776
778
|
/**
|
|
@@ -11,7 +11,7 @@ export type PropertyConfig<T extends CMSType = any> = {
|
|
|
11
11
|
/**
|
|
12
12
|
* Key used to identify this property config.
|
|
13
13
|
*/
|
|
14
|
-
key: string
|
|
14
|
+
key: PropertyConfigId | string;
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Name of this field type.
|
|
@@ -48,7 +48,7 @@ export type PropertyConfig<T extends CMSType = any> = {
|
|
|
48
48
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
export type
|
|
51
|
+
export type PropertyConfigId =
|
|
52
52
|
"text_field" |
|
|
53
53
|
"multiline" |
|
|
54
54
|
"markdown" |
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Permissions } from "../index";
|
|
2
|
+
|
|
3
|
+
export type Role = {
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* ID of the role
|
|
7
|
+
*/
|
|
8
|
+
id: string;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Name of the role
|
|
12
|
+
*/
|
|
13
|
+
name: string;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* If this flag is true, the user can perform any action
|
|
17
|
+
*/
|
|
18
|
+
isAdmin?: boolean;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Default permissions for all collections for this role.
|
|
22
|
+
* You can override this values at the collection level using
|
|
23
|
+
* {@link collectionPermissions}
|
|
24
|
+
*/
|
|
25
|
+
defaultPermissions?: Permissions;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Record of stripped collection ids to their permissions.
|
|
29
|
+
* @see stripCollectionPath
|
|
30
|
+
*/
|
|
31
|
+
collectionPermissions?: Record<string, Permissions>;
|
|
32
|
+
|
|
33
|
+
config?: {
|
|
34
|
+
|
|
35
|
+
createCollections?: boolean;
|
|
36
|
+
|
|
37
|
+
editCollections?: boolean | "own";
|
|
38
|
+
|
|
39
|
+
deleteCollections?: boolean | "own";
|
|
40
|
+
}
|
|
41
|
+
}
|
package/src/types/storage.ts
CHANGED
|
@@ -6,6 +6,7 @@ export interface UploadFileProps {
|
|
|
6
6
|
fileName?: string,
|
|
7
7
|
path?: string,
|
|
8
8
|
metadata?: any,
|
|
9
|
+
bucket?: string
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
/**
|
|
@@ -16,6 +17,10 @@ export interface UploadFileResult {
|
|
|
16
17
|
* Storage path including the file name where the file was uploaded.
|
|
17
18
|
*/
|
|
18
19
|
path: string;
|
|
20
|
+
/**
|
|
21
|
+
* Bucket where the file was uploaded
|
|
22
|
+
*/
|
|
23
|
+
bucket: string;
|
|
19
24
|
}
|
|
20
25
|
|
|
21
26
|
/**
|
|
@@ -73,24 +78,28 @@ export interface StorageSource {
|
|
|
73
78
|
* @param fileName
|
|
74
79
|
* @param path
|
|
75
80
|
* @param metadata
|
|
81
|
+
* @param bucket
|
|
76
82
|
*/
|
|
77
83
|
uploadFile: ({
|
|
78
84
|
file,
|
|
79
85
|
fileName,
|
|
80
86
|
path,
|
|
81
|
-
metadata
|
|
87
|
+
metadata,
|
|
88
|
+
bucket
|
|
82
89
|
}: UploadFileProps) => Promise<UploadFileResult>;
|
|
83
90
|
|
|
84
91
|
/**
|
|
85
92
|
* Convert a storage path or URL into a download configuration
|
|
86
93
|
* @param path
|
|
94
|
+
* @param bucket
|
|
87
95
|
*/
|
|
88
|
-
getDownloadURL: (pathOrUrl: string) => Promise<DownloadConfig>;
|
|
96
|
+
getDownloadURL: (pathOrUrl: string, bucket?: string) => Promise<DownloadConfig>;
|
|
89
97
|
|
|
90
98
|
/**
|
|
91
99
|
* Get a file from a storage path.
|
|
92
100
|
* It returns null if the file does not exist.
|
|
93
101
|
* @param props
|
|
102
|
+
* @param bucket
|
|
94
103
|
*/
|
|
95
|
-
getFile: (path:string) => Promise<File | null>;
|
|
104
|
+
getFile: (path:string, bucket?: string) => Promise<File | null>;
|
|
96
105
|
}
|
package/src/types/user.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Role } from "./roles";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* This interface represents a user.
|
|
3
5
|
* It has some of the same fields as a Firebase User.
|
|
@@ -34,4 +36,9 @@ export type User = {
|
|
|
34
36
|
*/
|
|
35
37
|
readonly isAnonymous: boolean;
|
|
36
38
|
|
|
39
|
+
/**
|
|
40
|
+
*
|
|
41
|
+
*/
|
|
42
|
+
roles?: Role[];
|
|
43
|
+
|
|
37
44
|
};
|
package/src/util/collections.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DefaultSelectedViewBuilder,
|
|
3
3
|
DefaultSelectedViewParams,
|
|
4
|
+
EntityCollection,
|
|
5
|
+
PermissionsBuilder,
|
|
4
6
|
PropertiesOrBuilders,
|
|
5
7
|
PropertyOrBuilder
|
|
6
8
|
} from "../types";
|
|
@@ -48,3 +50,23 @@ export function resolveDefaultSelectedView(
|
|
|
48
50
|
return defaultSelectedView(params);
|
|
49
51
|
}
|
|
50
52
|
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* If a collection is not applying permissions, we apply the given permissionsBuilder.
|
|
56
|
+
* This is used to apply the role permissions to the collections, unless they are already
|
|
57
|
+
* applying permissions.
|
|
58
|
+
* @param collections
|
|
59
|
+
* @param permissionsBuilder
|
|
60
|
+
*/
|
|
61
|
+
export const applyPermissionsFunctionIfEmpty = (collections: EntityCollection[], permissionsBuilder?: PermissionsBuilder<any, any>): EntityCollection[] => {
|
|
62
|
+
|
|
63
|
+
return collections.map(collection => {
|
|
64
|
+
if (collection.permissions) {
|
|
65
|
+
return collection;
|
|
66
|
+
}
|
|
67
|
+
return ({
|
|
68
|
+
...collection,
|
|
69
|
+
permissions: permissionsBuilder
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
}
|
package/src/util/entities.ts
CHANGED
|
@@ -139,7 +139,7 @@ export function sanitizeData<M extends Record<string, any>>
|
|
|
139
139
|
return result;
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
-
export function getReferenceFrom<M extends Record<string, any>>(entity: Entity<M>): EntityReference
|
|
142
|
+
export function getReferenceFrom<M extends Record<string, any>>(entity: Entity<M>): EntityReference {
|
|
143
143
|
return new EntityReference(entity.id, entity.path);
|
|
144
144
|
}
|
|
145
145
|
|
package/src/util/icon_list.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { iconSynonyms } from "./icon_synonyms";
|
|
2
2
|
import { iconKeys } from "@firecms/ui";
|
|
3
3
|
|
|
4
4
|
// @ts-ignore
|
|
@@ -12,6 +12,6 @@ iconsSearch.addDocuments(iconKeys
|
|
|
12
12
|
return {
|
|
13
13
|
key: importName,
|
|
14
14
|
// @ts-ignore
|
|
15
|
-
synonyms:
|
|
15
|
+
synonyms: iconSynonyms[importName] ?? [],
|
|
16
16
|
}
|
|
17
17
|
}));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const
|
|
1
|
+
export const iconSynonyms = {
|
|
2
2
|
abc: "alphabet character font letter symbol text type",
|
|
3
3
|
access_alarm: "clock time",
|
|
4
4
|
access_alarms: "clock time",
|
|
@@ -84,7 +84,6 @@ export const icon_synonyms = {
|
|
|
84
84
|
apartment: "accommodation architecture building city company estate flat home house office places real residence residential shelter units workplace",
|
|
85
85
|
api: "developer development enterprise software",
|
|
86
86
|
app_blocking: "Android applications cancel cell device hardware iOS mobile phone stopped tablet",
|
|
87
|
-
apple: "brand logo",
|
|
88
87
|
app_registration: "apps edit pencil register",
|
|
89
88
|
approval: "apply approvals approve certificate certification disapproval drive file impression ink mark postage stamp",
|
|
90
89
|
apps: "all applications circles collection components dots grid homescreen icons interface squares ui ux",
|
|
@@ -527,7 +526,6 @@ export const icon_synonyms = {
|
|
|
527
526
|
egg_alt: "breakfast brunch food",
|
|
528
527
|
eighteen_mp: "camera digits font image letters megapixels numbers quality resolution symbol text type",
|
|
529
528
|
eight_k: "8000 8K alphabet character digit display font letter number pixels resolution symbol text type video",
|
|
530
|
-
eight_k_plus: "+ 7000 8K alphabet character digit display font letter number pixels resolution symbol text type video",
|
|
531
529
|
eight_mp: "camera digit font image letters megapixels number quality resolution symbol text type",
|
|
532
530
|
eightteen_mp: "camera digits font image letters megapixels numbers quality resolution symbol text type",
|
|
533
531
|
eject: "arrow disc drive dvd player remove triangle up usb",
|
|
@@ -722,7 +720,6 @@ export const icon_synonyms = {
|
|
|
722
720
|
four_g_mobiledata: "alphabet cellular character digit font letter network number phone signal speed symbol text type wifi",
|
|
723
721
|
four_g_plus_mobiledata: "alphabet cellular character digit font letter network number phone signal speed symbol text type wifi",
|
|
724
722
|
four_k: "4000 4K alphabet character digit display font letter number pixels resolution symbol text type video",
|
|
725
|
-
four_k_plus: "+ 4000 4K alphabet character digit display font letter number pixels resolution symbol text type video",
|
|
726
723
|
four_mp: "camera digit font image letters megapixels number quality resolution symbol text type",
|
|
727
724
|
fourteen_mp: "camera digits font image letters megapixels numbers quality resolution symbol text type",
|
|
728
725
|
free_breakfast: "beverage cafe coffee cup drink mug tea",
|
package/src/util/icons.tsx
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { CMSView, EntityCollection } from "../types";
|
|
3
2
|
import { hashString } from "./hash";
|
|
4
3
|
import { coolIconKeys, Icon, iconKeys } from "@firecms/ui";
|
|
5
4
|
import { slugify } from "./strings";
|
|
@@ -14,8 +13,17 @@ export function getIcon(iconKey?: string, className?: string): React.ReactElemen
|
|
|
14
13
|
return iconKey in iconKeysMap ? <Icon iconKey={iconKey} size={"medium"} className={className}/> : undefined;
|
|
15
14
|
}
|
|
16
15
|
|
|
16
|
+
export type IconViewProps = {
|
|
17
|
+
path: string;
|
|
18
|
+
name: string;
|
|
19
|
+
singularName?: string;
|
|
20
|
+
group?: string;
|
|
21
|
+
icon?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
17
24
|
export const IconForView = React.memo(
|
|
18
|
-
function IconForView({ collectionOrView, className }: { collectionOrView
|
|
25
|
+
function IconForView({ collectionOrView, className }: { collectionOrView?: IconViewProps, className?: string }): React.ReactElement {
|
|
26
|
+
if (!collectionOrView) return <></>;
|
|
19
27
|
const icon = getIcon(collectionOrView.icon, className);
|
|
20
28
|
if (collectionOrView?.icon && icon)
|
|
21
29
|
return icon;
|
|
@@ -39,7 +47,7 @@ export const IconForView = React.memo(
|
|
|
39
47
|
|
|
40
48
|
return <Icon iconKey={key} size={"medium"} className={className}/>;
|
|
41
49
|
}, (prevProps, nextProps) => {
|
|
42
|
-
return equal(prevProps.collectionOrView
|
|
50
|
+
return equal(prevProps.collectionOrView?.icon, nextProps.collectionOrView?.icon);
|
|
43
51
|
});
|
|
44
52
|
|
|
45
53
|
const iconKeysMap: Record<string, string> = iconKeys.reduce((acc: Record<string, string>, key) => {
|
|
@@ -60,14 +60,14 @@ export function resolveCollectionPathIds(path: string, allCollections: EntityCol
|
|
|
60
60
|
/**
|
|
61
61
|
* Find the corresponding view at any depth for a given path.
|
|
62
62
|
* Note that path or segments of the paths can be collection aliases.
|
|
63
|
-
* @param
|
|
63
|
+
* @param pathOrId
|
|
64
64
|
* @param collections
|
|
65
65
|
*/
|
|
66
|
-
export function getCollectionByPathOrId(
|
|
66
|
+
export function getCollectionByPathOrId(pathOrId: string, collections: EntityCollection[]): EntityCollection | undefined {
|
|
67
67
|
|
|
68
|
-
const subpaths = removeInitialAndTrailingSlashes(
|
|
68
|
+
const subpaths = removeInitialAndTrailingSlashes(pathOrId).split("/");
|
|
69
69
|
if (subpaths.length % 2 === 0) {
|
|
70
|
-
throw Error(`
|
|
70
|
+
throw Error(`getCollectionByPathOrId: Collection paths must have an odd number of segments: ${pathOrId}`);
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
const subpathCombinations = getCollectionPathsCombinations(subpaths);
|
|
@@ -80,10 +80,10 @@ export function getCollectionByPathOrId(pathOrAlias: string, collections: Entity
|
|
|
80
80
|
|
|
81
81
|
if (navigationEntry) {
|
|
82
82
|
|
|
83
|
-
if (subpathCombination ===
|
|
83
|
+
if (subpathCombination === pathOrId) {
|
|
84
84
|
result = navigationEntry;
|
|
85
85
|
} else if (navigationEntry.subcollections) {
|
|
86
|
-
const newPath =
|
|
86
|
+
const newPath = pathOrId.replace(subpathCombination, "").split("/").slice(2).join("/");
|
|
87
87
|
if (newPath.length > 0)
|
|
88
88
|
result = getCollectionByPathOrId(newPath, navigationEntry.subcollections);
|
|
89
89
|
}
|
package/src/util/objects.ts
CHANGED
|
@@ -30,20 +30,6 @@ export function mergeDeep<T extends object>(target: T, source: any): T {
|
|
|
30
30
|
return output;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
// export function getValueInPath(o: object | undefined, path: string): any {
|
|
34
|
-
// if (!o) return undefined;
|
|
35
|
-
// if (typeof o === "object") {
|
|
36
|
-
// if (path in o) {
|
|
37
|
-
// return (o as any)[path];
|
|
38
|
-
// }
|
|
39
|
-
// if (path.includes(".")) {
|
|
40
|
-
// const pathSegments = path.split(".");
|
|
41
|
-
// return getValueInPath((o as any)[pathSegments[0]], pathSegments.slice(1).join("."))
|
|
42
|
-
// }
|
|
43
|
-
// }
|
|
44
|
-
// return undefined;
|
|
45
|
-
// }
|
|
46
|
-
|
|
47
33
|
export function getValueInPath(o: object | undefined, path: string): any {
|
|
48
34
|
if (!o) return undefined;
|
|
49
35
|
if (typeof o === "object") {
|