@firecms/core 3.0.0-beta.10 → 3.0.0-beta.11
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/ArrayContainer.d.ts +17 -5
- package/dist/components/EntityCollectionTable/EntityCollectionTable.d.ts +1 -1
- package/dist/components/EntityCollectionTable/EntityCollectionTableProps.d.ts +2 -2
- package/dist/components/EntityCollectionTable/internal/popup_field/PopupFormField.d.ts +6 -3
- 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/form/PropertyFieldBinding.d.ts +1 -1
- package/dist/form/components/index.d.ts +0 -1
- package/dist/form/field_bindings/MapFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/ReferenceFieldBinding.d.ts +2 -2
- package/dist/form/field_bindings/SwitchFieldBinding.d.ts +1 -2
- 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 +17515 -14786
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +17912 -15184
- package/dist/index.umd.js.map +1 -1
- package/dist/preview/PropertyPreviewProps.d.ts +1 -1
- package/dist/preview/components/EnumValuesChip.d.ts +1 -1
- package/dist/preview/util.d.ts +3 -3
- package/dist/types/auth.d.ts +7 -9
- package/dist/types/collections.d.ts +14 -13
- 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/fields.d.ts +18 -2
- 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/property_config.d.ts +0 -2
- package/dist/types/user.d.ts +1 -0
- package/dist/util/builders.d.ts +2 -2
- package/dist/util/entities.d.ts +1 -1
- package/dist/util/icon_synonyms.d.ts +0 -1
- package/dist/util/icons.d.ts +3 -1
- package/dist/util/objects.d.ts +1 -0
- package/dist/util/permissions.d.ts +4 -4
- package/dist/util/property_utils.d.ts +2 -2
- package/dist/util/resolutions.d.ts +6 -6
- package/package.json +131 -125
- package/src/app/Scaffold.tsx +4 -4
- package/src/components/ArrayContainer.tsx +79 -17
- package/src/components/CircularProgressCenter.tsx +1 -1
- package/src/components/ConfirmationDialog.tsx +2 -2
- package/src/components/DeleteEntityDialog.tsx +9 -18
- package/src/components/EntityCollectionTable/EntityCollectionRowActions.tsx +4 -1
- package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +14 -14
- package/src/components/EntityCollectionTable/EntityCollectionTableProps.tsx +2 -2
- package/src/components/EntityCollectionTable/PropertyTableCell.tsx +6 -4
- package/src/components/EntityCollectionTable/fields/TableReferenceField.tsx +8 -9
- package/src/components/EntityCollectionTable/fields/TableStorageUpload.tsx +5 -11
- package/src/components/EntityCollectionTable/internal/CollectionTableToolbar.tsx +2 -2
- package/src/components/EntityCollectionTable/internal/EntityTableCell.tsx +5 -5
- package/src/components/EntityCollectionTable/internal/EntityTableCellActions.tsx +2 -2
- package/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +79 -69
- package/src/components/EntityCollectionView/EntityCollectionView.tsx +9 -10
- package/src/components/EntityCollectionView/useSelectionController.tsx +5 -4
- package/src/components/EntityPreview.tsx +39 -30
- package/src/components/EntityView.tsx +5 -5
- package/src/components/ErrorView.tsx +3 -3
- package/src/components/HomePage/DefaultHomePage.tsx +1 -0
- package/src/components/HomePage/FavouritesView.tsx +6 -11
- package/src/components/HomePage/NavigationCard.tsx +1 -1
- package/src/components/HomePage/NavigationCardBinding.tsx +4 -9
- 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 +2 -2
- package/src/components/SelectableTable/SelectableTable.tsx +2 -2
- package/src/components/SelectableTable/filters/DateTimeFilterField.tsx +4 -2
- package/src/components/SelectableTable/filters/ReferenceFilterField.tsx +3 -1
- package/src/components/SelectableTable/filters/StringNumberFilterField.tsx +7 -5
- 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/VirtualTable/fields/VirtualTableDateField.tsx +1 -1
- package/src/components/VirtualTable/fields/VirtualTableSelect.tsx +2 -0
- package/src/components/common/useDataSourceEntityCollectionTableController.tsx +2 -2
- package/src/contexts/SnackbarProvider.tsx +2 -0
- package/src/core/DefaultAppBar.tsx +12 -11
- package/src/core/DefaultDrawer.tsx +11 -9
- package/src/core/DrawerNavigationItem.tsx +4 -4
- package/src/core/EntityEditView.tsx +50 -52
- package/src/core/FireCMS.tsx +5 -5
- package/src/core/SideDialogs.tsx +1 -1
- package/src/core/field_configs.tsx +4 -4
- package/src/form/PropertyFieldBinding.tsx +27 -20
- package/src/form/components/CustomIdField.tsx +2 -0
- package/src/form/components/StorageItemPreview.tsx +3 -3
- package/src/form/components/index.tsx +0 -1
- package/src/form/field_bindings/ArrayCustomShapedFieldBinding.tsx +3 -2
- package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +16 -10
- package/src/form/field_bindings/BlockFieldBinding.tsx +41 -23
- package/src/form/field_bindings/DateTimeFieldBinding.tsx +1 -1
- package/src/form/field_bindings/KeyValueFieldBinding.tsx +10 -7
- package/src/form/field_bindings/MapFieldBinding.tsx +58 -39
- package/src/form/field_bindings/ReferenceFieldBinding.tsx +4 -4
- package/src/form/field_bindings/RepeatFieldBinding.tsx +25 -20
- package/src/form/field_bindings/SelectFieldBinding.tsx +5 -4
- package/src/form/field_bindings/StorageUploadFieldBinding.tsx +1 -1
- package/src/form/field_bindings/SwitchFieldBinding.tsx +25 -25
- package/src/form/field_bindings/TextFieldBinding.tsx +3 -3
- package/src/hooks/data/delete.ts +4 -4
- package/src/hooks/data/save.ts +7 -8
- 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 +5 -6
- package/src/hooks/useFireCMSContext.tsx +5 -5
- package/src/hooks/useResolvedNavigationFrom.tsx +5 -5
- package/src/hooks/useValidateAuthenticator.tsx +3 -3
- package/src/internal/useBuildDataSource.ts +1 -1
- package/src/internal/useUnsavedChangesDialog.tsx +2 -2
- package/src/preview/PropertyPreview.tsx +3 -3
- package/src/preview/PropertyPreviewProps.tsx +1 -1
- package/src/preview/components/BooleanPreview.tsx +1 -1
- package/src/preview/components/EmptyValue.tsx +1 -1
- package/src/preview/components/EnumValuesChip.tsx +1 -1
- package/src/preview/components/ImagePreview.tsx +5 -6
- package/src/preview/components/UrlComponentPreview.tsx +4 -4
- package/src/preview/property_previews/ArrayOfMapsPreview.tsx +1 -1
- package/src/preview/property_previews/ArrayOfReferencesPreview.tsx +2 -2
- package/src/preview/property_previews/ArrayOfStorageComponentsPreview.tsx +2 -2
- package/src/preview/property_previews/ArrayOfStringsPreview.tsx +1 -1
- package/src/preview/property_previews/ArrayOneOfPreview.tsx +2 -2
- package/src/preview/property_previews/ArrayPropertyPreview.tsx +2 -2
- package/src/preview/property_previews/MapPropertyPreview.tsx +4 -4
- package/src/preview/property_previews/SkeletonPropertyComponent.tsx +12 -12
- package/src/preview/property_previews/StringPropertyPreview.tsx +2 -2
- package/src/preview/util.ts +10 -10
- package/src/types/auth.tsx +8 -12
- package/src/types/collections.ts +14 -13
- 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/fields.tsx +20 -2
- 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/property_config.tsx +0 -2
- package/src/types/user.ts +2 -0
- package/src/util/builders.ts +6 -6
- package/src/util/entities.ts +3 -1
- package/src/util/icon_list.ts +1 -0
- package/src/util/icon_synonyms.ts +0 -1
- package/src/util/icons.tsx +12 -8
- package/src/util/objects.ts +20 -0
- package/src/util/permissions.ts +8 -8
- package/src/util/property_utils.tsx +10 -3
- package/src/util/references.ts +8 -2
- package/src/util/resolutions.ts +8 -8
- package/src/util/useStorageUploadController.tsx +1 -1
- package/dist/form/components/FormikArrayContainer.d.ts +0 -19
- package/src/form/components/FormikArrayContainer.tsx +0 -47
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useCallback } from "react";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { CloseIcon, Collapse, IconButton, TextField } from "@firecms/ui";
|
|
4
4
|
import { FieldProps, PreviewType } from "../../types";
|
|
5
5
|
import { FieldHelperText, LabelWithIcon } from "../components";
|
|
6
6
|
import { getIconForProperty } from "../../util";
|
|
@@ -28,7 +28,7 @@ export function TextFieldBinding<T extends string | number>({
|
|
|
28
28
|
autoFocus,
|
|
29
29
|
property,
|
|
30
30
|
includeDescription,
|
|
31
|
-
size = "
|
|
31
|
+
size = "large"
|
|
32
32
|
}: TextFieldBindingProps<T>) {
|
|
33
33
|
|
|
34
34
|
let multiline: boolean | undefined;
|
|
@@ -85,7 +85,7 @@ export function TextFieldBinding<T extends string | number>({
|
|
|
85
85
|
endAdornment={
|
|
86
86
|
property.clearable && <IconButton
|
|
87
87
|
onClick={handleClearClick}>
|
|
88
|
-
<
|
|
88
|
+
<CloseIcon/>
|
|
89
89
|
</IconButton>
|
|
90
90
|
}
|
|
91
91
|
error={showError ? error : undefined}
|
package/src/hooks/data/delete.ts
CHANGED
|
@@ -12,10 +12,10 @@ import {
|
|
|
12
12
|
/**
|
|
13
13
|
* @group Hooks and utilities
|
|
14
14
|
*/
|
|
15
|
-
export type DeleteEntityWithCallbacksProps<M extends Record<string, any>,
|
|
15
|
+
export type DeleteEntityWithCallbacksProps<M extends Record<string, any>, USER extends User = User> =
|
|
16
16
|
DeleteEntityProps<M>
|
|
17
17
|
& {
|
|
18
|
-
callbacks?: EntityCallbacks<M,
|
|
18
|
+
callbacks?: EntityCallbacks<M, USER>;
|
|
19
19
|
onDeleteSuccess?: (entity: Entity<M>) => void;
|
|
20
20
|
onDeleteFailure?: (entity: Entity<M>, e: Error) => void;
|
|
21
21
|
onPreDeleteHookError?: (entity: Entity<M>, e: Error) => void;
|
|
@@ -43,7 +43,7 @@ export type DeleteEntityWithCallbacksProps<M extends Record<string, any>, UserTy
|
|
|
43
43
|
* @param context
|
|
44
44
|
* @group Hooks and utilities
|
|
45
45
|
*/
|
|
46
|
-
export async function deleteEntityWithCallbacks<M extends Record<string, any>,
|
|
46
|
+
export async function deleteEntityWithCallbacks<M extends Record<string, any>, USER extends User>({
|
|
47
47
|
dataSource,
|
|
48
48
|
entity,
|
|
49
49
|
collection,
|
|
@@ -56,7 +56,7 @@ export async function deleteEntityWithCallbacks<M extends Record<string, any>, U
|
|
|
56
56
|
}: DeleteEntityWithCallbacksProps<M> & {
|
|
57
57
|
collection: ResolvedEntityCollection<M>,
|
|
58
58
|
dataSource: DataSource,
|
|
59
|
-
context: FireCMSContext<
|
|
59
|
+
context: FireCMSContext<USER>
|
|
60
60
|
}
|
|
61
61
|
): Promise<boolean> {
|
|
62
62
|
|
package/src/hooks/data/save.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DataSource,
|
|
3
3
|
Entity,
|
|
4
|
-
EntityCallbacks,
|
|
5
4
|
EntityCollection,
|
|
6
5
|
EntityValues,
|
|
7
6
|
FireCMSContext,
|
|
@@ -49,7 +48,7 @@ export type SaveEntityWithCallbacksProps<M extends Record<string, any>> =
|
|
|
49
48
|
* @see useDataSource
|
|
50
49
|
* @group Hooks and utilities
|
|
51
50
|
*/
|
|
52
|
-
export async function saveEntityWithCallbacks<M extends Record<string, any>,
|
|
51
|
+
export async function saveEntityWithCallbacks<M extends Record<string, any>, USER extends User>({
|
|
53
52
|
collection,
|
|
54
53
|
path,
|
|
55
54
|
entityId,
|
|
@@ -63,9 +62,9 @@ export async function saveEntityWithCallbacks<M extends Record<string, any>, Use
|
|
|
63
62
|
onPreSaveHookError,
|
|
64
63
|
onSaveSuccessHookError
|
|
65
64
|
}: SaveEntityWithCallbacksProps<M> & {
|
|
66
|
-
collection: EntityCollection<M,
|
|
65
|
+
collection: EntityCollection<M, USER>,
|
|
67
66
|
dataSource: DataSource,
|
|
68
|
-
context: FireCMSContext<
|
|
67
|
+
context: FireCMSContext<USER>,
|
|
69
68
|
}
|
|
70
69
|
): Promise<void> {
|
|
71
70
|
|
|
@@ -86,7 +85,7 @@ export async function saveEntityWithCallbacks<M extends Record<string, any>, Use
|
|
|
86
85
|
path,
|
|
87
86
|
values: previousValues as EntityValues<M>,
|
|
88
87
|
entityId,
|
|
89
|
-
|
|
88
|
+
propertyConfigs: customizationController.propertyConfigs
|
|
90
89
|
});
|
|
91
90
|
updatedValues = await callbacks.onPreSave({
|
|
92
91
|
collection: resolvedCollection,
|
|
@@ -108,7 +107,7 @@ export async function saveEntityWithCallbacks<M extends Record<string, any>, Use
|
|
|
108
107
|
updatedValues = values;
|
|
109
108
|
}
|
|
110
109
|
|
|
111
|
-
console.
|
|
110
|
+
console.debug("Saving entity", {
|
|
112
111
|
entityId,
|
|
113
112
|
updatedValues,
|
|
114
113
|
collection
|
|
@@ -128,7 +127,7 @@ export async function saveEntityWithCallbacks<M extends Record<string, any>, Use
|
|
|
128
127
|
path,
|
|
129
128
|
values: updatedValues as EntityValues<M>,
|
|
130
129
|
entityId,
|
|
131
|
-
|
|
130
|
+
propertyConfigs: customizationController.propertyConfigs
|
|
132
131
|
});
|
|
133
132
|
callbacks.onSaveSuccess({
|
|
134
133
|
collection: resolvedCollection,
|
|
@@ -157,7 +156,7 @@ export async function saveEntityWithCallbacks<M extends Record<string, any>, Use
|
|
|
157
156
|
path,
|
|
158
157
|
values: updatedValues as EntityValues<M>,
|
|
159
158
|
entityId,
|
|
160
|
-
|
|
159
|
+
propertyConfigs: customizationController.propertyConfigs
|
|
161
160
|
});
|
|
162
161
|
callbacks.onSaveFailure({
|
|
163
162
|
collection: resolvedCollection,
|
|
@@ -60,7 +60,7 @@ export interface CollectionFetchResult<M extends Record<string, any>> {
|
|
|
60
60
|
* @param searchString
|
|
61
61
|
* @group Hooks and utilities
|
|
62
62
|
*/
|
|
63
|
-
export function useCollectionFetch<M extends Record<string, any>,
|
|
63
|
+
export function useCollectionFetch<M extends Record<string, any>, USER extends User>(
|
|
64
64
|
{
|
|
65
65
|
path: inputPath,
|
|
66
66
|
collection,
|
|
@@ -78,7 +78,7 @@ export function useCollectionFetch<M extends Record<string, any>, UserType exten
|
|
|
78
78
|
const sortByProperty = sortBy ? sortBy[0] : undefined;
|
|
79
79
|
const currentSort = sortBy ? sortBy[1] : undefined;
|
|
80
80
|
|
|
81
|
-
const context: FireCMSContext<
|
|
81
|
+
const context: FireCMSContext<USER> = useFireCMSContext();
|
|
82
82
|
|
|
83
83
|
const [data, setData] = useState<Entity<M>[]>([]);
|
|
84
84
|
|
|
@@ -7,10 +7,10 @@ import { useFireCMSContext } from "../useFireCMSContext";
|
|
|
7
7
|
/**
|
|
8
8
|
* @group Hooks and utilities
|
|
9
9
|
*/
|
|
10
|
-
export interface EntityFetchProps<M extends Record<string, any>,
|
|
10
|
+
export interface EntityFetchProps<M extends Record<string, any>, USER extends User = User> {
|
|
11
11
|
path: string;
|
|
12
12
|
entityId?: string;
|
|
13
|
-
collection: EntityCollection<M,
|
|
13
|
+
collection: EntityCollection<M, USER>;
|
|
14
14
|
useCache?: boolean;
|
|
15
15
|
}
|
|
16
16
|
|
|
@@ -35,20 +35,20 @@ const CACHE: Record<string, Entity<any> | undefined> = {};
|
|
|
35
35
|
* @group Hooks and utilities
|
|
36
36
|
*/
|
|
37
37
|
|
|
38
|
-
export function useEntityFetch<M extends Record<string, any>,
|
|
38
|
+
export function useEntityFetch<M extends Record<string, any>, USER extends User>(
|
|
39
39
|
{
|
|
40
40
|
path: inputPath,
|
|
41
41
|
entityId,
|
|
42
42
|
collection,
|
|
43
43
|
useCache = false
|
|
44
|
-
}: EntityFetchProps<M,
|
|
44
|
+
}: EntityFetchProps<M, USER>): EntityFetchResult<M> {
|
|
45
45
|
|
|
46
46
|
const dataSource = useDataSource(collection);
|
|
47
47
|
const navigationController = useNavigationController();
|
|
48
48
|
|
|
49
49
|
const path = navigationController.resolveAliasesFrom(inputPath);
|
|
50
50
|
|
|
51
|
-
const context: FireCMSContext<
|
|
51
|
+
const context: FireCMSContext<USER> = useFireCMSContext();
|
|
52
52
|
|
|
53
53
|
const [entity, setEntity] = useState<Entity<M> | undefined>();
|
|
54
54
|
const [dataLoading, setDataLoading] = useState<boolean>(true);
|
|
@@ -11,4 +11,4 @@ import { AuthControllerContext } from "../contexts/AuthControllerContext";
|
|
|
11
11
|
* @see AuthController
|
|
12
12
|
* @group Hooks and utilities
|
|
13
13
|
*/
|
|
14
|
-
export const useAuthController = <
|
|
14
|
+
export const useAuthController = <USER extends User = User, AuthControllerType extends AuthController<USER> = AuthController<USER>>(): AuthControllerType => useContext(AuthControllerContext) as AuthControllerType;
|
|
@@ -30,10 +30,10 @@ import { getParentReferencesFromPath } from "../util/parent_references_from_path
|
|
|
30
30
|
const DEFAULT_BASE_PATH = "/";
|
|
31
31
|
const DEFAULT_COLLECTION_PATH = "/c";
|
|
32
32
|
|
|
33
|
-
export type BuildNavigationContextProps<EC extends EntityCollection,
|
|
33
|
+
export type BuildNavigationContextProps<EC extends EntityCollection, USER extends User> = {
|
|
34
34
|
basePath?: string,
|
|
35
35
|
baseCollectionPath?: string,
|
|
36
|
-
authController: AuthController<
|
|
36
|
+
authController: AuthController<USER>;
|
|
37
37
|
collections?: EC[] | EntityCollectionsBuilder<EC>;
|
|
38
38
|
collectionPermissions?: PermissionsBuilder;
|
|
39
39
|
views?: CMSView[] | CMSViewsBuilder;
|
|
@@ -51,7 +51,7 @@ export type BuildNavigationContextProps<EC extends EntityCollection, UserType ex
|
|
|
51
51
|
injectCollections?: (collections: EntityCollection[]) => EntityCollection[];
|
|
52
52
|
};
|
|
53
53
|
|
|
54
|
-
export function useBuildNavigationController<EC extends EntityCollection,
|
|
54
|
+
export function useBuildNavigationController<EC extends EntityCollection, USER extends User>(props: BuildNavigationContextProps<EC, USER>): NavigationController {
|
|
55
55
|
const {
|
|
56
56
|
basePath = DEFAULT_BASE_PATH,
|
|
57
57
|
baseCollectionPath = DEFAULT_COLLECTION_PATH,
|
|
@@ -202,6 +202,7 @@ export function useBuildNavigationController<EC extends EntityCollection, UserTy
|
|
|
202
202
|
let shouldUpdateTopLevelNav = false;
|
|
203
203
|
if (!areCollectionListsEqual(collectionsRef.current ?? [], resolvedCollections)) {
|
|
204
204
|
collectionsRef.current = resolvedCollections;
|
|
205
|
+
console.log("Collections have changed", resolvedCollections);
|
|
205
206
|
shouldUpdateTopLevelNav = true;
|
|
206
207
|
}
|
|
207
208
|
if (collectionsRef.current === undefined) {
|
|
@@ -428,7 +429,7 @@ function filterOutNotAllowedCollections(resolvedCollections: EntityCollection[],
|
|
|
428
429
|
return resolvedCollections
|
|
429
430
|
.filter((c) => {
|
|
430
431
|
if (!c.permissions) return true;
|
|
431
|
-
const resolvedPermissions = resolvePermissions(c, authController, c.path, null)
|
|
432
|
+
const resolvedPermissions = resolvePermissions(c, authController, c.path, null);
|
|
432
433
|
return resolvedPermissions?.read !== false;
|
|
433
434
|
})
|
|
434
435
|
.map((c) => {
|
|
@@ -461,9 +462,7 @@ async function resolveCollections(collections: undefined | EntityCollection[] |
|
|
|
461
462
|
}
|
|
462
463
|
|
|
463
464
|
resolvedCollections = applyPermissionsFunctionIfEmpty(resolvedCollections, collectionPermissions);
|
|
464
|
-
|
|
465
465
|
resolvedCollections = filterOutNotAllowedCollections(resolvedCollections, authController);
|
|
466
|
-
|
|
467
466
|
return resolvedCollections;
|
|
468
467
|
}
|
|
469
468
|
|
|
@@ -21,9 +21,9 @@ import React, { useEffect } from "react";
|
|
|
21
21
|
* @see FireCMSContext
|
|
22
22
|
* @group Hooks and utilities
|
|
23
23
|
*/
|
|
24
|
-
export const useFireCMSContext = <
|
|
24
|
+
export const useFireCMSContext = <USER extends User = User, AuthControllerType extends AuthController<USER> = AuthController<USER>>(): FireCMSContext<USER, AuthControllerType> => {
|
|
25
25
|
|
|
26
|
-
const authController = useAuthController<
|
|
26
|
+
const authController = useAuthController<USER, AuthControllerType>();
|
|
27
27
|
const sideDialogsController = useSideDialogsController();
|
|
28
28
|
const sideEntityController = useSideEntityController();
|
|
29
29
|
const navigation = useNavigationController();
|
|
@@ -35,7 +35,7 @@ export const useFireCMSContext = <UserType extends User = User, AuthControllerTy
|
|
|
35
35
|
const customizationController = useCustomizationController();
|
|
36
36
|
const analyticsController = useAnalyticsController();
|
|
37
37
|
|
|
38
|
-
const fireCMSContextRef = React.useRef<FireCMSContext<
|
|
38
|
+
const fireCMSContextRef = React.useRef<FireCMSContext<USER, AuthControllerType>>({
|
|
39
39
|
authController,
|
|
40
40
|
sideDialogsController,
|
|
41
41
|
sideEntityController,
|
|
@@ -68,9 +68,9 @@ export const useFireCMSContext = <UserType extends User = User, AuthControllerTy
|
|
|
68
68
|
return fireCMSContextRef.current;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
// export const useFireCMSContext = <
|
|
71
|
+
// export const useFireCMSContext = <USER extends User = User, AuthControllerType extends AuthController<USER> = AuthController<USER>>(): FireCMSContext<USER, AuthControllerType> => {
|
|
72
72
|
//
|
|
73
|
-
// const authController = useAuthController<
|
|
73
|
+
// const authController = useAuthController<USER, AuthControllerType>();
|
|
74
74
|
// const sideDialogsController = useSideDialogsController();
|
|
75
75
|
// const sideEntityController = useSideEntityController();
|
|
76
76
|
// const navigation = useNavigationController();
|
|
@@ -55,12 +55,12 @@ interface ResolvedNavigationEntityCustom<M extends Record<string, any>> {
|
|
|
55
55
|
* @param context
|
|
56
56
|
* @group Hooks and utilities
|
|
57
57
|
*/
|
|
58
|
-
export function resolveNavigationFrom<M extends Record<string, any>,
|
|
58
|
+
export function resolveNavigationFrom<M extends Record<string, any>, USER extends User>({
|
|
59
59
|
path,
|
|
60
60
|
context
|
|
61
61
|
}: {
|
|
62
62
|
path: string,
|
|
63
|
-
context: FireCMSContext<
|
|
63
|
+
context: FireCMSContext<USER>
|
|
64
64
|
}): Promise<ResolvedNavigationEntry<M>[]> {
|
|
65
65
|
|
|
66
66
|
const dataSource = context.dataSource;
|
|
@@ -126,12 +126,12 @@ export interface NavigationFrom<M extends Record<string, any>> {
|
|
|
126
126
|
* in any React component that lives under `FireCMS`
|
|
127
127
|
* @group Hooks and utilities
|
|
128
128
|
*/
|
|
129
|
-
export function useResolvedNavigationFrom<M extends Record<string, any>,
|
|
129
|
+
export function useResolvedNavigationFrom<M extends Record<string, any>, USER extends User>(
|
|
130
130
|
{
|
|
131
131
|
path
|
|
132
132
|
}: NavigationFromProps): NavigationFrom<M> {
|
|
133
133
|
|
|
134
|
-
const context: FireCMSContext<
|
|
134
|
+
const context: FireCMSContext<USER> = useFireCMSContext();
|
|
135
135
|
|
|
136
136
|
const [data, setData] = useState<ResolvedNavigationEntry<M>[] | undefined>();
|
|
137
137
|
const [dataLoading, setDataLoading] = useState<boolean>(false);
|
|
@@ -142,7 +142,7 @@ export function useResolvedNavigationFrom<M extends Record<string, any>, UserTyp
|
|
|
142
142
|
if (navigation) {
|
|
143
143
|
setDataLoading(true);
|
|
144
144
|
setDataLoadingError(undefined);
|
|
145
|
-
resolveNavigationFrom<M,
|
|
145
|
+
resolveNavigationFrom<M, USER>({ path, context })
|
|
146
146
|
.then((res) => {
|
|
147
147
|
setData(res);
|
|
148
148
|
})
|
|
@@ -11,7 +11,7 @@ import { AuthController, Authenticator, DataSourceDelegate, StorageSource, User
|
|
|
11
11
|
* @param storageSource
|
|
12
12
|
* @param dataSourceDelegate
|
|
13
13
|
*/
|
|
14
|
-
export function useValidateAuthenticator<
|
|
14
|
+
export function useValidateAuthenticator<USER extends User = any>
|
|
15
15
|
({
|
|
16
16
|
disabled,
|
|
17
17
|
authController,
|
|
@@ -21,8 +21,8 @@ export function useValidateAuthenticator<UserType extends User = User, Controlle
|
|
|
21
21
|
}:
|
|
22
22
|
{
|
|
23
23
|
disabled?: boolean,
|
|
24
|
-
authController:
|
|
25
|
-
authenticator?: boolean | Authenticator<
|
|
24
|
+
authController: AuthController<USER>,
|
|
25
|
+
authenticator?: boolean | Authenticator<USER>,
|
|
26
26
|
dataSourceDelegate: DataSourceDelegate;
|
|
27
27
|
storageSource: StorageSource;
|
|
28
28
|
}): {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useCallback } from "react";
|
|
2
2
|
import { Blocker, Transition } from "history";
|
|
3
3
|
import { UNSAFE_NavigationContext, useNavigate } from "react-router-dom";
|
|
4
|
-
import { Button, Dialog, DialogActions, DialogContent, Typography } from "@firecms/ui";
|
|
4
|
+
import { Button, Dialog, DialogActions, DialogContent, DialogTitle, Typography } from "@firecms/ui";
|
|
5
5
|
|
|
6
6
|
export function useNavigationUnsavedChangesDialog(when: boolean, onSuccess: () => void):
|
|
7
7
|
{
|
|
@@ -89,8 +89,8 @@ export function UnsavedChangesDialog({
|
|
|
89
89
|
}}
|
|
90
90
|
open={open}
|
|
91
91
|
>
|
|
92
|
+
<DialogTitle variant={"h6"}>{title}</DialogTitle>
|
|
92
93
|
<DialogContent>
|
|
93
|
-
<Typography variant={"h6"}>{title}</Typography>
|
|
94
94
|
|
|
95
95
|
{body}
|
|
96
96
|
|
|
@@ -53,10 +53,10 @@ export const PropertyPreview = React.memo(function PropertyPreview<T extends CMS
|
|
|
53
53
|
const property = resolveProperty({
|
|
54
54
|
propertyKey,
|
|
55
55
|
propertyOrBuilder: inputProperty,
|
|
56
|
-
|
|
56
|
+
propertyConfigs: customizationController.propertyConfigs
|
|
57
57
|
});
|
|
58
58
|
|
|
59
|
-
if (
|
|
59
|
+
if (property === null) {
|
|
60
60
|
content = <EmptyValue/>;
|
|
61
61
|
} else if (property.Preview) {
|
|
62
62
|
content = createElement(property.Preview as React.ComponentType<PropertyPreviewProps>,
|
|
@@ -70,7 +70,7 @@ export const PropertyPreview = React.memo(function PropertyPreview<T extends CMS
|
|
|
70
70
|
// entity,
|
|
71
71
|
customProps: property.customProps
|
|
72
72
|
});
|
|
73
|
-
} else if (value === null) {
|
|
73
|
+
} else if (value === undefined || value === null) {
|
|
74
74
|
content = <EmptyValue/>;
|
|
75
75
|
} else if (property.dataType === "string") {
|
|
76
76
|
const stringProperty = property as ResolvedStringProperty;
|
|
@@ -21,6 +21,6 @@ export function BooleanPreview({
|
|
|
21
21
|
size={size}
|
|
22
22
|
color={"secondary"}/>
|
|
23
23
|
{property.name && <span
|
|
24
|
-
className={cls("text-text-secondary dark:text-text-secondary-dark", size === "
|
|
24
|
+
className={cls("text-text-secondary dark:text-text-secondary-dark", size === "small" ? "text-sm" : "")}>{property.name}</span>}
|
|
25
25
|
</div>;
|
|
26
26
|
}
|
|
@@ -6,5 +6,5 @@ import React from "react";
|
|
|
6
6
|
export function EmptyValue() {
|
|
7
7
|
|
|
8
8
|
return <div
|
|
9
|
-
className="rounded-full bg-
|
|
9
|
+
className="rounded-full bg-surface-200 bg-opacity-30 dark:bg-opacity-20 w-5 h-2 inline-block"/>;
|
|
10
10
|
}
|
|
@@ -6,7 +6,7 @@ import { buildEnumLabel, enumToObjectEntries, getColorScheme, getLabelOrConfigFr
|
|
|
6
6
|
export interface EnumValuesChipProps {
|
|
7
7
|
enumValues?: EnumValues;
|
|
8
8
|
enumKey: string | number;
|
|
9
|
-
size: "
|
|
9
|
+
size: "small" | "medium" | "large";
|
|
10
10
|
className?: string;
|
|
11
11
|
children?: React.ReactNode;
|
|
12
12
|
}
|
|
@@ -22,7 +22,7 @@ export function ImagePreview({
|
|
|
22
22
|
|
|
23
23
|
const imageSize = useMemo(() => getThumbnailMeasure(size), [size]);
|
|
24
24
|
|
|
25
|
-
if (size === "
|
|
25
|
+
if (size === "small") {
|
|
26
26
|
return (
|
|
27
27
|
<img src={url}
|
|
28
28
|
className={"rounded-md"}
|
|
@@ -56,7 +56,6 @@ export function ImagePreview({
|
|
|
56
56
|
className={"rounded-md"}
|
|
57
57
|
style={imageStyle}/>
|
|
58
58
|
|
|
59
|
-
|
|
60
59
|
<div className={"flex flex-row gap-2 absolute bottom-[-4px] right-[-4px] invisible group-hover:visible"}>
|
|
61
60
|
{navigator && <Tooltip
|
|
62
61
|
asChild={true}
|
|
@@ -69,8 +68,8 @@ export function ImagePreview({
|
|
|
69
68
|
e.preventDefault();
|
|
70
69
|
return navigator.clipboard.writeText(url);
|
|
71
70
|
}}>
|
|
72
|
-
<ContentCopyIcon className={"text-
|
|
73
|
-
size={"
|
|
71
|
+
<ContentCopyIcon className={"text-surface-700 dark:text-surface-300"}
|
|
72
|
+
size={"smallest"}/>
|
|
74
73
|
</IconButton>
|
|
75
74
|
</Tooltip>}
|
|
76
75
|
|
|
@@ -85,8 +84,8 @@ export function ImagePreview({
|
|
|
85
84
|
size={"small"}
|
|
86
85
|
onClick={(e: any) => e.stopPropagation()}
|
|
87
86
|
>
|
|
88
|
-
<OpenInNewIcon className={"text-
|
|
89
|
-
size={"
|
|
87
|
+
<OpenInNewIcon className={"text-surface-700 dark:text-surface-300"}
|
|
88
|
+
size={"smallest"}/>
|
|
90
89
|
</IconButton>
|
|
91
90
|
</Tooltip>
|
|
92
91
|
</div>
|
|
@@ -65,7 +65,7 @@ export function UrlComponentPreview({
|
|
|
65
65
|
width: getThumbnailMeasure(size),
|
|
66
66
|
height: getThumbnailMeasure(size)
|
|
67
67
|
}}>
|
|
68
|
-
<DescriptionIcon className="text-
|
|
68
|
+
<DescriptionIcon className="text-surface-700 dark:text-surface-300"/>
|
|
69
69
|
{hint &&
|
|
70
70
|
<Tooltip title={hint}>
|
|
71
71
|
<Typography
|
|
@@ -84,11 +84,11 @@ function VideoPreview({
|
|
|
84
84
|
}: { size: PreviewSize, src: string, interactive: boolean }) {
|
|
85
85
|
|
|
86
86
|
const imageSize = useMemo(() => {
|
|
87
|
-
if (size === "
|
|
87
|
+
if (size === "small")
|
|
88
88
|
return "140px";
|
|
89
|
-
else if (size === "small")
|
|
90
|
-
return "240px";
|
|
91
89
|
else if (size === "medium")
|
|
90
|
+
return "240px";
|
|
91
|
+
else if (size === "large")
|
|
92
92
|
return "100%";
|
|
93
93
|
else throw new Error("Invalid size");
|
|
94
94
|
}, [size]);
|
|
@@ -20,7 +20,7 @@ export function ArrayOfMapsPreview({
|
|
|
20
20
|
const property = resolveArrayProperty({
|
|
21
21
|
propertyKey,
|
|
22
22
|
property: inputProperty,
|
|
23
|
-
|
|
23
|
+
propertyConfigs: customizationController.propertyConfigs
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
if (Array.isArray(property?.of)) {
|
|
@@ -18,7 +18,7 @@ export function ArrayOfReferencesPreview({
|
|
|
18
18
|
const property = resolveArrayProperty({
|
|
19
19
|
propertyKey,
|
|
20
20
|
property: inputProperty,
|
|
21
|
-
|
|
21
|
+
propertyConfigs: customizationController.propertyConfigs
|
|
22
22
|
});
|
|
23
23
|
|
|
24
24
|
if (Array.isArray(property?.of)) {
|
|
@@ -28,7 +28,7 @@ export function ArrayOfReferencesPreview({
|
|
|
28
28
|
if (property?.dataType !== "array" || !property.of || property.of.dataType !== "reference")
|
|
29
29
|
throw Error("Picked wrong preview component ArrayOfReferencesPreview");
|
|
30
30
|
|
|
31
|
-
const childSize: PreviewSize = size === "medium" ? "
|
|
31
|
+
const childSize: PreviewSize = size === "medium" ? "medium" : "small";
|
|
32
32
|
|
|
33
33
|
return (
|
|
34
34
|
<div className="flex flex-col w-full">
|
|
@@ -23,7 +23,7 @@ export function ArrayOfStorageComponentsPreview({
|
|
|
23
23
|
const property = resolveArrayProperty({
|
|
24
24
|
propertyKey,
|
|
25
25
|
property: inputProperty,
|
|
26
|
-
|
|
26
|
+
propertyConfigs: customizationController.propertyConfigs
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
if (Array.isArray(property.of)) {
|
|
@@ -33,7 +33,7 @@ export function ArrayOfStorageComponentsPreview({
|
|
|
33
33
|
if (property.dataType !== "array" || !property.of || property.of.dataType !== "string")
|
|
34
34
|
throw Error("Picked wrong preview component ArrayOfStorageComponentsPreview");
|
|
35
35
|
|
|
36
|
-
const childSize: PreviewSize = size === "medium" ? "
|
|
36
|
+
const childSize: PreviewSize = size === "medium" ? "medium" : "small";
|
|
37
37
|
|
|
38
38
|
return (
|
|
39
39
|
<div className={"flex flex-wrap gap-2"}>
|
|
@@ -21,7 +21,7 @@ export function ArrayOfStringsPreview({
|
|
|
21
21
|
const property = resolveArrayProperty({
|
|
22
22
|
propertyKey,
|
|
23
23
|
property: inputProperty,
|
|
24
|
-
|
|
24
|
+
propertyConfigs: customizationController.propertyConfigs
|
|
25
25
|
});
|
|
26
26
|
|
|
27
27
|
if (Array.isArray(property.of)) {
|
|
@@ -23,7 +23,7 @@ export function ArrayOneOfPreview({
|
|
|
23
23
|
const property = resolveArrayProperty({
|
|
24
24
|
propertyKey,
|
|
25
25
|
property: inputProperty,
|
|
26
|
-
|
|
26
|
+
propertyConfigs: customizationController.propertyConfigs
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
if (property?.dataType !== "array")
|
|
@@ -37,7 +37,7 @@ export function ArrayOneOfPreview({
|
|
|
37
37
|
|
|
38
38
|
if (!values) return null;
|
|
39
39
|
|
|
40
|
-
const childSize: PreviewSize = size === "medium" ? "
|
|
40
|
+
const childSize: PreviewSize = size === "medium" ? "medium" : "small";
|
|
41
41
|
|
|
42
42
|
const typeField = property.oneOf.typeField ?? DEFAULT_ONE_OF_TYPE;
|
|
43
43
|
const valueField = property.oneOf.valueField ?? DEFAULT_ONE_OF_VALUE;
|
|
@@ -23,7 +23,7 @@ export function ArrayPropertyPreview({
|
|
|
23
23
|
const property = resolveArrayProperty({
|
|
24
24
|
propertyKey,
|
|
25
25
|
property: inputProperty,
|
|
26
|
-
|
|
26
|
+
propertyConfigs: customizationController.propertyConfigs
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
if (!property.of) {
|
|
@@ -37,7 +37,7 @@ export function ArrayPropertyPreview({
|
|
|
37
37
|
|
|
38
38
|
if (!values) return null;
|
|
39
39
|
|
|
40
|
-
const childSize: PreviewSize = size === "medium" ? "
|
|
40
|
+
const childSize: PreviewSize = size === "medium" ? "medium" : "small";
|
|
41
41
|
|
|
42
42
|
return (
|
|
43
43
|
<div className="flex flex-col gap-2">
|
|
@@ -34,7 +34,7 @@ export function MapPropertyPreview<T extends Record<string, any> = Record<string
|
|
|
34
34
|
|
|
35
35
|
const mapPropertyKeys: string[] = Object.keys(mapProperty.properties)
|
|
36
36
|
|
|
37
|
-
if (size === "
|
|
37
|
+
if (size === "small")
|
|
38
38
|
return (
|
|
39
39
|
<div className="w-full flex flex-col space-y-1 md:space-y-2">
|
|
40
40
|
{mapPropertyKeys.map((key, index) => (
|
|
@@ -110,7 +110,7 @@ export function KeyValuePreview({ value }: { value: any }) {
|
|
|
110
110
|
return <div
|
|
111
111
|
className="flex flex-col gap-1 w-full">
|
|
112
112
|
{
|
|
113
|
-
Object.entries(value).map(([key, childValue]) => (
|
|
113
|
+
Object.entries(value).map(([key, childValue]: [string, any]) => (
|
|
114
114
|
<div
|
|
115
115
|
key={`map_preview_table_${key}}`}
|
|
116
116
|
className={cls(defaultBorderMixin, "last:border-b-0 border-b")}>
|
|
@@ -127,9 +127,9 @@ export function KeyValuePreview({ value }: { value: any }) {
|
|
|
127
127
|
</div>
|
|
128
128
|
<div
|
|
129
129
|
className="flex-grow max-w-[75%]">
|
|
130
|
-
{
|
|
130
|
+
{childValue && <Typography>
|
|
131
131
|
<ErrorBoundary>
|
|
132
|
-
{childValue
|
|
132
|
+
{childValue.toString()}
|
|
133
133
|
</ErrorBoundary>
|
|
134
134
|
</Typography>}
|
|
135
135
|
</div>
|