@firecms/core 3.0.0-beta.12 → 3.0.0-beta.13

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 (84) hide show
  1. package/dist/app/Scaffold.d.ts +4 -0
  2. package/dist/components/ArrayContainer.d.ts +12 -5
  3. package/dist/components/EntityCollectionView/EntityCollectionView.d.ts +4 -0
  4. package/dist/components/EntityJsonPreview.d.ts +3 -0
  5. package/dist/core/DefaultAppBar.d.ts +8 -2
  6. package/dist/core/EntityEditView.d.ts +8 -1
  7. package/dist/core/FireCMS.d.ts +2 -2
  8. package/dist/form/EntityForm.d.ts +5 -1
  9. package/dist/form/PropertyFieldBinding.d.ts +1 -1
  10. package/dist/hooks/data/save.d.ts +1 -1
  11. package/dist/index.es.js +8630 -8578
  12. package/dist/index.es.js.map +1 -1
  13. package/dist/index.umd.js +8663 -8612
  14. package/dist/index.umd.js.map +1 -1
  15. package/dist/internal/useBuildDataSource.d.ts +3 -2
  16. package/dist/internal/useBuildSideEntityController.d.ts +3 -3
  17. package/dist/types/collections.d.ts +6 -0
  18. package/dist/types/fields.d.ts +4 -1
  19. package/dist/types/firecms.d.ts +1 -1
  20. package/dist/types/navigation.d.ts +4 -0
  21. package/dist/types/plugins.d.ts +1 -0
  22. package/dist/types/properties.d.ts +22 -1
  23. package/dist/util/createFormexStub.d.ts +2 -0
  24. package/dist/util/navigation_utils.d.ts +2 -1
  25. package/dist/util/objects.d.ts +1 -1
  26. package/dist/util/property_utils.d.ts +2 -2
  27. package/dist/util/references.d.ts +2 -2
  28. package/dist/util/resolutions.d.ts +11 -6
  29. package/package.json +6 -5
  30. package/src/app/Scaffold.tsx +13 -3
  31. package/src/components/ArrayContainer.tsx +40 -23
  32. package/src/components/DeleteEntityDialog.tsx +4 -2
  33. package/src/components/EntityCollectionTable/EntityCollectionRowActions.tsx +8 -6
  34. package/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +5 -2
  35. package/src/components/EntityCollectionView/EntityCollectionView.tsx +22 -6
  36. package/src/components/EntityJsonPreview.tsx +66 -0
  37. package/src/components/EntityPreview.tsx +10 -3
  38. package/src/components/EntityView.tsx +4 -1
  39. package/src/components/ReferenceTable/ReferenceSelectionTable.tsx +3 -1
  40. package/src/components/VirtualTable/VirtualTable.tsx +29 -1
  41. package/src/components/common/default_entity_actions.tsx +15 -4
  42. package/src/core/DefaultAppBar.tsx +17 -5
  43. package/src/core/EntityEditView.tsx +111 -35
  44. package/src/core/FireCMS.tsx +13 -12
  45. package/src/form/EntityForm.tsx +31 -23
  46. package/src/form/PropertyFieldBinding.tsx +8 -5
  47. package/src/form/field_bindings/ArrayCustomShapedFieldBinding.tsx +4 -1
  48. package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +1 -0
  49. package/src/form/field_bindings/BlockFieldBinding.tsx +1 -1
  50. package/src/form/field_bindings/KeyValueFieldBinding.tsx +1 -1
  51. package/src/form/field_bindings/MarkdownEditorFieldBinding.tsx +6 -2
  52. package/src/form/field_bindings/MultiSelectFieldBinding.tsx +2 -2
  53. package/src/form/field_bindings/RepeatFieldBinding.tsx +8 -2
  54. package/src/form/field_bindings/SelectFieldBinding.tsx +1 -1
  55. package/src/form/field_bindings/StorageUploadFieldBinding.tsx +5 -2
  56. package/src/hooks/data/save.ts +24 -29
  57. package/src/hooks/useBuildNavigationController.tsx +12 -1
  58. package/src/hooks/useFireCMSContext.tsx +0 -30
  59. package/src/internal/useBuildDataSource.ts +9 -5
  60. package/src/internal/useBuildSideEntityController.tsx +26 -20
  61. package/src/preview/PropertyPreview.tsx +4 -2
  62. package/src/preview/property_previews/ArrayOfMapsPreview.tsx +4 -3
  63. package/src/preview/property_previews/ArrayOfReferencesPreview.tsx +4 -3
  64. package/src/preview/property_previews/ArrayOfStorageComponentsPreview.tsx +4 -2
  65. package/src/preview/property_previews/ArrayOfStringsPreview.tsx +4 -3
  66. package/src/preview/property_previews/ArrayOneOfPreview.tsx +4 -2
  67. package/src/preview/property_previews/ArrayPropertyPreview.tsx +4 -2
  68. package/src/routes/FireCMSRoute.tsx +15 -4
  69. package/src/types/collections.ts +7 -0
  70. package/src/types/fields.tsx +5 -1
  71. package/src/types/firecms.tsx +1 -1
  72. package/src/types/navigation.ts +5 -0
  73. package/src/types/plugins.tsx +1 -0
  74. package/src/types/properties.ts +27 -1
  75. package/src/types/side_entity_controller.tsx +5 -0
  76. package/src/util/createFormexStub.tsx +62 -0
  77. package/src/util/join_collections.ts +3 -1
  78. package/src/util/navigation_from_path.ts +5 -1
  79. package/src/util/navigation_utils.ts +64 -15
  80. package/src/util/objects.ts +5 -1
  81. package/src/util/property_utils.tsx +7 -3
  82. package/src/util/references.ts +8 -6
  83. package/src/util/resolutions.ts +17 -9
  84. package/src/util/useStorageUploadController.tsx +21 -2
@@ -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}
@@ -66,7 +66,7 @@ export function SelectFieldBinding<T extends EnumType>({
66
66
  />
67
67
  </PropertyIdCopyTooltip>}
68
68
  endAdornment={
69
- property.clearable && <IconButton
69
+ property.clearable && !disabled && <IconButton
70
70
  onClick={handleClearClick}>
71
71
  <CloseIcon/>
72
72
  </IconButton>
@@ -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,11 +57,13 @@ 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
 
63
65
  const storageSource = useStorageSource(context.collection);
64
- const disabled = isReadOnly(property) || !!property.disabled || isSubmitting;
66
+ const disabled = isReadOnly(property) || !!property.disabled || isSubmitting || context.disabled;
65
67
 
66
68
  const {
67
69
  internalValue,
@@ -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,
@@ -291,6 +291,16 @@ export function useBuildNavigationController<EC extends EntityCollection, USER e
291
291
 
292
292
  }, [userConfigPersistence]);
293
293
 
294
+ const getCollectionById = useCallback((id: string): EC | undefined => {
295
+ const collections = collectionsRef.current;
296
+ if (collections === undefined)
297
+ throw Error("getCollectionById: Collections have not been initialised yet");
298
+ const collection: EntityCollection | undefined = collections.find(c => c.id === id);
299
+ if (!collection)
300
+ return undefined;
301
+ return collection as EC;
302
+ }, []);
303
+
294
304
  const getCollectionFromPaths = useCallback(<EC extends EntityCollection>(pathSegments: string[]): EC | undefined => {
295
305
 
296
306
  const collections = collectionsRef.current;
@@ -398,6 +408,7 @@ export function useBuildNavigationController<EC extends EntityCollection, USER e
398
408
  baseCollectionPath,
399
409
  initialised,
400
410
  getCollection,
411
+ getCollectionById,
401
412
  getCollectionFromPaths,
402
413
  getCollectionFromIds,
403
414
  isUrlCollectionPath,
@@ -528,7 +539,7 @@ function useCustomBlocker(): NavigationBlocker {
528
539
  return shouldBlock;
529
540
  });
530
541
  } catch (e) {
531
- console.warn("Blocker not available, navigation will not be blocked");
542
+ // console.warn("Blocker not available, navigation will not be blocked");
532
543
  }
533
544
 
534
545
  const updateBlockListener = (path: string, block: boolean, basePath?: string) => {
@@ -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,
@@ -20,18 +21,19 @@ import {
20
21
  import { ADDITIONAL_TAB_WIDTH, CONTAINER_FULL_WIDTH, FORM_CONTAINER_WIDTH } from "./common";
21
22
  import { useCustomizationController, useLargeLayout } from "../hooks";
22
23
  import { EntitySidePanel } from "../core/EntitySidePanel";
24
+ import { JSON_TAB_VALUE } from "../core/EntityEditView";
23
25
 
24
26
  const NEW_URL_HASH = "new_side";
25
27
  const SIDE_URL_HASH = "side";
26
28
 
27
- 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 {
28
30
  if (small) return CONTAINER_FULL_WIDTH;
29
31
 
30
32
  const {
31
33
  selectedSecondaryForm
32
34
  } = resolvedSelectedEntityView(props.collection?.entityViews, customizationController, props.selectedTab);
33
35
 
34
- const shouldUseSmallLayout = !props.selectedTab || Boolean(selectedSecondaryForm);
36
+ const shouldUseSmallLayout = !props.selectedTab || props.selectedTab === JSON_TAB_VALUE || Boolean(selectedSecondaryForm);
35
37
 
36
38
  let resolvedWidth: string | undefined;
37
39
  if (props.width) {
@@ -48,21 +50,22 @@ export function getEntityViewWidth(props: EntitySidePanelProps<any>, small: bool
48
50
  } else if (!props.collection) {
49
51
  return FORM_CONTAINER_WIDTH;
50
52
  } else {
51
- return calculateCollectionDesiredWidth(props.collection);
53
+ return calculateCollectionDesiredWidth(props.collection, authController);
52
54
  }
53
55
  }
54
56
  }
55
57
 
56
58
  const collectionViewWidthCache: { [key: string]: string } = {};
57
59
 
58
- function calculateCollectionDesiredWidth(collection: EntityCollection<any>): string {
60
+ function calculateCollectionDesiredWidth(collection: EntityCollection<any>, authController: AuthController): string {
59
61
  if (collectionViewWidthCache[collection.id]) {
60
62
  return collectionViewWidthCache[collection.id];
61
63
  }
62
64
  const resolvedCollection = resolveCollection({
63
65
  collection,
64
66
  path: "__ignored",
65
- ignoreMissingFields: true
67
+ ignoreMissingFields: true,
68
+ authController
66
69
  });
67
70
 
68
71
  let result = FORM_CONTAINER_WIDTH
@@ -97,7 +100,9 @@ function getNestedPropertiesDepth(property: ResolvedProperty, accumulator: numbe
97
100
  }
98
101
 
99
102
  export const useBuildSideEntityController = (navigation: NavigationController,
100
- sideDialogsController: SideDialogsController): SideEntityController => {
103
+ sideDialogsController: SideDialogsController,
104
+ authController: AuthController
105
+ ): SideEntityController => {
101
106
 
102
107
  const location = useLocation();
103
108
  const initialised = useRef<boolean>(false);
@@ -105,7 +110,6 @@ export const useBuildSideEntityController = (navigation: NavigationController,
105
110
 
106
111
  const smallLayout = !useLargeLayout();
107
112
 
108
- // only on initialisation, create panels from URL
109
113
  useEffect(() => {
110
114
 
111
115
  const newFlag = location.hash === `#${NEW_URL_HASH}`;
@@ -118,9 +122,9 @@ export const useBuildSideEntityController = (navigation: NavigationController,
118
122
  for (let i = 0; i < panelsFromUrl.length; i++) {
119
123
  const props = panelsFromUrl[i];
120
124
  if (i === 0)
121
- sideDialogsController.replace(propsToSidePanel(props, navigation.buildUrlCollectionPath, navigation.resolveIdsFrom, smallLayout, customizationController));
125
+ sideDialogsController.replace(propsToSidePanel(props, navigation.buildUrlCollectionPath, navigation.resolveIdsFrom, smallLayout, customizationController, authController));
122
126
  else
123
- sideDialogsController.open(propsToSidePanel(props, navigation.buildUrlCollectionPath, navigation.resolveIdsFrom, smallLayout, customizationController))
127
+ sideDialogsController.open(propsToSidePanel(props, navigation.buildUrlCollectionPath, navigation.resolveIdsFrom, smallLayout, customizationController, authController))
124
128
  }
125
129
  }
126
130
  initialised.current = true;
@@ -140,7 +144,7 @@ export const useBuildSideEntityController = (navigation: NavigationController,
140
144
  return;
141
145
  }
142
146
  const lastPanel = panelsFromUrl[panelsFromUrl.length - 1];
143
- const panelProps = propsToSidePanel(lastPanel, navigation.buildUrlCollectionPath, navigation.resolveIdsFrom, smallLayout, customizationController);
147
+ const panelProps = propsToSidePanel(lastPanel, navigation.buildUrlCollectionPath, navigation.resolveIdsFrom, smallLayout, customizationController, authController);
144
148
  const lastCurrentPanel = currentPanelKeys.length > 0 ? currentPanelKeys[currentPanelKeys.length - 1] : undefined;
145
149
  if (!lastCurrentPanel || lastCurrentPanel !== panelProps.key) {
146
150
  sideDialogsController.replace(panelProps);
@@ -153,7 +157,7 @@ export const useBuildSideEntityController = (navigation: NavigationController,
153
157
  useEffect(() => {
154
158
  const updatedSidePanels = sideDialogsController.sidePanels.map(sidePanelProps => {
155
159
  if (sidePanelProps.additional) {
156
- return propsToSidePanel(sidePanelProps.additional, navigation.buildUrlCollectionPath, navigation.resolveIdsFrom, smallLayout, customizationController);
160
+ return propsToSidePanel(sidePanelProps.additional, navigation.buildUrlCollectionPath, navigation.resolveIdsFrom, smallLayout, customizationController, authController);
157
161
  }
158
162
  return sidePanelProps;
159
163
  });
@@ -186,10 +190,11 @@ export const useBuildSideEntityController = (navigation: NavigationController,
186
190
  navigation.buildUrlCollectionPath,
187
191
  navigation.resolveIdsFrom,
188
192
  smallLayout,
189
- customizationController
193
+ customizationController,
194
+ authController
190
195
  ));
191
196
 
192
- }, [sideDialogsController, navigation.buildUrlCollectionPath, navigation.resolveIdsFrom, smallLayout]);
197
+ }, [sideDialogsController, navigation.buildUrlCollectionPath, navigation.resolveIdsFrom, smallLayout, authController.user]);
193
198
 
194
199
  const replace = useCallback((props: EntitySidePanelProps<any>) => {
195
200
 
@@ -197,9 +202,9 @@ export const useBuildSideEntityController = (navigation: NavigationController,
197
202
  throw Error("If you want to copy an entity you need to provide an entityId");
198
203
  }
199
204
 
200
- sideDialogsController.replace(propsToSidePanel(props, navigation.buildUrlCollectionPath, navigation.resolveIdsFrom, smallLayout, customizationController));
205
+ sideDialogsController.replace(propsToSidePanel(props, navigation.buildUrlCollectionPath, navigation.resolveIdsFrom, smallLayout, customizationController, authController));
201
206
 
202
- }, [navigation.buildUrlCollectionPath, navigation.resolveIdsFrom, sideDialogsController, smallLayout]);
207
+ }, [navigation.buildUrlCollectionPath, navigation.resolveIdsFrom, sideDialogsController, smallLayout, authController.user]);
203
208
 
204
209
  return {
205
210
  close,
@@ -228,6 +233,7 @@ export function buildSidePanelsFromUrl(path: string, collections: EntityCollecti
228
233
  if (navigationEntry.type === "entity") {
229
234
  sidePanel = {
230
235
  path: navigationEntry.path,
236
+ // fullIdPath: navigationEntry.path,
231
237
  entityId: navigationEntry.entityId,
232
238
  copy: false,
233
239
  width: navigationEntry.parentCollection?.sideDialogWidth
@@ -249,6 +255,7 @@ export function buildSidePanelsFromUrl(path: string, collections: EntityCollecti
249
255
  if (newFlag) {
250
256
  sidePanel = {
251
257
  path: lastCollectionPath,
258
+ // fullIdPath: lastCollectionPath,
252
259
  copy: false
253
260
  }
254
261
  }
@@ -260,23 +267,22 @@ const propsToSidePanel = (props: EntitySidePanelProps,
260
267
  buildUrlCollectionPath: (path: string) => string,
261
268
  resolveIdsFrom: (pathWithAliases: string) => string,
262
269
  smallLayout: boolean,
263
- customizationController: CustomizationController): SideDialogPanelProps => {
270
+ customizationController: CustomizationController,
271
+ authController: AuthController
272
+ ): SideDialogPanelProps => {
264
273
 
265
274
  const collectionPath = removeInitialAndTrailingSlashes(props.path);
266
275
 
267
276
  const newPath = props.entityId
268
277
  ? buildUrlCollectionPath(`${collectionPath}/${props.entityId}${props.selectedTab ? "/" + props.selectedTab : ""}#${SIDE_URL_HASH}`)
269
278
  : buildUrlCollectionPath(`${collectionPath}#${NEW_URL_HASH}`);
270
- const resolvedPath = resolveIdsFrom(props.path);
271
279
 
272
280
  const resolvedPanelProps: EntitySidePanelProps<any> = {
273
281
  ...props,
274
- path: resolvedPath,
275
282
  formProps: props.formProps
276
283
  };
277
284
 
278
- const entityViewWidth = getEntityViewWidth(props, smallLayout, customizationController);
279
-
285
+ const entityViewWidth = getEntityViewWidth(props, smallLayout, customizationController, authController);
280
286
  return {
281
287
  key: `${props.path}/${props.entityId}`,
282
288
  component: <EntitySidePanel {...resolvedPanelProps}/>,
@@ -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)) {