@firecms/core 3.0.0-canary.210 → 3.0.0-canary.212

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 (51) hide show
  1. package/dist/components/ArrayContainer.d.ts +12 -5
  2. package/dist/components/EntityJsonPreview.d.ts +3 -0
  3. package/dist/core/EntityEditView.d.ts +3 -1
  4. package/dist/hooks/data/save.d.ts +1 -1
  5. package/dist/index.es.js +10632 -10671
  6. package/dist/index.es.js.map +1 -1
  7. package/dist/index.umd.js +10501 -10541
  8. package/dist/index.umd.js.map +1 -1
  9. package/dist/internal/useBuildDataSource.d.ts +3 -2
  10. package/dist/internal/useBuildSideEntityController.d.ts +3 -3
  11. package/dist/types/collections.d.ts +2 -0
  12. package/dist/types/properties.d.ts +16 -1
  13. package/dist/util/property_utils.d.ts +2 -2
  14. package/dist/util/references.d.ts +2 -2
  15. package/dist/util/resolutions.d.ts +7 -2
  16. package/package.json +6 -5
  17. package/src/components/ArrayContainer.tsx +40 -23
  18. package/src/components/DeleteEntityDialog.tsx +4 -2
  19. package/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +4 -2
  20. package/src/components/EntityCollectionView/EntityCollectionView.tsx +4 -2
  21. package/src/components/EntityJsonPreview.tsx +66 -0
  22. package/src/components/EntityPreview.tsx +10 -3
  23. package/src/components/EntityView.tsx +4 -1
  24. package/src/components/ReferenceTable/ReferenceSelectionTable.tsx +3 -1
  25. package/src/core/EntityEditView.tsx +30 -7
  26. package/src/core/FireCMS.tsx +12 -11
  27. package/src/form/EntityForm.tsx +11 -6
  28. package/src/form/PropertyFieldBinding.tsx +6 -3
  29. package/src/form/field_bindings/ArrayCustomShapedFieldBinding.tsx +4 -1
  30. package/src/form/field_bindings/BlockFieldBinding.tsx +1 -1
  31. package/src/form/field_bindings/KeyValueFieldBinding.tsx +1 -1
  32. package/src/form/field_bindings/MarkdownEditorFieldBinding.tsx +6 -2
  33. package/src/form/field_bindings/RepeatFieldBinding.tsx +8 -2
  34. package/src/form/field_bindings/StorageUploadFieldBinding.tsx +4 -1
  35. package/src/hooks/data/save.ts +24 -29
  36. package/src/hooks/useFireCMSContext.tsx +0 -30
  37. package/src/internal/useBuildDataSource.ts +9 -5
  38. package/src/internal/useBuildSideEntityController.tsx +24 -17
  39. package/src/preview/PropertyPreview.tsx +4 -2
  40. package/src/preview/property_previews/ArrayOfMapsPreview.tsx +4 -3
  41. package/src/preview/property_previews/ArrayOfReferencesPreview.tsx +4 -3
  42. package/src/preview/property_previews/ArrayOfStorageComponentsPreview.tsx +4 -2
  43. package/src/preview/property_previews/ArrayOfStringsPreview.tsx +4 -3
  44. package/src/preview/property_previews/ArrayOneOfPreview.tsx +4 -2
  45. package/src/preview/property_previews/ArrayPropertyPreview.tsx +4 -2
  46. package/src/types/collections.ts +2 -0
  47. package/src/types/properties.ts +20 -1
  48. package/src/util/property_utils.tsx +7 -3
  49. package/src/util/references.ts +8 -6
  50. package/src/util/resolutions.ts +13 -7
  51. package/src/util/useStorageUploadController.tsx +4 -2
@@ -16,12 +16,14 @@ import {
16
16
  useFireCMSContext,
17
17
  useLargeLayout
18
18
  } from "../hooks";
19
- import { CircularProgress, cls, defaultBorderMixin, Tab, Tabs, Typography } from "@firecms/ui";
19
+ import { CircularProgress, cls, CodeIcon, defaultBorderMixin, Tab, Tabs, Typography } from "@firecms/ui";
20
20
  import { getEntityFromCache } from "../util/entity_cache";
21
21
  import { EntityForm, EntityFormProps } from "../form";
22
22
  import { EntityEditViewFormActions } from "./EntityEditViewFormActions";
23
+ import { EntityJsonPreview } from "../components/EntityJsonPreview";
23
24
 
24
- const MAIN_TAB_VALUE = "main_##Q$SC^#S6";
25
+ export const MAIN_TAB_VALUE = "__main_##Q$SC^#S6";
26
+ export const JSON_TAB_VALUE = "__json";
25
27
 
26
28
  export type OnUpdateParams = {
27
29
  entity: Entity<any>,
@@ -141,7 +143,7 @@ export function EntityEditViewInner<M extends Record<string, any>>({
141
143
  barActions,
142
144
  status,
143
145
  setStatus,
144
- formProps,
146
+ formProps
145
147
  }: EntityEditViewProps<M> & {
146
148
  entity?: Entity<M>,
147
149
  cachedDirtyValues?: Partial<M>, // dirty cached entity in memory
@@ -186,7 +188,8 @@ export function EntityEditViewInner<M extends Record<string, any>>({
186
188
  const subcollectionsCount = subcollections?.length ?? 0;
187
189
  const customViews = collection.entityViews;
188
190
  const customViewsCount = customViews?.length ?? 0;
189
- const hasAdditionalViews = customViewsCount > 0 || subcollectionsCount > 0;
191
+ const includeJsonView = true;
192
+ const hasAdditionalViews = customViewsCount > 0 || subcollectionsCount > 0 || includeJsonView;
190
193
 
191
194
  const {
192
195
  resolvedEntityViews,
@@ -229,6 +232,17 @@ export function EntityEditViewInner<M extends Record<string, any>>({
229
232
 
230
233
  const globalLoading = dataLoading && !usedEntity;
231
234
 
235
+ const jsonView = <div
236
+ className={cls("relative flex-1 h-full overflow-auto w-full",
237
+ { "hidden": selectedTab !== JSON_TAB_VALUE })}
238
+ key={"json_view"}
239
+ role="tabpanel">
240
+ <ErrorBoundary>
241
+ <EntityJsonPreview
242
+ values={formContext?.values ?? {}}/>
243
+ </ErrorBoundary>
244
+ </div>;
245
+
232
246
  const subCollectionsViews = subcollections && subcollections.map((subcollection) => {
233
247
  const subcollectionId = subcollection.id ?? subcollection.path;
234
248
  const fullPath = usedEntity ? `${path}/${usedEntity?.id}/${removeInitialAndTrailingSlashes(subcollectionId)}` : undefined;
@@ -269,7 +283,7 @@ export function EntityEditViewInner<M extends Record<string, any>>({
269
283
  path,
270
284
  entityId,
271
285
  selectedTab: value === MAIN_TAB_VALUE ? undefined : value,
272
- collection,
286
+ collection
273
287
  });
274
288
  }
275
289
  };
@@ -303,7 +317,7 @@ export function EntityEditViewInner<M extends Record<string, any>>({
303
317
  onSaved={(params) => {
304
318
  const res = {
305
319
  ...params,
306
- selectedTab: MAIN_TAB_VALUE === selectedTab ? undefined : selectedTab,
320
+ selectedTab: MAIN_TAB_VALUE === selectedTab ? undefined : selectedTab
307
321
  };
308
322
  onSaved?.(res);
309
323
  formProps?.onSaved?.(res);
@@ -350,6 +364,14 @@ export function EntityEditViewInner<M extends Record<string, any>>({
350
364
  onSideTabClick(value);
351
365
  }}>
352
366
 
367
+ {includeJsonView && <Tab
368
+ disabled={!hasAdditionalViews}
369
+ value={JSON_TAB_VALUE}
370
+ innerClassName={"block"}
371
+ className={"text-sm"}>
372
+ <CodeIcon size={"small"}/>
373
+ </Tab>}
374
+
353
375
  <Tab
354
376
  disabled={!hasAdditionalViews}
355
377
  value={MAIN_TAB_VALUE}
@@ -357,6 +379,7 @@ export function EntityEditViewInner<M extends Record<string, any>>({
357
379
  {collection.singularName ?? collection.name}
358
380
  </Tab>
359
381
 
382
+
360
383
  {customViewTabs}
361
384
 
362
385
  {subcollectionTabs}
@@ -369,7 +392,7 @@ export function EntityEditViewInner<M extends Record<string, any>>({
369
392
  </div>
370
393
  : entityView}
371
394
 
372
- {/*{secondaryForms}*/}
395
+ {jsonView}
373
396
 
374
397
  {customViewsView}
375
398
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  import React, { useMemo } from "react";
4
4
  import { CenteredView, Typography } from "@firecms/ui";
5
- import { CustomizationController, EntityCollection, FireCMSContext, FireCMSPlugin, FireCMSProps, User } from "../types";
5
+ import { CustomizationController, FireCMSContext, FireCMSPlugin, FireCMSProps, User } from "../types";
6
6
  import { AuthControllerContext } from "../contexts";
7
7
  import { useBuildSideEntityController } from "../internal/useBuildSideEntityController";
8
8
  import { useCustomizationController, useFireCMSContext } from "../hooks";
@@ -53,17 +53,8 @@ export function FireCMS<USER extends User>(props: FireCMSProps<USER>) {
53
53
  apiKey
54
54
  } = props;
55
55
 
56
- /**
57
- * Controller in charge of fetching and persisting data
58
- */
59
- const dataSource = useBuildDataSource({
60
- delegate: dataSourceDelegate,
61
- propertyConfigs,
62
- navigationController
63
- });
64
-
65
56
  const sideDialogsController = useBuildSideDialogsController();
66
- const sideEntityController = useBuildSideEntityController(navigationController, sideDialogsController);
57
+ const sideEntityController = useBuildSideEntityController(navigationController, sideDialogsController, authController);
67
58
 
68
59
  const pluginsLoading = plugins?.some(p => p.loading) ?? false;
69
60
 
@@ -90,6 +81,16 @@ export function FireCMS<USER extends User>(props: FireCMSProps<USER>) {
90
81
  plugins
91
82
  });
92
83
 
84
+ /**
85
+ * Controller in charge of fetching and persisting data
86
+ */
87
+ const dataSource = useBuildDataSource({
88
+ delegate: dataSourceDelegate,
89
+ propertyConfigs,
90
+ navigationController,
91
+ authController
92
+ });
93
+
93
94
  if (accessResponse?.message) {
94
95
  console.warn(accessResponse.message);
95
96
  }
@@ -1,5 +1,6 @@
1
1
  import React, { useCallback, useDeferredValue, useEffect, useMemo, useRef, useState } from "react";
2
2
  import {
3
+ AuthController,
3
4
  CMSAnalyticsEvent,
4
5
  Entity,
5
6
  EntityCollection,
@@ -28,6 +29,7 @@ import {
28
29
 
29
30
  import {
30
31
  saveEntityWithCallbacks,
32
+ useAuthController,
31
33
  useCustomizationController,
32
34
  useDataSource,
33
35
  useFireCMSContext,
@@ -116,6 +118,7 @@ export function EntityForm<M extends Record<string, any>>({
116
118
  console.warn(`The collection ${collection.path} has customId and formAutoSave enabled. This is not supported and formAutoSave will be ignored`);
117
119
  }
118
120
 
121
+ const authController = useAuthController();
119
122
  const [status, setStatus] = useState<EntityStatus>(initialStatus);
120
123
  const [saving, setSaving] = useState(false);
121
124
 
@@ -204,7 +207,7 @@ export function EntityForm<M extends Record<string, any>>({
204
207
  };
205
208
 
206
209
  const formex: FormexController<M> = formexProp ?? useCreateFormex<M>({
207
- initialValues: (initialDirtyValues ?? getInitialEntityValues(collection, path, status, entity, customizationController.propertyConfigs)) as M,
210
+ initialValues: (initialDirtyValues ?? getInitialEntityValues(authController, collection, path, status, entity, customizationController.propertyConfigs)) as M,
208
211
  initialDirty: Boolean(initialDirtyValues),
209
212
  onSubmit,
210
213
  onReset: () => {
@@ -222,7 +225,6 @@ export function EntityForm<M extends Record<string, any>>({
222
225
  }
223
226
  });
224
227
 
225
-
226
228
  useEffect(() => {
227
229
 
228
230
  const handleKeyDown = (e: KeyboardEvent) => {
@@ -251,7 +253,8 @@ export function EntityForm<M extends Record<string, any>>({
251
253
  entityId,
252
254
  values: formex.values,
253
255
  previousValues: formex.initialValues,
254
- propertyConfigs: customizationController.propertyConfigs
256
+ propertyConfigs: customizationController.propertyConfigs,
257
+ authController
255
258
  }), [collection, path, entityId, formex.values, formex.initialValues, customizationController.propertyConfigs]);
256
259
 
257
260
  const onPreSaveHookError = useCallback((e: Error) => {
@@ -679,7 +682,7 @@ export function EntityForm<M extends Record<string, any>>({
679
682
  <form
680
683
  onSubmit={formContext.formex.handleSubmit}
681
684
  onReset={() => formex.resetForm({
682
- values: getInitialEntityValues(collection, path, status, entity, customizationController.propertyConfigs) as M
685
+ values: getInitialEntityValues(authController, collection, path, status, entity, customizationController.propertyConfigs) as M
683
686
  })}
684
687
  noValidate
685
688
  className={cls("flex-1 flex flex-row w-full overflow-y-auto justify-center", className)}>
@@ -716,17 +719,19 @@ export function EntityForm<M extends Record<string, any>>({
716
719
  }
717
720
 
718
721
  function getInitialEntityValues<M extends object>(
722
+ authController: AuthController,
719
723
  collection: EntityCollection,
720
724
  path: string,
721
725
  status: "new" | "existing" | "copy",
722
726
  entity: Entity<M> | undefined,
723
- propertyConfigs?: Record<string, PropertyConfig>
727
+ propertyConfigs?: Record<string, PropertyConfig>,
724
728
  ): Partial<EntityValues<M>> {
725
729
  const resolvedCollection = resolveCollection({
726
730
  collection,
727
731
  path,
728
732
  values: entity?.values,
729
- propertyConfigs
733
+ propertyConfigs,
734
+ authController
730
735
  });
731
736
  const properties = resolvedCollection.properties;
732
737
  if ((status === "existing" || status === "copy") && entity) {
@@ -17,7 +17,7 @@ import {
17
17
  import { ReadOnlyFieldBinding } from "./field_bindings/ReadOnlyFieldBinding";
18
18
 
19
19
  import { isHidden, isPropertyBuilder, isReadOnly, resolveProperty } from "../util";
20
- import { useCustomizationController } from "../hooks";
20
+ import { useAuthController, useCustomizationController } from "../hooks";
21
21
  import { Typography } from "@firecms/ui";
22
22
  import { getFieldConfig, getFieldId } from "../core";
23
23
  import { ErrorBoundary } from "../components";
@@ -90,6 +90,7 @@ function PropertyFieldBindingInternal<T extends CMSType = CMSType, M extends Rec
90
90
  onPropertyChange
91
91
  }: PropertyFieldBindingProps<T, M>): ReactElement<PropertyFieldBindingProps<T, M>> {
92
92
 
93
+ const authController = useAuthController();
93
94
  const customizationController = useCustomizationController();
94
95
 
95
96
  return (
@@ -107,7 +108,8 @@ function PropertyFieldBindingInternal<T extends CMSType = CMSType, M extends Rec
107
108
  path: context.path,
108
109
  entityId: context.entityId,
109
110
  propertyConfigs: customizationController.propertyConfigs,
110
- index
111
+ index,
112
+ authController
111
113
  });
112
114
 
113
115
  const disabled = disabledProp || isReadOnly(resolvedProperty) || Boolean(resolvedProperty?.disabled);
@@ -139,7 +141,8 @@ function PropertyFieldBindingInternal<T extends CMSType = CMSType, M extends Rec
139
141
  path: context.path,
140
142
  entityId: context.entityId,
141
143
  propertyConfigs: customizationController.propertyConfigs,
142
- index
144
+ index,
145
+ authController
143
146
  });
144
147
  Component = configProperty.Field as ComponentType<FieldProps<T>>;
145
148
  }
@@ -5,6 +5,7 @@ import { PropertyFieldBinding } from "../PropertyFieldBinding";
5
5
  import { ExpandablePanel, Typography } from "@firecms/ui";
6
6
  import { getArrayResolvedProperties, getIconForProperty, isReadOnly } from "../../util";
7
7
  import { useClearRestoreValue } from "../useClearRestoreValue";
8
+ import { useAuthController } from "../../hooks";
8
9
 
9
10
  /**
10
11
  * Array field used for custom
@@ -27,6 +28,7 @@ export function ArrayCustomShapedFieldBinding<T extends Array<any>>({
27
28
  disabled
28
29
  }: FieldProps<T, any, any>) {
29
30
 
31
+ const authController = useAuthController();
30
32
  const minimalistView = minimalistViewProp || property.minimalistView;
31
33
 
32
34
  let resolvedProperties = "resolvedProperties" in property ? property.resolvedProperties : undefined;
@@ -35,7 +37,8 @@ export function ArrayCustomShapedFieldBinding<T extends Array<any>>({
35
37
  propertyValue: value,
36
38
  propertyKey,
37
39
  property,
38
- ignoreMissingFields: false
40
+ ignoreMissingFields: false,
41
+ authController
39
42
  })
40
43
  }
41
44
 
@@ -88,7 +88,7 @@ export function BlockFieldBinding<T extends Array<any>>({
88
88
  buildEntry={buildEntry}
89
89
  onInternalIdAdded={setLastAddedId}
90
90
  disabled={isSubmitting || Boolean(property.disabled)}
91
- includeAddButton={!property.disabled}
91
+ canAddElements={!property.disabled}
92
92
  onValueChange={(value) => setFieldValue(propertyKey, value)}
93
93
  newDefaultEntry={{
94
94
  [property.oneOf!.typeField ?? DEFAULT_ONE_OF_TYPE]: firstOneOfKey,
@@ -329,7 +329,7 @@ function MapKeyValueRow<T extends Record<string, any>>({
329
329
  addLabel={fieldKey ? `Add to ${fieldKey}` : "Add"}
330
330
  size={"small"}
331
331
  disabled={disabled || !fieldKey}
332
- includeAddButton={true}
332
+ canAddElements={true}
333
333
  onValueChange={(newValue) => {
334
334
  setValue({
335
335
  ...value,
@@ -8,6 +8,7 @@ import {
8
8
  randomString,
9
9
  ResolvedArrayProperty,
10
10
  ResolvedStringProperty,
11
+ useAuthController,
11
12
  useStorageSource
12
13
  } from "../../index";
13
14
  import { cls, fieldBackgroundDisabledMixin, fieldBackgroundHoverMixin, fieldBackgroundMixin } from "@firecms/ui";
@@ -34,6 +35,7 @@ export function MarkdownEditorFieldBinding({
34
35
  customProps,
35
36
  }: FieldProps<string, MarkdownEditorFieldProps>) {
36
37
 
38
+ const authController = useAuthController();
37
39
  const disabled = disabledProp || isSubmitting;
38
40
  const highlight = customProps?.highlight;
39
41
  const editorProps = customProps?.editorProps;
@@ -62,7 +64,8 @@ export function MarkdownEditorFieldBinding({
62
64
 
63
65
  const resolvedProperty = resolveProperty({
64
66
  propertyOrBuilder: property as PropertyOrBuilder,
65
- values: entityValues
67
+ values: entityValues,
68
+ authController
66
69
  }) as ResolvedStringProperty | ResolvedArrayProperty<string[]>;
67
70
 
68
71
  const fileNameBuilder = useCallback(async (file: File) => {
@@ -89,7 +92,8 @@ export function MarkdownEditorFieldBinding({
89
92
  if (!storage) return "/";
90
93
  const resolvedProperty = resolveProperty({
91
94
  propertyOrBuilder: property,
92
- values: entityValues
95
+ values: entityValues,
96
+ authController
93
97
  }) as ResolvedStringProperty | ResolvedArrayProperty<string[]>;
94
98
  return resolveStoragePathString({
95
99
  input: storage.storagePath,
@@ -6,6 +6,7 @@ import { getArrayResolvedProperties, getDefaultValueFor, getIconForProperty, mer
6
6
  import { PropertyFieldBinding } from "../PropertyFieldBinding";
7
7
  import { ExpandablePanel, Typography } from "@firecms/ui";
8
8
  import { useClearRestoreValue } from "../useClearRestoreValue";
9
+ import { useAuthController } from "../../hooks";
9
10
 
10
11
  /**
11
12
  * Generic array field that allows reordering and renders the child property
@@ -31,6 +32,7 @@ export function RepeatFieldBinding<T extends Array<any>>({
31
32
  disabled
32
33
  }: FieldProps<T>) {
33
34
 
35
+ const authController = useAuthController();
34
36
  const minimalistView = minimalistViewProp || property.minimalistView;
35
37
 
36
38
  if (!property.of)
@@ -42,7 +44,8 @@ export function RepeatFieldBinding<T extends Array<any>>({
42
44
  propertyValue: value,
43
45
  propertyKey,
44
46
  property,
45
- ignoreMissingFields: false
47
+ ignoreMissingFields: false,
48
+ authController
46
49
  })
47
50
  }
48
51
 
@@ -81,13 +84,16 @@ export function RepeatFieldBinding<T extends Array<any>>({
81
84
  </ErrorBoundary>;
82
85
  };
83
86
 
87
+ const canAddElements = !property.disabled && !isSubmitting && !disabled && (property.canAddElements || property.canAddElements === undefined);
88
+ const sortable = property.sortable === undefined ? true : property.sortable;
84
89
  const arrayContainer = <ArrayContainer droppableId={propertyKey}
85
90
  addLabel={property.name ? "Add entry to " + property.name : "Add entry"}
86
91
  value={value}
87
92
  buildEntry={buildEntry}
88
93
  onInternalIdAdded={setLastAddedId}
89
94
  disabled={isSubmitting || Boolean(property.disabled)}
90
- includeAddButton={!property.disabled}
95
+ canAddElements={canAddElements}
96
+ sortable={sortable}
91
97
  newDefaultEntry={getDefaultValueFor(property.of)}
92
98
  onValueChange={(value) => setFieldValue(propertyKey, value)}
93
99
  className={property.widthPercentage !== undefined ? "mt-8" : undefined}
@@ -13,7 +13,7 @@ import { PreviewSize } from "../../preview";
13
13
  import { FieldHelperText, LabelWithIconAndTooltip } from "../components";
14
14
 
15
15
  import { getIconForProperty, isReadOnly, resolveProperty } from "../../util";
16
- import { useSnackbarController, useStorageSource } from "../../hooks";
16
+ import { useAuthController, useSnackbarController, useStorageSource } from "../../hooks";
17
17
  import { DragDropContext, Draggable, Droppable } from "@hello-pangea/dnd";
18
18
  import { StorageFieldItem, useStorageUploadController } from "../../util/useStorageUploadController";
19
19
  import { StorageUploadProgress } from "../components/StorageUploadProgress";
@@ -57,6 +57,8 @@ export function StorageUploadFieldBinding({
57
57
  isSubmitting,
58
58
  }: StorageUploadFieldProps) {
59
59
 
60
+ const authController = useAuthController();
61
+
60
62
  if (!context.entityId)
61
63
  throw new Error("StorageUploadFieldBinding: Entity id is null");
62
64
 
@@ -91,6 +93,7 @@ export function StorageUploadFieldBinding({
91
93
 
92
94
  const resolvedProperty = resolveProperty({
93
95
  propertyOrBuilder: property as PropertyOrBuilder,
96
+ authController
94
97
  }) as ResolvedStringProperty | ResolvedArrayProperty<string[]>;
95
98
 
96
99
  return (
@@ -1,12 +1,4 @@
1
- import {
2
- DataSource,
3
- Entity,
4
- EntityCollection,
5
- EntityValues,
6
- FireCMSContext,
7
- SaveEntityProps,
8
- User
9
- } from "../../types";
1
+ import { DataSource, Entity, EntityCollection, EntityValues, FireCMSContext, SaveEntityProps, User } from "../../types";
10
2
  import { useDataSource } from "./useDataSource";
11
3
  import { resolveCollection } from "../../util";
12
4
 
@@ -49,23 +41,23 @@ export type SaveEntityWithCallbacksProps<M extends Record<string, any>> =
49
41
  * @group Hooks and utilities
50
42
  */
51
43
  export async function saveEntityWithCallbacks<M extends Record<string, any>, USER extends User>({
52
- collection,
53
- path,
54
- entityId,
55
- values,
56
- previousValues,
57
- status,
58
- dataSource,
59
- context,
60
- onSaveSuccess,
61
- onSaveFailure,
62
- onPreSaveHookError,
63
- onSaveSuccessHookError
64
- }: SaveEntityWithCallbacksProps<M> & {
65
- collection: EntityCollection<M, USER>,
66
- dataSource: DataSource,
67
- context: FireCMSContext<USER>,
68
- }
44
+ collection,
45
+ path,
46
+ entityId,
47
+ values,
48
+ previousValues,
49
+ status,
50
+ dataSource,
51
+ context,
52
+ onSaveSuccess,
53
+ onSaveFailure,
54
+ onPreSaveHookError,
55
+ onSaveSuccessHookError
56
+ }: SaveEntityWithCallbacksProps<M> & {
57
+ collection: EntityCollection<M, USER>,
58
+ dataSource: DataSource,
59
+ context: FireCMSContext,
60
+ }
69
61
  ): Promise<void> {
70
62
 
71
63
  if (status !== "new" && !entityId) {
@@ -85,7 +77,8 @@ export async function saveEntityWithCallbacks<M extends Record<string, any>, USE
85
77
  path,
86
78
  values: previousValues as EntityValues<M>,
87
79
  entityId,
88
- propertyConfigs: customizationController.propertyConfigs
80
+ propertyConfigs: customizationController.propertyConfigs,
81
+ authController: context.authController
89
82
  });
90
83
  updatedValues = await callbacks.onPreSave({
91
84
  collection: resolvedCollection,
@@ -127,7 +120,8 @@ export async function saveEntityWithCallbacks<M extends Record<string, any>, USE
127
120
  path,
128
121
  values: updatedValues as EntityValues<M>,
129
122
  entityId,
130
- propertyConfigs: customizationController.propertyConfigs
123
+ propertyConfigs: customizationController.propertyConfigs,
124
+ authController: context.authController
131
125
  });
132
126
  callbacks.onSaveSuccess({
133
127
  collection: resolvedCollection,
@@ -156,7 +150,8 @@ export async function saveEntityWithCallbacks<M extends Record<string, any>, USE
156
150
  path,
157
151
  values: updatedValues as EntityValues<M>,
158
152
  entityId,
159
- propertyConfigs: customizationController.propertyConfigs
153
+ propertyConfigs: customizationController.propertyConfigs,
154
+ authController: context.authController
160
155
  });
161
156
  callbacks.onSaveFailure({
162
157
  collection: resolvedCollection,
@@ -67,33 +67,3 @@ export const useFireCMSContext = <USER extends User = User, AuthControllerType e
67
67
 
68
68
  return fireCMSContextRef.current;
69
69
  }
70
-
71
- // export const useFireCMSContext = <USER extends User = User, AuthControllerType extends AuthController<USER> = AuthController<USER>>(): FireCMSContext<USER, AuthControllerType> => {
72
- //
73
- // const authController = useAuthController<USER, AuthControllerType>();
74
- // const sideDialogsController = useSideDialogsController();
75
- // const sideEntityController = useSideEntityController();
76
- // const navigation = useNavigationController();
77
- // const dataSource = useDataSource();
78
- // const storageSource = useStorageSource();
79
- // const snackbarController = useSnackbarController();
80
- // const userConfigPersistence = useUserConfigurationPersistence();
81
- // const dialogsController = useDialogsController();
82
- // const customizationController = useCustomizationController();
83
- // const analyticsController = useAnalyticsController();
84
- //
85
- // return {
86
- // authController,
87
- // sideDialogsController,
88
- // sideEntityController,
89
- // navigation,
90
- // dataSource,
91
- // storageSource,
92
- // snackbarController,
93
- // userConfigPersistence,
94
- // dialogsController,
95
- // customizationController,
96
- // analyticsController
97
- // };
98
- //
99
- // };
@@ -1,5 +1,6 @@
1
1
  import { useCallback } from "react";
2
2
  import {
3
+ AuthController,
3
4
  DataSource,
4
5
  DataSourceDelegate,
5
6
  DeleteEntityProps,
@@ -27,11 +28,13 @@ import { resolveCollection, updateDateAutoValues } from "../util";
27
28
  export function useBuildDataSource({
28
29
  delegate,
29
30
  propertyConfigs,
30
- navigationController
31
+ navigationController,
32
+ authController
31
33
  }: {
32
34
  delegate: DataSourceDelegate,
33
35
  propertyConfigs?: Record<string, PropertyConfig>;
34
36
  navigationController: NavigationController;
37
+ authController: AuthController;
35
38
  }): DataSource {
36
39
 
37
40
  return {
@@ -209,26 +212,27 @@ export function useBuildDataSource({
209
212
  collection,
210
213
  path,
211
214
  entityId,
212
- propertyConfigs: propertyConfigs
215
+ propertyConfigs: propertyConfigs,
216
+ authController
213
217
  })
214
218
  : undefined;
215
219
 
216
220
  const properties: ResolvedProperties<M> | undefined = resolvedCollection?.properties;
217
221
 
218
- const firestoreValues = usedDelegate.cmsToDelegateModel(
222
+ const delegateValues = usedDelegate.cmsToDelegateModel(
219
223
  values,
220
224
  );
221
225
 
222
226
  const updatedValues: EntityValues<M> = properties
223
227
  ? updateDateAutoValues(
224
228
  {
225
- inputValues: firestoreValues,
229
+ inputValues: delegateValues,
226
230
  properties,
227
231
  status,
228
232
  timestampNowValue: usedDelegate.currentTime?.() ?? new Date(),
229
233
  setDateToMidnight: usedDelegate.setDateToMidnight
230
234
  })
231
- : firestoreValues;
235
+ : delegateValues;
232
236
 
233
237
  return usedDelegate.saveEntity({
234
238
  path,