@firecms/core 3.0.0-alpha.81 → 3.0.0-alpha.82
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/EntityCollectionTableProps.d.ts +3 -3
- package/dist/components/EntityCollectionTable/column_utils.d.ts +2 -2
- package/dist/components/EntityCollectionTable/fields/TableReferenceField.d.ts +5 -1
- package/dist/components/EntityCollectionView/EntityCollectionView.d.ts +1 -1
- package/dist/components/EntityCollectionView/EntityCollectionViewActions.d.ts +1 -1
- package/dist/components/VirtualTable/VirtualTableProps.d.ts +1 -1
- package/dist/contexts/AnalyticsContext.d.ts +3 -0
- package/dist/contexts/CustomizationControllerContext.d.ts +3 -0
- package/dist/core/field_configs.d.ts +1 -1
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/useAnalyticsController.d.ts +5 -0
- package/dist/hooks/useCustomizationController.d.ts +11 -0
- package/dist/hooks/useFireCMSContext.d.ts +0 -1
- package/dist/index.es.js +4614 -4592
- 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/useBuildCustomizationController.d.ts +2 -0
- package/dist/types/analytics_controller.d.ts +7 -0
- package/dist/types/collections.d.ts +3 -0
- package/dist/types/customization_controller.d.ts +47 -0
- package/dist/types/entity_callbacks.d.ts +17 -3
- package/dist/types/firecms_context.d.ts +6 -46
- package/dist/types/index.d.ts +2 -0
- package/dist/util/icons.d.ts +4 -1
- package/dist/util/useTraceUpdate.d.ts +1 -1
- package/package.json +3 -3
- package/src/components/DeleteEntityDialog.tsx +9 -3
- package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +28 -5
- package/src/components/EntityCollectionTable/EntityCollectionTableProps.tsx +4 -5
- package/src/components/EntityCollectionTable/column_utils.tsx +3 -3
- package/src/components/EntityCollectionTable/fields/TableReferenceField.tsx +125 -122
- package/src/components/EntityCollectionTable/filters/DateTimeFilterField.tsx +2 -2
- package/src/components/EntityCollectionTable/internal/default_entity_actions.tsx +3 -3
- package/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +4 -3
- package/src/components/EntityCollectionView/EntityCollectionView.tsx +74 -50
- package/src/components/EntityCollectionView/EntityCollectionViewActions.tsx +5 -3
- package/src/components/EntityPreview.tsx +11 -7
- package/src/components/HomePage/DefaultHomePage.tsx +9 -8
- package/src/components/HomePage/NavigationCollectionCard.tsx +6 -5
- package/src/components/ReferenceSelectionInner.tsx +13 -9
- package/src/components/VirtualTable/VirtualTable.tsx +23 -20
- package/src/components/VirtualTable/VirtualTableCell.tsx +27 -9
- package/src/components/VirtualTable/VirtualTableHeader.tsx +1 -1
- package/src/components/VirtualTable/VirtualTableProps.tsx +2 -2
- package/src/components/VirtualTable/fields/VirtualTableDateField.tsx +2 -2
- package/src/contexts/AnalyticsContext.tsx +4 -0
- package/src/contexts/CustomizationControllerContext.tsx +4 -0
- package/src/core/Drawer.tsx +7 -6
- package/src/core/FireCMS.tsx +39 -29
- package/src/form/EntityForm.tsx +16 -5
- package/src/form/PropertyFieldBinding.tsx +8 -10
- package/src/form/components/CustomIdField.tsx +7 -5
- package/src/form/field_bindings/ArrayCustomShapedFieldBinding.tsx +1 -2
- package/src/form/field_bindings/DateTimeFieldBinding.tsx +2 -2
- package/src/form/field_bindings/KeyValueFieldBinding.tsx +4 -6
- package/src/hooks/data/save.ts +8 -3
- package/src/hooks/index.tsx +1 -0
- package/src/hooks/useAnalyticsController.tsx +8 -0
- package/src/hooks/useCustomizationController.tsx +14 -0
- package/src/hooks/useFireCMSContext.tsx +8 -7
- package/src/internal/EntityView.tsx +4 -2
- package/src/internal/useBuildCustomizationController.tsx +5 -0
- package/src/internal/useBuildSideDialogsController.tsx +0 -1
- package/src/preview/PropertyPreview.tsx +4 -3
- package/src/preview/components/DatePreview.tsx +4 -5
- package/src/preview/components/ReferencePreview.tsx +17 -8
- package/src/preview/property_previews/ArrayOfMapsPreview.tsx +3 -3
- package/src/preview/property_previews/ArrayOfReferencesPreview.tsx +3 -3
- package/src/preview/property_previews/ArrayOfStorageComponentsPreview.tsx +3 -3
- package/src/preview/property_previews/ArrayOfStringsPreview.tsx +4 -4
- package/src/preview/property_previews/ArrayOneOfPreview.tsx +3 -3
- package/src/preview/property_previews/ArrayPropertyPreview.tsx +3 -3
- package/src/types/analytics_controller.tsx +10 -0
- package/src/types/collections.ts +3 -0
- package/src/types/customization_controller.tsx +58 -0
- package/src/types/entity_callbacks.ts +22 -3
- package/src/types/firecms_context.tsx +6 -51
- package/src/types/index.ts +2 -0
- package/src/util/icons.tsx +22 -19
- package/src/util/useTraceUpdate.tsx +5 -5
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
import { ReadOnlyFieldBinding } from "./field_bindings/ReadOnlyFieldBinding";
|
|
18
18
|
|
|
19
19
|
import { isHidden, isPropertyBuilder, isReadOnly, resolveProperty } from "../util";
|
|
20
|
-
import {
|
|
20
|
+
import { useCustomizationController } from "../hooks";
|
|
21
21
|
import { Typography } from "@firecms/ui";
|
|
22
22
|
import { getFieldConfig, getFieldId } from "../core";
|
|
23
23
|
import { ErrorBoundary } from "../components";
|
|
@@ -81,9 +81,9 @@ function PropertyFieldBindingInternal<T extends CMSType = CMSType, CustomProps =
|
|
|
81
81
|
autoFocus,
|
|
82
82
|
}: PropertyFieldBindingProps<T, M>): ReactElement<PropertyFieldBindingProps<T, M>> {
|
|
83
83
|
|
|
84
|
-
const
|
|
84
|
+
const customizationController = useCustomizationController();
|
|
85
85
|
|
|
86
|
-
const shouldAlwaysRerender = shouldPropertyReRender(property,
|
|
86
|
+
const shouldAlwaysRerender = shouldPropertyReRender(property, customizationController.plugins);
|
|
87
87
|
// we use the standard Field for user defined fields, since it rebuilds
|
|
88
88
|
// when there are changes in other values, in contrast to FastField
|
|
89
89
|
const FieldComponent = shouldAlwaysRerender ? Field : FastField;
|
|
@@ -102,7 +102,7 @@ function PropertyFieldBindingInternal<T extends CMSType = CMSType, CustomProps =
|
|
|
102
102
|
values: fieldProps.form.values,
|
|
103
103
|
path: context.path,
|
|
104
104
|
entityId: context.entityId,
|
|
105
|
-
fields:
|
|
105
|
+
fields: customizationController.propertyConfigs
|
|
106
106
|
});
|
|
107
107
|
|
|
108
108
|
if (resolvedProperty === null || isHidden(resolvedProperty)) {
|
|
@@ -114,9 +114,9 @@ function PropertyFieldBindingInternal<T extends CMSType = CMSType, CustomProps =
|
|
|
114
114
|
Component = resolvedProperty.Field as ComponentType<FieldProps<any>>;
|
|
115
115
|
}
|
|
116
116
|
} else {
|
|
117
|
-
const propertyConfig = getFieldConfig(resolvedProperty,
|
|
117
|
+
const propertyConfig = getFieldConfig(resolvedProperty, customizationController.propertyConfigs);
|
|
118
118
|
if (!propertyConfig) {
|
|
119
|
-
console.log("INTERNAL: Could not find field config for property", { propertyKey, resolvedProperty, fields:
|
|
119
|
+
console.log("INTERNAL: Could not find field config for property", { propertyKey, resolvedProperty, fields: customizationController.propertyConfigs, propertyConfig });
|
|
120
120
|
throw new Error(`INTERNAL: Could not find field config for property ${propertyKey}`);
|
|
121
121
|
}
|
|
122
122
|
const configProperty = resolveProperty({
|
|
@@ -125,7 +125,7 @@ function PropertyFieldBindingInternal<T extends CMSType = CMSType, CustomProps =
|
|
|
125
125
|
values: fieldProps.form.values,
|
|
126
126
|
path: context.path,
|
|
127
127
|
entityId: context.entityId,
|
|
128
|
-
fields:
|
|
128
|
+
fields: customizationController.propertyConfigs
|
|
129
129
|
});
|
|
130
130
|
Component = configProperty.Field as ComponentType<FieldProps<T>>;
|
|
131
131
|
}
|
|
@@ -189,7 +189,7 @@ function FieldInternal<T extends CMSType, CustomProps, M extends Record<string,
|
|
|
189
189
|
fieldProps: FormikFieldProps<T>
|
|
190
190
|
}) {
|
|
191
191
|
|
|
192
|
-
const { plugins } =
|
|
192
|
+
const { plugins } = useCustomizationController();
|
|
193
193
|
|
|
194
194
|
const customFieldProps: any = property.customProps;
|
|
195
195
|
const value = fieldProps.field.value;
|
|
@@ -197,8 +197,6 @@ function FieldInternal<T extends CMSType, CustomProps, M extends Record<string,
|
|
|
197
197
|
const error = getIn(fieldProps.form.errors, propertyKey);
|
|
198
198
|
const touched = getIn(fieldProps.form.touched, propertyKey);
|
|
199
199
|
|
|
200
|
-
console.log("error", propertyKey, error);
|
|
201
|
-
|
|
202
200
|
const showError: boolean = error &&
|
|
203
201
|
(fieldProps.form.submitCount > 0 || property.validation?.unique) &&
|
|
204
202
|
(!Array.isArray(error) || !!error.filter((e: any) => !!e).length);
|
|
@@ -2,12 +2,14 @@ import React, { useMemo } from "react";
|
|
|
2
2
|
|
|
3
3
|
import { ErrorMessage } from "formik";
|
|
4
4
|
|
|
5
|
-
import { Entity, EntityStatus, EnumValueConfig, EnumValues
|
|
5
|
+
import { Entity, EntityStatus, EnumValueConfig, EnumValues } from "../../types";
|
|
6
6
|
|
|
7
|
-
import { useClipboard,
|
|
7
|
+
import { useClipboard, useSnackbarController } from "../../hooks";
|
|
8
8
|
import { enumToObjectEntries } from "../../util";
|
|
9
9
|
import { ContentCopyIcon, IconButton, OpenInNewIcon, Select, SelectItem, TextField, Tooltip } from "@firecms/ui";
|
|
10
10
|
import { EnumValuesChip } from "../../preview";
|
|
11
|
+
import { useCustomizationController } from "../../hooks/useCustomizationController";
|
|
12
|
+
import { CustomizationController } from "../../types/customization_controller";
|
|
11
13
|
|
|
12
14
|
export function CustomIdField<M extends Record<string, any>>({
|
|
13
15
|
customId,
|
|
@@ -42,7 +44,7 @@ export function CustomIdField<M extends Record<string, any>>({
|
|
|
42
44
|
})
|
|
43
45
|
});
|
|
44
46
|
|
|
45
|
-
const
|
|
47
|
+
const customizationController: CustomizationController = useCustomizationController();
|
|
46
48
|
|
|
47
49
|
const fieldProps = {
|
|
48
50
|
label: idSetAutomatically ? "ID is set automatically" : "ID",
|
|
@@ -60,10 +62,10 @@ export function CustomIdField<M extends Record<string, any>>({
|
|
|
60
62
|
</IconButton>
|
|
61
63
|
</Tooltip>
|
|
62
64
|
|
|
63
|
-
{
|
|
65
|
+
{customizationController?.entityLinkBuilder &&
|
|
64
66
|
<Tooltip title={"Open in the console"}>
|
|
65
67
|
<IconButton component={"a"}
|
|
66
|
-
href={
|
|
68
|
+
href={customizationController.entityLinkBuilder({ entity })}
|
|
67
69
|
rel="noopener noreferrer"
|
|
68
70
|
target="_blank"
|
|
69
71
|
onClick={(e) => e.stopPropagation()}
|
|
@@ -2,7 +2,7 @@ import React from "react";
|
|
|
2
2
|
import { FieldProps } from "../../types";
|
|
3
3
|
import { FieldHelperText } from "../components";
|
|
4
4
|
import { PropertyFieldBinding } from "../PropertyFieldBinding";
|
|
5
|
-
import { useClearRestoreValue
|
|
5
|
+
import { useClearRestoreValue } from "../../hooks";
|
|
6
6
|
import { ExpandablePanel } from "@firecms/ui";
|
|
7
7
|
import { getIconForProperty } from "../../util";
|
|
8
8
|
import { LabelWithIcon } from "../../components";
|
|
@@ -29,7 +29,6 @@ export function ArrayCustomShapedFieldBinding<T extends Array<any>>({
|
|
|
29
29
|
disabled
|
|
30
30
|
}: FieldProps<T, any, any>) {
|
|
31
31
|
|
|
32
|
-
const { propertyConfigs } = useFireCMSContext();
|
|
33
32
|
if (!Array.isArray(property.resolvedProperties))
|
|
34
33
|
throw Error("ArrayCustomShapedFieldBinding misconfiguration. Property `of` not set");
|
|
35
34
|
|
|
@@ -4,7 +4,7 @@ import { FieldProps } from "../../types";
|
|
|
4
4
|
|
|
5
5
|
import { FieldHelperText } from "../components";
|
|
6
6
|
import { LabelWithIcon } from "../../components";
|
|
7
|
-
import { useClearRestoreValue,
|
|
7
|
+
import { useClearRestoreValue, useCustomizationController } from "../../hooks";
|
|
8
8
|
import { getIconForProperty } from "../../util";
|
|
9
9
|
import { DateTimeField } from "@firecms/ui";
|
|
10
10
|
|
|
@@ -30,7 +30,7 @@ export function DateTimeFieldBinding({
|
|
|
30
30
|
includeDescription
|
|
31
31
|
}: DateTimeFieldProps) {
|
|
32
32
|
|
|
33
|
-
const { locale } =
|
|
33
|
+
const { locale } = useCustomizationController();
|
|
34
34
|
const internalValue = value || null;
|
|
35
35
|
|
|
36
36
|
useClearRestoreValue({
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import React, { useEffect, useState } from "react";
|
|
2
2
|
import { DataType, EntityReference, FieldProps, GeoPoint } from "../../types";
|
|
3
3
|
|
|
4
|
-
import { ArrayContainer } from "../../components";
|
|
4
|
+
import { ArrayContainer, LabelWithIcon } from "../../components";
|
|
5
5
|
import { FieldHelperText } from "../components";
|
|
6
|
-
|
|
7
|
-
import { LabelWithIcon } from "../../components";
|
|
8
6
|
import {
|
|
9
7
|
AddIcon,
|
|
10
8
|
ArrowDropDownIcon,
|
|
@@ -22,7 +20,7 @@ import {
|
|
|
22
20
|
Typography
|
|
23
21
|
} from "@firecms/ui";
|
|
24
22
|
import { getDefaultValueForDataType, getIconForProperty } from "../../util";
|
|
25
|
-
import {
|
|
23
|
+
import { useCustomizationController } from "../../hooks";
|
|
26
24
|
|
|
27
25
|
type MapEditViewRowState = [number, {
|
|
28
26
|
key: string,
|
|
@@ -257,7 +255,7 @@ function MapKeyValueRow<T extends Record<string, any>>({
|
|
|
257
255
|
updateDataType: (rowId: number, dataType: DataType) => void
|
|
258
256
|
}) {
|
|
259
257
|
|
|
260
|
-
const { locale } =
|
|
258
|
+
const { locale } = useCustomizationController();
|
|
261
259
|
|
|
262
260
|
function buildInput(entryValue: any, fieldKey: string, dataType: DataType) {
|
|
263
261
|
if (dataType === "string" || dataType === "number") {
|
|
@@ -439,7 +437,7 @@ function ArrayKeyValueRow<T>({
|
|
|
439
437
|
disabled?: boolean,
|
|
440
438
|
}) {
|
|
441
439
|
|
|
442
|
-
const { locale } =
|
|
440
|
+
const { locale } = useCustomizationController();
|
|
443
441
|
const [selectedDataType, setSelectedDataType] = useState<DataType>(getDataType(value) ?? "string");
|
|
444
442
|
|
|
445
443
|
function doUpdateDataType(dataType: DataType) {
|
package/src/hooks/data/save.ts
CHANGED
|
@@ -70,8 +70,13 @@ export async function saveEntityWithCallbacks<M extends Record<string, any>, Use
|
|
|
70
70
|
}
|
|
71
71
|
): Promise<void> {
|
|
72
72
|
|
|
73
|
+
if (status !== "new" && !entityId) {
|
|
74
|
+
throw new Error("Entity id must be specified when updating an existing entity");
|
|
75
|
+
}
|
|
73
76
|
let updatedValues: Partial<EntityValues<M>>;
|
|
74
77
|
|
|
78
|
+
const customizationController = context.customizationController;
|
|
79
|
+
|
|
75
80
|
const resolvedPath = context.navigation.resolveAliasesFrom(path);
|
|
76
81
|
|
|
77
82
|
const callbacks = collection.callbacks;
|
|
@@ -82,7 +87,7 @@ export async function saveEntityWithCallbacks<M extends Record<string, any>, Use
|
|
|
82
87
|
path,
|
|
83
88
|
values: previousValues as EntityValues<M>,
|
|
84
89
|
entityId,
|
|
85
|
-
fields:
|
|
90
|
+
fields: customizationController.propertyConfigs
|
|
86
91
|
});
|
|
87
92
|
updatedValues = await callbacks.onPreSave({
|
|
88
93
|
collection: resolvedCollection,
|
|
@@ -119,7 +124,7 @@ export async function saveEntityWithCallbacks<M extends Record<string, any>, Use
|
|
|
119
124
|
path,
|
|
120
125
|
values: updatedValues as EntityValues<M>,
|
|
121
126
|
entityId,
|
|
122
|
-
fields:
|
|
127
|
+
fields: customizationController.propertyConfigs
|
|
123
128
|
});
|
|
124
129
|
callbacks.onSaveSuccess({
|
|
125
130
|
collection: resolvedCollection,
|
|
@@ -147,7 +152,7 @@ export async function saveEntityWithCallbacks<M extends Record<string, any>, Use
|
|
|
147
152
|
path,
|
|
148
153
|
values: updatedValues as EntityValues<M>,
|
|
149
154
|
entityId,
|
|
150
|
-
fields:
|
|
155
|
+
fields: customizationController.propertyConfigs
|
|
151
156
|
});
|
|
152
157
|
callbacks.onSaveFailure({
|
|
153
158
|
collection: resolvedCollection,
|
package/src/hooks/index.tsx
CHANGED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { useContext } from "react";
|
|
2
|
+
import { AnalyticsController } from "../types";
|
|
3
|
+
import { AnalyticsContext } from "../contexts/AnalyticsContext";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @group Hooks and utilities
|
|
7
|
+
*/
|
|
8
|
+
export const useAnalyticsController = (): AnalyticsController => useContext(AnalyticsContext);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useContext } from "react";
|
|
2
|
+
import { CustomizationController } from "../types/customization_controller";
|
|
3
|
+
import { CustomizationControllerContext } from "../contexts/CustomizationControllerContext";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Use this hook to retrieve the customization controller.
|
|
7
|
+
* This hook includes all the customization options that can be used
|
|
8
|
+
* to customize the CMS.
|
|
9
|
+
*
|
|
10
|
+
* You will likely not need to use this hook directly.
|
|
11
|
+
*
|
|
12
|
+
* @group Hooks and utilities
|
|
13
|
+
*/
|
|
14
|
+
export const useCustomizationController = (): CustomizationController => useContext(CustomizationControllerContext);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { createContext, useContext } from "react";
|
|
2
1
|
import { AuthController, FireCMSContext, User } from "../types";
|
|
3
2
|
import { useAuthController } from "./useAuthController";
|
|
4
3
|
import { useSideDialogsController } from "./useSideDialogsController";
|
|
@@ -9,8 +8,8 @@ import { useStorageSource } from "./useStorageSource";
|
|
|
9
8
|
import { useSnackbarController } from "./useSnackbarController";
|
|
10
9
|
import { useUserConfigurationPersistence } from "./useUserConfigurationPersistence";
|
|
11
10
|
import { useDialogsController } from "./useDialogsController";
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
import { useCustomizationController } from "./useCustomizationController";
|
|
12
|
+
import { useAnalyticsController } from "./useAnalyticsController";
|
|
14
13
|
|
|
15
14
|
/**
|
|
16
15
|
* Hook to retrieve the {@link FireCMSContext}.
|
|
@@ -23,7 +22,6 @@ export const FireCMSContextInstance = createContext<Partial<FireCMSContext>>({})
|
|
|
23
22
|
*/
|
|
24
23
|
export const useFireCMSContext = <UserType extends User = User, AuthControllerType extends AuthController<UserType> = AuthController<UserType>>(): FireCMSContext<UserType, AuthControllerType> => {
|
|
25
24
|
|
|
26
|
-
const partialContext = useContext(FireCMSContextInstance) as FireCMSContext<UserType, AuthControllerType>;
|
|
27
25
|
const authController = useAuthController<UserType, AuthControllerType>();
|
|
28
26
|
const sideDialogsController = useSideDialogsController();
|
|
29
27
|
const sideEntityController = useSideEntityController();
|
|
@@ -33,9 +31,10 @@ export const useFireCMSContext = <UserType extends User = User, AuthControllerTy
|
|
|
33
31
|
const snackbarController = useSnackbarController();
|
|
34
32
|
const userConfigPersistence = useUserConfigurationPersistence();
|
|
35
33
|
const dialogsController = useDialogsController();
|
|
34
|
+
const customizationController = useCustomizationController();
|
|
35
|
+
const analyticsController = useAnalyticsController();
|
|
36
36
|
|
|
37
37
|
return {
|
|
38
|
-
...partialContext,
|
|
39
38
|
authController,
|
|
40
39
|
sideDialogsController,
|
|
41
40
|
sideEntityController,
|
|
@@ -44,7 +43,9 @@ export const useFireCMSContext = <UserType extends User = User, AuthControllerTy
|
|
|
44
43
|
storageSource,
|
|
45
44
|
snackbarController,
|
|
46
45
|
userConfigPersistence,
|
|
47
|
-
dialogsController
|
|
48
|
-
|
|
46
|
+
dialogsController,
|
|
47
|
+
customizationController,
|
|
48
|
+
analyticsController
|
|
49
|
+
};
|
|
49
50
|
|
|
50
51
|
};
|
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
import {
|
|
23
23
|
saveEntityWithCallbacks,
|
|
24
24
|
useAuthController,
|
|
25
|
+
useCustomizationController,
|
|
25
26
|
useDataSource,
|
|
26
27
|
useEntityFetch,
|
|
27
28
|
useFireCMSContext,
|
|
@@ -98,6 +99,7 @@ export function EntityView<M extends Record<string, any>, UserType extends User>
|
|
|
98
99
|
const sideDialogContext = useSideDialogContext();
|
|
99
100
|
const sideEntityController = useSideEntityController();
|
|
100
101
|
const snackbarController = useSnackbarController();
|
|
102
|
+
const customizationController = useCustomizationController();
|
|
101
103
|
const context = useFireCMSContext();
|
|
102
104
|
const authController = useAuthController<UserType>();
|
|
103
105
|
|
|
@@ -297,7 +299,7 @@ export function EntityView<M extends Record<string, any>, UserType extends User>
|
|
|
297
299
|
};
|
|
298
300
|
|
|
299
301
|
const resolvedEntityViews = customViews ? customViews
|
|
300
|
-
.map(e => resolveEntityView(e,
|
|
302
|
+
.map(e => resolveEntityView(e, customizationController.entityViews))
|
|
301
303
|
.filter(Boolean) as EntityCustomView[]
|
|
302
304
|
: [];
|
|
303
305
|
const customViewsView: React.ReactNode[] | undefined = customViews && resolvedEntityViews
|
|
@@ -411,7 +413,7 @@ export function EntityView<M extends Record<string, any>, UserType extends User>
|
|
|
411
413
|
}
|
|
412
414
|
|
|
413
415
|
function buildForm() {
|
|
414
|
-
const plugins =
|
|
416
|
+
const plugins = customizationController.plugins;
|
|
415
417
|
let form = <EntityForm
|
|
416
418
|
status={status}
|
|
417
419
|
path={path}
|
|
@@ -4,7 +4,6 @@ import { SideDialogPanelProps, SideDialogsController } from "../types";
|
|
|
4
4
|
import equal from "react-fast-compare"
|
|
5
5
|
|
|
6
6
|
export function useBuildSideDialogsController(): SideDialogsController {
|
|
7
|
-
console.log("useBuildSideDialogsController");
|
|
8
7
|
|
|
9
8
|
const location = useLocation();
|
|
10
9
|
const navigate = useNavigate();
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
import { resolveProperty } from "../util";
|
|
14
14
|
|
|
15
15
|
import { PropertyPreviewProps } from "./PropertyPreviewProps";
|
|
16
|
-
import {
|
|
16
|
+
import { useCustomizationController } from "../hooks";
|
|
17
17
|
import { EmptyValue } from "./components/EmptyValue";
|
|
18
18
|
import { UrlComponentPreview } from "./components/UrlComponentPreview";
|
|
19
19
|
import { StorageThumbnail } from "./components/StorageThumbnail";
|
|
@@ -37,7 +37,8 @@ import { ErrorView } from "../components";
|
|
|
37
37
|
*/
|
|
38
38
|
export const PropertyPreview = React.memo(function PropertyPreview<T extends CMSType>(props: PropertyPreviewProps<T>) {
|
|
39
39
|
|
|
40
|
-
const
|
|
40
|
+
const customizationController = useCustomizationController();
|
|
41
|
+
|
|
41
42
|
let content: React.ReactNode | any;
|
|
42
43
|
const {
|
|
43
44
|
property: inputProperty,
|
|
@@ -53,7 +54,7 @@ export const PropertyPreview = React.memo(function PropertyPreview<T extends CMS
|
|
|
53
54
|
propertyKey,
|
|
54
55
|
propertyOrBuilder: inputProperty,
|
|
55
56
|
propertyValue: value,
|
|
56
|
-
fields:
|
|
57
|
+
fields: customizationController.propertyConfigs
|
|
57
58
|
});
|
|
58
59
|
|
|
59
60
|
if (value === undefined || property === null) {
|
|
@@ -2,8 +2,7 @@ import React from "react";
|
|
|
2
2
|
|
|
3
3
|
import { format } from "date-fns";
|
|
4
4
|
import * as locales from "date-fns/locale";
|
|
5
|
-
import {
|
|
6
|
-
import { useFireCMSContext } from "../../hooks";
|
|
5
|
+
import { useCustomizationController } from "../../hooks";
|
|
7
6
|
import { defaultDateFormat } from "../../util";
|
|
8
7
|
|
|
9
8
|
/**
|
|
@@ -13,10 +12,10 @@ export function DatePreview({
|
|
|
13
12
|
date
|
|
14
13
|
}: { date: Date }): React.ReactElement {
|
|
15
14
|
|
|
16
|
-
const
|
|
15
|
+
const customizationController = useCustomizationController();
|
|
17
16
|
// @ts-ignore
|
|
18
|
-
const dateUtilsLocale =
|
|
19
|
-
const dateFormat: string =
|
|
17
|
+
const dateUtilsLocale = customizationController?.locale ? locales[customizationController?.locale] : undefined;
|
|
18
|
+
const dateFormat: string = customizationController?.dateTimeFormat ?? defaultDateFormat;
|
|
20
19
|
const formattedDate = date ? format(date, dateFormat, { locale: dateUtilsLocale }) : "";
|
|
21
20
|
|
|
22
21
|
return (
|
|
@@ -4,12 +4,18 @@ import { useMemo } from "react";
|
|
|
4
4
|
import { Entity, EntityCollection, EntityReference, ResolvedProperty } from "../../types";
|
|
5
5
|
|
|
6
6
|
import { getReferencePreviewKeys, getValueInPath, resolveCollection } from "../../util";
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
useCustomizationController,
|
|
9
|
+
useEntityFetch,
|
|
10
|
+
useNavigationController,
|
|
11
|
+
useSideEntityController
|
|
12
|
+
} from "../../hooks";
|
|
8
13
|
import { PropertyPreview } from "../PropertyPreview";
|
|
9
14
|
import { PreviewSize } from "../PropertyPreviewProps";
|
|
10
15
|
import { SkeletonPropertyComponent } from "../property_previews/SkeletonPropertyComponent";
|
|
11
16
|
import { cn, IconButton, KeyboardTabIcon, Skeleton, Tooltip, Typography } from "@firecms/ui";
|
|
12
17
|
import { ErrorView } from "../../components";
|
|
18
|
+
import { useAnalyticsController } from "../../hooks/useAnalyticsController";
|
|
13
19
|
|
|
14
20
|
export type ReferencePreviewProps = {
|
|
15
21
|
disabled?: boolean;
|
|
@@ -58,13 +64,14 @@ function ReferencePreviewInternal<M extends Record<string, any>>({
|
|
|
58
64
|
allowEntityNavigation = true
|
|
59
65
|
}: ReferencePreviewProps) {
|
|
60
66
|
|
|
61
|
-
const
|
|
67
|
+
const customizationController = useCustomizationController();
|
|
68
|
+
|
|
62
69
|
const navigationController = useNavigationController();
|
|
63
70
|
|
|
64
71
|
const collection = navigationController.getCollection<EntityCollection<M>>(reference.path);
|
|
65
72
|
if (!collection) {
|
|
66
|
-
if (
|
|
67
|
-
return <
|
|
73
|
+
if (customizationController.components?.missingReference) {
|
|
74
|
+
return <customizationController.components.missingReference path={reference.path}/>;
|
|
68
75
|
} else {
|
|
69
76
|
throw Error(`Couldn't find the corresponding collection view for the path: ${reference.path}`);
|
|
70
77
|
}
|
|
@@ -85,7 +92,9 @@ function ReferencePreviewExisting<M extends Record<string, any> = any>({ referen
|
|
|
85
92
|
collection: EntityCollection<M>
|
|
86
93
|
}) {
|
|
87
94
|
|
|
88
|
-
const
|
|
95
|
+
const customizationController = useCustomizationController();
|
|
96
|
+
|
|
97
|
+
const analyticsController = useAnalyticsController();
|
|
89
98
|
const sideEntityController = useSideEntityController();
|
|
90
99
|
|
|
91
100
|
const {
|
|
@@ -109,10 +118,10 @@ function ReferencePreviewExisting<M extends Record<string, any> = any>({ referen
|
|
|
109
118
|
collection,
|
|
110
119
|
path: reference.path,
|
|
111
120
|
values: usedEntity?.values,
|
|
112
|
-
fields:
|
|
121
|
+
fields: customizationController.propertyConfigs
|
|
113
122
|
}), [collection]);
|
|
114
123
|
|
|
115
|
-
const listProperties = useMemo(() => getReferencePreviewKeys(resolvedCollection,
|
|
124
|
+
const listProperties = useMemo(() => getReferencePreviewKeys(resolvedCollection, customizationController.propertyConfigs, previewProperties, size === "small" || size === "medium" ? 3 : 1),
|
|
116
125
|
[previewProperties, resolvedCollection, size]);
|
|
117
126
|
|
|
118
127
|
let body: React.ReactNode;
|
|
@@ -179,7 +188,7 @@ function ReferencePreviewExisting<M extends Record<string, any> = any>({ referen
|
|
|
179
188
|
size={"small"}
|
|
180
189
|
onClick={(e) => {
|
|
181
190
|
e.stopPropagation();
|
|
182
|
-
|
|
191
|
+
analyticsController.onAnalyticsEvent?.("entity_click_from_reference", {
|
|
183
192
|
path: usedEntity.path,
|
|
184
193
|
entityId: usedEntity.id
|
|
185
194
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { ErrorBoundary } from "../../components";
|
|
3
|
-
import {
|
|
3
|
+
import { useCustomizationController } from "../../hooks";
|
|
4
4
|
import { PropertyPreviewProps } from "../PropertyPreviewProps";
|
|
5
5
|
import { PropertyPreview } from "../PropertyPreview";
|
|
6
6
|
import { resolveArrayProperty } from "../../util";
|
|
@@ -15,13 +15,13 @@ export function ArrayOfMapsPreview({
|
|
|
15
15
|
size,
|
|
16
16
|
// entity
|
|
17
17
|
}: PropertyPreviewProps<Record<string, any>[]>) {
|
|
18
|
-
const fireCMSContext = useFireCMSContext();
|
|
19
18
|
|
|
19
|
+
const customizationController = useCustomizationController();
|
|
20
20
|
const property = resolveArrayProperty({
|
|
21
21
|
propertyKey,
|
|
22
22
|
property: inputProperty,
|
|
23
23
|
propertyValue: value,
|
|
24
|
-
fields:
|
|
24
|
+
fields: customizationController.propertyConfigs
|
|
25
25
|
});
|
|
26
26
|
|
|
27
27
|
if (Array.isArray(property?.of)) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ResolvedReferenceProperty } from "../../types";
|
|
2
2
|
import { resolveArrayProperty } from "../../util";
|
|
3
|
-
import {
|
|
3
|
+
import { useCustomizationController } from "../../hooks";
|
|
4
4
|
import { PreviewSize, PropertyPreviewProps } from "../PropertyPreviewProps";
|
|
5
5
|
import { ReferencePreview } from "../components/ReferencePreview";
|
|
6
6
|
|
|
@@ -14,12 +14,12 @@ export function ArrayOfReferencesPreview({
|
|
|
14
14
|
size
|
|
15
15
|
}: PropertyPreviewProps<any[]>) {
|
|
16
16
|
|
|
17
|
-
const
|
|
17
|
+
const customizationController = useCustomizationController();
|
|
18
18
|
const property = resolveArrayProperty({
|
|
19
19
|
propertyKey,
|
|
20
20
|
property: inputProperty,
|
|
21
21
|
propertyValue: value,
|
|
22
|
-
fields:
|
|
22
|
+
fields: customizationController.propertyConfigs
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
if (Array.isArray(property?.of)) {
|
|
@@ -3,7 +3,7 @@ import React from "react";
|
|
|
3
3
|
import { resolveArrayProperty } from "../../util";
|
|
4
4
|
import { ResolvedProperty } from "../../types";
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { useCustomizationController } from "../../hooks";
|
|
7
7
|
import { PreviewSize, PropertyPreviewProps } from "../PropertyPreviewProps";
|
|
8
8
|
import { PropertyPreview } from "../PropertyPreview";
|
|
9
9
|
import { ErrorBoundary } from "../../components";
|
|
@@ -19,12 +19,12 @@ export function ArrayOfStorageComponentsPreview({
|
|
|
19
19
|
size
|
|
20
20
|
}: PropertyPreviewProps<any[]>) {
|
|
21
21
|
|
|
22
|
-
const
|
|
22
|
+
const customizationController = useCustomizationController();
|
|
23
23
|
const property = resolveArrayProperty({
|
|
24
24
|
propertyKey,
|
|
25
25
|
property: inputProperty,
|
|
26
26
|
propertyValue: value,
|
|
27
|
-
fields:
|
|
27
|
+
fields: customizationController.propertyConfigs
|
|
28
28
|
});
|
|
29
29
|
|
|
30
30
|
if (Array.isArray(property.of)) {
|
|
@@ -3,7 +3,7 @@ import { ResolvedStringProperty } from "../../types";
|
|
|
3
3
|
|
|
4
4
|
import { resolveArrayProperty } from "../../util";
|
|
5
5
|
import { PropertyPreviewProps, StringPropertyPreview } from "../../preview";
|
|
6
|
-
import {
|
|
6
|
+
import { useCustomizationController } from "../../hooks";
|
|
7
7
|
import { ErrorBoundary } from "../../components";
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -17,12 +17,12 @@ export function ArrayOfStringsPreview({
|
|
|
17
17
|
size
|
|
18
18
|
}: PropertyPreviewProps<string[]>) {
|
|
19
19
|
|
|
20
|
-
const
|
|
20
|
+
const customizationController = useCustomizationController();
|
|
21
21
|
const property = resolveArrayProperty({
|
|
22
22
|
propertyKey,
|
|
23
23
|
property: inputProperty,
|
|
24
24
|
propertyValue: value,
|
|
25
|
-
fields:
|
|
25
|
+
fields: customizationController.propertyConfigs
|
|
26
26
|
});
|
|
27
27
|
|
|
28
28
|
if (Array.isArray(property.of)) {
|
|
@@ -45,7 +45,7 @@ export function ArrayOfStringsPreview({
|
|
|
45
45
|
<StringPropertyPreview propertyKey={propertyKey}
|
|
46
46
|
property={stringProperty}
|
|
47
47
|
value={v}
|
|
48
|
-
|
|
48
|
+
// entity={entity}
|
|
49
49
|
size={size}/>
|
|
50
50
|
</ErrorBoundary>
|
|
51
51
|
</div>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { resolveArrayProperty } from "../../util";
|
|
3
3
|
import { ResolvedProperty } from "../../types";
|
|
4
|
-
import {
|
|
4
|
+
import { useCustomizationController } from "../../hooks";
|
|
5
5
|
import { PreviewSize, PropertyPreviewProps } from "../PropertyPreviewProps";
|
|
6
6
|
import { PropertyPreview } from "../PropertyPreview";
|
|
7
7
|
import { cn, defaultBorderMixin } from "@firecms/ui";
|
|
@@ -19,12 +19,12 @@ export function ArrayOneOfPreview({
|
|
|
19
19
|
// entity
|
|
20
20
|
}: PropertyPreviewProps<any[]>) {
|
|
21
21
|
|
|
22
|
-
const
|
|
22
|
+
const customizationController = useCustomizationController();
|
|
23
23
|
const property = resolveArrayProperty({
|
|
24
24
|
propertyKey,
|
|
25
25
|
property: inputProperty,
|
|
26
26
|
propertyValue: value,
|
|
27
|
-
fields:
|
|
27
|
+
fields: customizationController.propertyConfigs
|
|
28
28
|
});
|
|
29
29
|
|
|
30
30
|
if (property?.dataType !== "array")
|
|
@@ -2,7 +2,7 @@ import React from "react";
|
|
|
2
2
|
|
|
3
3
|
import { resolveArrayProperty } from "../../util";
|
|
4
4
|
import { ResolvedProperty } from "../../types";
|
|
5
|
-
import {
|
|
5
|
+
import { useCustomizationController } from "../../hooks";
|
|
6
6
|
import { PreviewSize, PropertyPreviewProps } from "../PropertyPreviewProps";
|
|
7
7
|
import { PropertyPreview } from "../PropertyPreview";
|
|
8
8
|
import { cn, defaultBorderMixin } from "@firecms/ui";
|
|
@@ -19,12 +19,12 @@ export function ArrayPropertyPreview({
|
|
|
19
19
|
size
|
|
20
20
|
}: PropertyPreviewProps<any[]>) {
|
|
21
21
|
|
|
22
|
-
const
|
|
22
|
+
const customizationController = useCustomizationController();
|
|
23
23
|
const property = resolveArrayProperty({
|
|
24
24
|
propertyKey,
|
|
25
25
|
property: inputProperty,
|
|
26
26
|
propertyValue: value,
|
|
27
|
-
fields:
|
|
27
|
+
fields: customizationController.propertyConfigs
|
|
28
28
|
});
|
|
29
29
|
|
|
30
30
|
if (!property.of) {
|