@firecms/core 3.0.0-canary.5 → 3.0.0-canary.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/components/ClearFilterSortButton.d.ts +5 -0
- package/dist/components/EntityCollectionTable/EntityCollectionRowActions.d.ts +11 -11
- package/dist/components/EntityCollectionTable/EntityCollectionTable.d.ts +2 -2
- package/dist/components/EntityCollectionTable/EntityCollectionTableProps.d.ts +5 -3
- package/dist/components/EntityCollectionTable/PropertyTableCell.d.ts +3 -2
- package/dist/components/EntityCollectionTable/column_utils.d.ts +1 -2
- package/dist/components/EntityCollectionTable/internal/CollectionTableToolbar.d.ts +1 -4
- package/dist/components/EntityCollectionTable/internal/popup_field/PopupFormField.d.ts +1 -1
- package/dist/components/EntityCollectionView/EntityCollectionView.d.ts +12 -3
- package/dist/components/EntityCollectionView/EntityCollectionViewStartActions.d.ts +11 -0
- package/dist/components/EntityCollectionView/useSelectionController.d.ts +2 -0
- package/dist/components/EntityPreview.d.ts +25 -7
- package/dist/components/EntityView.d.ts +11 -0
- package/dist/components/FieldCaption.d.ts +5 -0
- package/dist/components/FireCMSAppBar.d.ts +3 -2
- package/dist/components/HomePage/NavigationCard.d.ts +8 -0
- package/dist/components/HomePage/{NavigationCollectionCard.d.ts → NavigationCardBinding.d.ts} +2 -2
- package/dist/components/HomePage/SmallNavigationCard.d.ts +6 -0
- package/dist/components/HomePage/index.d.ts +3 -1
- package/dist/components/SelectableTable/SelectableTable.d.ts +1 -1
- package/dist/components/VirtualTable/VirtualTableProps.d.ts +1 -1
- package/dist/components/common/types.d.ts +4 -6
- package/dist/components/common/useDataSourceEntityCollectionTableController.d.ts +3 -0
- package/dist/components/index.d.ts +4 -2
- package/dist/contexts/AuthControllerContext.d.ts +1 -1
- package/dist/core/{EntityView.d.ts → EntityEditView.d.ts} +2 -2
- package/dist/core/NavigationRoutes.d.ts +1 -1
- package/dist/core/Scaffold.d.ts +1 -1
- package/dist/form/EntityForm.d.ts +1 -1
- package/dist/form/components/ErrorFocus.d.ts +1 -1
- package/dist/form/components/StorageItemPreview.d.ts +3 -2
- package/dist/form/components/StorageUploadProgress.d.ts +1 -1
- package/dist/form/field_bindings/KeyValueFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/MapFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/StorageUploadFieldBinding.d.ts +4 -3
- package/dist/form/field_bindings/TextFieldBinding.d.ts +2 -2
- package/dist/form/validation.d.ts +1 -1
- package/dist/hooks/data/delete.d.ts +2 -2
- package/dist/hooks/data/save.d.ts +2 -3
- package/dist/hooks/data/useDataSource.d.ts +2 -2
- package/dist/hooks/data/useEntityFetch.d.ts +3 -3
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/useBuildNavigationController.d.ts +6 -4
- package/dist/hooks/useProjectLog.d.ts +6 -2
- package/dist/hooks/useStorageSource.d.ts +2 -2
- package/dist/hooks/useValidateAuthenticator.d.ts +21 -0
- package/dist/index.es.js +10402 -9898
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +5 -5
- package/dist/index.umd.js.map +1 -1
- package/dist/internal/useBuildDataSource.d.ts +1 -12
- package/dist/preview/PropertyPreview.d.ts +1 -1
- package/dist/preview/PropertyPreviewProps.d.ts +1 -4
- package/dist/preview/components/BooleanPreview.d.ts +5 -1
- package/dist/preview/components/EnumValuesChip.d.ts +1 -1
- package/dist/preview/components/ReferencePreview.d.ts +1 -7
- package/dist/types/analytics.d.ts +1 -1
- package/dist/types/auth.d.ts +37 -1
- package/dist/types/collections.d.ts +29 -5
- package/dist/types/datasource.d.ts +3 -6
- package/dist/types/entities.d.ts +5 -1
- package/dist/types/entity_actions.d.ts +14 -0
- package/dist/types/entity_callbacks.d.ts +2 -2
- package/dist/types/entity_overrides.d.ts +6 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/navigation.d.ts +14 -13
- package/dist/types/permissions.d.ts +5 -1
- package/dist/types/plugins.d.ts +20 -20
- package/dist/types/properties.d.ts +4 -4
- package/dist/types/property_config.d.ts +2 -2
- package/dist/types/roles.d.ts +31 -0
- package/dist/types/storage.d.ts +11 -3
- package/dist/types/user.d.ts +5 -0
- package/dist/util/collections.d.ts +9 -1
- package/dist/util/entities.d.ts +1 -1
- package/dist/util/icon_synonyms.d.ts +1 -4
- package/dist/util/icons.d.ts +8 -2
- package/dist/util/navigation_utils.d.ts +2 -2
- package/dist/util/permissions.d.ts +4 -4
- package/dist/util/references.d.ts +4 -2
- package/dist/util/resolutions.d.ts +9 -13
- package/dist/util/useTraceUpdate.d.ts +1 -0
- package/package.json +139 -119
- package/src/components/ClearFilterSortButton.tsx +41 -0
- package/src/components/DeleteEntityDialog.tsx +4 -4
- package/src/components/EntityCollectionTable/EntityCollectionRowActions.tsx +2 -2
- package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +275 -278
- package/src/components/EntityCollectionTable/EntityCollectionTableProps.tsx +9 -5
- package/src/components/EntityCollectionTable/PropertyTableCell.tsx +44 -44
- package/src/components/EntityCollectionTable/column_utils.tsx +3 -3
- package/src/components/EntityCollectionTable/fields/TableReferenceField.tsx +9 -16
- package/src/components/EntityCollectionTable/fields/TableStorageUpload.tsx +3 -3
- package/src/components/EntityCollectionTable/internal/CollectionTableToolbar.tsx +27 -32
- package/src/components/EntityCollectionTable/internal/EntityTableCell.tsx +11 -6
- package/src/components/EntityCollectionTable/internal/default_entity_actions.tsx +9 -5
- package/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +2 -4
- package/src/components/EntityCollectionView/EntityCollectionView.tsx +69 -64
- package/src/components/EntityCollectionView/EntityCollectionViewActions.tsx +5 -6
- package/src/components/EntityCollectionView/EntityCollectionViewStartActions.tsx +68 -0
- package/src/components/EntityCollectionView/useSelectionController.tsx +30 -0
- package/src/components/EntityPreview.tsx +207 -70
- package/src/components/EntityView.tsx +84 -0
- package/src/components/FieldCaption.tsx +14 -0
- package/src/components/FireCMSAppBar.tsx +33 -11
- package/src/components/HomePage/DefaultHomePage.tsx +15 -11
- package/src/components/HomePage/NavigationCard.tsx +69 -0
- package/src/components/HomePage/NavigationCardBinding.tsx +116 -0
- package/src/components/HomePage/SmallNavigationCard.tsx +45 -0
- package/src/components/HomePage/index.tsx +3 -1
- package/src/components/ReferenceTable/ReferenceSelectionTable.tsx +4 -4
- package/src/components/ReferenceWidget.tsx +4 -4
- package/src/components/SearchIconsView.tsx +4 -4
- package/src/components/SelectableTable/SelectableTable.tsx +1 -1
- package/src/components/SelectableTable/filters/BooleanFilterField.tsx +2 -3
- package/src/components/SelectableTable/filters/DateTimeFilterField.tsx +23 -8
- package/src/components/SelectableTable/filters/ReferenceFilterField.tsx +35 -24
- package/src/components/SelectableTable/filters/StringNumberFilterField.tsx +35 -15
- package/src/components/VirtualTable/VirtualTable.tsx +28 -20
- package/src/components/VirtualTable/VirtualTableProps.tsx +1 -1
- package/src/components/VirtualTable/fields/VirtualTableDateField.tsx +1 -1
- package/src/components/common/types.tsx +4 -6
- package/src/components/common/useDataSourceEntityCollectionTableController.tsx +12 -1
- package/src/components/index.tsx +4 -2
- package/src/contexts/AuthControllerContext.tsx +1 -1
- package/src/core/Drawer.tsx +66 -39
- package/src/core/{EntityView.tsx → EntityEditView.tsx} +21 -40
- package/src/core/EntitySidePanel.tsx +2 -2
- package/src/core/FireCMS.tsx +18 -3
- package/src/core/NavigationRoutes.tsx +11 -4
- package/src/core/Scaffold.tsx +5 -4
- package/src/core/field_configs.tsx +1 -2
- package/src/form/EntityForm.tsx +40 -21
- package/src/form/PropertyFieldBinding.tsx +0 -2
- package/src/form/components/StorageItemPreview.tsx +5 -3
- package/src/form/components/StorageUploadProgress.tsx +7 -6
- package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +8 -12
- package/src/form/field_bindings/DateTimeFieldBinding.tsx +1 -1
- package/src/form/field_bindings/KeyValueFieldBinding.tsx +15 -15
- package/src/form/field_bindings/MapFieldBinding.tsx +15 -15
- package/src/form/field_bindings/ReadOnlyFieldBinding.tsx +1 -1
- package/src/form/field_bindings/ReferenceFieldBinding.tsx +1 -0
- package/src/form/field_bindings/StorageUploadFieldBinding.tsx +14 -5
- package/src/form/field_bindings/TextFieldBinding.tsx +7 -5
- package/src/form/validation.ts +3 -4
- package/src/hooks/data/delete.ts +3 -3
- package/src/hooks/data/save.ts +2 -2
- package/src/hooks/data/useCollectionFetch.tsx +1 -1
- package/src/hooks/data/useDataSource.tsx +8 -3
- package/src/hooks/data/useEntityFetch.tsx +4 -4
- package/src/hooks/index.tsx +2 -0
- package/src/hooks/useBuildLocalConfigurationPersistence.tsx +9 -10
- package/src/hooks/useBuildModeController.tsx +11 -5
- package/src/hooks/useBuildNavigationController.tsx +199 -81
- package/src/hooks/useProjectLog.tsx +17 -7
- package/src/hooks/useReferenceDialog.tsx +2 -2
- package/src/hooks/useStorageSource.tsx +7 -2
- package/src/hooks/useValidateAuthenticator.tsx +115 -0
- package/src/internal/useBuildDataSource.ts +42 -44
- package/src/internal/useBuildSideEntityController.tsx +86 -20
- package/src/preview/PropertyPreview.tsx +3 -14
- package/src/preview/PropertyPreviewProps.tsx +1 -11
- package/src/preview/components/BooleanPreview.tsx +19 -4
- package/src/preview/components/EnumValuesChip.tsx +1 -1
- package/src/preview/components/ReferencePreview.tsx +55 -147
- package/src/preview/property_previews/ArrayOfMapsPreview.tsx +0 -1
- package/src/preview/property_previews/ArrayOfReferencesPreview.tsx +0 -1
- package/src/preview/property_previews/ArrayOfStorageComponentsPreview.tsx +0 -1
- package/src/preview/property_previews/ArrayOfStringsPreview.tsx +0 -1
- package/src/preview/property_previews/ArrayOneOfPreview.tsx +0 -1
- package/src/preview/property_previews/ArrayPropertyPreview.tsx +0 -1
- package/src/preview/property_previews/StringPropertyPreview.tsx +8 -7
- package/src/types/analytics.ts +1 -0
- package/src/types/auth.tsx +50 -1
- package/src/types/collections.ts +33 -5
- package/src/types/datasource.ts +8 -5
- package/src/types/entities.ts +9 -1
- package/src/types/entity_actions.tsx +17 -0
- package/src/types/entity_callbacks.ts +2 -2
- package/src/types/entity_overrides.tsx +7 -0
- package/src/types/firecms.tsx +0 -1
- package/src/types/index.ts +2 -1
- package/src/types/navigation.ts +17 -16
- package/src/types/permissions.ts +6 -1
- package/src/types/plugins.tsx +26 -28
- package/src/types/properties.ts +8 -6
- package/src/types/property_config.tsx +2 -2
- package/src/types/roles.ts +41 -0
- package/src/types/side_entity_controller.tsx +1 -0
- package/src/types/storage.ts +12 -3
- package/src/types/user.ts +7 -0
- package/src/util/collections.ts +22 -0
- package/src/util/entities.ts +1 -1
- package/src/util/icon_list.ts +2 -2
- package/src/util/icon_synonyms.ts +1 -4
- package/src/util/icons.tsx +11 -3
- package/src/util/navigation_utils.ts +6 -6
- package/src/util/objects.ts +0 -14
- package/src/util/permissions.ts +11 -8
- package/src/util/references.ts +36 -5
- package/src/util/resolutions.ts +6 -24
- package/src/util/strings.ts +2 -2
- package/src/util/useTraceUpdate.tsx +2 -1
- package/dist/core/SideEntityView.d.ts +0 -7
- package/dist/internal/useLocaleConfig.d.ts +0 -1
- package/dist/types/appcheck.d.ts +0 -26
- package/src/components/HomePage/NavigationCollectionCard.tsx +0 -146
- package/src/core/SideEntityView.tsx +0 -38
- package/src/internal/useLocaleConfig.tsx +0 -18
- package/src/types/appcheck.ts +0 -29
|
@@ -1,21 +1,17 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { useMemo } from "react";
|
|
3
2
|
|
|
4
|
-
import { Entity, EntityCollection, EntityReference
|
|
5
|
-
|
|
6
|
-
import { getReferencePreviewKeys, getValueInPath, resolveCollection } from "../../util";
|
|
3
|
+
import { Entity, EntityCollection, EntityReference } from "../../types";
|
|
7
4
|
import {
|
|
8
5
|
useCustomizationController,
|
|
9
6
|
useEntityFetch,
|
|
10
7
|
useNavigationController,
|
|
11
8
|
useSideEntityController
|
|
12
9
|
} from "../../hooks";
|
|
13
|
-
import { PropertyPreview } from "../PropertyPreview";
|
|
14
10
|
import { PreviewSize } from "../PropertyPreviewProps";
|
|
15
|
-
import {
|
|
16
|
-
import { cn, IconButton, KeyboardTabIcon, Skeleton, Tooltip, Typography } from "@firecms/ui";
|
|
11
|
+
import { IconButton, KeyboardTabIcon, Skeleton, Tooltip } from "@firecms/ui";
|
|
17
12
|
import { ErrorView } from "../../components";
|
|
18
13
|
import { useAnalyticsController } from "../../hooks/useAnalyticsController";
|
|
14
|
+
import { EntityPreview, EntityPreviewContainer } from "../../components/EntityPreview";
|
|
19
15
|
|
|
20
16
|
export type ReferencePreviewProps = {
|
|
21
17
|
disabled?: boolean;
|
|
@@ -23,7 +19,7 @@ export type ReferencePreviewProps = {
|
|
|
23
19
|
size: PreviewSize;
|
|
24
20
|
previewProperties?: string[];
|
|
25
21
|
onClick?: (e: React.SyntheticEvent) => void;
|
|
26
|
-
|
|
22
|
+
hover?: boolean;
|
|
27
23
|
allowEntityNavigation?: boolean;
|
|
28
24
|
};
|
|
29
25
|
|
|
@@ -34,12 +30,12 @@ export const ReferencePreview = React.memo<ReferencePreviewProps>(function Refer
|
|
|
34
30
|
const reference = props.reference;
|
|
35
31
|
if (!(typeof reference === "object" && "isEntityReference" in reference && reference.isEntityReference())) {
|
|
36
32
|
console.warn("Reference preview received value of type", typeof reference);
|
|
37
|
-
return <
|
|
33
|
+
return <EntityPreviewContainer
|
|
38
34
|
onClick={props.onClick}
|
|
39
35
|
size={props.size}>
|
|
40
36
|
<ErrorView error={"Unexpected value. Click to edit"}
|
|
41
37
|
tooltip={JSON.stringify(reference)}/>
|
|
42
|
-
</
|
|
38
|
+
</EntityPreviewContainer>;
|
|
43
39
|
}
|
|
44
40
|
return <ReferencePreviewInternal {...props} />;
|
|
45
41
|
}, areEqual) as React.FunctionComponent<ReferencePreviewProps>;
|
|
@@ -47,7 +43,7 @@ export const ReferencePreview = React.memo<ReferencePreviewProps>(function Refer
|
|
|
47
43
|
function areEqual(prevProps: ReferencePreviewProps, nextProps: ReferencePreviewProps) {
|
|
48
44
|
return prevProps.disabled === nextProps.disabled &&
|
|
49
45
|
prevProps.size === nextProps.size &&
|
|
50
|
-
prevProps.
|
|
46
|
+
prevProps.hover === nextProps.hover &&
|
|
51
47
|
prevProps.reference?.id === nextProps.reference?.id &&
|
|
52
48
|
prevProps.reference?.path === nextProps.reference?.path &&
|
|
53
49
|
prevProps.allowEntityNavigation === nextProps.allowEntityNavigation
|
|
@@ -59,7 +55,7 @@ function ReferencePreviewInternal<M extends Record<string, any>>({
|
|
|
59
55
|
reference,
|
|
60
56
|
previewProperties,
|
|
61
57
|
size,
|
|
62
|
-
|
|
58
|
+
hover,
|
|
63
59
|
onClick,
|
|
64
60
|
allowEntityNavigation = true
|
|
65
61
|
}: ReferencePreviewProps) {
|
|
@@ -68,7 +64,7 @@ function ReferencePreviewInternal<M extends Record<string, any>>({
|
|
|
68
64
|
|
|
69
65
|
const navigationController = useNavigationController();
|
|
70
66
|
|
|
71
|
-
const collection = navigationController.getCollection
|
|
67
|
+
const collection = navigationController.getCollection(reference.path);
|
|
72
68
|
if (!collection) {
|
|
73
69
|
if (customizationController.components?.missingReference) {
|
|
74
70
|
return <customizationController.components.missingReference path={reference.path}/>;
|
|
@@ -85,18 +81,22 @@ function ReferencePreviewInternal<M extends Record<string, any>>({
|
|
|
85
81
|
disabled={disabled}
|
|
86
82
|
allowEntityNavigation={allowEntityNavigation}
|
|
87
83
|
onClick={onClick}
|
|
88
|
-
|
|
84
|
+
hover={hover}/>
|
|
89
85
|
}
|
|
90
86
|
|
|
91
|
-
function ReferencePreviewExisting<M extends Record<string, any> = any>({
|
|
87
|
+
function ReferencePreviewExisting<M extends Record<string, any> = any>({
|
|
88
|
+
reference,
|
|
89
|
+
collection,
|
|
90
|
+
previewProperties,
|
|
91
|
+
size,
|
|
92
|
+
disabled,
|
|
93
|
+
allowEntityNavigation,
|
|
94
|
+
onClick,
|
|
95
|
+
hover
|
|
96
|
+
}: ReferencePreviewProps & {
|
|
92
97
|
collection: EntityCollection<M>
|
|
93
98
|
}) {
|
|
94
99
|
|
|
95
|
-
const customizationController = useCustomizationController();
|
|
96
|
-
|
|
97
|
-
const analyticsController = useAnalyticsController();
|
|
98
|
-
const sideEntityController = useSideEntityController();
|
|
99
|
-
|
|
100
100
|
const {
|
|
101
101
|
entity,
|
|
102
102
|
dataLoading,
|
|
@@ -114,145 +114,53 @@ function ReferencePreviewExisting<M extends Record<string, any> = any>({ referen
|
|
|
114
114
|
|
|
115
115
|
const usedEntity = entity ?? referencesCache.get(reference.pathWithId);
|
|
116
116
|
|
|
117
|
-
const resolvedCollection = useMemo(() => resolveCollection({
|
|
118
|
-
collection,
|
|
119
|
-
path: reference.path,
|
|
120
|
-
values: usedEntity?.values,
|
|
121
|
-
fields: customizationController.propertyConfigs
|
|
122
|
-
}), [collection]);
|
|
123
|
-
|
|
124
|
-
const listProperties = useMemo(() => getReferencePreviewKeys(resolvedCollection, customizationController.propertyConfigs, previewProperties, size === "small" || size === "medium" ? 3 : 1),
|
|
125
|
-
[previewProperties, resolvedCollection, size]);
|
|
126
|
-
|
|
127
117
|
let body: React.ReactNode;
|
|
128
118
|
|
|
129
|
-
if (!resolvedCollection) {
|
|
130
|
-
return <ErrorView
|
|
131
|
-
error={"Could not find collection with id " + resolvedCollection}/>
|
|
132
|
-
}
|
|
133
|
-
|
|
134
119
|
if (!reference) {
|
|
135
120
|
body = <ErrorView error={"Reference not set"}/>;
|
|
136
121
|
} else if (usedEntity && !usedEntity.values) {
|
|
137
122
|
body = <ErrorView error={"Reference does not exist"}
|
|
138
123
|
tooltip={reference.path}/>;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
size !== "medium"
|
|
149
|
-
? "block whitespace-nowrap overflow-hidden truncate"
|
|
150
|
-
: ""
|
|
151
|
-
}`}>
|
|
152
|
-
<Typography variant={"caption"}
|
|
153
|
-
className={"font-mono"}>
|
|
154
|
-
{reference.id}
|
|
155
|
-
</Typography>
|
|
156
|
-
</div>
|
|
157
|
-
: <Skeleton/>)}
|
|
158
|
-
|
|
159
|
-
{listProperties && listProperties.map((key) => {
|
|
160
|
-
const childProperty = resolvedCollection.properties[key as string];
|
|
161
|
-
if (!childProperty) return null;
|
|
162
|
-
|
|
163
|
-
return (
|
|
164
|
-
<div key={"ref_prev_" + (key as string)}
|
|
165
|
-
className={listProperties.length > 1 ? "my-0.5" : "my-0"}>
|
|
166
|
-
{
|
|
167
|
-
usedEntity
|
|
168
|
-
? <PropertyPreview
|
|
169
|
-
propertyKey={key as string}
|
|
170
|
-
value={getValueInPath(usedEntity.values, key)}
|
|
171
|
-
property={childProperty as ResolvedProperty}
|
|
172
|
-
// entity={usedEntity}
|
|
173
|
-
size={"tiny"}/>
|
|
174
|
-
: <SkeletonPropertyComponent
|
|
175
|
-
property={childProperty as ResolvedProperty}
|
|
176
|
-
size={"tiny"}/>
|
|
177
|
-
}
|
|
178
|
-
</div>
|
|
179
|
-
);
|
|
180
|
-
})}
|
|
181
|
-
|
|
182
|
-
</div>
|
|
183
|
-
<div className={`my-${size === "tiny" ? 2 : 4}`}>
|
|
184
|
-
{!disabled && usedEntity && allowEntityNavigation &&
|
|
185
|
-
<Tooltip title={`See details for ${usedEntity.id}`}>
|
|
186
|
-
<IconButton
|
|
187
|
-
color={"inherit"}
|
|
188
|
-
size={"small"}
|
|
189
|
-
onClick={(e) => {
|
|
190
|
-
e.stopPropagation();
|
|
191
|
-
analyticsController.onAnalyticsEvent?.("entity_click_from_reference", {
|
|
192
|
-
path: usedEntity.path,
|
|
193
|
-
entityId: usedEntity.id
|
|
194
|
-
});
|
|
195
|
-
sideEntityController.open({
|
|
196
|
-
entityId: usedEntity.id,
|
|
197
|
-
path: usedEntity.path,
|
|
198
|
-
collection: resolvedCollection,
|
|
199
|
-
updateUrl: true
|
|
200
|
-
});
|
|
201
|
-
}}>
|
|
202
|
-
<KeyboardTabIcon size={"small"}/>
|
|
203
|
-
</IconButton>
|
|
204
|
-
</Tooltip>}
|
|
205
|
-
</div>
|
|
206
|
-
</>
|
|
124
|
+
}
|
|
125
|
+
if (body) {
|
|
126
|
+
|
|
127
|
+
return (
|
|
128
|
+
<EntityPreviewContainer onClick={disabled ? undefined : onClick}
|
|
129
|
+
hover={disabled ? undefined : hover}
|
|
130
|
+
size={size}>
|
|
131
|
+
{body}
|
|
132
|
+
</EntityPreviewContainer>
|
|
207
133
|
);
|
|
208
134
|
}
|
|
209
135
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
export function ReferencePreviewContainer({
|
|
220
|
-
children,
|
|
221
|
-
onHover,
|
|
222
|
-
size,
|
|
223
|
-
onClick
|
|
224
|
-
}: {
|
|
225
|
-
children: React.ReactNode;
|
|
226
|
-
onHover?: boolean;
|
|
227
|
-
size: PreviewSize;
|
|
228
|
-
onClick?: (e: React.SyntheticEvent) => void;
|
|
229
|
-
}) {
|
|
230
|
-
return <Typography variant={"label"}
|
|
231
|
-
className={cn("bg-opacity-70 bg-gray-100 dark:bg-gray-800 dark:bg-opacity-60",
|
|
232
|
-
"w-full",
|
|
233
|
-
"flex",
|
|
234
|
-
"rounded-md",
|
|
235
|
-
"overflow-hidden",
|
|
236
|
-
onHover ? "hover:bg-opacity-90 dark:hover:bg-opacity-90" : "",
|
|
237
|
-
size === "medium" ? "p-2" : "p-1",
|
|
238
|
-
size === "tiny" ? "items-center" : "",
|
|
239
|
-
"transition-colors duration-300 ease-in-out ",
|
|
240
|
-
// onHover ? "shadow-outline" : "",
|
|
241
|
-
onClick ? "cursor-pointer" : "")}
|
|
242
|
-
style={{
|
|
243
|
-
// @ts-ignore
|
|
244
|
-
tabindex: 0
|
|
245
|
-
}}
|
|
246
|
-
onClick={(event) => {
|
|
247
|
-
if (onClick) {
|
|
248
|
-
event.preventDefault();
|
|
249
|
-
onClick(event);
|
|
250
|
-
}
|
|
251
|
-
}}>
|
|
136
|
+
if (dataLoading && !usedEntity) {
|
|
137
|
+
return (
|
|
138
|
+
<EntityPreviewContainer onClick={disabled ? undefined : onClick}
|
|
139
|
+
hover={disabled ? undefined : hover}
|
|
140
|
+
size={size}>
|
|
141
|
+
<Skeleton/>
|
|
142
|
+
</EntityPreviewContainer>
|
|
143
|
+
);
|
|
144
|
+
}
|
|
252
145
|
|
|
253
|
-
|
|
146
|
+
if (!usedEntity) {
|
|
147
|
+
return (
|
|
148
|
+
<EntityPreviewContainer onClick={disabled ? undefined : onClick}
|
|
149
|
+
hover={disabled ? undefined : hover}
|
|
150
|
+
size={size}>
|
|
151
|
+
<ErrorView error={"Entity not found"}/>
|
|
152
|
+
</EntityPreviewContainer>
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
return <EntityPreview size={size}
|
|
156
|
+
previewProperties={previewProperties}
|
|
157
|
+
disabled={disabled}
|
|
158
|
+
entity={usedEntity}
|
|
159
|
+
collection={collection}
|
|
160
|
+
onClick={onClick}
|
|
161
|
+
includeEntityNavigation={allowEntityNavigation}
|
|
162
|
+
hover={hover}/>;
|
|
254
163
|
|
|
255
|
-
</Typography>
|
|
256
164
|
}
|
|
257
165
|
|
|
258
166
|
const referencesCache = new Map<string, Entity<any>>();
|
|
@@ -6,7 +6,7 @@ import { PreviewType } from "../../types";
|
|
|
6
6
|
import { UrlComponentPreview } from "../components/UrlComponentPreview";
|
|
7
7
|
import { PropertyPreviewProps } from "../PropertyPreviewProps";
|
|
8
8
|
import { ErrorBoundary } from "../../components";
|
|
9
|
-
import { Chip, getColorSchemeForSeed } from "@firecms/ui";
|
|
9
|
+
import { Chip, cn, getColorSchemeForSeed } from "@firecms/ui";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* @group Preview components
|
|
@@ -24,14 +24,14 @@ export function StringPropertyPreview({
|
|
|
24
24
|
return <EnumValuesChip
|
|
25
25
|
enumKey={enumKey}
|
|
26
26
|
enumValues={resolvedProperty.enumValues}
|
|
27
|
-
size={size
|
|
27
|
+
size={size}/>;
|
|
28
28
|
} else if (property.previewAsTag) {
|
|
29
29
|
const colorScheme = getColorSchemeForSeed(propertyKey ?? "");
|
|
30
30
|
return (
|
|
31
31
|
<ErrorBoundary>
|
|
32
32
|
<Chip
|
|
33
33
|
colorScheme={colorScheme}
|
|
34
|
-
size={size
|
|
34
|
+
size={size}>
|
|
35
35
|
{value}
|
|
36
36
|
</Chip>
|
|
37
37
|
</ErrorBoundary>);
|
|
@@ -45,15 +45,16 @@ export function StringPropertyPreview({
|
|
|
45
45
|
if (!value) return <></>;
|
|
46
46
|
const lines = value.split("\n");
|
|
47
47
|
return value && value.includes("\n")
|
|
48
|
-
? <div className={"overflow-x-scroll"}>
|
|
48
|
+
? <div className={cn("overflow-x-scroll", size === "tiny" ? "text-sm" : "")}>
|
|
49
49
|
{lines.map((str, index) =>
|
|
50
50
|
<React.Fragment key={`string_preview_${index}`}>
|
|
51
51
|
<span>{str}</span>
|
|
52
52
|
{index !== lines.length - 1 && <br/>}
|
|
53
53
|
</React.Fragment>)}
|
|
54
54
|
</div>
|
|
55
|
-
:
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
: (size === "tiny"
|
|
56
|
+
? <span className={"text-sm"}>{value}</span>
|
|
57
|
+
: <>{value}</>
|
|
58
|
+
);
|
|
58
59
|
}
|
|
59
60
|
}
|
package/src/types/analytics.ts
CHANGED
package/src/types/auth.tsx
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { User } from "./user";
|
|
2
|
+
import { Role } from "./roles";
|
|
3
|
+
import { DataSourceDelegate } from "./datasource";
|
|
4
|
+
import { StorageSource } from "./storage";
|
|
2
5
|
|
|
3
6
|
/**
|
|
4
7
|
* Controller for retrieving the logged user or performing auth related operations.
|
|
@@ -6,7 +9,7 @@ import { User } from "./user";
|
|
|
6
9
|
* to do it as the result of a hook.
|
|
7
10
|
* @group Hooks and utilities
|
|
8
11
|
*/
|
|
9
|
-
export type AuthController<UserType extends User =
|
|
12
|
+
export type AuthController<UserType extends User = any, ExtraData extends any = any> = {
|
|
10
13
|
|
|
11
14
|
/**
|
|
12
15
|
* The user currently logged in
|
|
@@ -14,6 +17,11 @@ export type AuthController<UserType extends User = User> = {
|
|
|
14
17
|
*/
|
|
15
18
|
user: UserType | null;
|
|
16
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Roles related to the logged user
|
|
22
|
+
*/
|
|
23
|
+
roles?: Role[];
|
|
24
|
+
|
|
17
25
|
/**
|
|
18
26
|
* Initial loading flag. It is used not to display the login screen
|
|
19
27
|
* when the app first loads, and it has not been checked whether the user
|
|
@@ -21,6 +29,12 @@ export type AuthController<UserType extends User = User> = {
|
|
|
21
29
|
*/
|
|
22
30
|
initialLoading?: boolean;
|
|
23
31
|
|
|
32
|
+
/**
|
|
33
|
+
* Loading flag. It is used to display a loading screen when the user is
|
|
34
|
+
* logging in or out.
|
|
35
|
+
*/
|
|
36
|
+
authLoading: boolean;
|
|
37
|
+
|
|
24
38
|
/**
|
|
25
39
|
* Sign out
|
|
26
40
|
*/
|
|
@@ -46,4 +60,39 @@ export type AuthController<UserType extends User = User> = {
|
|
|
46
60
|
*/
|
|
47
61
|
loginSkipped: boolean;
|
|
48
62
|
|
|
63
|
+
extra: ExtraData;
|
|
64
|
+
|
|
65
|
+
setExtra: (extra: ExtraData) => void;
|
|
66
|
+
|
|
67
|
+
// setUser?: (user: UserType | null) => void;
|
|
68
|
+
|
|
69
|
+
// setRoles?: (roles: Role[]) => void;
|
|
49
70
|
};
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Implement this function to allow access to specific users.
|
|
74
|
+
* @group Hooks and utilities
|
|
75
|
+
*/
|
|
76
|
+
export type Authenticator<UserType extends User = User, Controller extends AuthController<UserType> = AuthController<UserType>> = (props: {
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Logged-in user or null
|
|
80
|
+
*/
|
|
81
|
+
user: UserType | null;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* AuthController
|
|
85
|
+
*/
|
|
86
|
+
authController: Controller;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Connector to your database, e.g. your Firestore database
|
|
90
|
+
*/
|
|
91
|
+
dataSourceDelegate: DataSourceDelegate;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Used storage implementation
|
|
95
|
+
*/
|
|
96
|
+
storageSource: StorageSource;
|
|
97
|
+
|
|
98
|
+
}) => boolean | Promise<boolean>;
|
package/src/types/collections.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { EnumValues, PropertiesOrBuilders } from "./properties";
|
|
|
8
8
|
import { FormContext } from "./fields";
|
|
9
9
|
import { EntityAction } from "./entity_actions";
|
|
10
10
|
import { ExportConfig } from "./export_import";
|
|
11
|
+
import { EntityOverrides } from "./entity_overrides";
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* This interface represents a view that includes a collection of entities.
|
|
@@ -16,7 +17,7 @@ import { ExportConfig } from "./export_import";
|
|
|
16
17
|
*
|
|
17
18
|
* @group Models
|
|
18
19
|
*/
|
|
19
|
-
export interface EntityCollection<M extends Record<string, any> = any, UserType extends User =
|
|
20
|
+
export interface EntityCollection<M extends Record<string, any> = any, UserType extends User = any> {
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
23
|
* You can set an alias that will be used internally instead of the `path`.
|
|
@@ -76,6 +77,13 @@ export interface EntityCollection<M extends Record<string, any> = any, UserType
|
|
|
76
77
|
*/
|
|
77
78
|
properties: PropertiesOrBuilders<M>;
|
|
78
79
|
|
|
80
|
+
/**
|
|
81
|
+
* Title property of the entity. This is the property that will be used
|
|
82
|
+
* as the title in entity related views and references.
|
|
83
|
+
* If not specified, the first property simple text property will be used.
|
|
84
|
+
*/
|
|
85
|
+
titleProperty?: keyof M,
|
|
86
|
+
|
|
79
87
|
/**
|
|
80
88
|
* Can this collection be edited by the end user.
|
|
81
89
|
* Defaults to `true`.
|
|
@@ -99,6 +107,10 @@ export interface EntityCollection<M extends Record<string, any> = any, UserType
|
|
|
99
107
|
* `subcollection:`. e.g. `subcollection:orders`.
|
|
100
108
|
* - If you are using a collection group, you will also have an
|
|
101
109
|
* additional `collectionGroupParent` column.
|
|
110
|
+
* You can use this prop to hide some properties from the table view.
|
|
111
|
+
* Note that if you set this prop, other ways to hide fields, like
|
|
112
|
+
* `hidden` in the property definition,will be ignored.
|
|
113
|
+
* `propertiesOrder` has precedence over `hidden`.
|
|
102
114
|
*/
|
|
103
115
|
propertiesOrder?: Extract<keyof M, string>[];
|
|
104
116
|
|
|
@@ -139,7 +151,7 @@ export interface EntityCollection<M extends Record<string, any> = any, UserType
|
|
|
139
151
|
* is being created, updated or deleted.
|
|
140
152
|
* Useful for adding your own logic or blocking the execution of the operation.
|
|
141
153
|
*/
|
|
142
|
-
callbacks?: EntityCallbacks<M>;
|
|
154
|
+
callbacks?: EntityCallbacks<M, UserType>;
|
|
143
155
|
|
|
144
156
|
/**
|
|
145
157
|
* Builder for rendering additional components such as buttons in the
|
|
@@ -276,6 +288,22 @@ export interface EntityCollection<M extends Record<string, any> = any, UserType
|
|
|
276
288
|
*
|
|
277
289
|
*/
|
|
278
290
|
exportable?: boolean | ExportConfig<UserType>;
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* User id of the owner of this collection. This is used only by plugins, or if you
|
|
294
|
+
* are writing custom code
|
|
295
|
+
*/
|
|
296
|
+
ownerId?: string;
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Overrides for the entity view, like the data source or the storage source.
|
|
300
|
+
*/
|
|
301
|
+
overrides?: EntityOverrides;
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Width of the side dialog (in pixels) when opening an entity in this collection.
|
|
305
|
+
*/
|
|
306
|
+
sideDialogWidth?: number | string;
|
|
279
307
|
}
|
|
280
308
|
|
|
281
309
|
/**
|
|
@@ -346,7 +374,7 @@ export type SelectionController<M extends Record<string, any> = any> = {
|
|
|
346
374
|
|
|
347
375
|
/**
|
|
348
376
|
* Filter conditions in a `Query.where()` clause are specified using the
|
|
349
|
-
* strings
|
|
377
|
+
* strings `<`, `<=`, `==`, `>=`, `>`, `array-contains`, `in`, and `array-contains-any`.
|
|
350
378
|
* @group Models
|
|
351
379
|
*/
|
|
352
380
|
export type WhereFilterOp =
|
|
@@ -436,7 +464,7 @@ export interface AdditionalFieldDelegate<M extends Record<string, any> = any,
|
|
|
436
464
|
* view.
|
|
437
465
|
* @param entity
|
|
438
466
|
*/
|
|
439
|
-
value?: (props: { entity: Entity<M>, context: FireCMSContext }) => string | number | Promise<string | number> | undefined;
|
|
467
|
+
value?: (props: { entity: Entity<M>, context: FireCMSContext<any> }) => string | number | Promise<string | number> | undefined;
|
|
440
468
|
}
|
|
441
469
|
|
|
442
470
|
/**
|
|
@@ -508,7 +536,7 @@ export type EntityTableController<M extends Record<string, any> = any> = {
|
|
|
508
536
|
filterValues?: FilterValues<Extract<keyof M, string>>;
|
|
509
537
|
setFilterValues?: (filterValues: FilterValues<Extract<keyof M, string>>) => void;
|
|
510
538
|
sortBy?: [Extract<keyof M, string>, "asc" | "desc"];
|
|
511
|
-
setSortBy?: (sortBy
|
|
539
|
+
setSortBy?: (sortBy?: [Extract<keyof M, string>, "asc" | "desc"]) => void;
|
|
512
540
|
searchString?: string;
|
|
513
541
|
setSearchString?: (searchString?: string) => void;
|
|
514
542
|
clearFilter?: () => void;
|
package/src/types/datasource.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { ResolvedEntityCollection } from "./resolved_entities";
|
|
|
8
8
|
export interface FetchEntityProps<M extends Record<string, any> = any> {
|
|
9
9
|
path: string;
|
|
10
10
|
entityId: string;
|
|
11
|
-
collection?: EntityCollection<M>
|
|
11
|
+
collection?: EntityCollection<M, any>
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
/**
|
|
@@ -216,6 +216,7 @@ export interface DataSource {
|
|
|
216
216
|
* @param props
|
|
217
217
|
*/
|
|
218
218
|
isFilterCombinationValid?(props: FilterCombinationValidProps): boolean;
|
|
219
|
+
|
|
219
220
|
}
|
|
220
221
|
|
|
221
222
|
export type FilterCombinationValidProps = {
|
|
@@ -366,24 +367,26 @@ export interface DataSourceDelegate {
|
|
|
366
367
|
* Convert a FireCMS reference to a reference that can be used by the datasource
|
|
367
368
|
* @param reference
|
|
368
369
|
*/
|
|
369
|
-
buildReference: (reference: EntityReference) => any,
|
|
370
|
+
// buildReference: (reference: EntityReference) => any,
|
|
370
371
|
|
|
371
372
|
/**
|
|
372
373
|
* Convert a FireCMS GeoPoint to a GeoPoint that can be used by the datasource
|
|
373
374
|
* @param geoPoint
|
|
374
375
|
*/
|
|
375
|
-
buildGeoPoint: (geoPoint: GeoPoint) => any,
|
|
376
|
+
// buildGeoPoint: (geoPoint: GeoPoint) => any,
|
|
376
377
|
|
|
377
378
|
/**
|
|
378
379
|
* Get the object to generate the current time in the datasource
|
|
379
380
|
*/
|
|
380
381
|
currentTime(): any;
|
|
381
382
|
|
|
382
|
-
buildDate: (date: Date) => any;
|
|
383
|
+
// buildDate: (date: Date) => any;
|
|
383
384
|
|
|
384
|
-
buildDeleteFieldValue: () => any;
|
|
385
|
+
// buildDeleteFieldValue: () => any;
|
|
385
386
|
|
|
386
387
|
delegateToCMSModel: (data: any) => any;
|
|
387
388
|
|
|
389
|
+
cmsToDelegateModel: (data: any) => any;
|
|
390
|
+
|
|
388
391
|
setDateToMidnight: (input?: any) => any;
|
|
389
392
|
}
|
package/src/types/entities.ts
CHANGED
|
@@ -37,7 +37,7 @@ export type EntityValues<M extends object> = M;
|
|
|
37
37
|
/**
|
|
38
38
|
* Class used to create a reference to an entity in a different path
|
|
39
39
|
*/
|
|
40
|
-
export class EntityReference
|
|
40
|
+
export class EntityReference {
|
|
41
41
|
/**
|
|
42
42
|
* ID of the entity
|
|
43
43
|
*/
|
|
@@ -78,3 +78,11 @@ export class GeoPoint {
|
|
|
78
78
|
this.longitude = longitude;
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
|
+
|
|
82
|
+
export class Vector {
|
|
83
|
+
readonly value: number[];
|
|
84
|
+
|
|
85
|
+
constructor(value: number[]) {
|
|
86
|
+
this.value = value;
|
|
87
|
+
}
|
|
88
|
+
}
|