@firecms/core 3.0.0-canary.54 → 3.0.0-canary.55
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/fields/TableReferenceField.d.ts +2 -0
- package/dist/components/EntityCollectionTable/internal/EntityTableCell.d.ts +2 -2
- package/dist/components/EntityPreview.d.ts +3 -2
- package/dist/components/FireCMSAppBar.d.ts +2 -1
- package/dist/components/ReferenceWidget.d.ts +3 -1
- package/dist/components/SelectableTable/filters/ReferenceFilterField.d.ts +2 -1
- package/dist/components/VirtualTable/VirtualTableProps.d.ts +1 -6
- package/dist/components/VirtualTable/types.d.ts +3 -3
- package/dist/components/common/table_height.d.ts +5 -0
- package/dist/index.es.js +2017 -1975
- 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/preview/components/ReferencePreview.d.ts +2 -1
- package/dist/types/properties.d.ts +8 -0
- package/package.json +4 -4
- package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +1 -1
- package/src/components/EntityCollectionTable/PropertyTableCell.tsx +5 -2
- package/src/components/EntityCollectionTable/fields/TableReferenceField.tsx +9 -1
- package/src/components/EntityCollectionTable/internal/EntityTableCell.tsx +2 -3
- package/src/components/EntityPreview.tsx +6 -4
- package/src/components/FireCMSAppBar.tsx +5 -2
- package/src/components/ReferenceWidget.tsx +19 -9
- package/src/components/SelectableTable/SelectableTable.tsx +4 -2
- package/src/components/SelectableTable/filters/ReferenceFilterField.tsx +4 -1
- package/src/components/VirtualTable/VirtualTable.tsx +7 -8
- package/src/components/VirtualTable/VirtualTableProps.tsx +1 -6
- package/src/components/VirtualTable/VirtualTableRow.tsx +2 -3
- package/src/components/VirtualTable/types.tsx +2 -3
- package/src/components/{VirtualTable/common.tsx → common/table_height.tsx} +5 -2
- package/src/core/EntityEditView.tsx +3 -2
- package/src/core/FireCMS.tsx +33 -36
- package/src/form/EntityForm.tsx +7 -10
- package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +2 -0
- package/src/form/field_bindings/ReferenceFieldBinding.tsx +15 -13
- package/src/form/field_bindings/SelectFieldBinding.tsx +0 -3
- package/src/hooks/data/save.ts +2 -0
- package/src/hooks/useValidateAuthenticator.tsx +15 -15
- package/src/preview/PropertyPreview.tsx +2 -1
- package/src/preview/components/ReferencePreview.tsx +21 -22
- package/src/preview/property_previews/ArrayOfReferencesPreview.tsx +2 -0
- package/src/preview/property_previews/NumberPropertyPreview.tsx +0 -1
- package/src/types/properties.ts +10 -0
- package/dist/components/VirtualTable/common.d.ts +0 -2
package/src/form/EntityForm.tsx
CHANGED
|
@@ -35,12 +35,9 @@ import {
|
|
|
35
35
|
} from "../hooks";
|
|
36
36
|
import { ErrorFocus } from "./components/ErrorFocus";
|
|
37
37
|
import { CustomIdField } from "./components/CustomIdField";
|
|
38
|
-
import { Alert, Button, cn, DialogActions, IconButton, Tooltip, Typography } from "@firecms/ui";
|
|
39
|
-
import { ErrorBoundary } from "../components";
|
|
40
|
-
import {
|
|
41
|
-
copyEntityAction,
|
|
42
|
-
deleteEntityAction
|
|
43
|
-
} from "../components/common/default_entity_actions";
|
|
38
|
+
import { Alert, Button, CircularProgress, cn, DialogActions, IconButton, Tooltip, Typography } from "@firecms/ui";
|
|
39
|
+
import { CircularProgressCenter, ErrorBoundary } from "../components";
|
|
40
|
+
import { copyEntityAction, deleteEntityAction } from "../components/common/default_entity_actions";
|
|
44
41
|
import { useAnalyticsController } from "../hooks/useAnalyticsController";
|
|
45
42
|
import { ValidationError } from "yup";
|
|
46
43
|
import { PropertyIdCopyTooltipContent } from "../components/PropertyIdCopyTooltipContent";
|
|
@@ -674,10 +671,10 @@ function InnerForm<M extends Record<string, any>>(props: FormexController<M> & {
|
|
|
674
671
|
</IconButton>
|
|
675
672
|
))}
|
|
676
673
|
</div>}
|
|
677
|
-
|
|
674
|
+
{isSubmitting && <CircularProgress size={"small"}/>}
|
|
678
675
|
<Button
|
|
679
676
|
variant="text"
|
|
680
|
-
disabled={disabled}
|
|
677
|
+
disabled={disabled || isSubmitting}
|
|
681
678
|
type="reset"
|
|
682
679
|
>
|
|
683
680
|
{status === "existing" ? "Discard" : "Clear"}
|
|
@@ -687,7 +684,7 @@ function InnerForm<M extends Record<string, any>>(props: FormexController<M> & {
|
|
|
687
684
|
variant="text"
|
|
688
685
|
color="primary"
|
|
689
686
|
type="submit"
|
|
690
|
-
disabled={disabled}
|
|
687
|
+
disabled={disabled || isSubmitting}
|
|
691
688
|
onClick={() => {
|
|
692
689
|
closeAfterSaveRef.current = false;
|
|
693
690
|
}}
|
|
@@ -701,7 +698,7 @@ function InnerForm<M extends Record<string, any>>(props: FormexController<M> & {
|
|
|
701
698
|
variant="filled"
|
|
702
699
|
color="primary"
|
|
703
700
|
type="submit"
|
|
704
|
-
disabled={disabled}
|
|
701
|
+
disabled={disabled || isSubmitting}
|
|
705
702
|
onClick={() => {
|
|
706
703
|
closeAfterSaveRef.current = true;
|
|
707
704
|
}}
|
|
@@ -88,6 +88,8 @@ export function ArrayOfReferencesFieldBinding({
|
|
|
88
88
|
onClick={onEntryClick}
|
|
89
89
|
hover={!disabled}
|
|
90
90
|
reference={entryValue}
|
|
91
|
+
includeId={ofProperty.includeId}
|
|
92
|
+
includeEntityLink={ofProperty.includeEntityLink}
|
|
91
93
|
/>
|
|
92
94
|
);
|
|
93
95
|
}, [ofProperty.path, ofProperty.previewProperties, value]);
|
|
@@ -27,19 +27,19 @@ export function ReferenceFieldBinding<M extends Record<string, any>>(props: Fiel
|
|
|
27
27
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
function ReferenceFieldBindingInternal
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
30
|
+
function ReferenceFieldBindingInternal({
|
|
31
|
+
value,
|
|
32
|
+
setValue,
|
|
33
|
+
error,
|
|
34
|
+
showError,
|
|
35
|
+
isSubmitting,
|
|
36
|
+
disabled,
|
|
37
|
+
touched,
|
|
38
|
+
autoFocus,
|
|
39
|
+
property,
|
|
40
|
+
includeDescription,
|
|
41
|
+
context
|
|
42
|
+
}: FieldProps<EntityReference>) {
|
|
43
43
|
if (!property.path) {
|
|
44
44
|
throw new Error("Property path is required for ReferenceFieldBinding");
|
|
45
45
|
}
|
|
@@ -99,6 +99,8 @@ function ReferenceFieldBindingInternal<M extends Record<string, any>>({
|
|
|
99
99
|
size={"medium"}
|
|
100
100
|
onClick={disabled || isSubmitting ? undefined : onEntryClick}
|
|
101
101
|
reference={value}
|
|
102
|
+
includeEntityLink={property.includeEntityLink}
|
|
103
|
+
includeId={property.includeId}
|
|
102
104
|
/>}
|
|
103
105
|
|
|
104
106
|
{!value && <div className="justify-center text-left">
|
|
@@ -30,8 +30,6 @@ export function SelectFieldBinding<T extends EnumType>({
|
|
|
30
30
|
includeDescription
|
|
31
31
|
}: SelectProps<T>) {
|
|
32
32
|
|
|
33
|
-
console.log("SelectFieldBinding", propertyKey, value,)
|
|
34
|
-
|
|
35
33
|
const enumValues = property.enumValues;
|
|
36
34
|
|
|
37
35
|
useClearRestoreValue({
|
|
@@ -72,7 +70,6 @@ export function SelectFieldBinding<T extends EnumType>({
|
|
|
72
70
|
return setValue(newValue as T);
|
|
73
71
|
}}
|
|
74
72
|
renderValue={(enumKey: any) => {
|
|
75
|
-
console.log("renderValue", enumKey)
|
|
76
73
|
return <EnumValuesChip
|
|
77
74
|
enumKey={enumKey}
|
|
78
75
|
enumValues={enumValues}
|
package/src/hooks/data/save.ts
CHANGED
|
@@ -108,6 +108,7 @@ export async function saveEntityWithCallbacks<M extends Record<string, any>, Use
|
|
|
108
108
|
updatedValues = values;
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
+
console.log("Saving entity", entityId, updatedValues);
|
|
111
112
|
return dataSource.saveEntity({
|
|
112
113
|
collection,
|
|
113
114
|
path: resolvedPath,
|
|
@@ -116,6 +117,7 @@ export async function saveEntityWithCallbacks<M extends Record<string, any>, Use
|
|
|
116
117
|
previousValues,
|
|
117
118
|
status
|
|
118
119
|
}).then((entity) => {
|
|
120
|
+
console.log("Entity saved");
|
|
119
121
|
try {
|
|
120
122
|
if (callbacks?.onSaveSuccess) {
|
|
121
123
|
const resolvedCollection = resolveCollection<M>({
|
|
@@ -11,20 +11,21 @@ import { AuthController, Authenticator, DataSourceDelegate, StorageSource, User
|
|
|
11
11
|
* @param storageSource
|
|
12
12
|
* @param dataSourceDelegate
|
|
13
13
|
*/
|
|
14
|
-
export function useValidateAuthenticator<UserType extends User = User, Controller extends AuthController<UserType> = AuthController<UserType>>
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
14
|
+
export function useValidateAuthenticator<UserType extends User = User, Controller extends AuthController<UserType> = AuthController<UserType>>
|
|
15
|
+
({
|
|
16
|
+
disabled,
|
|
17
|
+
authController,
|
|
18
|
+
authenticator,
|
|
19
|
+
storageSource,
|
|
20
|
+
dataSourceDelegate
|
|
21
|
+
}:
|
|
22
|
+
{
|
|
23
|
+
disabled?: boolean,
|
|
24
|
+
authController: Controller,
|
|
25
|
+
authenticator?: boolean | Authenticator<UserType, Controller>,
|
|
26
|
+
dataSourceDelegate: DataSourceDelegate;
|
|
27
|
+
storageSource: StorageSource;
|
|
28
|
+
}): {
|
|
28
29
|
canAccessMainView: boolean,
|
|
29
30
|
authLoading: boolean,
|
|
30
31
|
notAllowedError: any,
|
|
@@ -70,7 +71,6 @@ export function useValidateAuthenticator<UserType extends User = User, Controlle
|
|
|
70
71
|
}
|
|
71
72
|
|
|
72
73
|
const delegateUser = authController.user;
|
|
73
|
-
console.debug("Checking authentication for user", delegateUser);
|
|
74
74
|
|
|
75
75
|
if (authenticator instanceof Function && delegateUser && !equal(checkedUserRef.current?.uid, delegateUser.uid)) {
|
|
76
76
|
setAuthLoading(true);
|
|
@@ -171,8 +171,9 @@ export const PropertyPreview = React.memo(function PropertyPreview<T extends CMS
|
|
|
171
171
|
content = <ReferencePreview
|
|
172
172
|
disabled={!property.path}
|
|
173
173
|
previewProperties={property.previewProperties}
|
|
174
|
+
includeId={property.includeId}
|
|
175
|
+
includeEntityLink={property.includeEntityLink}
|
|
174
176
|
size={props.size}
|
|
175
|
-
// onClick={props.onClick}
|
|
176
177
|
reference={value as EntityReference}
|
|
177
178
|
/>;
|
|
178
179
|
} else {
|
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
|
|
3
3
|
import { Entity, EntityCollection, EntityReference } from "../../types";
|
|
4
|
-
import {
|
|
5
|
-
useCustomizationController,
|
|
6
|
-
useEntityFetch,
|
|
7
|
-
useNavigationController,
|
|
8
|
-
useSideEntityController
|
|
9
|
-
} from "../../hooks";
|
|
4
|
+
import { useCustomizationController, useEntityFetch, useNavigationController } from "../../hooks";
|
|
10
5
|
import { PreviewSize } from "../PropertyPreviewProps";
|
|
11
|
-
import {
|
|
6
|
+
import { Skeleton } from "@firecms/ui";
|
|
12
7
|
import { ErrorView } from "../../components";
|
|
13
|
-
import { useAnalyticsController } from "../../hooks/useAnalyticsController";
|
|
14
8
|
import { EntityPreview, EntityPreviewContainer } from "../../components/EntityPreview";
|
|
15
9
|
|
|
16
10
|
export type ReferencePreviewProps = {
|
|
@@ -20,7 +14,8 @@ export type ReferencePreviewProps = {
|
|
|
20
14
|
previewProperties?: string[];
|
|
21
15
|
onClick?: (e: React.SyntheticEvent) => void;
|
|
22
16
|
hover?: boolean;
|
|
23
|
-
|
|
17
|
+
includeEntityLink?: boolean;
|
|
18
|
+
includeId?: boolean;
|
|
24
19
|
};
|
|
25
20
|
|
|
26
21
|
/**
|
|
@@ -46,19 +41,20 @@ function areEqual(prevProps: ReferencePreviewProps, nextProps: ReferencePreviewP
|
|
|
46
41
|
prevProps.hover === nextProps.hover &&
|
|
47
42
|
prevProps.reference?.id === nextProps.reference?.id &&
|
|
48
43
|
prevProps.reference?.path === nextProps.reference?.path &&
|
|
49
|
-
prevProps.
|
|
44
|
+
prevProps.includeEntityLink === nextProps.includeEntityLink
|
|
50
45
|
;
|
|
51
46
|
}
|
|
52
47
|
|
|
53
|
-
function ReferencePreviewInternal
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
48
|
+
function ReferencePreviewInternal({
|
|
49
|
+
disabled,
|
|
50
|
+
reference,
|
|
51
|
+
previewProperties,
|
|
52
|
+
size,
|
|
53
|
+
hover,
|
|
54
|
+
onClick,
|
|
55
|
+
includeEntityLink = true,
|
|
56
|
+
includeId = true
|
|
57
|
+
}: ReferencePreviewProps) {
|
|
62
58
|
|
|
63
59
|
const customizationController = useCustomizationController();
|
|
64
60
|
|
|
@@ -79,7 +75,8 @@ function ReferencePreviewInternal<M extends Record<string, any>>({
|
|
|
79
75
|
previewProperties={previewProperties}
|
|
80
76
|
size={size}
|
|
81
77
|
disabled={disabled}
|
|
82
|
-
|
|
78
|
+
includeEntityLink={includeEntityLink}
|
|
79
|
+
includeId={includeId}
|
|
83
80
|
onClick={onClick}
|
|
84
81
|
hover={hover}/>
|
|
85
82
|
}
|
|
@@ -90,7 +87,8 @@ function ReferencePreviewExisting<M extends Record<string, any> = any>({
|
|
|
90
87
|
previewProperties,
|
|
91
88
|
size,
|
|
92
89
|
disabled,
|
|
93
|
-
|
|
90
|
+
includeEntityLink,
|
|
91
|
+
includeId,
|
|
94
92
|
onClick,
|
|
95
93
|
hover
|
|
96
94
|
}: ReferencePreviewProps & {
|
|
@@ -158,7 +156,8 @@ function ReferencePreviewExisting<M extends Record<string, any> = any>({
|
|
|
158
156
|
entity={usedEntity}
|
|
159
157
|
collection={collection}
|
|
160
158
|
onClick={onClick}
|
|
161
|
-
|
|
159
|
+
includeEntityLink={includeEntityLink}
|
|
160
|
+
includeId={includeId}
|
|
162
161
|
hover={hover}/>;
|
|
163
162
|
|
|
164
163
|
}
|
|
@@ -15,7 +15,6 @@ export function NumberPropertyPreview({
|
|
|
15
15
|
if (property.enumValues) {
|
|
16
16
|
const enumKey = value;
|
|
17
17
|
const enumValues = enumToObjectEntries(property.enumValues);
|
|
18
|
-
console.log("NumberPropertyPreview", enumValues)
|
|
19
18
|
if (!enumValues)
|
|
20
19
|
return <>{value}</>;
|
|
21
20
|
return <EnumValuesChip
|
package/src/types/properties.ts
CHANGED
|
@@ -609,6 +609,16 @@ export interface ReferenceProperty extends BaseProperty<EntityReference> {
|
|
|
609
609
|
*/
|
|
610
610
|
previewProperties?: string[];
|
|
611
611
|
|
|
612
|
+
/**
|
|
613
|
+
* Should the reference include the ID of the entity. Defaults to `true`
|
|
614
|
+
*/
|
|
615
|
+
includeId?: boolean;
|
|
616
|
+
|
|
617
|
+
/**
|
|
618
|
+
* Should the reference include a link to the entity (open the entity details). Defaults to `true`
|
|
619
|
+
*/
|
|
620
|
+
includeEntityLink?: boolean;
|
|
621
|
+
|
|
612
622
|
}
|
|
613
623
|
|
|
614
624
|
/**
|