@firecms/core 3.0.0-canary.211 → 3.0.0-canary.213

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 (48) hide show
  1. package/dist/components/ArrayContainer.d.ts +12 -5
  2. package/dist/hooks/data/save.d.ts +1 -1
  3. package/dist/index.es.js +10571 -10708
  4. package/dist/index.es.js.map +1 -1
  5. package/dist/index.umd.js +10441 -10578
  6. package/dist/index.umd.js.map +1 -1
  7. package/dist/internal/useBuildDataSource.d.ts +3 -2
  8. package/dist/internal/useBuildSideEntityController.d.ts +3 -3
  9. package/dist/types/collections.d.ts +2 -0
  10. package/dist/types/properties.d.ts +16 -1
  11. package/dist/util/property_utils.d.ts +2 -2
  12. package/dist/util/references.d.ts +2 -2
  13. package/dist/util/resolutions.d.ts +7 -2
  14. package/package.json +5 -5
  15. package/src/components/ArrayContainer.tsx +40 -23
  16. package/src/components/DeleteEntityDialog.tsx +4 -2
  17. package/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +4 -2
  18. package/src/components/EntityCollectionView/EntityCollectionView.tsx +4 -2
  19. package/src/components/EntityPreview.tsx +10 -3
  20. package/src/components/EntityView.tsx +4 -1
  21. package/src/components/ReferenceTable/ReferenceSelectionTable.tsx +3 -1
  22. package/src/core/FireCMS.tsx +12 -11
  23. package/src/form/EntityForm.tsx +11 -6
  24. package/src/form/PropertyFieldBinding.tsx +6 -3
  25. package/src/form/field_bindings/ArrayCustomShapedFieldBinding.tsx +4 -1
  26. package/src/form/field_bindings/BlockFieldBinding.tsx +1 -1
  27. package/src/form/field_bindings/KeyValueFieldBinding.tsx +1 -1
  28. package/src/form/field_bindings/MarkdownEditorFieldBinding.tsx +6 -2
  29. package/src/form/field_bindings/MultiSelectFieldBinding.tsx +2 -2
  30. package/src/form/field_bindings/RepeatFieldBinding.tsx +8 -2
  31. package/src/form/field_bindings/StorageUploadFieldBinding.tsx +4 -1
  32. package/src/hooks/data/save.ts +24 -29
  33. package/src/hooks/useFireCMSContext.tsx +0 -30
  34. package/src/internal/useBuildDataSource.ts +9 -5
  35. package/src/internal/useBuildSideEntityController.tsx +22 -16
  36. package/src/preview/PropertyPreview.tsx +4 -2
  37. package/src/preview/property_previews/ArrayOfMapsPreview.tsx +4 -3
  38. package/src/preview/property_previews/ArrayOfReferencesPreview.tsx +4 -3
  39. package/src/preview/property_previews/ArrayOfStorageComponentsPreview.tsx +4 -2
  40. package/src/preview/property_previews/ArrayOfStringsPreview.tsx +4 -3
  41. package/src/preview/property_previews/ArrayOneOfPreview.tsx +4 -2
  42. package/src/preview/property_previews/ArrayPropertyPreview.tsx +4 -2
  43. package/src/types/collections.ts +2 -0
  44. package/src/types/properties.ts +20 -1
  45. package/src/util/property_utils.tsx +7 -3
  46. package/src/util/references.ts +8 -6
  47. package/src/util/resolutions.ts +13 -7
  48. package/src/util/useStorageUploadController.tsx +4 -2
@@ -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,
@@ -23,7 +23,7 @@ export function MultiSelectFieldBinding({
23
23
  disabled,
24
24
  property,
25
25
  includeDescription,
26
- size = "medium",
26
+ size = "large",
27
27
  autoFocus
28
28
  }: FieldProps<EnumType[], any, any>) {
29
29
 
@@ -83,7 +83,7 @@ export function MultiSelectFieldBinding({
83
83
  <>
84
84
  <MultiSelect
85
85
  className={"w-full mt-2"}
86
- size={size === "medium" ? "medium" : "small"}
86
+ size={size}
87
87
  value={validValue ? value.map((v) => v.toString()) : []}
88
88
  disabled={disabled}
89
89
  modalPopover={true}
@@ -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,
@@ -1,5 +1,6 @@
1
1
  import { useCallback, useEffect, useRef } from "react";
2
2
  import {
3
+ AuthController,
3
4
  CustomizationController,
4
5
  EntityCollection,
5
6
  EntitySidePanelProps,
@@ -25,7 +26,7 @@ import { JSON_TAB_VALUE } from "../core/EntityEditView";
25
26
  const NEW_URL_HASH = "new_side";
26
27
  const SIDE_URL_HASH = "side";
27
28
 
28
- export function getEntityViewWidth(props: EntitySidePanelProps<any>, small: boolean, customizationController: CustomizationController): string {
29
+ export function getEntityViewWidth(props: EntitySidePanelProps<any>, small: boolean, customizationController: CustomizationController, authController: AuthController): string {
29
30
  if (small) return CONTAINER_FULL_WIDTH;
30
31
 
31
32
  const {
@@ -49,21 +50,22 @@ export function getEntityViewWidth(props: EntitySidePanelProps<any>, small: bool
49
50
  } else if (!props.collection) {
50
51
  return FORM_CONTAINER_WIDTH;
51
52
  } else {
52
- return calculateCollectionDesiredWidth(props.collection);
53
+ return calculateCollectionDesiredWidth(props.collection, authController);
53
54
  }
54
55
  }
55
56
  }
56
57
 
57
58
  const collectionViewWidthCache: { [key: string]: string } = {};
58
59
 
59
- function calculateCollectionDesiredWidth(collection: EntityCollection<any>): string {
60
+ function calculateCollectionDesiredWidth(collection: EntityCollection<any>, authController: AuthController): string {
60
61
  if (collectionViewWidthCache[collection.id]) {
61
62
  return collectionViewWidthCache[collection.id];
62
63
  }
63
64
  const resolvedCollection = resolveCollection({
64
65
  collection,
65
66
  path: "__ignored",
66
- ignoreMissingFields: true
67
+ ignoreMissingFields: true,
68
+ authController
67
69
  });
68
70
 
69
71
  let result = FORM_CONTAINER_WIDTH
@@ -98,7 +100,9 @@ function getNestedPropertiesDepth(property: ResolvedProperty, accumulator: numbe
98
100
  }
99
101
 
100
102
  export const useBuildSideEntityController = (navigation: NavigationController,
101
- sideDialogsController: SideDialogsController): SideEntityController => {
103
+ sideDialogsController: SideDialogsController,
104
+ authController: AuthController
105
+ ): SideEntityController => {
102
106
 
103
107
  const location = useLocation();
104
108
  const initialised = useRef<boolean>(false);
@@ -106,7 +110,6 @@ export const useBuildSideEntityController = (navigation: NavigationController,
106
110
 
107
111
  const smallLayout = !useLargeLayout();
108
112
 
109
- // only on initialisation, create panels from URL
110
113
  useEffect(() => {
111
114
 
112
115
  const newFlag = location.hash === `#${NEW_URL_HASH}`;
@@ -119,9 +122,9 @@ export const useBuildSideEntityController = (navigation: NavigationController,
119
122
  for (let i = 0; i < panelsFromUrl.length; i++) {
120
123
  const props = panelsFromUrl[i];
121
124
  if (i === 0)
122
- sideDialogsController.replace(propsToSidePanel(props, navigation.buildUrlCollectionPath, navigation.resolveIdsFrom, smallLayout, customizationController));
125
+ sideDialogsController.replace(propsToSidePanel(props, navigation.buildUrlCollectionPath, navigation.resolveIdsFrom, smallLayout, customizationController, authController));
123
126
  else
124
- sideDialogsController.open(propsToSidePanel(props, navigation.buildUrlCollectionPath, navigation.resolveIdsFrom, smallLayout, customizationController))
127
+ sideDialogsController.open(propsToSidePanel(props, navigation.buildUrlCollectionPath, navigation.resolveIdsFrom, smallLayout, customizationController, authController))
125
128
  }
126
129
  }
127
130
  initialised.current = true;
@@ -141,7 +144,7 @@ export const useBuildSideEntityController = (navigation: NavigationController,
141
144
  return;
142
145
  }
143
146
  const lastPanel = panelsFromUrl[panelsFromUrl.length - 1];
144
- const panelProps = propsToSidePanel(lastPanel, navigation.buildUrlCollectionPath, navigation.resolveIdsFrom, smallLayout, customizationController);
147
+ const panelProps = propsToSidePanel(lastPanel, navigation.buildUrlCollectionPath, navigation.resolveIdsFrom, smallLayout, customizationController, authController);
145
148
  const lastCurrentPanel = currentPanelKeys.length > 0 ? currentPanelKeys[currentPanelKeys.length - 1] : undefined;
146
149
  if (!lastCurrentPanel || lastCurrentPanel !== panelProps.key) {
147
150
  sideDialogsController.replace(panelProps);
@@ -154,7 +157,7 @@ export const useBuildSideEntityController = (navigation: NavigationController,
154
157
  useEffect(() => {
155
158
  const updatedSidePanels = sideDialogsController.sidePanels.map(sidePanelProps => {
156
159
  if (sidePanelProps.additional) {
157
- return propsToSidePanel(sidePanelProps.additional, navigation.buildUrlCollectionPath, navigation.resolveIdsFrom, smallLayout, customizationController);
160
+ return propsToSidePanel(sidePanelProps.additional, navigation.buildUrlCollectionPath, navigation.resolveIdsFrom, smallLayout, customizationController, authController);
158
161
  }
159
162
  return sidePanelProps;
160
163
  });
@@ -187,10 +190,11 @@ export const useBuildSideEntityController = (navigation: NavigationController,
187
190
  navigation.buildUrlCollectionPath,
188
191
  navigation.resolveIdsFrom,
189
192
  smallLayout,
190
- customizationController
193
+ customizationController,
194
+ authController
191
195
  ));
192
196
 
193
- }, [sideDialogsController, navigation.buildUrlCollectionPath, navigation.resolveIdsFrom, smallLayout]);
197
+ }, [sideDialogsController, navigation.buildUrlCollectionPath, navigation.resolveIdsFrom, smallLayout, authController.user]);
194
198
 
195
199
  const replace = useCallback((props: EntitySidePanelProps<any>) => {
196
200
 
@@ -198,9 +202,9 @@ export const useBuildSideEntityController = (navigation: NavigationController,
198
202
  throw Error("If you want to copy an entity you need to provide an entityId");
199
203
  }
200
204
 
201
- sideDialogsController.replace(propsToSidePanel(props, navigation.buildUrlCollectionPath, navigation.resolveIdsFrom, smallLayout, customizationController));
205
+ sideDialogsController.replace(propsToSidePanel(props, navigation.buildUrlCollectionPath, navigation.resolveIdsFrom, smallLayout, customizationController, authController));
202
206
 
203
- }, [navigation.buildUrlCollectionPath, navigation.resolveIdsFrom, sideDialogsController, smallLayout]);
207
+ }, [navigation.buildUrlCollectionPath, navigation.resolveIdsFrom, sideDialogsController, smallLayout, authController.user]);
204
208
 
205
209
  return {
206
210
  close,
@@ -261,7 +265,9 @@ const propsToSidePanel = (props: EntitySidePanelProps,
261
265
  buildUrlCollectionPath: (path: string) => string,
262
266
  resolveIdsFrom: (pathWithAliases: string) => string,
263
267
  smallLayout: boolean,
264
- customizationController: CustomizationController): SideDialogPanelProps => {
268
+ customizationController: CustomizationController,
269
+ authController: AuthController
270
+ ): SideDialogPanelProps => {
265
271
 
266
272
  const collectionPath = removeInitialAndTrailingSlashes(props.path);
267
273
 
@@ -276,7 +282,7 @@ const propsToSidePanel = (props: EntitySidePanelProps,
276
282
  formProps: props.formProps
277
283
  };
278
284
 
279
- const entityViewWidth = getEntityViewWidth(props, smallLayout, customizationController);
285
+ const entityViewWidth = getEntityViewWidth(props, smallLayout, customizationController, authController);
280
286
 
281
287
  return {
282
288
  key: `${props.path}/${props.entityId}`,
@@ -13,7 +13,7 @@ import {
13
13
  import { resolveProperty } from "../util";
14
14
 
15
15
  import { PropertyPreviewProps } from "./PropertyPreviewProps";
16
- import { useCustomizationController } from "../hooks";
16
+ import { useAuthController, useCustomizationController } from "../hooks";
17
17
  import { EmptyValue } from "./components/EmptyValue";
18
18
  import { UrlComponentPreview } from "./components/UrlComponentPreview";
19
19
  import { StorageThumbnail } from "./components/StorageThumbnail";
@@ -37,6 +37,7 @@ import { ErrorView } from "../components";
37
37
  */
38
38
  export const PropertyPreview = React.memo(function PropertyPreview<T extends CMSType>(props: PropertyPreviewProps<T>) {
39
39
 
40
+ const authController = useAuthController();
40
41
  const customizationController = useCustomizationController();
41
42
 
42
43
  let content: React.ReactNode | any;
@@ -53,7 +54,8 @@ export const PropertyPreview = React.memo(function PropertyPreview<T extends CMS
53
54
  const property = resolveProperty({
54
55
  propertyKey,
55
56
  propertyOrBuilder: inputProperty,
56
- propertyConfigs: customizationController.propertyConfigs
57
+ propertyConfigs: customizationController.propertyConfigs,
58
+ authController
57
59
  });
58
60
 
59
61
  if (property === null) {
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import { ErrorBoundary } from "../../components";
3
- import { useCustomizationController } from "../../hooks";
3
+ import { useAuthController, useCustomizationController } from "../../hooks";
4
4
  import { PropertyPreviewProps } from "../PropertyPreviewProps";
5
5
  import { PropertyPreview } from "../PropertyPreview";
6
6
  import { resolveArrayProperty } from "../../util";
@@ -15,12 +15,13 @@ export function ArrayOfMapsPreview({
15
15
  size,
16
16
  // entity
17
17
  }: PropertyPreviewProps<Record<string, any>[]>) {
18
-
18
+ const authController = useAuthController();
19
19
  const customizationController = useCustomizationController();
20
20
  const property = resolveArrayProperty({
21
21
  propertyKey,
22
22
  property: inputProperty,
23
- propertyConfigs: customizationController.propertyConfigs
23
+ propertyConfigs: customizationController.propertyConfigs,
24
+ authController
24
25
  });
25
26
 
26
27
  if (Array.isArray(property?.of)) {
@@ -1,6 +1,6 @@
1
1
  import { ResolvedReferenceProperty } from "../../types";
2
2
  import { resolveArrayProperty } from "../../util";
3
- import { useCustomizationController } from "../../hooks";
3
+ import { useAuthController, useCustomizationController } from "../../hooks";
4
4
  import { PreviewSize, PropertyPreviewProps } from "../PropertyPreviewProps";
5
5
  import { ReferencePreview } from "../components/ReferencePreview";
6
6
 
@@ -13,12 +13,13 @@ export function ArrayOfReferencesPreview({
13
13
  property: inputProperty,
14
14
  size
15
15
  }: PropertyPreviewProps<any[]>) {
16
-
16
+ const authController = useAuthController();
17
17
  const customizationController = useCustomizationController();
18
18
  const property = resolveArrayProperty({
19
19
  propertyKey,
20
20
  property: inputProperty,
21
- propertyConfigs: customizationController.propertyConfigs
21
+ propertyConfigs: customizationController.propertyConfigs,
22
+ authController
22
23
  });
23
24
 
24
25
  if (Array.isArray(property?.of)) {
@@ -3,7 +3,7 @@ import React from "react";
3
3
  import { resolveArrayProperty } from "../../util";
4
4
  import { ResolvedProperty } from "../../types";
5
5
 
6
- import { useCustomizationController } from "../../hooks";
6
+ import { useAuthController, useCustomizationController } from "../../hooks";
7
7
  import { PreviewSize, PropertyPreviewProps } from "../PropertyPreviewProps";
8
8
  import { PropertyPreview } from "../PropertyPreview";
9
9
  import { ErrorBoundary } from "../../components";
@@ -19,11 +19,13 @@ export function ArrayOfStorageComponentsPreview({
19
19
  size
20
20
  }: PropertyPreviewProps<any[]>) {
21
21
 
22
+ const authController = useAuthController();
22
23
  const customizationController = useCustomizationController();
23
24
  const property = resolveArrayProperty({
24
25
  propertyKey,
25
26
  property: inputProperty,
26
- propertyConfigs: customizationController.propertyConfigs
27
+ propertyConfigs: customizationController.propertyConfigs,
28
+ authController
27
29
  });
28
30
 
29
31
  if (Array.isArray(property.of)) {
@@ -3,7 +3,7 @@ import { ResolvedStringProperty } from "../../types";
3
3
 
4
4
  import { resolveArrayProperty } from "../../util";
5
5
  import { PropertyPreviewProps, StringPropertyPreview } from "../../preview";
6
- import { useCustomizationController } from "../../hooks";
6
+ import { useAuthController, useCustomizationController } from "../../hooks";
7
7
  import { ErrorBoundary } from "../../components";
8
8
 
9
9
  /**
@@ -16,12 +16,13 @@ export function ArrayOfStringsPreview({
16
16
  // entity,
17
17
  size
18
18
  }: PropertyPreviewProps<string[]>) {
19
-
19
+ const authController = useAuthController();
20
20
  const customizationController = useCustomizationController();
21
21
  const property = resolveArrayProperty({
22
22
  propertyKey,
23
23
  property: inputProperty,
24
- propertyConfigs: customizationController.propertyConfigs
24
+ propertyConfigs: customizationController.propertyConfigs,
25
+ authController
25
26
  });
26
27
 
27
28
  if (Array.isArray(property.of)) {