@firecms/core 3.0.0-beta.8 → 3.0.0-beta.9
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/app/Drawer.d.ts +1 -1
- package/dist/app/Scaffold.d.ts +1 -1
- package/dist/components/ArrayContainer.d.ts +2 -1
- package/dist/components/CircularProgressCenter.d.ts +1 -1
- package/dist/components/EntityCollectionTable/EntityCollectionRowActions.d.ts +0 -1
- package/dist/components/EntityCollectionTable/fields/TableReferenceField.d.ts +1 -1
- package/dist/components/EntityCollectionTable/internal/popup_field/PopupFormField.d.ts +1 -1
- package/dist/components/EntityCollectionView/EntityCollectionView.d.ts +1 -1
- package/dist/components/EntityPreview.d.ts +1 -1
- package/dist/components/ErrorView.d.ts +1 -1
- package/dist/components/HomePage/DefaultHomePage.d.ts +1 -1
- package/dist/components/HomePage/NavigationCardBinding.d.ts +1 -1
- package/dist/components/PropertyIdCopyTooltip.d.ts +8 -0
- package/dist/components/VirtualTable/VirtualTableProps.d.ts +10 -6
- package/dist/components/common/useColumnsIds.d.ts +2 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/core/DefaultAppBar.d.ts +1 -1
- package/dist/core/DefaultDrawer.d.ts +1 -1
- package/dist/core/DrawerNavigationItem.d.ts +2 -1
- package/dist/core/EntityEditView.d.ts +3 -3
- package/dist/core/FireCMS.d.ts +1 -1
- package/dist/core/NavigationRoutes.d.ts +1 -1
- package/dist/form/PropertyFieldBinding.d.ts +1 -1
- package/dist/form/components/FormikArrayContainer.d.ts +2 -1
- package/dist/form/components/LabelWithIcon.d.ts +1 -1
- package/dist/form/components/LabelWithIconAndTooltip.d.ts +15 -0
- package/dist/form/components/index.d.ts +1 -0
- package/dist/form/field_bindings/ArrayCustomShapedFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/BlockFieldBinding.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/MarkdownEditorFieldBinding.d.ts +11 -0
- package/dist/form/field_bindings/{MultiSelectBinding.d.ts → MultiSelectFieldBinding.d.ts} +1 -1
- package/dist/form/field_bindings/ReadOnlyFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/RepeatFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/SelectFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/StorageUploadFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/TextFieldBinding.d.ts +1 -1
- package/dist/form/index.d.ts +3 -3
- package/dist/form/useClearRestoreValue.d.ts +2 -2
- package/dist/hooks/useProjectLog.d.ts +2 -2
- package/dist/index.es.js +14127 -11014
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +19987 -587
- 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/components/ReferencePreview.d.ts +1 -1
- package/dist/types/auth.d.ts +1 -1
- package/dist/types/collections.d.ts +12 -3
- package/dist/types/datasource.d.ts +35 -22
- package/dist/types/entities.d.ts +1 -0
- package/dist/types/entity_overrides.d.ts +2 -2
- package/dist/types/fields.d.ts +20 -15
- package/dist/types/navigation.d.ts +1 -0
- package/dist/types/properties.d.ts +18 -18
- package/dist/types/side_dialogs_controller.d.ts +10 -0
- package/dist/types/storage.d.ts +75 -0
- package/dist/util/entities.d.ts +1 -1
- package/dist/util/icon_list.d.ts +5 -1
- package/dist/util/icons.d.ts +1 -0
- package/dist/util/index.d.ts +1 -0
- package/dist/util/plurals.d.ts +0 -2
- package/dist/util/property_utils.d.ts +1 -1
- package/dist/util/resolutions.d.ts +15 -1
- package/dist/util/storage.d.ts +1 -1
- package/dist/util/useStorageUploadController.d.ts +2 -2
- package/package.json +15 -17
- package/src/app/Drawer.tsx +1 -1
- package/src/app/Scaffold.tsx +22 -27
- package/src/components/ArrayContainer.tsx +15 -10
- package/src/components/CircularProgressCenter.tsx +1 -1
- package/src/components/EntityCollectionTable/EntityCollectionRowActions.tsx +4 -9
- package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +2 -2
- package/src/components/EntityCollectionTable/PropertyTableCell.tsx +4 -2
- package/src/components/EntityCollectionTable/fields/TableReferenceField.tsx +21 -14
- package/src/components/EntityCollectionTable/fields/TableStorageUpload.tsx +12 -4
- package/src/components/EntityCollectionTable/internal/EntityTableCell.tsx +17 -19
- package/src/components/EntityCollectionTable/internal/EntityTableCellActions.tsx +19 -7
- package/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +3 -5
- package/src/components/EntityCollectionView/EntityCollectionView.tsx +26 -25
- package/src/components/EntityCollectionView/useSelectionController.tsx +19 -7
- package/src/components/EntityPreview.tsx +30 -31
- package/src/components/ErrorView.tsx +1 -1
- package/src/components/HomePage/DefaultHomePage.tsx +24 -18
- package/src/components/HomePage/NavigationCardBinding.tsx +1 -1
- package/src/components/HomePage/SmallNavigationCard.tsx +1 -2
- package/src/components/PropertyIdCopyTooltip.tsx +48 -0
- package/src/components/ReferenceTable/ReferenceSelectionTable.tsx +7 -6
- package/src/components/SearchIconsView.tsx +5 -2
- package/src/components/SelectableTable/SelectableTable.tsx +2 -4
- package/src/components/SelectableTable/filters/DateTimeFilterField.tsx +1 -1
- package/src/components/SelectableTable/filters/StringNumberFilterField.tsx +54 -7
- package/src/components/VirtualTable/VirtualTable.tsx +33 -9
- package/src/components/VirtualTable/VirtualTableCell.tsx +1 -9
- package/src/components/VirtualTable/VirtualTableProps.tsx +12 -8
- package/src/components/VirtualTable/fields/VirtualTableDateField.tsx +3 -3
- package/src/components/VirtualTable/fields/VirtualTableInput.tsx +2 -1
- package/src/components/VirtualTable/fields/VirtualTableNumberInput.tsx +2 -1
- package/src/components/VirtualTable/fields/VirtualTableSelect.tsx +14 -28
- package/src/components/common/useColumnsIds.tsx +13 -0
- package/src/components/common/useDataSourceEntityCollectionTableController.tsx +12 -12
- package/src/components/common/useTableSearchHelper.ts +1 -0
- package/src/components/index.tsx +1 -0
- package/src/core/DefaultAppBar.tsx +3 -3
- package/src/core/DefaultDrawer.tsx +18 -12
- package/src/core/DrawerNavigationItem.tsx +31 -27
- package/src/core/EntityEditView.tsx +136 -109
- package/src/core/FireCMS.tsx +2 -2
- package/src/core/NavigationRoutes.tsx +1 -1
- package/src/core/SideDialogs.tsx +1 -0
- package/src/core/field_configs.tsx +5 -5
- package/src/form/PropertyFieldBinding.tsx +24 -14
- package/src/form/components/CustomIdField.tsx +4 -2
- package/src/form/components/FieldHelperText.tsx +1 -1
- package/src/form/components/FormikArrayContainer.tsx +4 -1
- package/src/form/components/LabelWithIcon.tsx +27 -19
- package/src/form/components/LabelWithIconAndTooltip.tsx +28 -0
- package/src/form/components/StorageItemPreview.tsx +1 -0
- package/src/form/components/StorageUploadProgress.tsx +0 -1
- package/src/form/components/index.tsx +1 -0
- package/src/form/field_bindings/ArrayCustomShapedFieldBinding.tsx +22 -14
- package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +24 -22
- package/src/form/field_bindings/BlockFieldBinding.tsx +13 -11
- package/src/form/field_bindings/DateTimeFieldBinding.tsx +17 -14
- package/src/form/field_bindings/KeyValueFieldBinding.tsx +8 -7
- package/src/form/field_bindings/MapFieldBinding.tsx +16 -24
- package/src/form/field_bindings/MarkdownEditorFieldBinding.tsx +150 -0
- package/src/form/field_bindings/{MultiSelectBinding.tsx → MultiSelectFieldBinding.tsx} +25 -20
- package/src/form/field_bindings/ReadOnlyFieldBinding.tsx +9 -7
- package/src/form/field_bindings/ReferenceFieldBinding.tsx +27 -18
- package/src/form/field_bindings/RepeatFieldBinding.tsx +27 -17
- package/src/form/field_bindings/SelectFieldBinding.tsx +17 -10
- package/src/form/field_bindings/StorageUploadFieldBinding.tsx +36 -17
- package/src/form/field_bindings/SwitchFieldBinding.tsx +9 -5
- package/src/form/field_bindings/TextFieldBinding.tsx +26 -23
- package/src/form/index.tsx +4 -9
- package/src/form/useClearRestoreValue.tsx +2 -2
- package/src/hooks/data/delete.ts +2 -1
- package/src/hooks/data/save.ts +5 -2
- package/src/hooks/data/useDataSource.tsx +11 -3
- package/src/hooks/useBuildNavigationController.tsx +10 -3
- package/src/hooks/useProjectLog.tsx +18 -7
- package/src/internal/useBuildDataSource.ts +59 -76
- package/src/internal/useBuildSideDialogsController.tsx +1 -0
- package/src/internal/useBuildSideEntityController.tsx +17 -4
- package/src/internal/useUnsavedChangesDialog.tsx +3 -1
- package/src/preview/PropertyPreview.tsx +2 -2
- package/src/preview/PropertyPreviewProps.tsx +1 -1
- package/src/preview/components/BooleanPreview.tsx +1 -1
- package/src/preview/components/EnumValuesChip.tsx +1 -1
- package/src/preview/components/ImagePreview.tsx +4 -2
- package/src/preview/components/ReferencePreview.tsx +2 -13
- package/src/preview/components/UrlComponentPreview.tsx +1 -1
- package/src/preview/property_previews/ArrayOfMapsPreview.tsx +1 -1
- package/src/preview/property_previews/ArrayOfReferencesPreview.tsx +1 -1
- package/src/preview/property_previews/ArrayOfStorageComponentsPreview.tsx +1 -1
- package/src/preview/property_previews/ArrayOneOfPreview.tsx +2 -2
- package/src/preview/property_previews/ArrayPropertyPreview.tsx +1 -1
- package/src/preview/property_previews/MapPropertyPreview.tsx +1 -1
- package/src/preview/property_previews/SkeletonPropertyComponent.tsx +2 -2
- package/src/preview/property_previews/StringPropertyPreview.tsx +2 -2
- package/src/preview/util.ts +2 -2
- package/src/types/auth.tsx +1 -1
- package/src/types/collections.ts +15 -4
- package/src/types/datasource.ts +42 -27
- package/src/types/entities.ts +2 -0
- package/src/types/entity_overrides.tsx +2 -2
- package/src/types/fields.tsx +23 -17
- package/src/types/navigation.ts +1 -0
- package/src/types/properties.ts +18 -17
- package/src/types/side_dialogs_controller.tsx +13 -0
- package/src/types/storage.ts +82 -0
- package/src/util/entities.ts +1 -1
- package/src/util/icon_list.ts +14 -9
- package/src/util/icons.tsx +8 -2
- package/src/util/index.ts +1 -0
- package/src/util/plurals.ts +0 -2
- package/src/util/property_utils.tsx +1 -1
- package/src/util/references.ts +3 -0
- package/src/util/resolutions.ts +43 -11
- package/src/util/storage.ts +6 -2
- package/src/util/useStorageUploadController.tsx +15 -7
- package/dist/components/PropertyIdCopyTooltipContent.d.ts +0 -3
- package/dist/form/PropertiesForm.d.ts +0 -8
- package/dist/form/field_bindings/MarkdownFieldBinding.d.ts +0 -9
- package/src/components/PropertyIdCopyTooltipContent.tsx +0 -27
- package/src/form/PropertiesForm.tsx +0 -81
- package/src/form/field_bindings/MarkdownFieldBinding.tsx +0 -695
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import React, { useCallback } from "react";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
ArrayProperty,
|
|
5
|
+
FieldProps,
|
|
6
|
+
PropertyOrBuilder,
|
|
7
|
+
ResolvedArrayProperty,
|
|
8
|
+
ResolvedStringProperty,
|
|
9
|
+
StorageConfig
|
|
10
|
+
} from "../../types";
|
|
4
11
|
import { useDropzone } from "react-dropzone";
|
|
5
12
|
import { PreviewSize } from "../../preview";
|
|
6
|
-
import { FieldHelperText,
|
|
13
|
+
import { FieldHelperText, LabelWithIconAndTooltip } from "../components";
|
|
7
14
|
|
|
8
|
-
import { getIconForProperty, isReadOnly } from "../../util";
|
|
15
|
+
import { getIconForProperty, isReadOnly, resolveProperty } from "../../util";
|
|
9
16
|
import { useSnackbarController, useStorageSource } from "../../hooks";
|
|
10
17
|
import { DragDropContext, Draggable, Droppable } from "@hello-pangea/dnd";
|
|
11
18
|
import { StorageFieldItem, useStorageUploadController } from "../../util/useStorageUploadController";
|
|
@@ -16,7 +23,6 @@ import {
|
|
|
16
23
|
fieldBackgroundDisabledMixin,
|
|
17
24
|
fieldBackgroundHoverMixin,
|
|
18
25
|
fieldBackgroundMixin,
|
|
19
|
-
focusedMixin,
|
|
20
26
|
Typography
|
|
21
27
|
} from "@firecms/ui";
|
|
22
28
|
import { useClearRestoreValue } from "../useClearRestoreValue";
|
|
@@ -44,7 +50,7 @@ export function StorageUploadFieldBinding({
|
|
|
44
50
|
error,
|
|
45
51
|
showError,
|
|
46
52
|
autoFocus,
|
|
47
|
-
|
|
53
|
+
minimalistView,
|
|
48
54
|
property,
|
|
49
55
|
includeDescription,
|
|
50
56
|
context,
|
|
@@ -83,22 +89,28 @@ export function StorageUploadFieldBinding({
|
|
|
83
89
|
setValue
|
|
84
90
|
});
|
|
85
91
|
|
|
92
|
+
const resolvedProperty = resolveProperty({
|
|
93
|
+
propertyOrBuilder: property as PropertyOrBuilder,
|
|
94
|
+
}) as ResolvedStringProperty | ResolvedArrayProperty<string[]>;
|
|
95
|
+
|
|
86
96
|
return (
|
|
87
97
|
|
|
88
98
|
<>
|
|
89
99
|
|
|
90
|
-
{!
|
|
91
|
-
<
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
100
|
+
{!minimalistView &&
|
|
101
|
+
<LabelWithIconAndTooltip
|
|
102
|
+
propertyKey={propertyKey}
|
|
103
|
+
icon={getIconForProperty(property, "small")}
|
|
104
|
+
required={property.validation?.required}
|
|
105
|
+
title={property.name}
|
|
106
|
+
className={"text-text-secondary dark:text-text-secondary-dark ml-3.5"}/>}
|
|
95
107
|
|
|
96
108
|
<StorageUpload
|
|
97
109
|
value={internalValue}
|
|
98
110
|
name={propertyKey}
|
|
99
111
|
disabled={disabled ?? false}
|
|
100
112
|
autoFocus={autoFocus ?? false}
|
|
101
|
-
property={
|
|
113
|
+
property={resolvedProperty}
|
|
102
114
|
onChange={setValue}
|
|
103
115
|
setInternalValue={setInternalValue}
|
|
104
116
|
onFilesAdded={onFilesAdded}
|
|
@@ -170,10 +182,18 @@ function FileDropComponent({
|
|
|
170
182
|
onDropRejected: (fileRejections, event) => {
|
|
171
183
|
for (const fileRejection of fileRejections) {
|
|
172
184
|
for (const error of fileRejection.errors) {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
185
|
+
console.error("Error uploading file: ", error);
|
|
186
|
+
if (error.code === "file-too-large") {
|
|
187
|
+
snackbarContext.open({
|
|
188
|
+
type: "error",
|
|
189
|
+
message: `Error uploading file: File is larger than ${storage.maxSize} bytes`
|
|
190
|
+
});
|
|
191
|
+
} else if (error.code === "file-invalid-type") {
|
|
192
|
+
snackbarContext.open({
|
|
193
|
+
type: "error",
|
|
194
|
+
message: "Error uploading file: File type is not supported"
|
|
195
|
+
});
|
|
196
|
+
}
|
|
177
197
|
}
|
|
178
198
|
}
|
|
179
199
|
}
|
|
@@ -188,7 +208,6 @@ function FileDropComponent({
|
|
|
188
208
|
disabled ? fieldBackgroundDisabledMixin : fieldBackgroundHoverMixin,
|
|
189
209
|
dropZoneClasses,
|
|
190
210
|
multipleFilesSupported && internalValue.length ? "" : "flex",
|
|
191
|
-
focusedMixin,
|
|
192
211
|
{
|
|
193
212
|
[nonActiveDropClasses]: !isDragActive,
|
|
194
213
|
[activeDropClasses]: isDragActive,
|
|
@@ -246,7 +265,7 @@ function FileDropComponent({
|
|
|
246
265
|
ref={provided.innerRef}
|
|
247
266
|
{...provided.draggableProps}
|
|
248
267
|
{...provided.dragHandleProps}
|
|
249
|
-
className={cls(
|
|
268
|
+
className={cls("rounded-md")}
|
|
250
269
|
style={{
|
|
251
270
|
...provided.draggableProps.style
|
|
252
271
|
}}
|
|
@@ -5,6 +5,7 @@ import { getIconForProperty } from "../../util";
|
|
|
5
5
|
import { FieldHelperText, LabelWithIcon } from "../components";
|
|
6
6
|
import { BooleanSwitchWithLabel } from "@firecms/ui";
|
|
7
7
|
import { useClearRestoreValue } from "../useClearRestoreValue";
|
|
8
|
+
import { PropertyIdCopyTooltip } from "../../components";
|
|
8
9
|
|
|
9
10
|
type SwitchFieldProps = FieldProps<boolean>;
|
|
10
11
|
|
|
@@ -23,7 +24,7 @@ export const SwitchFieldBinding = React.forwardRef(function SwitchFieldBinding({
|
|
|
23
24
|
showError,
|
|
24
25
|
autoFocus,
|
|
25
26
|
disabled,
|
|
26
|
-
|
|
27
|
+
size = "medium",
|
|
27
28
|
property,
|
|
28
29
|
includeDescription
|
|
29
30
|
}: SwitchFieldProps, ref) {
|
|
@@ -37,17 +38,20 @@ export const SwitchFieldBinding = React.forwardRef(function SwitchFieldBinding({
|
|
|
37
38
|
return (
|
|
38
39
|
<>
|
|
39
40
|
|
|
41
|
+
<PropertyIdCopyTooltip propertyKey={propertyKey}>
|
|
40
42
|
<BooleanSwitchWithLabel
|
|
41
43
|
value={value}
|
|
42
44
|
onValueChange={(v) => setValue(v)}
|
|
43
45
|
error={showError}
|
|
44
|
-
label={<LabelWithIcon
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
label={<LabelWithIcon
|
|
47
|
+
icon={getIconForProperty(property, "small")}
|
|
48
|
+
required={property.validation?.required}
|
|
49
|
+
title={property.name}/>}
|
|
47
50
|
disabled={disabled}
|
|
48
51
|
autoFocus={autoFocus}
|
|
49
|
-
size={
|
|
52
|
+
size={size}
|
|
50
53
|
/>
|
|
54
|
+
</PropertyIdCopyTooltip>
|
|
51
55
|
|
|
52
56
|
<FieldHelperText includeDescription={includeDescription}
|
|
53
57
|
showError={showError}
|
|
@@ -6,6 +6,7 @@ import { FieldHelperText, LabelWithIcon } from "../components";
|
|
|
6
6
|
import { getIconForProperty } from "../../util";
|
|
7
7
|
import { PropertyPreview } from "../../preview";
|
|
8
8
|
import { useClearRestoreValue } from "../useClearRestoreValue";
|
|
9
|
+
import { PropertyIdCopyTooltip } from "../../components/PropertyIdCopyTooltip";
|
|
9
10
|
|
|
10
11
|
interface TextFieldBindingProps<T extends string | number> extends FieldProps<T> {
|
|
11
12
|
allowInfinity?: boolean
|
|
@@ -18,7 +19,6 @@ interface TextFieldBindingProps<T extends string | number> extends FieldProps<T>
|
|
|
18
19
|
* @group Form fields
|
|
19
20
|
*/
|
|
20
21
|
export function TextFieldBinding<T extends string | number>({
|
|
21
|
-
context,
|
|
22
22
|
propertyKey,
|
|
23
23
|
value,
|
|
24
24
|
setValue,
|
|
@@ -28,6 +28,7 @@ export function TextFieldBinding<T extends string | number>({
|
|
|
28
28
|
autoFocus,
|
|
29
29
|
property,
|
|
30
30
|
includeDescription,
|
|
31
|
+
size = "medium"
|
|
31
32
|
}: TextFieldBindingProps<T>) {
|
|
32
33
|
|
|
33
34
|
let multiline: boolean | undefined;
|
|
@@ -67,27 +68,29 @@ export function TextFieldBinding<T extends string | number>({
|
|
|
67
68
|
const isMultiline = Boolean(multiline);
|
|
68
69
|
|
|
69
70
|
const inputType = property.dataType === "number" ? "number" : undefined;
|
|
70
|
-
return (
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
<
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
71
|
+
return (<>
|
|
72
|
+
<PropertyIdCopyTooltip propertyKey={propertyKey}>
|
|
73
|
+
<TextField
|
|
74
|
+
size={size}
|
|
75
|
+
value={value}
|
|
76
|
+
onChange={onChange}
|
|
77
|
+
autoFocus={autoFocus}
|
|
78
|
+
label={<LabelWithIcon
|
|
79
|
+
icon={getIconForProperty(property, "small")}
|
|
80
|
+
required={property.validation?.required}
|
|
81
|
+
title={property.name}/>}
|
|
82
|
+
type={inputType}
|
|
83
|
+
multiline={isMultiline}
|
|
84
|
+
disabled={disabled}
|
|
85
|
+
endAdornment={
|
|
86
|
+
property.clearable && <IconButton
|
|
87
|
+
onClick={handleClearClick}>
|
|
88
|
+
<ClearIcon/>
|
|
89
|
+
</IconButton>
|
|
90
|
+
}
|
|
91
|
+
error={showError ? error : undefined}
|
|
92
|
+
inputClassName={error ? "text-red-500 dark:text-red-600" : ""}/>
|
|
93
|
+
</PropertyIdCopyTooltip>
|
|
91
94
|
<FieldHelperText includeDescription={includeDescription}
|
|
92
95
|
showError={showError}
|
|
93
96
|
error={error}
|
|
@@ -100,7 +103,7 @@ export function TextFieldBinding<T extends string | number>({
|
|
|
100
103
|
<PropertyPreview
|
|
101
104
|
value={value}
|
|
102
105
|
property={property}
|
|
103
|
-
size={
|
|
106
|
+
size={size}/>
|
|
104
107
|
</Collapse>}
|
|
105
108
|
|
|
106
109
|
</>
|
package/src/form/index.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SelectFieldBinding } from "./field_bindings/SelectFieldBinding";
|
|
2
|
-
import {
|
|
2
|
+
import { MultiSelectFieldBinding } from "./field_bindings/MultiSelectFieldBinding";
|
|
3
3
|
import { ArrayOfReferencesFieldBinding } from "./field_bindings/ArrayOfReferencesFieldBinding";
|
|
4
4
|
import { StorageUploadFieldBinding } from "./field_bindings/StorageUploadFieldBinding";
|
|
5
5
|
import { TextFieldBinding } from "./field_bindings/TextFieldBinding";
|
|
@@ -11,13 +11,13 @@ import { KeyValueFieldBinding } from "./field_bindings/KeyValueFieldBinding";
|
|
|
11
11
|
import { RepeatFieldBinding } from "./field_bindings/RepeatFieldBinding";
|
|
12
12
|
import { BlockFieldBinding } from "./field_bindings/BlockFieldBinding";
|
|
13
13
|
import { ReadOnlyFieldBinding } from "./field_bindings/ReadOnlyFieldBinding";
|
|
14
|
-
import {
|
|
14
|
+
import { MarkdownEditorFieldBinding } from "./field_bindings/MarkdownEditorFieldBinding";
|
|
15
15
|
import { ArrayCustomShapedFieldBinding } from "./field_bindings/ArrayCustomShapedFieldBinding";
|
|
16
16
|
|
|
17
17
|
export {
|
|
18
18
|
ArrayCustomShapedFieldBinding,
|
|
19
19
|
RepeatFieldBinding,
|
|
20
|
-
|
|
20
|
+
MultiSelectFieldBinding,
|
|
21
21
|
ArrayOfReferencesFieldBinding,
|
|
22
22
|
BlockFieldBinding,
|
|
23
23
|
DateTimeFieldBinding,
|
|
@@ -28,16 +28,11 @@ export {
|
|
|
28
28
|
SelectFieldBinding,
|
|
29
29
|
StorageUploadFieldBinding,
|
|
30
30
|
SwitchFieldBinding,
|
|
31
|
-
|
|
31
|
+
MarkdownEditorFieldBinding,
|
|
32
32
|
TextFieldBinding
|
|
33
33
|
};
|
|
34
34
|
|
|
35
35
|
export * from "./components";
|
|
36
36
|
|
|
37
|
-
// export type { EntityFormProps } from "./EntityForm";
|
|
38
|
-
// export {
|
|
39
|
-
// EntityForm
|
|
40
|
-
// } from "./EntityForm";
|
|
41
|
-
|
|
42
37
|
export { PropertyFieldBinding } from "./PropertyFieldBinding";
|
|
43
38
|
export * from "./useClearRestoreValue";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useEffect, useRef } from "react";
|
|
2
|
-
import { CMSType, ResolvedProperty } from "../types";
|
|
2
|
+
import { CMSType, Property, ResolvedProperty } from "../types";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Hook we use to restore a value after it has been cleared
|
|
@@ -14,7 +14,7 @@ export function useClearRestoreValue<T extends CMSType>({
|
|
|
14
14
|
setValue
|
|
15
15
|
}:
|
|
16
16
|
{
|
|
17
|
-
property: ResolvedProperty<T>,
|
|
17
|
+
property: Property<T> | ResolvedProperty<T>,
|
|
18
18
|
value: T,
|
|
19
19
|
setValue: (value: T | null, shouldValidate?: boolean) => void
|
|
20
20
|
}) {
|
package/src/hooks/data/delete.ts
CHANGED
package/src/hooks/data/save.ts
CHANGED
|
@@ -108,7 +108,11 @@ export async function saveEntityWithCallbacks<M extends Record<string, any>, Use
|
|
|
108
108
|
updatedValues = values;
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
console.log("Saving entity",
|
|
111
|
+
console.log("Saving entity", {
|
|
112
|
+
entityId,
|
|
113
|
+
updatedValues,
|
|
114
|
+
collection
|
|
115
|
+
});
|
|
112
116
|
return dataSource.saveEntity({
|
|
113
117
|
collection,
|
|
114
118
|
path: resolvedPath,
|
|
@@ -117,7 +121,6 @@ export async function saveEntityWithCallbacks<M extends Record<string, any>, Use
|
|
|
117
121
|
previousValues,
|
|
118
122
|
status
|
|
119
123
|
}).then((entity) => {
|
|
120
|
-
console.log("Entity saved");
|
|
121
124
|
try {
|
|
122
125
|
if (callbacks?.onSaveSuccess) {
|
|
123
126
|
const resolvedCollection = resolveCollection<M>({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useContext
|
|
1
|
+
import { useContext } from "react";
|
|
2
2
|
import { DataSource, EntityCollection } from "../../types";
|
|
3
3
|
import { DataSourceContext } from "../../contexts/DataSourceContext";
|
|
4
4
|
|
|
@@ -7,8 +7,16 @@ import { DataSourceContext } from "../../contexts/DataSourceContext";
|
|
|
7
7
|
* @group Hooks and utilities
|
|
8
8
|
*/
|
|
9
9
|
export const useDataSource = (collection?: EntityCollection<any, any>): DataSource => {
|
|
10
|
+
// const customizationController = useCustomizationController();
|
|
11
|
+
// const navigationController = useNavigationController();
|
|
10
12
|
const defaultDataSource = useContext(DataSourceContext);
|
|
11
|
-
if (collection?.overrides?.
|
|
12
|
-
|
|
13
|
+
// if (collection?.overrides?.dataSourceDelegate) {
|
|
14
|
+
// console.trace("Using custom data source for collection " + collection.id);
|
|
15
|
+
// return useBuildDataSource({
|
|
16
|
+
// delegate: collection.overrides.dataSourceDelegate,
|
|
17
|
+
// propertyConfigs: customizationController?.propertyConfigs,
|
|
18
|
+
// navigationController: navigationController
|
|
19
|
+
// });
|
|
20
|
+
// }
|
|
13
21
|
return defaultDataSource;
|
|
14
22
|
};
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
applyPermissionsFunctionIfEmpty,
|
|
21
21
|
getCollectionByPathOrId,
|
|
22
22
|
mergeDeep,
|
|
23
|
+
removeFunctions,
|
|
23
24
|
removeInitialAndTrailingSlashes,
|
|
24
25
|
resolveCollectionPathIds,
|
|
25
26
|
resolvePermissions
|
|
@@ -203,6 +204,10 @@ export function useBuildNavigationController<EC extends EntityCollection, UserTy
|
|
|
203
204
|
collectionsRef.current = resolvedCollections;
|
|
204
205
|
shouldUpdateTopLevelNav = true;
|
|
205
206
|
}
|
|
207
|
+
if (collectionsRef.current === undefined) {
|
|
208
|
+
collectionsRef.current = resolvedCollections;
|
|
209
|
+
shouldUpdateTopLevelNav = true;
|
|
210
|
+
}
|
|
206
211
|
if (!equal(viewsRef.current, resolvedViews)) {
|
|
207
212
|
viewsRef.current = resolvedViews;
|
|
208
213
|
shouldUpdateTopLevelNav = true;
|
|
@@ -221,8 +226,10 @@ export function useBuildNavigationController<EC extends EntityCollection, UserTy
|
|
|
221
226
|
setNavigationLoadingError(e as any);
|
|
222
227
|
}
|
|
223
228
|
|
|
224
|
-
|
|
225
|
-
|
|
229
|
+
if (navigationLoading)
|
|
230
|
+
setNavigationLoading(false);
|
|
231
|
+
if (!initialised)
|
|
232
|
+
setInitialised(true);
|
|
226
233
|
|
|
227
234
|
}, [
|
|
228
235
|
collectionsProp,
|
|
@@ -505,5 +512,5 @@ function areCollectionsEqual(a: EntityCollection, b: EntityCollection) {
|
|
|
505
512
|
if (!areCollectionListsEqual(subcollectionsA ?? [], subcollectionsB ?? [])) {
|
|
506
513
|
return false;
|
|
507
514
|
}
|
|
508
|
-
return equal(restA, restB);
|
|
515
|
+
return equal(removeFunctions(restA), removeFunctions(restB));
|
|
509
516
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useEffect, useRef, useState } from "react";
|
|
2
|
-
import { AuthController, FireCMSPlugin } from "../types";
|
|
2
|
+
import { AuthController, DataSourceDelegate, FireCMSPlugin } from "../types";
|
|
3
3
|
|
|
4
4
|
export const DEFAULT_SERVER_DEV = "https://api-kdoe6pj3qq-ey.a.run.app";
|
|
5
5
|
export const DEFAULT_SERVER = "https://api-drplyi3b6q-ey.a.run.app";
|
|
@@ -9,17 +9,26 @@ export type AccessResponse = {
|
|
|
9
9
|
message?: string;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
async function makeRequest(authController: AuthController, pluginKeys: string[] | undefined) {
|
|
13
|
-
|
|
12
|
+
async function makeRequest(authController: AuthController, dataSourceKey: string, pluginKeys: string[] | undefined) {
|
|
13
|
+
let idToken: string | null;
|
|
14
|
+
try {
|
|
15
|
+
idToken = await authController.getAuthToken();
|
|
16
|
+
} catch (e) {
|
|
17
|
+
idToken = null;
|
|
18
|
+
}
|
|
14
19
|
return fetch(DEFAULT_SERVER + "/access_log",
|
|
15
20
|
{
|
|
16
21
|
// mode: "no-cors",
|
|
17
22
|
method: "POST",
|
|
18
23
|
headers: {
|
|
19
24
|
"Content-Type": "application/json",
|
|
20
|
-
Authorization: `Basic ${
|
|
25
|
+
Authorization: `Basic ${idToken}`
|
|
21
26
|
},
|
|
22
|
-
body: JSON.stringify({
|
|
27
|
+
body: JSON.stringify({
|
|
28
|
+
email: authController.user?.email ?? null,
|
|
29
|
+
datasource: dataSourceKey,
|
|
30
|
+
plugins: pluginKeys
|
|
31
|
+
})
|
|
23
32
|
})
|
|
24
33
|
.then(async (res) => {
|
|
25
34
|
return res.json();
|
|
@@ -27,15 +36,17 @@ async function makeRequest(authController: AuthController, pluginKeys: string[]
|
|
|
27
36
|
}
|
|
28
37
|
|
|
29
38
|
export function useProjectLog(authController: AuthController,
|
|
39
|
+
dataSourceDelegate: DataSourceDelegate,
|
|
30
40
|
plugins?: FireCMSPlugin<any, any, any>[]): AccessResponse | null {
|
|
31
41
|
const [accessResponse, setAccessResponse] = useState<AccessResponse | null>(null);
|
|
32
42
|
const accessedUserRef = useRef<string | null>(null);
|
|
43
|
+
const dataSourceKey = dataSourceDelegate.key;
|
|
33
44
|
const pluginKeys = plugins?.map(plugin => plugin.key);
|
|
34
45
|
useEffect(() => {
|
|
35
46
|
if (authController.user && authController.user.uid !== accessedUserRef.current && !authController.initialLoading) {
|
|
36
|
-
makeRequest(authController, pluginKeys).then(setAccessResponse);
|
|
47
|
+
makeRequest(authController, dataSourceKey, pluginKeys).then(setAccessResponse);
|
|
37
48
|
accessedUserRef.current = authController.user.uid;
|
|
38
49
|
}
|
|
39
|
-
}, [authController, pluginKeys]);
|
|
50
|
+
}, [authController, dataSourceKey, pluginKeys]);
|
|
40
51
|
return accessResponse;
|
|
41
52
|
}
|