@firecms/core 3.0.0-canary.144 → 3.0.0-canary.145
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/dist/components/EntityCollectionTable/EntityCollectionTable.d.ts +1 -1
- package/dist/components/EntityCollectionTable/EntityCollectionTableProps.d.ts +2 -2
- package/dist/components/common/useDataSourceEntityCollectionTableController.d.ts +1 -1
- package/dist/core/EntityEditView.d.ts +1 -1
- package/dist/core/FireCMS.d.ts +1 -1
- package/dist/hooks/data/delete.d.ts +4 -4
- package/dist/hooks/data/save.d.ts +3 -3
- package/dist/hooks/data/useCollectionFetch.d.ts +1 -1
- package/dist/hooks/data/useEntityFetch.d.ts +3 -3
- package/dist/hooks/useAuthController.d.ts +1 -1
- package/dist/hooks/useBuildNavigationController.d.ts +3 -3
- package/dist/hooks/useFireCMSContext.d.ts +1 -1
- package/dist/hooks/useResolvedNavigationFrom.d.ts +3 -3
- package/dist/hooks/useValidateAuthenticator.d.ts +3 -3
- package/dist/index.es.js +70 -67
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +70 -67
- package/dist/index.umd.js.map +1 -1
- package/dist/types/auth.d.ts +8 -6
- package/dist/types/collections.d.ts +12 -12
- package/dist/types/datasource.d.ts +0 -4
- package/dist/types/entity_actions.d.ts +4 -4
- package/dist/types/entity_callbacks.d.ts +16 -16
- package/dist/types/export_import.d.ts +4 -4
- package/dist/types/firecms.d.ts +2 -2
- package/dist/types/firecms_context.d.ts +1 -1
- package/dist/types/permissions.d.ts +4 -4
- package/dist/types/plugins.d.ts +8 -8
- package/dist/types/user.d.ts +1 -0
- package/dist/util/builders.d.ts +2 -2
- package/dist/util/permissions.d.ts +4 -4
- package/package.json +5 -5
- package/src/app/Scaffold.tsx +2 -2
- package/src/components/ArrayContainer.tsx +1 -1
- package/src/components/CircularProgressCenter.tsx +1 -1
- package/src/components/EntityCollectionTable/EntityCollectionRowActions.tsx +1 -1
- package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +5 -5
- package/src/components/EntityCollectionTable/EntityCollectionTableProps.tsx +2 -2
- package/src/components/EntityCollectionTable/fields/TableReferenceField.tsx +3 -3
- package/src/components/EntityCollectionTable/fields/TableStorageUpload.tsx +2 -2
- package/src/components/EntityCollectionTable/internal/CollectionTableToolbar.tsx +1 -1
- package/src/components/EntityCollectionTable/internal/EntityTableCell.tsx +4 -4
- package/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +3 -3
- package/src/components/EntityCollectionView/EntityCollectionView.tsx +3 -3
- package/src/components/EntityPreview.tsx +2 -2
- package/src/components/EntityView.tsx +4 -4
- package/src/components/HomePage/FavouritesView.tsx +1 -1
- package/src/components/HomePage/NavigationCard.tsx +1 -1
- package/src/components/HomePage/NavigationCardBinding.tsx +1 -1
- package/src/components/HomePage/NavigationGroup.tsx +1 -1
- package/src/components/PropertyConfigBadge.tsx +1 -1
- package/src/components/PropertyIdCopyTooltip.tsx +1 -1
- package/src/components/ReferenceTable/ReferenceSelectionTable.tsx +1 -1
- package/src/components/SelectableTable/SelectableTable.tsx +2 -2
- package/src/components/SelectableTable/filters/DateTimeFilterField.tsx +1 -1
- package/src/components/SelectableTable/filters/ReferenceFilterField.tsx +1 -1
- package/src/components/SelectableTable/filters/StringNumberFilterField.tsx +1 -1
- package/src/components/VirtualTable/VirtualTableHeader.tsx +8 -8
- package/src/components/VirtualTable/VirtualTableHeaderRow.tsx +1 -1
- package/src/components/VirtualTable/VirtualTableRow.tsx +1 -1
- package/src/components/common/useDataSourceEntityCollectionTableController.tsx +2 -2
- package/src/core/DefaultDrawer.tsx +2 -2
- package/src/core/DrawerNavigationItem.tsx +3 -3
- package/src/core/EntityEditView.tsx +4 -4
- package/src/core/FireCMS.tsx +1 -1
- package/src/core/SideDialogs.tsx +1 -1
- package/src/core/field_configs.tsx +1 -1
- package/src/form/components/StorageItemPreview.tsx +2 -2
- package/src/form/field_bindings/MapFieldBinding.tsx +1 -1
- package/src/form/field_bindings/ReferenceFieldBinding.tsx +3 -3
- package/src/hooks/data/delete.ts +4 -4
- package/src/hooks/data/save.ts +3 -3
- package/src/hooks/data/useCollectionFetch.tsx +2 -2
- package/src/hooks/data/useEntityFetch.tsx +5 -5
- package/src/hooks/useAuthController.tsx +1 -1
- package/src/hooks/useBuildNavigationController.tsx +7 -6
- package/src/hooks/useFireCMSContext.tsx +5 -5
- package/src/hooks/useResolvedNavigationFrom.tsx +5 -5
- package/src/hooks/useValidateAuthenticator.tsx +3 -3
- package/src/preview/components/EmptyValue.tsx +1 -1
- package/src/preview/components/ImagePreview.tsx +2 -2
- package/src/preview/components/UrlComponentPreview.tsx +1 -1
- package/src/types/auth.tsx +8 -8
- package/src/types/collections.ts +12 -12
- package/src/types/datasource.ts +0 -5
- package/src/types/entity_actions.tsx +4 -4
- package/src/types/entity_callbacks.ts +18 -18
- package/src/types/export_import.ts +4 -4
- package/src/types/firecms.tsx +2 -2
- package/src/types/firecms_context.tsx +1 -1
- package/src/types/permissions.ts +5 -5
- package/src/types/plugins.tsx +8 -8
- package/src/types/user.ts +2 -0
- package/src/util/builders.ts +6 -6
- package/src/util/permissions.ts +8 -8
package/dist/types/auth.d.ts
CHANGED
|
@@ -8,16 +8,16 @@ import { StorageSource } from "./storage";
|
|
|
8
8
|
* to do it as the result of a hook.
|
|
9
9
|
* @group Hooks and utilities
|
|
10
10
|
*/
|
|
11
|
-
export type AuthController<
|
|
11
|
+
export type AuthController<USER extends User = any, ExtraData = any> = {
|
|
12
12
|
/**
|
|
13
13
|
* The user currently logged in
|
|
14
14
|
* The values can be: the user object, null if they skipped login
|
|
15
15
|
*/
|
|
16
|
-
user:
|
|
16
|
+
user: USER | null;
|
|
17
17
|
/**
|
|
18
18
|
* Roles related to the logged user
|
|
19
19
|
*/
|
|
20
|
-
|
|
20
|
+
userRoles?: Role[];
|
|
21
21
|
/**
|
|
22
22
|
* Initial loading flag. It is used not to display the login screen
|
|
23
23
|
* when the app first loads, and it has not been checked whether the user
|
|
@@ -51,20 +51,22 @@ export type AuthController<UserType extends User = any, ExtraData = any> = {
|
|
|
51
51
|
loginSkipped: boolean;
|
|
52
52
|
extra: ExtraData;
|
|
53
53
|
setExtra: (extra: ExtraData) => void;
|
|
54
|
+
setUser?: (user: USER | null) => void;
|
|
55
|
+
setUserRoles?: (roles: Role[]) => void;
|
|
54
56
|
};
|
|
55
57
|
/**
|
|
56
58
|
* Implement this function to allow access to specific users.
|
|
57
59
|
* @group Hooks and utilities
|
|
58
60
|
*/
|
|
59
|
-
export type Authenticator<
|
|
61
|
+
export type Authenticator<USER extends User = User> = (props: {
|
|
60
62
|
/**
|
|
61
63
|
* Logged-in user or null
|
|
62
64
|
*/
|
|
63
|
-
user:
|
|
65
|
+
user: USER | null;
|
|
64
66
|
/**
|
|
65
67
|
* AuthController
|
|
66
68
|
*/
|
|
67
|
-
authController:
|
|
69
|
+
authController: AuthController<USER>;
|
|
68
70
|
/**
|
|
69
71
|
* Connector to your database, e.g. your Firestore database
|
|
70
72
|
*/
|
|
@@ -16,7 +16,7 @@ import { EntityOverrides } from "./entity_overrides";
|
|
|
16
16
|
*
|
|
17
17
|
* @group Models
|
|
18
18
|
*/
|
|
19
|
-
export interface EntityCollection<M extends Record<string, any> = any,
|
|
19
|
+
export interface EntityCollection<M extends Record<string, any> = any, USER extends User = any> {
|
|
20
20
|
/**
|
|
21
21
|
* You can set an alias that will be used internally instead of the `path`.
|
|
22
22
|
* The `alias` value will be used to determine the URL of the collection,
|
|
@@ -122,7 +122,7 @@ export interface EntityCollection<M extends Record<string, any> = any, UserType
|
|
|
122
122
|
* Permissions the logged-in user can perform on this collection.
|
|
123
123
|
* If not specified everything defaults to `true`.
|
|
124
124
|
*/
|
|
125
|
-
permissions?: Permissions | PermissionsBuilder<EntityCollection,
|
|
125
|
+
permissions?: Permissions | PermissionsBuilder<EntityCollection, USER, M>;
|
|
126
126
|
/**
|
|
127
127
|
* Are the entities in this collection selectable. Defaults to `true`
|
|
128
128
|
*/
|
|
@@ -138,7 +138,7 @@ export interface EntityCollection<M extends Record<string, any> = any, UserType
|
|
|
138
138
|
* is being created, updated or deleted.
|
|
139
139
|
* Useful for adding your own logic or blocking the execution of the operation.
|
|
140
140
|
*/
|
|
141
|
-
callbacks?: EntityCallbacks<M,
|
|
141
|
+
callbacks?: EntityCallbacks<M, USER>;
|
|
142
142
|
/**
|
|
143
143
|
* Builder for rendering additional components such as buttons in the
|
|
144
144
|
* collection toolbar
|
|
@@ -167,7 +167,7 @@ export interface EntityCollection<M extends Record<string, any> = any, UserType
|
|
|
167
167
|
* }
|
|
168
168
|
* ```
|
|
169
169
|
*/
|
|
170
|
-
entityActions?: EntityAction<M,
|
|
170
|
+
entityActions?: EntityAction<M, USER>[];
|
|
171
171
|
/**
|
|
172
172
|
* Pass your own selection controller if you want to control selected
|
|
173
173
|
* entities externally.
|
|
@@ -212,7 +212,7 @@ export interface EntityCollection<M extends Record<string, any> = any, UserType
|
|
|
212
212
|
* You can add additional fields to the collection view by implementing
|
|
213
213
|
* an additional field delegate.
|
|
214
214
|
*/
|
|
215
|
-
additionalFields?: AdditionalFieldDelegate<M,
|
|
215
|
+
additionalFields?: AdditionalFieldDelegate<M, USER>[];
|
|
216
216
|
/**
|
|
217
217
|
* Default size of the rendered collection
|
|
218
218
|
*/
|
|
@@ -257,7 +257,7 @@ export interface EntityCollection<M extends Record<string, any> = any, UserType
|
|
|
257
257
|
/**
|
|
258
258
|
*
|
|
259
259
|
*/
|
|
260
|
-
exportable?: boolean | ExportConfig<
|
|
260
|
+
exportable?: boolean | ExportConfig<USER>;
|
|
261
261
|
/**
|
|
262
262
|
* User id of the owner of this collection. This is used only by plugins, or if you
|
|
263
263
|
* are writing custom code
|
|
@@ -283,7 +283,7 @@ export interface EntityCollection<M extends Record<string, any> = any, UserType
|
|
|
283
283
|
*
|
|
284
284
|
* @group Models
|
|
285
285
|
*/
|
|
286
|
-
export interface CollectionActionsProps<M extends Record<string, any> = any,
|
|
286
|
+
export interface CollectionActionsProps<M extends Record<string, any> = any, USER extends User = User, EC extends EntityCollection<M> = EntityCollection<M>> {
|
|
287
287
|
/**
|
|
288
288
|
* Full collection path of this entity. This is the full path, like
|
|
289
289
|
* `users/1234/addresses`
|
|
@@ -314,7 +314,7 @@ export interface CollectionActionsProps<M extends Record<string, any> = any, Use
|
|
|
314
314
|
/**
|
|
315
315
|
* Context of the app status
|
|
316
316
|
*/
|
|
317
|
-
context: FireCMSContext<
|
|
317
|
+
context: FireCMSContext<USER>;
|
|
318
318
|
/**
|
|
319
319
|
* Count of the entities in this collection
|
|
320
320
|
*/
|
|
@@ -357,16 +357,16 @@ export type FilterCombination<Key extends string> = Partial<Record<Key, "asc" |
|
|
|
357
357
|
* @group Models
|
|
358
358
|
*/
|
|
359
359
|
export type CollectionSize = "xs" | "s" | "m" | "l" | "xl";
|
|
360
|
-
export type AdditionalFieldDelegateProps<M extends Record<string, any> = any,
|
|
360
|
+
export type AdditionalFieldDelegateProps<M extends Record<string, any> = any, USER extends User = User> = {
|
|
361
361
|
entity: Entity<M>;
|
|
362
|
-
context: FireCMSContext<
|
|
362
|
+
context: FireCMSContext<USER>;
|
|
363
363
|
};
|
|
364
364
|
/**
|
|
365
365
|
* Use this interface for adding additional fields to entity collection views.
|
|
366
366
|
* If you need to do some async loading you can use {@link AsyncPreviewComponent}
|
|
367
367
|
* @group Models
|
|
368
368
|
*/
|
|
369
|
-
export interface AdditionalFieldDelegate<M extends Record<string, any> = any,
|
|
369
|
+
export interface AdditionalFieldDelegate<M extends Record<string, any> = any, USER extends User = User> {
|
|
370
370
|
/**
|
|
371
371
|
* ID of this column. You can use this id in the `properties` field of the
|
|
372
372
|
* collection in any order you want
|
|
@@ -383,7 +383,7 @@ export interface AdditionalFieldDelegate<M extends Record<string, any> = any, Us
|
|
|
383
383
|
/**
|
|
384
384
|
* Builder for the content of the cell for this column
|
|
385
385
|
*/
|
|
386
|
-
Builder?: React.ComponentType<AdditionalFieldDelegateProps<M,
|
|
386
|
+
Builder?: React.ComponentType<AdditionalFieldDelegateProps<M, USER>>;
|
|
387
387
|
/**
|
|
388
388
|
* If this column needs to update dynamically based on other properties,
|
|
389
389
|
* you can define an array of keys as strings with the
|
|
@@ -177,10 +177,6 @@ export interface DataSourceDelegate {
|
|
|
177
177
|
* If the data source has been initialised
|
|
178
178
|
*/
|
|
179
179
|
initialised?: boolean;
|
|
180
|
-
/**
|
|
181
|
-
* If the user is authenticated to use the data source
|
|
182
|
-
*/
|
|
183
|
-
authenticated?: boolean;
|
|
184
180
|
/**
|
|
185
181
|
* Fetch data from a collection
|
|
186
182
|
* @param path
|
|
@@ -8,7 +8,7 @@ import { SideEntityController } from "./side_entity_controller";
|
|
|
8
8
|
* An entity action is a custom action that can be performed on an entity.
|
|
9
9
|
* They are displayed in the entity view and in the collection view.
|
|
10
10
|
*/
|
|
11
|
-
export type EntityAction<M extends object = any,
|
|
11
|
+
export type EntityAction<M extends object = any, USER extends User = User> = {
|
|
12
12
|
/**
|
|
13
13
|
* Title of the action
|
|
14
14
|
*/
|
|
@@ -21,7 +21,7 @@ export type EntityAction<M extends object = any, UserType extends User = User> =
|
|
|
21
21
|
* Callback when the action is clicked
|
|
22
22
|
* @param props
|
|
23
23
|
*/
|
|
24
|
-
onClick: (props: EntityActionClickProps<M,
|
|
24
|
+
onClick: (props: EntityActionClickProps<M, USER>) => Promise<void> | void;
|
|
25
25
|
/**
|
|
26
26
|
* Show this action collapsed in the menu of the collection view.
|
|
27
27
|
* Defaults to true
|
|
@@ -33,9 +33,9 @@ export type EntityAction<M extends object = any, UserType extends User = User> =
|
|
|
33
33
|
*/
|
|
34
34
|
includeInForm?: boolean;
|
|
35
35
|
};
|
|
36
|
-
export type EntityActionClickProps<M extends object,
|
|
36
|
+
export type EntityActionClickProps<M extends object, USER extends User = User> = {
|
|
37
37
|
entity: Entity<M>;
|
|
38
|
-
context: FireCMSContext<
|
|
38
|
+
context: FireCMSContext<USER>;
|
|
39
39
|
fullPath?: string;
|
|
40
40
|
collection?: EntityCollection<M>;
|
|
41
41
|
selectionController?: SelectionController;
|
|
@@ -9,29 +9,29 @@ import { User } from "./user";
|
|
|
9
9
|
* Useful for adding your own logic or blocking the execution of the operation.
|
|
10
10
|
* @group Models
|
|
11
11
|
*/
|
|
12
|
-
export type EntityCallbacks<M extends Record<string, any> = any,
|
|
12
|
+
export type EntityCallbacks<M extends Record<string, any> = any, USER extends User = User> = {
|
|
13
13
|
/**
|
|
14
14
|
* Callback used after fetching data
|
|
15
15
|
* @param entityFetchProps
|
|
16
16
|
*/
|
|
17
|
-
onFetch?(entityFetchProps: EntityOnFetchProps<M,
|
|
17
|
+
onFetch?(entityFetchProps: EntityOnFetchProps<M, USER>): Promise<Entity<M>> | Entity<M>;
|
|
18
18
|
/**
|
|
19
19
|
* Callback used when save is successful
|
|
20
20
|
* @param entitySaveProps
|
|
21
21
|
*/
|
|
22
|
-
onSaveSuccess?(entitySaveProps: EntityOnSaveProps<M,
|
|
22
|
+
onSaveSuccess?(entitySaveProps: EntityOnSaveProps<M, USER>): Promise<void> | void;
|
|
23
23
|
/**
|
|
24
24
|
* Callback used when saving fails
|
|
25
25
|
* @param entitySaveProps
|
|
26
26
|
*/
|
|
27
|
-
onSaveFailure?(entitySaveProps: EntityOnSaveFailureProps<M,
|
|
27
|
+
onSaveFailure?(entitySaveProps: EntityOnSaveFailureProps<M, USER>): Promise<void> | void;
|
|
28
28
|
/**
|
|
29
29
|
* Callback used before saving, you need to return the values that will get
|
|
30
30
|
* saved. If you throw an error in this method the process stops, and an
|
|
31
31
|
* error snackbar gets displayed.
|
|
32
32
|
* @param entitySaveProps
|
|
33
33
|
*/
|
|
34
|
-
onPreSave?(entitySaveProps: EntityOnPreSaveProps<M,
|
|
34
|
+
onPreSave?(entitySaveProps: EntityOnPreSaveProps<M, USER>): Promise<Partial<EntityValues<M>>> | Partial<EntityValues<M>>;
|
|
35
35
|
/**
|
|
36
36
|
* Callback used after the entity is deleted.
|
|
37
37
|
* If you throw an error in this method the process stops, and an
|
|
@@ -39,13 +39,13 @@ export type EntityCallbacks<M extends Record<string, any> = any, UserType extend
|
|
|
39
39
|
*
|
|
40
40
|
* @param entityDeleteProps
|
|
41
41
|
*/
|
|
42
|
-
onPreDelete?(entityDeleteProps: EntityOnDeleteProps<M,
|
|
42
|
+
onPreDelete?(entityDeleteProps: EntityOnDeleteProps<M, USER>): void;
|
|
43
43
|
/**
|
|
44
44
|
* Callback used after the entity is deleted.
|
|
45
45
|
*
|
|
46
46
|
* @param entityDeleteProps
|
|
47
47
|
*/
|
|
48
|
-
onDelete?(entityDeleteProps: EntityOnDeleteProps<M,
|
|
48
|
+
onDelete?(entityDeleteProps: EntityOnDeleteProps<M, USER>): void;
|
|
49
49
|
/**
|
|
50
50
|
* Callback fired when any value in the form changes. You can use it
|
|
51
51
|
* to define the ID of a `new` entity based on the current values.
|
|
@@ -59,11 +59,11 @@ export type EntityCallbacks<M extends Record<string, any> = any, UserType extend
|
|
|
59
59
|
* Parameters passed to hooks when an entity is fetched
|
|
60
60
|
* @group Models
|
|
61
61
|
*/
|
|
62
|
-
export interface EntityOnFetchProps<M extends Record<string, any> = any,
|
|
62
|
+
export interface EntityOnFetchProps<M extends Record<string, any> = any, USER extends User = User> {
|
|
63
63
|
/**
|
|
64
64
|
* Collection of the entity
|
|
65
65
|
*/
|
|
66
|
-
collection: EntityCollection<M,
|
|
66
|
+
collection: EntityCollection<M, USER>;
|
|
67
67
|
/**
|
|
68
68
|
* Full path of the CMS where this collection is being fetched.
|
|
69
69
|
* Might contain unresolved aliases.
|
|
@@ -76,27 +76,27 @@ export interface EntityOnFetchProps<M extends Record<string, any> = any, UserTyp
|
|
|
76
76
|
/**
|
|
77
77
|
* Context of the app status
|
|
78
78
|
*/
|
|
79
|
-
context: FireCMSContext<
|
|
79
|
+
context: FireCMSContext<USER>;
|
|
80
80
|
}
|
|
81
81
|
/**
|
|
82
82
|
* Parameters passed to hooks before an entity is saved
|
|
83
83
|
* @group Models
|
|
84
84
|
*/
|
|
85
|
-
export type EntityOnPreSaveProps<M extends Record<string, any> = any,
|
|
85
|
+
export type EntityOnPreSaveProps<M extends Record<string, any> = any, USER extends User = User> = Omit<EntityOnSaveProps<M, USER>, "entityId"> & {
|
|
86
86
|
entityId?: string;
|
|
87
87
|
};
|
|
88
88
|
/**
|
|
89
89
|
* Parameters passed to hooks before an entity is saved
|
|
90
90
|
* @group Models
|
|
91
91
|
*/
|
|
92
|
-
export type EntityOnSaveFailureProps<M extends Record<string, any> = any,
|
|
92
|
+
export type EntityOnSaveFailureProps<M extends Record<string, any> = any, USER extends User = User> = Omit<EntityOnSaveProps<M, USER>, "entityId"> & {
|
|
93
93
|
entityId?: string;
|
|
94
94
|
};
|
|
95
95
|
/**
|
|
96
96
|
* Parameters passed to hooks when an entity is saved
|
|
97
97
|
* @group Models
|
|
98
98
|
*/
|
|
99
|
-
export interface EntityOnSaveProps<M extends Record<string, any> = any,
|
|
99
|
+
export interface EntityOnSaveProps<M extends Record<string, any> = any, USER extends User = User> {
|
|
100
100
|
/**
|
|
101
101
|
* Resolved collection of the entity
|
|
102
102
|
*/
|
|
@@ -129,13 +129,13 @@ export interface EntityOnSaveProps<M extends Record<string, any> = any, UserType
|
|
|
129
129
|
/**
|
|
130
130
|
* Context of the app status
|
|
131
131
|
*/
|
|
132
|
-
context: FireCMSContext<
|
|
132
|
+
context: FireCMSContext<USER>;
|
|
133
133
|
}
|
|
134
134
|
/**
|
|
135
135
|
* Parameters passed to hooks when an entity is deleted
|
|
136
136
|
* @group Models
|
|
137
137
|
*/
|
|
138
|
-
export interface EntityOnDeleteProps<M extends Record<string, any> = any,
|
|
138
|
+
export interface EntityOnDeleteProps<M extends Record<string, any> = any, USER extends User = User> {
|
|
139
139
|
/**
|
|
140
140
|
* collection of the entity being deleted
|
|
141
141
|
*/
|
|
@@ -155,7 +155,7 @@ export interface EntityOnDeleteProps<M extends Record<string, any> = any, UserTy
|
|
|
155
155
|
/**
|
|
156
156
|
* Context of the app status
|
|
157
157
|
*/
|
|
158
|
-
context: FireCMSContext<
|
|
158
|
+
context: FireCMSContext<USER>;
|
|
159
159
|
}
|
|
160
160
|
/**
|
|
161
161
|
* Parameters passed to hooks when an entity is deleted
|
|
@@ -6,16 +6,16 @@ import { FireCMSContext } from "./firecms_context";
|
|
|
6
6
|
* exports
|
|
7
7
|
* @group Models
|
|
8
8
|
*/
|
|
9
|
-
export interface ExportConfig<
|
|
10
|
-
additionalFields: ExportMappingFunction<
|
|
9
|
+
export interface ExportConfig<USER extends User = User> {
|
|
10
|
+
additionalFields: ExportMappingFunction<USER>[];
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
13
|
* @group Models
|
|
14
14
|
*/
|
|
15
|
-
export interface ExportMappingFunction<
|
|
15
|
+
export interface ExportMappingFunction<USER extends User = User> {
|
|
16
16
|
key: string;
|
|
17
17
|
builder: ({ entity, context }: {
|
|
18
18
|
entity: Entity<any>;
|
|
19
|
-
context: FireCMSContext<
|
|
19
|
+
context: FireCMSContext<USER>;
|
|
20
20
|
}) => Promise<string> | string;
|
|
21
21
|
}
|
package/dist/types/firecms.d.ts
CHANGED
|
@@ -44,7 +44,7 @@ export type CMSViewsBuilder = (params: {
|
|
|
44
44
|
/**
|
|
45
45
|
* @group Models
|
|
46
46
|
*/
|
|
47
|
-
export type FireCMSProps<
|
|
47
|
+
export type FireCMSProps<USER extends User, EC extends EntityCollection> = {
|
|
48
48
|
/**
|
|
49
49
|
* Use this function to return the components you want to render under
|
|
50
50
|
* FireCMS
|
|
@@ -105,7 +105,7 @@ export type FireCMSProps<UserType extends User, EC extends EntityCollection> = {
|
|
|
105
105
|
/**
|
|
106
106
|
* Delegate for implementing your auth operations.
|
|
107
107
|
*/
|
|
108
|
-
authController: AuthController<
|
|
108
|
+
authController: AuthController<USER>;
|
|
109
109
|
/**
|
|
110
110
|
* Use this controller to access the configuration that is stored locally,
|
|
111
111
|
* and not defined in code
|
|
@@ -17,7 +17,7 @@ import { AnalyticsController } from "./analytics_controller";
|
|
|
17
17
|
* @group Hooks and utilities
|
|
18
18
|
* @see useFireCMSContext
|
|
19
19
|
*/
|
|
20
|
-
export type FireCMSContext<
|
|
20
|
+
export type FireCMSContext<USER extends User = User, AuthControllerType extends AuthController<USER> = AuthController<USER>> = {
|
|
21
21
|
/**
|
|
22
22
|
* Connector to your database, e.g. your Firestore database
|
|
23
23
|
*/
|
|
@@ -30,7 +30,7 @@ export interface Permissions {
|
|
|
30
30
|
* Props passed to a {@link PermissionsBuilder}
|
|
31
31
|
* @group Models
|
|
32
32
|
*/
|
|
33
|
-
export interface PermissionsBuilderProps<EC extends EntityCollection = EntityCollection,
|
|
33
|
+
export interface PermissionsBuilderProps<EC extends EntityCollection = EntityCollection, USER extends User = User, M extends object = InferCollectionType<EC>> {
|
|
34
34
|
/**
|
|
35
35
|
* Entity being edited, might be null in some cases, when the operation
|
|
36
36
|
* refers to the collection.
|
|
@@ -49,7 +49,7 @@ export interface PermissionsBuilderProps<EC extends EntityCollection = EntityCol
|
|
|
49
49
|
/**
|
|
50
50
|
* Logged in user
|
|
51
51
|
*/
|
|
52
|
-
user:
|
|
52
|
+
user: USER | null;
|
|
53
53
|
/**
|
|
54
54
|
* Collection these permissions apply to
|
|
55
55
|
*/
|
|
@@ -57,11 +57,11 @@ export interface PermissionsBuilderProps<EC extends EntityCollection = EntityCol
|
|
|
57
57
|
/**
|
|
58
58
|
* Auth controller
|
|
59
59
|
*/
|
|
60
|
-
authController: AuthController<
|
|
60
|
+
authController: AuthController<USER>;
|
|
61
61
|
}
|
|
62
62
|
/**
|
|
63
63
|
* Builder used to assign permissions to entities,
|
|
64
64
|
* based on the logged user or collection.
|
|
65
65
|
* @group Models
|
|
66
66
|
*/
|
|
67
|
-
export type PermissionsBuilder<EC extends EntityCollection = EntityCollection,
|
|
67
|
+
export type PermissionsBuilder<EC extends EntityCollection = EntityCollection, USER extends User = User, M extends object = InferCollectionType<EC>> = (({ pathSegments, user, collection, authController }: PermissionsBuilderProps<EC, USER, M>) => Permissions | undefined);
|
package/dist/types/plugins.d.ts
CHANGED
|
@@ -138,7 +138,7 @@ export type FireCMSPlugin<PROPS = any, FORM_PROPS = any, EC extends EntityCollec
|
|
|
138
138
|
*
|
|
139
139
|
* @group Models
|
|
140
140
|
*/
|
|
141
|
-
export interface PluginHomePageActionsProps<EP extends object = object, M extends Record<string, any> = any,
|
|
141
|
+
export interface PluginHomePageActionsProps<EP extends object = object, M extends Record<string, any> = any, USER extends User = User, EC extends EntityCollection<M> = EntityCollection<M>> {
|
|
142
142
|
/**
|
|
143
143
|
* Collection path of this entity. This is the full path, like
|
|
144
144
|
* `users/1234/addresses`
|
|
@@ -151,16 +151,16 @@ export interface PluginHomePageActionsProps<EP extends object = object, M extend
|
|
|
151
151
|
/**
|
|
152
152
|
* Context of the app status
|
|
153
153
|
*/
|
|
154
|
-
context: FireCMSContext<
|
|
154
|
+
context: FireCMSContext<USER>;
|
|
155
155
|
extraProps?: EP;
|
|
156
156
|
}
|
|
157
|
-
export interface PluginFormActionProps<
|
|
157
|
+
export interface PluginFormActionProps<USER extends User = User, EC extends EntityCollection = EntityCollection> {
|
|
158
158
|
entityId?: string;
|
|
159
159
|
path: string;
|
|
160
160
|
status: EntityStatus;
|
|
161
161
|
collection: EC;
|
|
162
162
|
formContext?: FormContext<any>;
|
|
163
|
-
context: FireCMSContext<
|
|
163
|
+
context: FireCMSContext<USER>;
|
|
164
164
|
currentEntityId?: string;
|
|
165
165
|
}
|
|
166
166
|
export type PluginFieldBuilderParams<T extends CMSType = CMSType, M extends Record<string, any> = any, EC extends EntityCollection<M> = EntityCollection<M>> = {
|
|
@@ -172,10 +172,10 @@ export type PluginFieldBuilderParams<T extends CMSType = CMSType, M extends Reco
|
|
|
172
172
|
path?: string;
|
|
173
173
|
collection?: EC;
|
|
174
174
|
};
|
|
175
|
-
export interface PluginGenericProps<
|
|
176
|
-
context: FireCMSContext<
|
|
175
|
+
export interface PluginGenericProps<USER extends User = User> {
|
|
176
|
+
context: FireCMSContext<USER>;
|
|
177
177
|
}
|
|
178
|
-
export interface PluginHomePageAdditionalCardsProps<
|
|
178
|
+
export interface PluginHomePageAdditionalCardsProps<USER extends User = User> {
|
|
179
179
|
group?: string;
|
|
180
|
-
context: FireCMSContext<
|
|
180
|
+
context: FireCMSContext<USER>;
|
|
181
181
|
}
|
package/dist/types/user.d.ts
CHANGED
package/dist/util/builders.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { AdditionalFieldDelegate, ArrayProperty, BooleanProperty, CMSType, DateP
|
|
|
5
5
|
* @param collection
|
|
6
6
|
* @group Builder
|
|
7
7
|
*/
|
|
8
|
-
export declare function buildCollection<M extends Record<string, any> = any,
|
|
8
|
+
export declare function buildCollection<M extends Record<string, any> = any, USER extends User = User>(collection: EntityCollection<M, USER>): EntityCollection<M, USER>;
|
|
9
9
|
/**
|
|
10
10
|
* Identity function we use to defeat the type system of Typescript and preserve
|
|
11
11
|
* the property keys.
|
|
@@ -54,7 +54,7 @@ export declare function buildEntityCallbacks<M extends Record<string, any> = any
|
|
|
54
54
|
* @param additionalFieldDelegate
|
|
55
55
|
* @group Builder
|
|
56
56
|
*/
|
|
57
|
-
export declare function buildAdditionalFieldDelegate<M extends Record<string, any>,
|
|
57
|
+
export declare function buildAdditionalFieldDelegate<M extends Record<string, any>, USER extends User = User>(additionalFieldDelegate: AdditionalFieldDelegate<M, USER>): AdditionalFieldDelegate<M, USER>;
|
|
58
58
|
/**
|
|
59
59
|
* Identity function we use to defeat the type system of Typescript and build
|
|
60
60
|
* additional field delegates views with all its properties
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AuthController, Entity, EntityCollection, Permissions, User } from "../types";
|
|
2
|
-
export declare function resolvePermissions<M extends Record<string, any>,
|
|
3
|
-
export declare function canEditEntity<M extends Record<string, any>,
|
|
4
|
-
export declare function canCreateEntity<M extends Record<string, any>,
|
|
5
|
-
export declare function canDeleteEntity<M extends Record<string, any>,
|
|
2
|
+
export declare function resolvePermissions<M extends Record<string, any>, USER extends User>(collection: EntityCollection<M>, authController: AuthController<USER>, path: string, entity: Entity<M> | null): Permissions | undefined;
|
|
3
|
+
export declare function canEditEntity<M extends Record<string, any>, USER extends User>(collection: EntityCollection<M>, authController: AuthController<USER>, path: string, entity: Entity<M> | null): boolean;
|
|
4
|
+
export declare function canCreateEntity<M extends Record<string, any>, USER extends User>(collection: EntityCollection<M>, authController: AuthController<USER>, path: string, entity: Entity<M> | null): boolean;
|
|
5
|
+
export declare function canDeleteEntity<M extends Record<string, any>, USER extends User>(collection: EntityCollection<M>, authController: AuthController<USER>, path: string, entity: Entity<M> | null): boolean;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firecms/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.0.0-canary.
|
|
4
|
+
"version": "3.0.0-canary.145",
|
|
5
5
|
"description": "Awesome Firebase/Firestore-based headless open-source CMS",
|
|
6
6
|
"funding": {
|
|
7
7
|
"url": "https://github.com/sponsors/firecmsco"
|
|
@@ -46,9 +46,9 @@
|
|
|
46
46
|
"./package.json": "./package.json"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@firecms/editor": "^3.0.0-canary.
|
|
50
|
-
"@firecms/formex": "^3.0.0-canary.
|
|
51
|
-
"@firecms/ui": "^3.0.0-canary.
|
|
49
|
+
"@firecms/editor": "^3.0.0-canary.145",
|
|
50
|
+
"@firecms/formex": "^3.0.0-canary.145",
|
|
51
|
+
"@firecms/ui": "^3.0.0-canary.145",
|
|
52
52
|
"@hello-pangea/dnd": "^17.0.0",
|
|
53
53
|
"@radix-ui/react-portal": "^1.1.2",
|
|
54
54
|
"clsx": "^2.1.1",
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
"dist",
|
|
101
101
|
"src"
|
|
102
102
|
],
|
|
103
|
-
"gitHead": "
|
|
103
|
+
"gitHead": "e5d660f00c5806e1b63839c013af3c973f3dd47e",
|
|
104
104
|
"publishConfig": {
|
|
105
105
|
"access": "public"
|
|
106
106
|
},
|
package/src/app/Scaffold.tsx
CHANGED
|
@@ -91,7 +91,7 @@ export const Scaffold = React.memo<PropsWithChildren<ScaffoldProps>>(
|
|
|
91
91
|
autoOpenDrawer
|
|
92
92
|
}}>
|
|
93
93
|
<div
|
|
94
|
-
className={cls("flex h-screen w-screen bg-
|
|
94
|
+
className={cls("flex h-screen w-screen bg-surface-50 dark:bg-surface-900 text-surface-900 dark:text-white overflow-hidden", className)}
|
|
95
95
|
style={{
|
|
96
96
|
paddingTop: "env(safe-area-inset-top)",
|
|
97
97
|
paddingLeft: "env(safe-area-inset-left)",
|
|
@@ -168,7 +168,7 @@ function DrawerWrapper(props: {
|
|
|
168
168
|
sideOffset={12}
|
|
169
169
|
asChild={true}>
|
|
170
170
|
<div
|
|
171
|
-
className="ml-2 fixed top-1 left-2 sm:top-2 sm:left-3 !bg-
|
|
171
|
+
className="ml-2 fixed top-1 left-2 sm:top-2 sm:left-3 !bg-surface-50 dark:!bg-surface-900 rounded-full w-fit z-20">
|
|
172
172
|
<IconButton
|
|
173
173
|
color="inherit"
|
|
174
174
|
aria-label="Open menu"
|
|
@@ -256,7 +256,7 @@ export function ArrayContainerItem({
|
|
|
256
256
|
{...provided.draggableProps}
|
|
257
257
|
style={provided.draggableProps.style}
|
|
258
258
|
className={`${
|
|
259
|
-
!isDragging ? "hover:bg-
|
|
259
|
+
!isDragging ? "hover:bg-surface-accent-50 dark:hover:bg-surface-800 dark:hover:bg-opacity-20" : ""
|
|
260
260
|
} rounded-md opacity-100`}
|
|
261
261
|
>
|
|
262
262
|
<div
|
|
@@ -13,7 +13,7 @@ export function CircularProgressCenter({ text, ...props }: CircularProgressProps
|
|
|
13
13
|
}) {
|
|
14
14
|
return (
|
|
15
15
|
<div
|
|
16
|
-
className="flex w-full h-screen max-h-full max-w-full bg-
|
|
16
|
+
className="flex w-full h-screen max-h-full max-w-full bg-surface-50 dark:bg-surface-900 gap-4">
|
|
17
17
|
<div className="m-auto flex flex-col gap-2 items-center">
|
|
18
18
|
<CircularProgress {...props}/>
|
|
19
19
|
{text && <Typography
|
|
@@ -66,7 +66,7 @@ export const EntityCollectionRowActions = function EntityCollectionRowActions({
|
|
|
66
66
|
return (
|
|
67
67
|
<div
|
|
68
68
|
className={cls(
|
|
69
|
-
"h-full flex items-center justify-center flex-col bg-
|
|
69
|
+
"h-full flex items-center justify-center flex-col bg-surface-50 dark:bg-surface-900 bg-opacity-90 dark:bg-opacity-90 z-10",
|
|
70
70
|
frozen ? "sticky left-0" : ""
|
|
71
71
|
)}
|
|
72
72
|
style={{
|
|
@@ -41,7 +41,7 @@ import { getRowHeight } from "../common/table_height";
|
|
|
41
41
|
* @see VirtualTable
|
|
42
42
|
* @group Components
|
|
43
43
|
*/
|
|
44
|
-
export const EntityCollectionTable = function EntityCollectionTable<M extends Record<string, any>,
|
|
44
|
+
export const EntityCollectionTable = function EntityCollectionTable<M extends Record<string, any>, USER extends User>
|
|
45
45
|
({
|
|
46
46
|
className,
|
|
47
47
|
style,
|
|
@@ -84,7 +84,7 @@ export const EntityCollectionTable = function EntityCollectionTable<M extends Re
|
|
|
84
84
|
const largeLayout = useLargeLayout();
|
|
85
85
|
const selectedEntities = (selectionController?.selectedEntities?.length > 0 ? selectionController?.selectedEntities : highlightedEntities)?.filter(Boolean);
|
|
86
86
|
|
|
87
|
-
const context: FireCMSContext<
|
|
87
|
+
const context: FireCMSContext<USER> = useFireCMSContext();
|
|
88
88
|
|
|
89
89
|
const [size, setSize] = React.useState<CollectionSize>(defaultSize ?? "m");
|
|
90
90
|
|
|
@@ -98,12 +98,12 @@ export const EntityCollectionTable = function EntityCollectionTable<M extends Re
|
|
|
98
98
|
|
|
99
99
|
const onTextSearch = useCallback((newSearchString?: string) => tableController.setSearchString?.(newSearchString), []);
|
|
100
100
|
|
|
101
|
-
const additionalFieldsMap: Record<string, AdditionalFieldDelegate<M,
|
|
101
|
+
const additionalFieldsMap: Record<string, AdditionalFieldDelegate<M, USER>> = useMemo(() => {
|
|
102
102
|
return (additionalFields
|
|
103
103
|
? additionalFields
|
|
104
104
|
.map((aC) => ({ [aC.key]: aC as AdditionalFieldDelegate<M, any> }))
|
|
105
105
|
.reduce((a, b) => ({ ...a, ...b }), {})
|
|
106
|
-
: {}) as Record<string, AdditionalFieldDelegate<M,
|
|
106
|
+
: {}) as Record<string, AdditionalFieldDelegate<M, USER>>;
|
|
107
107
|
}, [additionalFields]);
|
|
108
108
|
|
|
109
109
|
const customFieldValidator: CustomFieldValidator | undefined = uniqueFieldValidator;
|
|
@@ -292,7 +292,7 @@ export const EntityCollectionTable = function EntityCollectionTable<M extends Re
|
|
|
292
292
|
|
|
293
293
|
<div ref={ref}
|
|
294
294
|
style={style}
|
|
295
|
-
className={cls("h-full w-full flex flex-col bg-white dark:bg-
|
|
295
|
+
className={cls("h-full w-full flex flex-col bg-white dark:bg-surface-950", className)}>
|
|
296
296
|
|
|
297
297
|
<CollectionTableToolbar
|
|
298
298
|
onTextSearch={textSearchEnabled ? onTextSearch : undefined}
|
|
@@ -16,7 +16,7 @@ import { OnCellValueChange, OnColumnResizeParams, UniqueFieldValidator } from ".
|
|
|
16
16
|
* @group Collection components
|
|
17
17
|
*/
|
|
18
18
|
export type EntityCollectionTableProps<M extends Record<string, any>,
|
|
19
|
-
|
|
19
|
+
USER extends User = User> = {
|
|
20
20
|
|
|
21
21
|
className?: string;
|
|
22
22
|
|
|
@@ -103,7 +103,7 @@ export type EntityCollectionTableProps<M extends Record<string, any>,
|
|
|
103
103
|
|
|
104
104
|
inlineEditing?: boolean;
|
|
105
105
|
|
|
106
|
-
additionalFields?: AdditionalFieldDelegate<M,
|
|
106
|
+
additionalFields?: AdditionalFieldDelegate<M, USER>[];
|
|
107
107
|
|
|
108
108
|
defaultSize?: CollectionSize;
|
|
109
109
|
|
|
@@ -154,14 +154,14 @@ export const TableReferenceFieldInternal = React.memo(
|
|
|
154
154
|
className={cls("px-4 py-2 text-sm font-medium flex items-center uppercase",
|
|
155
155
|
multiselect ? "gap-4" : "gap-6",
|
|
156
156
|
disabled
|
|
157
|
-
? "text-
|
|
158
|
-
: "cursor-pointer text-
|
|
157
|
+
? "text-surface-accent-500"
|
|
158
|
+
: "cursor-pointer text-surface-accent-700 dark:text-surface-accent-300 hover:bg-surface-accent-50 dark:hover:bg-surface-800 group-hover:bg-surface-accent-50 dark:group-hover:bg-surface-800")}
|
|
159
159
|
onClick={handleOpen}
|
|
160
160
|
size={"medium"}>
|
|
161
161
|
<IconForView
|
|
162
162
|
size={"small"}
|
|
163
163
|
collectionOrView={collection}
|
|
164
|
-
className={"text-
|
|
164
|
+
className={"text-surface-300 dark:text-surface-600"}/>
|
|
165
165
|
Edit {title}
|
|
166
166
|
</EntityPreviewContainer>}
|
|
167
167
|
|