@firecms/core 3.0.0-alpha.44 → 3.0.0-alpha.46

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 (53) hide show
  1. package/dist/contexts/NavigationContext.d.ts +2 -2
  2. package/dist/core/NavigationRoutes.d.ts +1 -1
  3. package/dist/core/index.d.ts +1 -1
  4. package/dist/hooks/data/save.d.ts +2 -1
  5. package/dist/hooks/index.d.ts +1 -2
  6. package/dist/hooks/{useNavigationContext.d.ts → useNavigationController.d.ts} +2 -2
  7. package/dist/index.es.js +5444 -5440
  8. package/dist/index.es.js.map +1 -1
  9. package/dist/index.umd.js +13 -13
  10. package/dist/index.umd.js.map +1 -1
  11. package/dist/{hooks → internal}/useBuildDataSource.d.ts +3 -2
  12. package/dist/internal/useBuildNavigationController.d.ts +14 -0
  13. package/dist/internal/useBuildSideEntityController.d.ts +2 -2
  14. package/dist/types/datasource.d.ts +3 -3
  15. package/dist/types/firecms.d.ts +4 -4
  16. package/dist/types/firecms_context.d.ts +2 -2
  17. package/dist/types/navigation.d.ts +2 -2
  18. package/package.json +2 -2
  19. package/src/components/EntityCollectionTable/fields/TableReferenceField.tsx +3 -3
  20. package/src/components/EntityCollectionTable/filters/ReferenceFilterField.tsx +3 -3
  21. package/src/components/EntityCollectionTable/useEntityCollectionTableController.tsx +2 -2
  22. package/src/components/EntityCollectionView/EntityCollectionView.tsx +4 -3
  23. package/src/components/EntityCollectionView/EntityCollectionViewActions.tsx +3 -3
  24. package/src/components/FireCMSAppBar.tsx +2 -2
  25. package/src/components/HomePage/DefaultHomePage.tsx +4 -4
  26. package/src/components/HomePage/FavouritesView.tsx +3 -3
  27. package/src/components/ReferenceSelectionInner.tsx +2 -2
  28. package/src/contexts/NavigationContext.tsx +2 -2
  29. package/src/core/Drawer.tsx +2 -2
  30. package/src/core/EntitySidePanel.tsx +4 -4
  31. package/src/core/FireCMS.tsx +29 -23
  32. package/src/core/NavigationRoutes.tsx +3 -3
  33. package/src/core/Scaffold.tsx +3 -3
  34. package/src/core/index.tsx +1 -1
  35. package/src/form/components/ReferenceWidget.tsx +4 -4
  36. package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +3 -3
  37. package/src/form/field_bindings/ReferenceFieldBinding.tsx +3 -3
  38. package/src/hooks/data/save.ts +11 -1
  39. package/src/hooks/data/useCollectionFetch.tsx +3 -3
  40. package/src/hooks/data/useEntityFetch.tsx +3 -3
  41. package/src/hooks/index.tsx +1 -2
  42. package/src/hooks/useFireCMSContext.tsx +2 -2
  43. package/src/hooks/{useNavigationContext.tsx → useNavigationController.tsx} +3 -3
  44. package/src/hooks/useReferenceDialog.tsx +2 -2
  45. package/src/{hooks → internal}/useBuildDataSource.ts +34 -25
  46. package/src/internal/{useBuildNavigationContext.tsx → useBuildNavigationController.tsx} +22 -18
  47. package/src/internal/useBuildSideEntityController.tsx +3 -3
  48. package/src/preview/components/ReferencePreview.tsx +3 -3
  49. package/src/types/datasource.ts +3 -3
  50. package/src/types/firecms.tsx +4 -4
  51. package/src/types/firecms_context.tsx +2 -2
  52. package/src/types/navigation.ts +2 -2
  53. package/dist/internal/useBuildNavigationContext.d.ts +0 -14
@@ -4,7 +4,7 @@ import { ReferencePreview } from "../../preview";
4
4
  import { FieldHelperText, FormikArrayContainer, LabelWithIcon } from "../components";
5
5
  import { getIconForProperty, getReferenceFrom } from "../../util";
6
6
 
7
- import { useClearRestoreValue, useNavigationContext, useReferenceDialog } from "../../hooks";
7
+ import { useClearRestoreValue, useNavigationController, useReferenceDialog } from "../../hooks";
8
8
  import { Button, ExpandablePanel } from "../../ui";
9
9
  import { ErrorView } from "../../components";
10
10
 
@@ -46,9 +46,9 @@ export function ArrayOfReferencesFieldBinding({
46
46
  setValue
47
47
  });
48
48
 
49
- const navigationContext = useNavigationContext();
49
+ const navigationController = useNavigationController();
50
50
  const collection: EntityCollection | undefined = useMemo(() => {
51
- return ofProperty.path ? navigationContext.getCollection(ofProperty.path) : undefined;
51
+ return ofProperty.path ? navigationController.getCollection(ofProperty.path) : undefined;
52
52
  }, [ofProperty.path]);
53
53
 
54
54
  if (!collection) {
@@ -1,7 +1,7 @@
1
1
  import React, { useCallback, useMemo } from "react";
2
2
 
3
3
  import { Entity, EntityCollection, EntityReference, FieldProps } from "../../types";
4
- import { useClearRestoreValue, useNavigationContext, useReferenceDialog } from "../../hooks";
4
+ import { useClearRestoreValue, useNavigationController, useReferenceDialog } from "../../hooks";
5
5
  import { ReadOnlyFieldBinding } from "./ReadOnlyFieldBinding";
6
6
  import { FieldHelperText, LabelWithIcon } from "../components";
7
7
  import { ReferencePreview } from "../../preview";
@@ -51,9 +51,9 @@ function ReferenceFieldBindingInternal<M extends Record<string, any>>({
51
51
 
52
52
  const validValue = value && value instanceof EntityReference;
53
53
 
54
- const navigationContext = useNavigationContext();
54
+ const navigationController = useNavigationController();
55
55
  const collection: EntityCollection | undefined = useMemo(() => {
56
- return property.path ? navigationContext.getCollection(property.path) : undefined;
56
+ return property.path ? navigationController.getCollection(property.path) : undefined;
57
57
  }, [property.path]);
58
58
 
59
59
  if (!collection) {
@@ -1,4 +1,13 @@
1
- import { DataSource, Entity, EntityCallbacks, EntityValues, FireCMSContext, SaveEntityProps, User } from "../../types";
1
+ import {
2
+ DataSource,
3
+ Entity,
4
+ EntityCallbacks,
5
+ EntityCollection,
6
+ EntityValues,
7
+ FireCMSContext,
8
+ SaveEntityProps,
9
+ User
10
+ } from "../../types";
2
11
  import { useDataSource } from "./useDataSource";
3
12
  import { resolveCollection } from "../../util";
4
13
 
@@ -55,6 +64,7 @@ export async function saveEntityWithCallbacks<M extends Record<string, any>, Use
55
64
  onPreSaveHookError,
56
65
  onSaveSuccessHookError
57
66
  }: SaveEntityWithCallbacksProps<M> & {
67
+ collection: EntityCollection<M>,
58
68
  dataSource: DataSource,
59
69
  context: FireCMSContext<UserType>,
60
70
  }
@@ -1,7 +1,7 @@
1
1
  import { useEffect, useState } from "react";
2
2
  import { Entity, EntityCollection, FilterValues, FireCMSContext, User } from "../../types";
3
3
  import { useDataSource } from "./useDataSource";
4
- import { useNavigationContext } from "../useNavigationContext";
4
+ import { useNavigationController } from "../useNavigationController";
5
5
  import { useFireCMSContext } from "../useFireCMSContext";
6
6
 
7
7
  /**
@@ -71,9 +71,9 @@ export function useCollectionFetch<M extends Record<string, any>, UserType exten
71
71
  }: CollectionFetchProps<M>): CollectionFetchResult<M> {
72
72
 
73
73
  const dataSource = useDataSource();
74
- const navigationContext = useNavigationContext();
74
+ const navigationController = useNavigationController();
75
75
 
76
- const path = navigationContext.resolveAliasesFrom(inputPath);
76
+ const path = navigationController.resolveAliasesFrom(inputPath);
77
77
 
78
78
  const sortByProperty = sortBy ? sortBy[0] : undefined;
79
79
  const currentSort = sortBy ? sortBy[1] : undefined;
@@ -1,7 +1,7 @@
1
1
  import { useEffect, useState } from "react";
2
2
  import { Entity, EntityCollection, FireCMSContext, User } from "../../types";
3
3
  import { useDataSource } from "./useDataSource";
4
- import { useNavigationContext } from "../useNavigationContext";
4
+ import { useNavigationController } from "../useNavigationController";
5
5
  import { useFireCMSContext } from "../useFireCMSContext";
6
6
 
7
7
  /**
@@ -44,9 +44,9 @@ export function useEntityFetch<M extends Record<string, any>, UserType extends U
44
44
  }: EntityFetchProps<M>): EntityFetchResult<M> {
45
45
 
46
46
  const dataSource = useDataSource();
47
- const navigationContext = useNavigationContext();
47
+ const navigationController = useNavigationController();
48
48
 
49
- const path = navigationContext.resolveAliasesFrom(inputPath);
49
+ const path = navigationController.resolveAliasesFrom(inputPath);
50
50
 
51
51
  const context: FireCMSContext<UserType> = useFireCMSContext();
52
52
 
@@ -5,7 +5,7 @@ export * from "./data/save";
5
5
  export * from "./data/delete";
6
6
 
7
7
  export * from "../form/useClearRestoreValue";
8
- export * from "./useNavigationContext";
8
+ export * from "./useNavigationController";
9
9
 
10
10
  export * from "./useResolvedNavigationFrom";
11
11
 
@@ -22,4 +22,3 @@ export * from "./useLargeLayout";
22
22
 
23
23
  export * from "./useReferenceDialog";
24
24
  export * from "./useBrowserTitleAndIcon";
25
- export * from "./useBuildDataSource";
@@ -2,7 +2,7 @@ import { createContext, useContext } from "react";
2
2
  import { AuthController, FireCMSContext, User } from "../types";
3
3
  import { useAuthController } from "./useAuthController";
4
4
  import { useSideDialogsController } from "./useSideDialogsController";
5
- import { useNavigationContext } from "./useNavigationContext";
5
+ import { useNavigationController } from "./useNavigationController";
6
6
  import { useSideEntityController } from "./useSideEntityController";
7
7
  import { useDataSource } from "./data/useDataSource";
8
8
  import { useStorageSource } from "./useStorageSource";
@@ -27,7 +27,7 @@ export const useFireCMSContext = <UserType extends User = User, AuthControllerTy
27
27
  const authController = useAuthController<UserType, AuthControllerType>();
28
28
  const sideDialogsController = useSideDialogsController();
29
29
  const sideEntityController = useSideEntityController();
30
- const navigation = useNavigationContext();
30
+ const navigation = useNavigationController();
31
31
  const dataSource = useDataSource();
32
32
  const storageSource = useStorageSource();
33
33
  const snackbarController = useSnackbarController();
@@ -1,6 +1,6 @@
1
1
  import { useContext } from "react";
2
- import { NavigationContext } from "../types";
3
- import { NavigationContextInstance } from "../contexts/NavigationContext";
2
+ import { NavigationController } from "../types";
3
+ import { NavigationContext } from "../contexts/NavigationContext";
4
4
 
5
5
  /**
6
6
  * Use this hook to get the navigation of the app.
@@ -9,4 +9,4 @@ import { NavigationContextInstance } from "../contexts/NavigationContext";
9
9
  *
10
10
  * @group Hooks and utilities
11
11
  */
12
- export const useNavigationContext = (): NavigationContext => useContext(NavigationContextInstance);
12
+ export const useNavigationController = (): NavigationController => useContext(NavigationContext);
@@ -1,7 +1,7 @@
1
1
  import { useSideDialogsController } from "./useSideDialogsController";
2
2
  import { ReferenceSelectionInner, ReferenceSelectionInnerProps } from "../components";
3
3
  import { useCallback } from "react";
4
- import { useNavigationContext } from "./useNavigationContext";
4
+ import { useNavigationController } from "./useNavigationController";
5
5
 
6
6
  /**
7
7
  * This hook is used to open a side dialog that allows the selection
@@ -18,7 +18,7 @@ export function useReferenceDialog<M extends Record<string, any>>(referenceDialo
18
18
  onClose?: () => void;
19
19
  }): { open: () => void; close: () => void } {
20
20
 
21
- const navigation = useNavigationContext();
21
+ const navigation = useNavigationController();
22
22
  const sideDialogsController = useSideDialogsController();
23
23
 
24
24
  const open = useCallback(() => {
@@ -13,6 +13,7 @@ import {
13
13
  GeoPoint,
14
14
  ListenCollectionProps,
15
15
  ListenEntityProps,
16
+ NavigationController,
16
17
  PropertyConfig,
17
18
  ResolvedProperties,
18
19
  SaveEntityProps
@@ -26,10 +27,12 @@ import { resolveCollection, updateDateAutoValues } from "../util";
26
27
  */
27
28
  export function useBuildDataSource({
28
29
  delegate,
29
- propertyConfigs
30
+ propertyConfigs,
31
+ navigationController
30
32
  }: {
31
33
  delegate: DataSourceDelegate,
32
34
  propertyConfigs?: Record<string, PropertyConfig>;
35
+ navigationController: NavigationController;
33
36
  }): DataSource {
34
37
 
35
38
  return {
@@ -50,7 +53,7 @@ export function useBuildDataSource({
50
53
  */
51
54
  fetchCollection: useCallback(<M extends Record<string, any>>({
52
55
  path,
53
- collection,
56
+ collection: collectionProp,
54
57
  filter,
55
58
  limit,
56
59
  startAfter,
@@ -59,7 +62,6 @@ export function useBuildDataSource({
59
62
  order
60
63
  }: FetchCollectionProps<M>
61
64
  ): Promise<Entity<M>[]> => {
62
-
63
65
  return delegate.fetchCollection<M>({
64
66
  path,
65
67
  filter,
@@ -92,7 +94,7 @@ export function useBuildDataSource({
92
94
  ? useCallback(<M extends Record<string, any>>(
93
95
  {
94
96
  path,
95
- collection,
97
+ collection: collectionProp,
96
98
  filter,
97
99
  limit,
98
100
  startAfter,
@@ -104,7 +106,8 @@ export function useBuildDataSource({
104
106
  }: ListenCollectionProps<M>
105
107
  ): () => void => {
106
108
 
107
- const isCollectionGroup = Boolean(collection.collectionGroup) ?? false;
109
+ const collection = collectionProp ?? navigationController.getCollection(path);
110
+ const isCollectionGroup = Boolean(collection?.collectionGroup) ?? false;
108
111
  if (!delegate.listenCollection)
109
112
  throw Error("useBuildDataSource delegate not initialised");
110
113
 
@@ -120,7 +123,7 @@ export function useBuildDataSource({
120
123
  onError,
121
124
  isCollectionGroup
122
125
  });
123
- }, [delegate])
126
+ }, [delegate, navigationController.getCollection])
124
127
  : undefined,
125
128
 
126
129
  /**
@@ -186,18 +189,22 @@ export function useBuildDataSource({
186
189
  path,
187
190
  entityId,
188
191
  values,
189
- collection,
192
+ collection: collectionProp,
190
193
  status
191
194
  }: SaveEntityProps<M>): Promise<Entity<M>> => {
192
195
 
193
- const resolvedCollection = resolveCollection<M>({
194
- collection,
195
- path,
196
- entityId,
197
- fields: propertyConfigs
198
- });
196
+ const collection = collectionProp ?? navigationController.getCollection(path);
197
+
198
+ const resolvedCollection = collection
199
+ ? resolveCollection<M>({
200
+ collection,
201
+ path,
202
+ entityId,
203
+ fields: propertyConfigs
204
+ })
205
+ : undefined;
199
206
 
200
- const properties: ResolvedProperties<M> = resolvedCollection.properties;
207
+ const properties: ResolvedProperties<M> | undefined = resolvedCollection?.properties;
201
208
 
202
209
  const firestoreValues = cmsToDelegateModel(
203
210
  values,
@@ -206,14 +213,16 @@ export function useBuildDataSource({
206
213
  delegate.buildDate,
207
214
  delegate.buildDeleteFieldValue
208
215
  );
209
- const updatedFirestoreValues: EntityValues<M> = updateDateAutoValues(
210
- {
211
- inputValues: firestoreValues,
212
- properties,
213
- status,
214
- timestampNowValue: delegate.currentTime(),
215
- setDateToMidnight: delegate.setDateToMidnight
216
- });
216
+ const updatedFirestoreValues: EntityValues<M> = properties
217
+ ? updateDateAutoValues(
218
+ {
219
+ inputValues: firestoreValues,
220
+ properties,
221
+ status,
222
+ timestampNowValue: delegate.currentTime(),
223
+ setDateToMidnight: delegate.setDateToMidnight
224
+ })
225
+ : firestoreValues;
217
226
 
218
227
  console.debug("Saving entity", path, entityId, updatedFirestoreValues);
219
228
 
@@ -229,7 +238,7 @@ export function useBuildDataSource({
229
238
  values: delegate.delegateToCMSModel(updatedFirestoreValues)
230
239
  } as Entity<M>;
231
240
  });
232
- }, [delegate.saveEntity]),
241
+ }, [delegate.saveEntity, navigationController.getCollection]),
233
242
 
234
243
  /**
235
244
  * Delete an entity
@@ -242,7 +251,7 @@ export function useBuildDataSource({
242
251
  entity
243
252
  }: DeleteEntityProps<M>
244
253
  ): Promise<void> => {
245
- return delegate.deleteEntity({entity});
254
+ return delegate.deleteEntity({ entity });
246
255
  }, [delegate.deleteEntity]),
247
256
 
248
257
  /**
@@ -265,7 +274,7 @@ export function useBuildDataSource({
265
274
  }, [delegate.checkUniqueField]),
266
275
 
267
276
  generateEntityId: useCallback((path: string): string => {
268
- return delegate.generateEntityId(path, );
277
+ return delegate.generateEntityId(path,);
269
278
  }, [delegate.generateEntityId]),
270
279
 
271
280
  countEntities: useCallback(async ({
@@ -5,12 +5,12 @@ import {
5
5
  AuthController,
6
6
  CMSView,
7
7
  CMSViewsBuilder,
8
- DataSource,
8
+ DataSource, DataSourceDelegate,
9
9
  EntityCollection,
10
10
  EntityCollectionsBuilder,
11
11
  EntityReference,
12
12
  FireCMSPlugin,
13
- NavigationContext,
13
+ NavigationController,
14
14
  TopNavigationEntry,
15
15
  TopNavigationResult,
16
16
  User,
@@ -24,28 +24,32 @@ import {
24
24
  resolvePermissions
25
25
  } from "../util";
26
26
  import { getParentReferencesFromPath } from "../util/parent_references_from_path";
27
+ import { useTraceUpdate } from "../util/useTraceUpdate";
28
+
29
+ const DEFAULT_BASE_PATH = "/";
30
+ const DEFAULT_COLLECTION_PATH = "/c";
27
31
 
28
32
  type BuildNavigationContextProps<EC extends EntityCollection, UserType extends User> = {
29
- basePath: string,
30
- baseCollectionPath: string,
33
+ basePath?: string,
34
+ baseCollectionPath?: string,
31
35
  authController: AuthController<UserType>;
32
36
  collections?: EC[] | EntityCollectionsBuilder<EC>;
33
37
  views?: CMSView[] | CMSViewsBuilder;
34
38
  userConfigPersistence?: UserConfigurationPersistence;
35
39
  plugins?: FireCMSPlugin[];
36
- dataSource: DataSource;
40
+ dataSource: DataSourceDelegate;
37
41
  };
38
42
 
39
- export function useBuildNavigationContext<EC extends EntityCollection, UserType extends User>({
40
- basePath,
41
- baseCollectionPath,
42
- authController,
43
- collections: baseCollections,
44
- views: baseViews,
45
- userConfigPersistence,
46
- plugins,
47
- dataSource
48
- }: BuildNavigationContextProps<EC, UserType>): NavigationContext {
43
+ export function useBuildNavigationController<EC extends EntityCollection, UserType extends User>({
44
+ basePath = DEFAULT_BASE_PATH,
45
+ baseCollectionPath = DEFAULT_COLLECTION_PATH,
46
+ authController,
47
+ collections: baseCollections,
48
+ views: baseViews,
49
+ userConfigPersistence,
50
+ plugins,
51
+ dataSource
52
+ }: BuildNavigationContextProps<EC, UserType>): NavigationController {
49
53
 
50
54
  const location = useLocation();
51
55
 
@@ -131,7 +135,7 @@ export function useBuildNavigationContext<EC extends EntityCollection, UserType
131
135
 
132
136
  setNavigationLoading(false);
133
137
  setInitialised(true);
134
- }, [baseCollections, authController.user, authController.initialLoading, dataSource, plugins, baseViews, computeTopNavigation]);
138
+ }, [baseCollections, authController.user, authController.initialLoading, plugins, baseViews, computeTopNavigation]);
135
139
 
136
140
  useEffect(() => {
137
141
  refreshNavigation();
@@ -288,7 +292,7 @@ function filterOutNotAllowedCollections(resolvedCollections: EntityCollection[],
288
292
  });
289
293
  }
290
294
 
291
- async function resolveCollections(collections: undefined | EntityCollection[] | EntityCollectionsBuilder<any>, authController: AuthController, dataSource: DataSource, plugins?: FireCMSPlugin[]) {
295
+ async function resolveCollections(collections: undefined | EntityCollection[] | EntityCollectionsBuilder<any>, authController: AuthController, dataSource: DataSourceDelegate, plugins?: FireCMSPlugin[]) {
292
296
  let resolvedCollections: EntityCollection[] = [];
293
297
  if (typeof collections === "function") {
294
298
  resolvedCollections = await collections({
@@ -312,7 +316,7 @@ async function resolveCollections(collections: undefined | EntityCollection[] |
312
316
  return resolvedCollections;
313
317
  }
314
318
 
315
- async function resolveCMSViews(baseViews: CMSView[] | CMSViewsBuilder | undefined, authController: AuthController, dataSource: DataSource) {
319
+ async function resolveCMSViews(baseViews: CMSView[] | CMSViewsBuilder | undefined, authController: AuthController, dataSource: DataSourceDelegate) {
316
320
  let resolvedViews: CMSView[] = [];
317
321
  if (typeof baseViews === "function") {
318
322
  resolvedViews = await baseViews({
@@ -2,7 +2,7 @@ import { useCallback, useEffect, useRef } from "react";
2
2
  import {
3
3
  EntityCollection,
4
4
  EntitySidePanelProps,
5
- NavigationContext,
5
+ NavigationController,
6
6
  SideDialogPanelProps,
7
7
  SideDialogsController,
8
8
  SideEntityController
@@ -23,7 +23,7 @@ export function getEntityViewWidth(props: EntitySidePanelProps<any>, small: bool
23
23
  return !mainViewSelected ? `calc(${ADDITIONAL_TAB_WIDTH} + ${resolvedWidth ?? FORM_CONTAINER_WIDTH})` : resolvedWidth ?? FORM_CONTAINER_WIDTH
24
24
  }
25
25
 
26
- export const useBuildSideEntityController = (navigation: NavigationContext,
26
+ export const useBuildSideEntityController = (navigation: NavigationController,
27
27
  sideDialogsController: SideDialogsController): SideEntityController => {
28
28
 
29
29
  const location = useLocation();
@@ -142,7 +142,7 @@ export function buildSidePanelsFromUrl(path: string, collections: EntityCollecti
142
142
  return sidePanels;
143
143
  }
144
144
 
145
- const propsToSidePanel = (props: EntitySidePanelProps<any>, navigation: NavigationContext, smallLayout: boolean): SideDialogPanelProps => {
145
+ const propsToSidePanel = (props: EntitySidePanelProps<any>, navigation: NavigationController, smallLayout: boolean): SideDialogPanelProps => {
146
146
 
147
147
  const collectionPath = removeInitialAndTrailingSlashes(props.path);
148
148
  const newPath = props.entityId
@@ -4,7 +4,7 @@ import { useMemo } from "react";
4
4
  import { Entity, EntityCollection, EntityReference, ResolvedProperty } from "../../types";
5
5
 
6
6
  import { getReferencePreviewKeys, getValueInPath, resolveCollection } from "../../util";
7
- import { useEntityFetch, useFireCMSContext, useNavigationContext, useSideEntityController } from "../../hooks";
7
+ import { useEntityFetch, useFireCMSContext, useNavigationController, useSideEntityController } from "../../hooks";
8
8
  import { PropertyPreview } from "../PropertyPreview";
9
9
  import { PreviewSize } from "../PropertyPreviewProps";
10
10
  import { SkeletonPropertyComponent } from "../property_previews/SkeletonPropertyComponent";
@@ -61,9 +61,9 @@ function ReferencePreviewInternal<M extends Record<string, any>>({
61
61
  }: ReferencePreviewProps) {
62
62
 
63
63
  const context = useFireCMSContext();
64
- const navigationContext = useNavigationContext();
64
+ const navigationController = useNavigationController();
65
65
 
66
- const collection = navigationContext.getCollection<EntityCollection<M>>(reference.path);
66
+ const collection = navigationController.getCollection<EntityCollection<M>>(reference.path);
67
67
  if (!collection) {
68
68
  if (context.components?.missingReference) {
69
69
  return <context.components.missingReference path={reference.path}/>;
@@ -8,7 +8,7 @@ import { ResolvedEntityCollection } from "./resolved_entities";
8
8
  export interface FetchEntityProps<M extends Record<string, any> = any> {
9
9
  path: string;
10
10
  entityId: string;
11
- collection: EntityCollection<M>
11
+ collection?: EntityCollection<M>
12
12
  }
13
13
 
14
14
  /**
@@ -26,7 +26,7 @@ export type ListenEntityProps<M extends Record<string, any> = any> =
26
26
  */
27
27
  export interface FetchCollectionProps<M extends Record<string, any> = any> {
28
28
  path: string;
29
- collection: EntityCollection<M> | ResolvedEntityCollection<M>;
29
+ collection?: EntityCollection<M> | ResolvedEntityCollection<M>;
30
30
  filter?: FilterValues<Extract<keyof M, string>>,
31
31
  limit?: number;
32
32
  startAfter?: any[];
@@ -53,7 +53,7 @@ export interface SaveEntityProps<M extends Record<string, any> = any> {
53
53
  values: Partial<EntityValues<M>>;
54
54
  entityId?: string; // can be empty for new entities
55
55
  previousValues?: Partial<EntityValues<M>>;
56
- collection: EntityCollection<M> | ResolvedEntityCollection<M>;
56
+ collection?: EntityCollection<M> | ResolvedEntityCollection<M>;
57
57
  status: EntityStatus;
58
58
  }
59
59
 
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
  import { User } from "./user";
3
3
  import { AuthController } from "./auth";
4
- import { DataSource } from "./datasource";
4
+ import { DataSource, DataSourceDelegate } from "./datasource";
5
5
  import { EntityCollection, EntityCustomView } from "./collections";
6
6
  import { CMSView } from "./navigation";
7
7
  import { FireCMSContext } from "./firecms_context";
@@ -26,7 +26,7 @@ import { CMSAnalyticsEvent } from "./analytics";
26
26
  export type EntityCollectionsBuilder<EC extends EntityCollection = EntityCollection> = (params: {
27
27
  user: User | null,
28
28
  authController: AuthController,
29
- dataSource: DataSource
29
+ dataSource: DataSourceDelegate
30
30
  }) => EC[] | Promise<EC[]>;
31
31
 
32
32
  /**
@@ -41,7 +41,7 @@ export type EntityCollectionsBuilder<EC extends EntityCollection = EntityCollect
41
41
  export type CMSViewsBuilder = (params: {
42
42
  user: User | null,
43
43
  authController: AuthController,
44
- dataSource: DataSource
44
+ dataSource: DataSourceDelegate
45
45
  }) => CMSView[] | Promise<CMSView[]>;
46
46
 
47
47
  /**
@@ -112,7 +112,7 @@ export type FireCMSProps<UserType extends User, EC extends EntityCollection> = {
112
112
  /**
113
113
  * Connector to your database
114
114
  */
115
- dataSource: DataSource;
115
+ dataSourceDelegate: DataSourceDelegate;
116
116
 
117
117
  /**
118
118
  * Connector to your file upload/fetch implementation
@@ -1,7 +1,7 @@
1
1
  import { Locale } from "./locales";
2
2
  import { DataSource } from "./datasource";
3
3
  import { StorageSource } from "./storage";
4
- import { NavigationContext } from "./navigation";
4
+ import { NavigationController } from "./navigation";
5
5
  import { SideEntityController } from "./side_entity_controller";
6
6
  import { AuthController } from "./auth";
7
7
  import { EntityLinkBuilder } from "./entity_link_builder";
@@ -50,7 +50,7 @@ export type FireCMSContext<UserType extends User = User, AuthControllerType exte
50
50
  * attributes.
51
51
  * @see useNavigation
52
52
  */
53
- navigation: NavigationContext;
53
+ navigation: NavigationController;
54
54
 
55
55
  /**
56
56
  * Controller to open the side dialog displaying entity forms
@@ -2,11 +2,11 @@ import { EntityCollection } from "./collections";
2
2
  import { EntityReference } from "./entities";
3
3
 
4
4
  /**
5
- * Context that includes the resolved navigation and utility methods and
5
+ * Controller that includes the resolved navigation and utility methods and
6
6
  * attributes.
7
7
  * @group Models
8
8
  */
9
- export type NavigationContext = {
9
+ export type NavigationController = {
10
10
 
11
11
  /**
12
12
  * List of the mapped collections in the CMS.
@@ -1,14 +0,0 @@
1
- import { AuthController, CMSView, CMSViewsBuilder, DataSource, EntityCollection, EntityCollectionsBuilder, FireCMSPlugin, NavigationContext, User, UserConfigurationPersistence } from "../types";
2
- type BuildNavigationContextProps<EC extends EntityCollection, UserType extends User> = {
3
- basePath: string;
4
- baseCollectionPath: string;
5
- authController: AuthController<UserType>;
6
- collections?: EC[] | EntityCollectionsBuilder<EC>;
7
- views?: CMSView[] | CMSViewsBuilder;
8
- userConfigPersistence?: UserConfigurationPersistence;
9
- plugins?: FireCMSPlugin[];
10
- dataSource: DataSource;
11
- };
12
- export declare function useBuildNavigationContext<EC extends EntityCollection, UserType extends User>({ basePath, baseCollectionPath, authController, collections: baseCollections, views: baseViews, userConfigPersistence, plugins, dataSource }: BuildNavigationContextProps<EC, UserType>): NavigationContext;
13
- export declare function getSidePanelKey(path: string, entityId?: string): string;
14
- export {};