@firecms/core 3.0.0-beta.7 → 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/AppBar.d.ts +12 -0
- package/dist/app/Drawer.d.ts +17 -0
- package/dist/app/Scaffold.d.ts +30 -0
- package/dist/app/index.d.ts +4 -0
- package/dist/app/useApp.d.ts +16 -0
- 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 +14 -6
- package/dist/components/common/useColumnsIds.d.ts +2 -1
- package/dist/components/index.d.ts +2 -1
- package/dist/{components/FireCMSAppBar.d.ts → core/DefaultAppBar.d.ts} +3 -8
- package/dist/core/DefaultDrawer.d.ts +19 -0
- package/dist/core/DrawerNavigationItem.d.ts +2 -1
- package/dist/core/EntityEditView.d.ts +18 -4
- package/dist/core/FireCMS.d.ts +1 -1
- package/dist/core/NavigationRoutes.d.ts +2 -2
- package/dist/core/index.d.ts +2 -2
- package/dist/form/PropertyFieldBinding.d.ts +1 -1
- package/dist/form/components/FieldHelperText.d.ts +3 -3
- 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/StorageItemPreview.d.ts +4 -4
- 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 +3 -5
- package/dist/form/field_bindings/TextFieldBinding.d.ts +1 -1
- package/dist/form/index.d.ts +3 -5
- package/dist/form/useClearRestoreValue.d.ts +2 -2
- package/dist/hooks/useProjectLog.d.ts +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +14434 -11300
- 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 +6 -1
- package/dist/preview/components/EnumValuesChip.d.ts +1 -1
- package/dist/preview/components/ReferencePreview.d.ts +1 -1
- package/dist/preview/components/StorageThumbnail.d.ts +2 -1
- package/dist/preview/components/UrlComponentPreview.d.ts +2 -1
- package/dist/types/auth.d.ts +2 -2
- package/dist/types/collections.d.ts +26 -3
- package/dist/types/datasource.d.ts +53 -30
- package/dist/types/entities.d.ts +1 -0
- package/dist/types/entity_overrides.d.ts +2 -2
- package/dist/types/fields.d.ts +47 -41
- package/dist/types/navigation.d.ts +1 -0
- package/dist/types/plugins.d.ts +11 -3
- package/dist/types/properties.d.ts +25 -20
- 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 +3 -2
- 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 +23 -2
- package/dist/util/useStorageUploadController.d.ts +3 -3
- package/package.json +18 -29
- package/src/app/AppBar.tsx +18 -0
- package/src/app/Drawer.tsx +25 -0
- package/src/{core → app}/Scaffold.tsx +71 -122
- package/src/app/index.ts +4 -0
- package/src/app/useApp.tsx +32 -0
- package/src/components/ArrayContainer.tsx +15 -10
- package/src/components/CircularProgressCenter.tsx +1 -1
- package/src/components/EntityCollectionTable/EntityCollectionRowActions.tsx +11 -18
- 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 +5 -6
- package/src/components/EntityCollectionView/EntityCollectionView.tsx +33 -29
- 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 +36 -10
- package/src/components/VirtualTable/VirtualTableCell.tsx +1 -9
- package/src/components/VirtualTable/VirtualTableProps.tsx +17 -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 +53 -12
- package/src/components/index.tsx +2 -1
- package/src/contexts/DialogsProvider.tsx +2 -2
- package/src/{components/FireCMSAppBar.tsx → core/DefaultAppBar.tsx} +28 -30
- package/src/core/DefaultDrawer.tsx +183 -0
- package/src/core/DrawerNavigationItem.tsx +31 -27
- package/src/core/EntityEditView.tsx +712 -145
- package/src/core/EntitySidePanel.tsx +0 -1
- package/src/core/FireCMS.tsx +2 -2
- package/src/core/NavigationRoutes.tsx +4 -4
- package/src/core/SideDialogs.tsx +1 -0
- package/src/core/field_configs.tsx +5 -5
- package/src/core/index.tsx +2 -2
- package/src/form/PropertyFieldBinding.tsx +53 -19
- package/src/form/components/CustomIdField.tsx +4 -2
- package/src/form/components/FieldHelperText.tsx +4 -4
- 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 +20 -10
- package/src/form/components/StorageUploadProgress.tsx +0 -1
- package/src/form/components/index.tsx +1 -0
- package/src/form/field_bindings/ArrayCustomShapedFieldBinding.tsx +26 -15
- package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +28 -25
- 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 +48 -42
- package/src/form/field_bindings/MapFieldBinding.tsx +17 -17
- 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 -14
- package/src/form/field_bindings/ReferenceFieldBinding.tsx +27 -18
- package/src/form/field_bindings/RepeatFieldBinding.tsx +32 -19
- package/src/form/field_bindings/SelectFieldBinding.tsx +17 -10
- package/src/form/field_bindings/StorageUploadFieldBinding.tsx +33 -43
- 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/form/validation.ts +1 -17
- 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/index.ts +1 -0
- package/src/internal/useBuildDataSource.ts +69 -74
- 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 +7 -4
- package/src/preview/PropertyPreviewProps.tsx +7 -1
- package/src/preview/components/BooleanPreview.tsx +1 -1
- package/src/preview/components/EnumValuesChip.tsx +1 -1
- package/src/preview/components/ImagePreview.tsx +24 -34
- package/src/preview/components/ReferencePreview.tsx +2 -12
- package/src/preview/components/StorageThumbnail.tsx +5 -1
- package/src/preview/components/UrlComponentPreview.tsx +44 -11
- 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 +2 -2
- package/src/types/collections.ts +29 -4
- package/src/types/customization_controller.tsx +0 -1
- package/src/types/datasource.ts +62 -43
- package/src/types/entities.ts +2 -0
- package/src/types/entity_overrides.tsx +2 -2
- package/src/types/fields.tsx +51 -45
- package/src/types/navigation.ts +1 -0
- package/src/types/plugins.tsx +12 -3
- package/src/types/properties.ts +25 -19
- package/src/types/side_dialogs_controller.tsx +13 -0
- package/src/types/storage.ts +82 -0
- package/src/util/entities.ts +5 -4
- 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/objects.ts +17 -7
- package/src/util/permissions.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 +79 -21
- package/src/util/useStorageUploadController.tsx +33 -7
- package/dist/components/PropertyIdCopyTooltipContent.d.ts +0 -3
- package/dist/core/Drawer.d.ts +0 -16
- package/dist/core/Scaffold.d.ts +0 -51
- package/dist/form/EntityForm.d.ts +0 -77
- package/dist/form/field_bindings/MarkdownFieldBinding.d.ts +0 -9
- package/src/components/PropertyIdCopyTooltipContent.tsx +0 -27
- package/src/core/Drawer.tsx +0 -139
- package/src/form/EntityForm.tsx +0 -736
- package/src/form/field_bindings/MarkdownFieldBinding.tsx +0 -695
|
@@ -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/form/validation.ts
CHANGED
|
@@ -112,23 +112,7 @@ export function getYupMapObjectSchema({
|
|
|
112
112
|
if (validation?.required) {
|
|
113
113
|
return shape.required(validation?.requiredMessage ? validation.requiredMessage : "Required").nullable(true);
|
|
114
114
|
}
|
|
115
|
-
return shape.nullable(true);
|
|
116
|
-
// const object: ObjectSchema<any> = yup.object().shape(objectSchema);
|
|
117
|
-
// return validation?.required
|
|
118
|
-
// ? object.required(validation?.requiredMessage ? validation.requiredMessage : "Required").nullable(true)
|
|
119
|
-
// : yup.object().optional().default(undefined).notRequired().nullable(true).test(
|
|
120
|
-
// "empty-check",
|
|
121
|
-
// "Optional map can be empty",
|
|
122
|
-
// (o: any, testContext: any) => {
|
|
123
|
-
// try {
|
|
124
|
-
// if (!o || Object.keys(o).length === 0) return true;
|
|
125
|
-
// return object.validateSync(o);
|
|
126
|
-
// } catch (e) {
|
|
127
|
-
// testContext.createError(e);
|
|
128
|
-
// console.error(e);
|
|
129
|
-
// return false;
|
|
130
|
-
// }
|
|
131
|
-
// });
|
|
115
|
+
return yup.object().shape(shape.fields).default(undefined).notRequired().nullable(true);
|
|
132
116
|
}
|
|
133
117
|
|
|
134
118
|
function getYupStringSchema({
|
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
|
}
|