@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.
Files changed (216) hide show
  1. package/dist/app/AppBar.d.ts +12 -0
  2. package/dist/app/Drawer.d.ts +17 -0
  3. package/dist/app/Scaffold.d.ts +30 -0
  4. package/dist/app/index.d.ts +4 -0
  5. package/dist/app/useApp.d.ts +16 -0
  6. package/dist/components/ArrayContainer.d.ts +2 -1
  7. package/dist/components/CircularProgressCenter.d.ts +1 -1
  8. package/dist/components/EntityCollectionTable/EntityCollectionRowActions.d.ts +0 -1
  9. package/dist/components/EntityCollectionTable/fields/TableReferenceField.d.ts +1 -1
  10. package/dist/components/EntityCollectionTable/internal/popup_field/PopupFormField.d.ts +1 -1
  11. package/dist/components/EntityCollectionView/EntityCollectionView.d.ts +1 -1
  12. package/dist/components/EntityPreview.d.ts +1 -1
  13. package/dist/components/ErrorView.d.ts +1 -1
  14. package/dist/components/HomePage/DefaultHomePage.d.ts +1 -1
  15. package/dist/components/HomePage/NavigationCardBinding.d.ts +1 -1
  16. package/dist/components/PropertyIdCopyTooltip.d.ts +8 -0
  17. package/dist/components/VirtualTable/VirtualTableProps.d.ts +14 -6
  18. package/dist/components/common/useColumnsIds.d.ts +2 -1
  19. package/dist/components/index.d.ts +2 -1
  20. package/dist/{components/FireCMSAppBar.d.ts → core/DefaultAppBar.d.ts} +3 -8
  21. package/dist/core/DefaultDrawer.d.ts +19 -0
  22. package/dist/core/DrawerNavigationItem.d.ts +2 -1
  23. package/dist/core/EntityEditView.d.ts +18 -4
  24. package/dist/core/FireCMS.d.ts +1 -1
  25. package/dist/core/NavigationRoutes.d.ts +2 -2
  26. package/dist/core/index.d.ts +2 -2
  27. package/dist/form/PropertyFieldBinding.d.ts +1 -1
  28. package/dist/form/components/FieldHelperText.d.ts +3 -3
  29. package/dist/form/components/FormikArrayContainer.d.ts +2 -1
  30. package/dist/form/components/LabelWithIcon.d.ts +1 -1
  31. package/dist/form/components/LabelWithIconAndTooltip.d.ts +15 -0
  32. package/dist/form/components/StorageItemPreview.d.ts +4 -4
  33. package/dist/form/components/index.d.ts +1 -0
  34. package/dist/form/field_bindings/ArrayCustomShapedFieldBinding.d.ts +1 -1
  35. package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.d.ts +1 -1
  36. package/dist/form/field_bindings/BlockFieldBinding.d.ts +1 -1
  37. package/dist/form/field_bindings/KeyValueFieldBinding.d.ts +1 -1
  38. package/dist/form/field_bindings/MapFieldBinding.d.ts +1 -1
  39. package/dist/form/field_bindings/MarkdownEditorFieldBinding.d.ts +11 -0
  40. package/dist/form/field_bindings/{MultiSelectBinding.d.ts → MultiSelectFieldBinding.d.ts} +1 -1
  41. package/dist/form/field_bindings/ReadOnlyFieldBinding.d.ts +1 -1
  42. package/dist/form/field_bindings/RepeatFieldBinding.d.ts +1 -1
  43. package/dist/form/field_bindings/SelectFieldBinding.d.ts +1 -1
  44. package/dist/form/field_bindings/StorageUploadFieldBinding.d.ts +3 -5
  45. package/dist/form/field_bindings/TextFieldBinding.d.ts +1 -1
  46. package/dist/form/index.d.ts +3 -5
  47. package/dist/form/useClearRestoreValue.d.ts +2 -2
  48. package/dist/hooks/useProjectLog.d.ts +2 -2
  49. package/dist/index.d.ts +1 -0
  50. package/dist/index.es.js +14434 -11300
  51. package/dist/index.es.js.map +1 -1
  52. package/dist/index.umd.js +19987 -587
  53. package/dist/index.umd.js.map +1 -1
  54. package/dist/preview/PropertyPreviewProps.d.ts +6 -1
  55. package/dist/preview/components/EnumValuesChip.d.ts +1 -1
  56. package/dist/preview/components/ReferencePreview.d.ts +1 -1
  57. package/dist/preview/components/StorageThumbnail.d.ts +2 -1
  58. package/dist/preview/components/UrlComponentPreview.d.ts +2 -1
  59. package/dist/types/auth.d.ts +2 -2
  60. package/dist/types/collections.d.ts +26 -3
  61. package/dist/types/datasource.d.ts +53 -30
  62. package/dist/types/entities.d.ts +1 -0
  63. package/dist/types/entity_overrides.d.ts +2 -2
  64. package/dist/types/fields.d.ts +47 -41
  65. package/dist/types/navigation.d.ts +1 -0
  66. package/dist/types/plugins.d.ts +11 -3
  67. package/dist/types/properties.d.ts +25 -20
  68. package/dist/types/side_dialogs_controller.d.ts +10 -0
  69. package/dist/types/storage.d.ts +75 -0
  70. package/dist/util/entities.d.ts +1 -1
  71. package/dist/util/icon_list.d.ts +5 -1
  72. package/dist/util/icons.d.ts +3 -2
  73. package/dist/util/index.d.ts +1 -0
  74. package/dist/util/plurals.d.ts +0 -2
  75. package/dist/util/property_utils.d.ts +1 -1
  76. package/dist/util/resolutions.d.ts +15 -1
  77. package/dist/util/storage.d.ts +23 -2
  78. package/dist/util/useStorageUploadController.d.ts +3 -3
  79. package/package.json +18 -29
  80. package/src/app/AppBar.tsx +18 -0
  81. package/src/app/Drawer.tsx +25 -0
  82. package/src/{core → app}/Scaffold.tsx +71 -122
  83. package/src/app/index.ts +4 -0
  84. package/src/app/useApp.tsx +32 -0
  85. package/src/components/ArrayContainer.tsx +15 -10
  86. package/src/components/CircularProgressCenter.tsx +1 -1
  87. package/src/components/EntityCollectionTable/EntityCollectionRowActions.tsx +11 -18
  88. package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +2 -2
  89. package/src/components/EntityCollectionTable/PropertyTableCell.tsx +4 -2
  90. package/src/components/EntityCollectionTable/fields/TableReferenceField.tsx +21 -14
  91. package/src/components/EntityCollectionTable/fields/TableStorageUpload.tsx +12 -4
  92. package/src/components/EntityCollectionTable/internal/EntityTableCell.tsx +17 -19
  93. package/src/components/EntityCollectionTable/internal/EntityTableCellActions.tsx +19 -7
  94. package/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +5 -6
  95. package/src/components/EntityCollectionView/EntityCollectionView.tsx +33 -29
  96. package/src/components/EntityCollectionView/useSelectionController.tsx +19 -7
  97. package/src/components/EntityPreview.tsx +30 -31
  98. package/src/components/ErrorView.tsx +1 -1
  99. package/src/components/HomePage/DefaultHomePage.tsx +24 -18
  100. package/src/components/HomePage/NavigationCardBinding.tsx +1 -1
  101. package/src/components/HomePage/SmallNavigationCard.tsx +1 -2
  102. package/src/components/PropertyIdCopyTooltip.tsx +48 -0
  103. package/src/components/ReferenceTable/ReferenceSelectionTable.tsx +7 -6
  104. package/src/components/SearchIconsView.tsx +5 -2
  105. package/src/components/SelectableTable/SelectableTable.tsx +2 -4
  106. package/src/components/SelectableTable/filters/DateTimeFilterField.tsx +1 -1
  107. package/src/components/SelectableTable/filters/StringNumberFilterField.tsx +54 -7
  108. package/src/components/VirtualTable/VirtualTable.tsx +36 -10
  109. package/src/components/VirtualTable/VirtualTableCell.tsx +1 -9
  110. package/src/components/VirtualTable/VirtualTableProps.tsx +17 -8
  111. package/src/components/VirtualTable/fields/VirtualTableDateField.tsx +3 -3
  112. package/src/components/VirtualTable/fields/VirtualTableInput.tsx +2 -1
  113. package/src/components/VirtualTable/fields/VirtualTableNumberInput.tsx +2 -1
  114. package/src/components/VirtualTable/fields/VirtualTableSelect.tsx +14 -28
  115. package/src/components/common/useColumnsIds.tsx +13 -0
  116. package/src/components/common/useDataSourceEntityCollectionTableController.tsx +12 -12
  117. package/src/components/common/useTableSearchHelper.ts +53 -12
  118. package/src/components/index.tsx +2 -1
  119. package/src/contexts/DialogsProvider.tsx +2 -2
  120. package/src/{components/FireCMSAppBar.tsx → core/DefaultAppBar.tsx} +28 -30
  121. package/src/core/DefaultDrawer.tsx +183 -0
  122. package/src/core/DrawerNavigationItem.tsx +31 -27
  123. package/src/core/EntityEditView.tsx +712 -145
  124. package/src/core/EntitySidePanel.tsx +0 -1
  125. package/src/core/FireCMS.tsx +2 -2
  126. package/src/core/NavigationRoutes.tsx +4 -4
  127. package/src/core/SideDialogs.tsx +1 -0
  128. package/src/core/field_configs.tsx +5 -5
  129. package/src/core/index.tsx +2 -2
  130. package/src/form/PropertyFieldBinding.tsx +53 -19
  131. package/src/form/components/CustomIdField.tsx +4 -2
  132. package/src/form/components/FieldHelperText.tsx +4 -4
  133. package/src/form/components/FormikArrayContainer.tsx +4 -1
  134. package/src/form/components/LabelWithIcon.tsx +27 -19
  135. package/src/form/components/LabelWithIconAndTooltip.tsx +28 -0
  136. package/src/form/components/StorageItemPreview.tsx +20 -10
  137. package/src/form/components/StorageUploadProgress.tsx +0 -1
  138. package/src/form/components/index.tsx +1 -0
  139. package/src/form/field_bindings/ArrayCustomShapedFieldBinding.tsx +26 -15
  140. package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +28 -25
  141. package/src/form/field_bindings/BlockFieldBinding.tsx +13 -11
  142. package/src/form/field_bindings/DateTimeFieldBinding.tsx +17 -14
  143. package/src/form/field_bindings/KeyValueFieldBinding.tsx +48 -42
  144. package/src/form/field_bindings/MapFieldBinding.tsx +17 -17
  145. package/src/form/field_bindings/MarkdownEditorFieldBinding.tsx +150 -0
  146. package/src/form/field_bindings/{MultiSelectBinding.tsx → MultiSelectFieldBinding.tsx} +25 -20
  147. package/src/form/field_bindings/ReadOnlyFieldBinding.tsx +9 -14
  148. package/src/form/field_bindings/ReferenceFieldBinding.tsx +27 -18
  149. package/src/form/field_bindings/RepeatFieldBinding.tsx +32 -19
  150. package/src/form/field_bindings/SelectFieldBinding.tsx +17 -10
  151. package/src/form/field_bindings/StorageUploadFieldBinding.tsx +33 -43
  152. package/src/form/field_bindings/SwitchFieldBinding.tsx +9 -5
  153. package/src/form/field_bindings/TextFieldBinding.tsx +26 -23
  154. package/src/form/index.tsx +4 -9
  155. package/src/form/useClearRestoreValue.tsx +2 -2
  156. package/src/form/validation.ts +1 -17
  157. package/src/hooks/data/delete.ts +2 -1
  158. package/src/hooks/data/save.ts +5 -2
  159. package/src/hooks/data/useDataSource.tsx +11 -3
  160. package/src/hooks/useBuildNavigationController.tsx +10 -3
  161. package/src/hooks/useProjectLog.tsx +18 -7
  162. package/src/index.ts +1 -0
  163. package/src/internal/useBuildDataSource.ts +69 -74
  164. package/src/internal/useBuildSideDialogsController.tsx +1 -0
  165. package/src/internal/useBuildSideEntityController.tsx +17 -4
  166. package/src/internal/useUnsavedChangesDialog.tsx +3 -1
  167. package/src/preview/PropertyPreview.tsx +7 -4
  168. package/src/preview/PropertyPreviewProps.tsx +7 -1
  169. package/src/preview/components/BooleanPreview.tsx +1 -1
  170. package/src/preview/components/EnumValuesChip.tsx +1 -1
  171. package/src/preview/components/ImagePreview.tsx +24 -34
  172. package/src/preview/components/ReferencePreview.tsx +2 -12
  173. package/src/preview/components/StorageThumbnail.tsx +5 -1
  174. package/src/preview/components/UrlComponentPreview.tsx +44 -11
  175. package/src/preview/property_previews/ArrayOfMapsPreview.tsx +1 -1
  176. package/src/preview/property_previews/ArrayOfReferencesPreview.tsx +1 -1
  177. package/src/preview/property_previews/ArrayOfStorageComponentsPreview.tsx +1 -1
  178. package/src/preview/property_previews/ArrayOneOfPreview.tsx +2 -2
  179. package/src/preview/property_previews/ArrayPropertyPreview.tsx +1 -1
  180. package/src/preview/property_previews/MapPropertyPreview.tsx +1 -1
  181. package/src/preview/property_previews/SkeletonPropertyComponent.tsx +2 -2
  182. package/src/preview/property_previews/StringPropertyPreview.tsx +2 -2
  183. package/src/preview/util.ts +2 -2
  184. package/src/types/auth.tsx +2 -2
  185. package/src/types/collections.ts +29 -4
  186. package/src/types/customization_controller.tsx +0 -1
  187. package/src/types/datasource.ts +62 -43
  188. package/src/types/entities.ts +2 -0
  189. package/src/types/entity_overrides.tsx +2 -2
  190. package/src/types/fields.tsx +51 -45
  191. package/src/types/navigation.ts +1 -0
  192. package/src/types/plugins.tsx +12 -3
  193. package/src/types/properties.ts +25 -19
  194. package/src/types/side_dialogs_controller.tsx +13 -0
  195. package/src/types/storage.ts +82 -0
  196. package/src/util/entities.ts +5 -4
  197. package/src/util/icon_list.ts +14 -9
  198. package/src/util/icons.tsx +8 -2
  199. package/src/util/index.ts +1 -0
  200. package/src/util/objects.ts +17 -7
  201. package/src/util/permissions.ts +1 -0
  202. package/src/util/plurals.ts +0 -2
  203. package/src/util/property_utils.tsx +1 -1
  204. package/src/util/references.ts +3 -0
  205. package/src/util/resolutions.ts +43 -11
  206. package/src/util/storage.ts +79 -21
  207. package/src/util/useStorageUploadController.tsx +33 -7
  208. package/dist/components/PropertyIdCopyTooltipContent.d.ts +0 -3
  209. package/dist/core/Drawer.d.ts +0 -16
  210. package/dist/core/Scaffold.d.ts +0 -51
  211. package/dist/form/EntityForm.d.ts +0 -77
  212. package/dist/form/field_bindings/MarkdownFieldBinding.d.ts +0 -9
  213. package/src/components/PropertyIdCopyTooltipContent.tsx +0 -27
  214. package/src/core/Drawer.tsx +0 -139
  215. package/src/form/EntityForm.tsx +0 -736
  216. 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
- touched,
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 icon={getIconForProperty(property, "small")}
45
- required={property.validation?.required}
46
- title={property.name}/>}
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={"medium"}
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
- <TextField
73
- value={value}
74
- onChange={onChange}
75
- autoFocus={autoFocus}
76
- label={<LabelWithIcon icon={getIconForProperty(property, "small")}
77
- required={property.validation?.required}
78
- title={property.name}/>}
79
- type={inputType}
80
- multiline={isMultiline}
81
- disabled={disabled}
82
- endAdornment={
83
- property.clearable && <IconButton
84
- onClick={handleClearClick}>
85
- <ClearIcon/>
86
- </IconButton>
87
- }
88
- error={showError ? error : undefined}
89
- inputClassName={error ? "text-red-500 dark:text-red-600" : ""}/>
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={"medium"}/>
106
+ size={size}/>
104
107
  </Collapse>}
105
108
 
106
109
  </>
@@ -1,5 +1,5 @@
1
1
  import { SelectFieldBinding } from "./field_bindings/SelectFieldBinding";
2
- import { MultiSelectBinding } from "./field_bindings/MultiSelectBinding";
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 { MarkdownFieldBinding } from "./field_bindings/MarkdownFieldBinding";
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
- MultiSelectBinding,
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
- MarkdownFieldBinding,
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
  }) {
@@ -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({
@@ -81,7 +81,8 @@ export async function deleteEntityWithCallbacks<M extends Record<string, any>, U
81
81
  }
82
82
  }
83
83
  return dataSource.deleteEntity({
84
- entity
84
+ entity,
85
+ collection
85
86
  }).then(() => {
86
87
  onDeleteSuccess && onDeleteSuccess(entity);
87
88
  try {
@@ -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", entityId, updatedValues);
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, useMemo } from "react";
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?.dataSource)
12
- return collection?.overrides.dataSource;
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
- setNavigationLoading(false);
225
- setInitialised(true);
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
- const firebaseToken = await authController.getAuthToken();
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 ${firebaseToken}`,
25
+ Authorization: `Basic ${idToken}`
21
26
  },
22
- body: JSON.stringify({ plugins: pluginKeys })
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
  }
package/src/index.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./core";
2
+ export * from "./app";
2
3
  export * from "./types";
3
4
  export * from "./form";
4
5
  export * from "./preview";