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

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 (52) 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 +2 -1
  6. package/dist/hooks/useBuildDataSource.d.ts +3 -2
  7. package/dist/hooks/useBuildNavigationController.d.ts +14 -0
  8. package/dist/hooks/{useNavigationContext.d.ts → useNavigationController.d.ts} +2 -2
  9. package/dist/index.es.js +4910 -4915
  10. package/dist/index.es.js.map +1 -1
  11. package/dist/index.umd.js +12 -12
  12. package/dist/index.umd.js.map +1 -1
  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 +7 -26
  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/FireCMSAppBar.tsx +2 -2
  24. package/src/components/HomePage/DefaultHomePage.tsx +4 -4
  25. package/src/components/HomePage/FavouritesView.tsx +3 -3
  26. package/src/components/ReferenceSelectionInner.tsx +2 -2
  27. package/src/contexts/NavigationContext.tsx +2 -2
  28. package/src/core/Drawer.tsx +2 -2
  29. package/src/core/EntitySidePanel.tsx +4 -4
  30. package/src/core/FireCMS.tsx +11 -29
  31. package/src/core/NavigationRoutes.tsx +3 -3
  32. package/src/core/Scaffold.tsx +3 -3
  33. package/src/core/index.tsx +1 -1
  34. package/src/form/components/ReferenceWidget.tsx +4 -4
  35. package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +3 -3
  36. package/src/form/field_bindings/ReferenceFieldBinding.tsx +3 -3
  37. package/src/hooks/data/save.ts +11 -1
  38. package/src/hooks/data/useCollectionFetch.tsx +3 -3
  39. package/src/hooks/data/useEntityFetch.tsx +3 -3
  40. package/src/hooks/index.tsx +2 -1
  41. package/src/hooks/useBuildDataSource.ts +33 -22
  42. package/src/{internal/useBuildNavigationContext.tsx → hooks/useBuildNavigationController.tsx} +20 -17
  43. package/src/hooks/useFireCMSContext.tsx +2 -2
  44. package/src/hooks/{useNavigationContext.tsx → useNavigationController.tsx} +3 -3
  45. package/src/hooks/useReferenceDialog.tsx +2 -2
  46. package/src/internal/useBuildSideEntityController.tsx +3 -3
  47. package/src/preview/components/ReferencePreview.tsx +3 -3
  48. package/src/types/datasource.ts +3 -3
  49. package/src/types/firecms.tsx +9 -29
  50. package/src/types/firecms_context.tsx +2 -2
  51. package/src/types/navigation.ts +2 -2
  52. package/dist/internal/useBuildNavigationContext.d.ts +0 -14
@@ -1,4 +1,4 @@
1
- import { EntityCollection, EntitySidePanelProps, NavigationContext, SideDialogsController, SideEntityController } from "../types";
1
+ import { EntityCollection, EntitySidePanelProps, NavigationController, SideDialogsController, SideEntityController } from "../types";
2
2
  export declare function getEntityViewWidth(props: EntitySidePanelProps<any>, small: boolean): string;
3
- export declare const useBuildSideEntityController: (navigation: NavigationContext, sideDialogsController: SideDialogsController) => SideEntityController;
3
+ export declare const useBuildSideEntityController: (navigation: NavigationController, sideDialogsController: SideDialogsController) => SideEntityController;
4
4
  export declare function buildSidePanelsFromUrl(path: string, collections: EntityCollection[], newFlag: boolean): EntitySidePanelProps<any>[];
@@ -7,7 +7,7 @@ import { ResolvedEntityCollection } from "./resolved_entities";
7
7
  export interface FetchEntityProps<M extends Record<string, any> = any> {
8
8
  path: string;
9
9
  entityId: string;
10
- collection: EntityCollection<M>;
10
+ collection?: EntityCollection<M>;
11
11
  }
12
12
  /**
13
13
  * @group Datasource
@@ -21,7 +21,7 @@ export type ListenEntityProps<M extends Record<string, any> = any> = FetchEntity
21
21
  */
22
22
  export interface FetchCollectionProps<M extends Record<string, any> = any> {
23
23
  path: string;
24
- collection: EntityCollection<M> | ResolvedEntityCollection<M>;
24
+ collection?: EntityCollection<M> | ResolvedEntityCollection<M>;
25
25
  filter?: FilterValues<Extract<keyof M, string>>;
26
26
  limit?: number;
27
27
  startAfter?: any[];
@@ -44,7 +44,7 @@ export interface SaveEntityProps<M extends Record<string, any> = any> {
44
44
  values: Partial<EntityValues<M>>;
45
45
  entityId?: string;
46
46
  previousValues?: Partial<EntityValues<M>>;
47
- collection: EntityCollection<M> | ResolvedEntityCollection<M>;
47
+ collection?: EntityCollection<M> | ResolvedEntityCollection<M>;
48
48
  status: EntityStatus;
49
49
  }
50
50
  /**
@@ -1,9 +1,9 @@
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
- import { CMSView } from "./navigation";
6
+ import { CMSView, NavigationController } from "./navigation";
7
7
  import { FireCMSContext } from "./firecms_context";
8
8
  import { PropertyConfig } from "./property_config";
9
9
  import { Locale } from "./locales";
@@ -25,7 +25,7 @@ import { CMSAnalyticsEvent } from "./analytics";
25
25
  export type EntityCollectionsBuilder<EC extends EntityCollection = EntityCollection> = (params: {
26
26
  user: User | null;
27
27
  authController: AuthController;
28
- dataSource: DataSource;
28
+ dataSource: DataSourceDelegate;
29
29
  }) => EC[] | Promise<EC[]>;
30
30
  /**
31
31
  * Use this callback to build custom views dynamically.
@@ -39,7 +39,7 @@ export type EntityCollectionsBuilder<EC extends EntityCollection = EntityCollect
39
39
  export type CMSViewsBuilder = (params: {
40
40
  user: User | null;
41
41
  authController: AuthController;
42
- dataSource: DataSource;
42
+ dataSource: DataSourceDelegate;
43
43
  }) => CMSView[] | Promise<CMSView[]>;
44
44
  /**
45
45
  * @group Models
@@ -62,18 +62,6 @@ export type FireCMSProps<UserType extends User, EC extends EntityCollection> = {
62
62
  */
63
63
  loading: boolean;
64
64
  }) => React.ReactNode;
65
- /**
66
- * List of the mapped collections in the CMS.
67
- * Each entry relates to a collection in the root database.
68
- * Each of the navigation entries in this field
69
- * generates an entry in the main menu.
70
- */
71
- collections?: EC[] | EntityCollectionsBuilder<EC>;
72
- /**
73
- * Custom additional views created by the developer, added to the main
74
- * navigation
75
- */
76
- views?: CMSView[] | CMSViewsBuilder;
77
65
  /**
78
66
  * Record of custom form fields to be used in the CMS.
79
67
  * You can use the key to reference the custom field in
@@ -110,17 +98,10 @@ export type FireCMSProps<UserType extends User, EC extends EntityCollection> = {
110
98
  */
111
99
  authController: AuthController<UserType>;
112
100
  /**
113
- * Path under the navigation routes of the CMS will be created. Defaults to `/`.
114
- * Internally FireCMS uses `react-router` to create the routes, the base path is attached to the
115
- * `BrowserRouter` component. If you are using FireCMS in a subpath of your website, you can use
116
- * this prop to specify the base path.
117
- */
118
- basePath?: string;
119
- /**
120
- * Path under the collection routes of the CMS will be created.
121
- * Defaults to `/c`.
101
+ * Controller in charge of managing the collections and views of the CMS.
102
+ * @see {@link useBuildNavigationController}
122
103
  */
123
- baseCollectionPath?: string;
104
+ navigationController: NavigationController;
124
105
  /**
125
106
  * Use this controller to access the configuration that is stored locally,
126
107
  * and not defined in code
@@ -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";
@@ -44,7 +44,7 @@ export type FireCMSContext<UserType extends User = User, AuthControllerType exte
44
44
  * attributes.
45
45
  * @see useNavigation
46
46
  */
47
- navigation: NavigationContext;
47
+ navigation: NavigationController;
48
48
  /**
49
49
  * Controller to open the side dialog displaying entity forms
50
50
  * @see useSideEntityController
@@ -1,11 +1,11 @@
1
1
  import { EntityCollection } from "./collections";
2
2
  import { EntityReference } from "./entities";
3
3
  /**
4
- * Context that includes the resolved navigation and utility methods and
4
+ * Controller that includes the resolved navigation and utility methods and
5
5
  * attributes.
6
6
  * @group Models
7
7
  */
8
- export type NavigationContext = {
8
+ export type NavigationController = {
9
9
  /**
10
10
  * List of the mapped collections in the CMS.
11
11
  * Each entry relates to a collection in the root database.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firecms/core",
3
- "version": "3.0.0-alpha.44",
3
+ "version": "3.0.0-alpha.45",
4
4
  "description": "Awesome Firebase/Firestore-based headless open-source CMS",
5
5
  "funding": {
6
6
  "url": "https://github.com/sponsors/firecmsco"
@@ -133,7 +133,7 @@
133
133
  "dist",
134
134
  "src"
135
135
  ],
136
- "gitHead": "50d78c13f520ad741773a85b155a6644423a14d1",
136
+ "gitHead": "8a8223081bd7f76d655564ca995dca085f22d727",
137
137
  "publishConfig": {
138
138
  "access": "public"
139
139
  }
@@ -4,7 +4,7 @@ import { CollectionSize, Entity, EntityCollection, EntityReference, FilterValues
4
4
 
5
5
  import { getPreviewSizeFrom } from "../../../preview/util";
6
6
  import { getReferenceFrom } from "../../../util";
7
- import { useFireCMSContext, useNavigationContext, useReferenceDialog } from "../../../hooks";
7
+ import { useFireCMSContext, useNavigationController, useReferenceDialog } from "../../../hooks";
8
8
  import { ErrorView } from "../../ErrorView";
9
9
  import { Button } from "../../../ui/Button";
10
10
 
@@ -24,9 +24,9 @@ type TableReferenceFieldProps = {
24
24
  export function TableReferenceField(props: TableReferenceFieldProps) {
25
25
 
26
26
  const context = useFireCMSContext();
27
- const navigationContext = useNavigationContext();
27
+ const navigationController = useNavigationController();
28
28
  const { path } = props;
29
- const collection = navigationContext.getCollection<EntityCollection>(path);
29
+ const collection = navigationController.getCollection<EntityCollection>(path);
30
30
  if (!collection) {
31
31
  if (context.components?.missingReference) {
32
32
  return <context.components.missingReference path={path}/>;
@@ -3,7 +3,7 @@ import { VirtualTableWhereFilterOp } from "../../VirtualTable";
3
3
  import { Entity, EntityCollection, EntityReference } from "../../../types";
4
4
  import { ReferencePreview } from "../../../preview";
5
5
  import { getReferenceFrom } from "../../../util";
6
- import { useNavigationContext, useReferenceDialog } from "../../../hooks";
6
+ import { useNavigationController, useReferenceDialog } from "../../../hooks";
7
7
  import { Button, Select, SelectItem } from "../../../ui";
8
8
 
9
9
  interface ReferenceFilterFieldProps {
@@ -94,9 +94,9 @@ export function ReferenceFilterField({
94
94
  }
95
95
  }
96
96
 
97
- const navigationContext = useNavigationContext();
97
+ const navigationController = useNavigationController();
98
98
  const collection: EntityCollection | undefined = useMemo(() => {
99
- return path ? navigationContext.getCollection(path) : undefined;
99
+ return path ? navigationController.getCollection(path) : undefined;
100
100
  }, [path]);
101
101
 
102
102
  const onSingleEntitySelected = (entity: Entity<any>) => {
@@ -1,6 +1,6 @@
1
1
  import React, { useCallback, useMemo } from "react";
2
2
 
3
- import { useCollectionFetch, useDataSource, useNavigationContext } from "../../hooks";
3
+ import { useCollectionFetch, useDataSource, useNavigationController } from "../../hooks";
4
4
  import { useDataOrder } from "../../hooks/data/useDataOrder";
5
5
  import { Entity, EntityCollection, FilterValues, SelectedCellProps, TableController, User } from "../../types";
6
6
  import { useDebouncedData } from "./useDebouncedData";
@@ -45,7 +45,7 @@ export function useEntityCollectionTableController<M extends Record<string, any>
45
45
 
46
46
  const [popupCell, setPopupCell] = React.useState<SelectedCellProps<M> | undefined>(undefined);
47
47
 
48
- const navigation = useNavigationContext();
48
+ const navigation = useNavigationController();
49
49
  const dataSource = useDataSource();
50
50
  const resolvedPath = useMemo(() => navigation.resolveAliasesFrom(fullPath), [fullPath, navigation.resolveAliasesFrom]);
51
51
 
@@ -42,7 +42,7 @@ import {
42
42
  useDataSource,
43
43
  useFireCMSContext,
44
44
  useLargeLayout,
45
- useNavigationContext,
45
+ useNavigationController,
46
46
  useSideEntityController
47
47
  } from "../../hooks";
48
48
  import { useUserConfigurationPersistence } from "../../hooks/useUserConfigurationPersistence";
@@ -109,7 +109,7 @@ export const EntityCollectionView = React.memo(
109
109
  ) {
110
110
 
111
111
  const dataSource = useDataSource();
112
- const navigation = useNavigationContext();
112
+ const navigation = useNavigationController();
113
113
  const sideEntityController = useSideEntityController();
114
114
  const authController = useAuthController();
115
115
  const userConfigPersistence = useUserConfigurationPersistence();
@@ -304,6 +304,7 @@ export const EntityCollectionView = React.memo(
304
304
 
305
305
  return saveEntityWithCallbacks({
306
306
  ...saveProps,
307
+ collection,
307
308
  callbacks: collection.callbacks,
308
309
  dataSource,
309
310
  context,
@@ -668,7 +669,7 @@ function EntitiesCount({
668
669
  }) {
669
670
 
670
671
  const dataSource = useDataSource();
671
- const navigation = useNavigationContext();
672
+ const navigation = useNavigationController();
672
673
  const [count, setCount] = useState<number | undefined>(undefined);
673
674
  const [error, setError] = useState<Error | undefined>(undefined);
674
675
 
@@ -3,7 +3,7 @@ import React from "react";
3
3
  import { Link as ReactLink } from "react-router-dom";
4
4
  import { ErrorBoundary } from "../components";
5
5
  import { Avatar, cn, IconButton, Menu, MenuItem, Typography } from "../ui";
6
- import { useAuthController, useLargeLayout, useModeController, useNavigationContext } from "../hooks";
6
+ import { useAuthController, useLargeLayout, useModeController, useNavigationController } from "../hooks";
7
7
  import { DarkModeIcon, LightModeIcon, LogoutIcon } from "../icons";
8
8
  import { Skeleton } from "../ui/Skeleton";
9
9
  import { User } from "../types";
@@ -50,7 +50,7 @@ export const FireCMSAppBar = function FireCMSAppBar({
50
50
  style,
51
51
  user: userProp
52
52
  }: FireCMSAppBarProps) {
53
- const navigation = useNavigationContext();
53
+ const navigation = useNavigationController();
54
54
 
55
55
  const authController = useAuthController();
56
56
  const {
@@ -1,6 +1,6 @@
1
1
  import React, { useCallback, useEffect, useState } from "react";
2
2
 
3
- import { useFireCMSContext, useNavigationContext } from "../../hooks";
3
+ import { useFireCMSContext, useNavigationController } from "../../hooks";
4
4
  import { PluginGenericProps, PluginHomePageAdditionalCardsProps } from "../../types";
5
5
 
6
6
  import { toArray } from "../../util/arrays";
@@ -35,9 +35,9 @@ export function DefaultHomePage({
35
35
  }) {
36
36
 
37
37
  const context = useFireCMSContext();
38
- const navigationContext = useNavigationContext();
38
+ const navigationController = useNavigationController();
39
39
 
40
- if (!navigationContext.topLevelNavigation)
40
+ if (!navigationController.topLevelNavigation)
41
41
  throw Error("Navigation not ready in FireCMSHomePage");
42
42
 
43
43
  const {
@@ -49,7 +49,7 @@ export function DefaultHomePage({
49
49
  const {
50
50
  navigationEntries,
51
51
  groups
52
- } = navigationContext.topLevelNavigation;
52
+ } = navigationController.topLevelNavigation;
53
53
 
54
54
  const [filteredUrls, setFilteredUrls] = useState<string[] | null>(null);
55
55
 
@@ -1,5 +1,5 @@
1
1
  import { useNavigate } from "react-router-dom";
2
- import { useNavigationContext } from "../../hooks";
2
+ import { useNavigationController } from "../../hooks";
3
3
  import { useUserConfigurationPersistence } from "../../hooks/useUserConfigurationPersistence";
4
4
  import { TopNavigationEntry } from "../../types";
5
5
  import { Chip, Collapse } from "../../ui";
@@ -46,14 +46,14 @@ function NavigationChip({ entry }: { entry: TopNavigationEntry }) {
46
46
 
47
47
  export function FavouritesView({ hidden }: { hidden: boolean }) {
48
48
 
49
- const navigationContext = useNavigationContext();
49
+ const navigationController = useNavigationController();
50
50
  const userConfigurationPersistence = useUserConfigurationPersistence();
51
51
 
52
52
  if (!userConfigurationPersistence)
53
53
  return null;
54
54
 
55
55
  const favouriteCollections = (userConfigurationPersistence?.favouritePaths ?? [])
56
- .map((path) => navigationContext.topLevelNavigation?.navigationEntries.find((entry) => entry.path === path))
56
+ .map((path) => navigationController.topLevelNavigation?.navigationEntries.find((entry) => entry.path === path))
57
57
  .filter(Boolean) as TopNavigationEntry[];
58
58
 
59
59
  return <Collapse in={favouriteCollections.length > 0}>
@@ -8,7 +8,7 @@ import {
8
8
  useDataSource,
9
9
  useFireCMSContext,
10
10
  useLargeLayout,
11
- useNavigationContext,
11
+ useNavigationController,
12
12
  useSideEntityController
13
13
  } from "../hooks";
14
14
  import { ErrorView } from "./ErrorView";
@@ -101,7 +101,7 @@ export function ReferenceSelectionInner<M extends Record<string, any>>(
101
101
 
102
102
  const sideDialogContext = useSideDialogContext();
103
103
  const sideEntityController = useSideEntityController();
104
- const navigation = useNavigationContext();
104
+ const navigation = useNavigationController();
105
105
  const context = useFireCMSContext();
106
106
 
107
107
  const fullPath = navigation.resolveAliasesFrom(pathInput);
@@ -1,4 +1,4 @@
1
1
  import React from "react";
2
- import { NavigationContext } from "../types";
2
+ import { NavigationController } from "../types";
3
3
 
4
- export const NavigationContextInstance = React.createContext<NavigationContext>({} as NavigationContext);
4
+ export const NavigationContext = React.createContext<NavigationController>({} as NavigationController);
@@ -1,6 +1,6 @@
1
1
  import React, { useCallback } from "react";
2
2
 
3
- import { useFireCMSContext, useLargeLayout, useNavigationContext } from "../hooks";
3
+ import { useFireCMSContext, useLargeLayout, useNavigationController } from "../hooks";
4
4
 
5
5
  import { NavLink } from "react-router-dom";
6
6
  import { CMSAnalyticsEvent, TopNavigationEntry, TopNavigationResult } from "../types";
@@ -28,7 +28,7 @@ export function Drawer({
28
28
  }: DrawerProps) {
29
29
 
30
30
  const context = useFireCMSContext();
31
- const navigation = useNavigationContext();
31
+ const navigation = useNavigationController();
32
32
 
33
33
  const tooltipsOpen = hovered && !drawerOpen;
34
34
  const largeLayout = useLargeLayout();
@@ -1,7 +1,7 @@
1
1
  import React, { useCallback, useEffect, useMemo } from "react";
2
2
 
3
3
  import { EntitySidePanelProps } from "../types";
4
- import { useNavigationContext } from "../hooks";
4
+ import { useNavigationController } from "../hooks";
5
5
 
6
6
  import { ErrorBoundary } from "../components";
7
7
  import { EntityView } from "../internal/EntityView";
@@ -23,21 +23,21 @@ export function EntitySidePanel(props: EntitySidePanelProps) {
23
23
  setBlockedNavigationMessage
24
24
  } = useSideDialogContext();
25
25
 
26
- const navigationContext = useNavigationContext();
26
+ const navigationController = useNavigationController();
27
27
 
28
28
  const collection = useMemo(() => {
29
29
  if (!props) return undefined;
30
30
  let usedCollection = props.collection;
31
31
 
32
32
  if (!usedCollection) {
33
- usedCollection = navigationContext.getCollection(props.path, props.entityId);
33
+ usedCollection = navigationController.getCollection(props.path, props.entityId);
34
34
  if (!usedCollection) {
35
35
  console.error("ERROR: No collection found in path `", props.path, "`. Entity id: ", props.entityId);
36
36
  throw Error("ERROR: No collection found in path `" + props.path + "`. Make sure you have defined a collection for this path in the root navigation.");
37
37
  }
38
38
  }
39
39
  return usedCollection;
40
- }, [navigationContext, props]);
40
+ }, [navigationController, props]);
41
41
 
42
42
  useEffect(() => {
43
43
  function beforeunload(e: any) {
@@ -2,25 +2,21 @@ import React, { useMemo } from "react";
2
2
 
3
3
  import { EntityCollection, FireCMSContext, FireCMSPlugin, FireCMSProps, User } from "../types";
4
4
  import { BreadcrumbsProvider } from "../contexts/BreacrumbsContext";
5
- import { ModeControllerContext } from "../contexts/ModeController";
5
+ import { AuthControllerContext, ModeControllerContext } from "../contexts";
6
6
  import { useBuildSideEntityController } from "../internal/useBuildSideEntityController";
7
- import { useBuildNavigationContext } from "../internal/useBuildNavigationContext";
8
- import { useBuildSideDialogsController } from "../internal/useBuildSideDialogsController";
9
7
  import { FireCMSContextInstance, useFireCMSContext, useModeController } from "../hooks";
8
+ import { useBuildSideDialogsController } from "../internal/useBuildSideDialogsController";
10
9
  import { ErrorView } from "../components";
11
10
  import { StorageSourceContext } from "../contexts/StorageSourceContext";
12
11
  import { UserConfigurationPersistenceContext } from "../contexts/UserConfigurationPersistenceContext";
13
12
  import { DataSourceContext } from "../contexts/DataSourceContext";
14
13
  import { SideEntityControllerContext } from "../contexts/SideEntityControllerContext";
15
- import { NavigationContextInstance } from "../contexts/NavigationContext";
16
- import { AuthControllerContext } from "../contexts/AuthControllerContext";
14
+ import { NavigationContext } from "../contexts/NavigationContext";
17
15
  import { SideDialogsControllerContext } from "../contexts/SideDialogsControllerContext";
18
16
  import { useLocaleConfig } from "../internal/useLocaleConfig";
19
17
  import { CenteredView } from "../ui";
20
18
  import { DialogsProvider } from "../contexts/DialogsProvider";
21
19
 
22
- const DEFAULT_BASE_PATH = "/";
23
- const DEFAULT_COLLECTION_PATH = "/c";
24
20
 
25
21
  /**
26
22
  * If you are using independent components of the CMS
@@ -39,8 +35,6 @@ export function FireCMS<UserType extends User, EC extends EntityCollection>(prop
39
35
  const modeController = useModeController();
40
36
  const {
41
37
  children,
42
- collections,
43
- views,
44
38
  entityLinkBuilder,
45
39
  userConfigPersistence,
46
40
  dateTimeFormat,
@@ -48,8 +42,7 @@ export function FireCMS<UserType extends User, EC extends EntityCollection>(prop
48
42
  authController,
49
43
  storageSource,
50
44
  dataSource,
51
- basePath = DEFAULT_BASE_PATH,
52
- baseCollectionPath = DEFAULT_COLLECTION_PATH,
45
+ navigationController,
53
46
  plugins,
54
47
  onAnalyticsEvent,
55
48
  propertyConfigs,
@@ -59,23 +52,12 @@ export function FireCMS<UserType extends User, EC extends EntityCollection>(prop
59
52
 
60
53
  useLocaleConfig(locale);
61
54
 
62
- const navigation = useBuildNavigationContext({
63
- basePath,
64
- baseCollectionPath,
65
- authController,
66
- collections,
67
- views,
68
- userConfigPersistence,
69
- dataSource,
70
- plugins
71
- });
72
-
73
55
  const sideDialogsController = useBuildSideDialogsController();
74
- const sideEntityController = useBuildSideEntityController(navigation, sideDialogsController);
56
+ const sideEntityController = useBuildSideEntityController(navigationController, sideDialogsController);
75
57
 
76
58
  const pluginsLoading = plugins?.some(p => p.loading) ?? false;
77
59
 
78
- const loading = authController.initialLoading || navigation.loading || pluginsLoading;
60
+ const loading = authController.initialLoading || navigationController.loading || pluginsLoading;
79
61
 
80
62
  const context: Partial<FireCMSContext> = useMemo(() => ({
81
63
  entityLinkBuilder,
@@ -88,12 +70,12 @@ export function FireCMS<UserType extends User, EC extends EntityCollection>(prop
88
70
  components
89
71
  }), [dateTimeFormat, locale, plugins, entityViews, propertyConfigs, components]);
90
72
 
91
- if (navigation.navigationLoadingError) {
73
+ if (navigationController.navigationLoadingError) {
92
74
  return (
93
75
  <CenteredView maxWidth={"md"} fullScreen={true}>
94
76
  <ErrorView
95
77
  title={"Error loading navigation"}
96
- error={navigation.navigationLoadingError}/>
78
+ error={navigationController.navigationLoadingError}/>
97
79
  </CenteredView>
98
80
  );
99
81
  }
@@ -123,8 +105,8 @@ export function FireCMS<UserType extends User, EC extends EntityCollection>(prop
123
105
  value={sideDialogsController}>
124
106
  <SideEntityControllerContext.Provider
125
107
  value={sideEntityController}>
126
- <NavigationContextInstance.Provider
127
- value={navigation}>
108
+ <NavigationContext.Provider
109
+ value={navigationController}>
128
110
  <BreadcrumbsProvider>
129
111
  <DialogsProvider>
130
112
  <FireCMSInternal
@@ -133,7 +115,7 @@ export function FireCMS<UserType extends User, EC extends EntityCollection>(prop
133
115
  </FireCMSInternal>
134
116
  </DialogsProvider>
135
117
  </BreadcrumbsProvider>
136
- </NavigationContextInstance.Provider>
118
+ </NavigationContext.Provider>
137
119
  </SideEntityControllerContext.Provider>
138
120
  </SideDialogsControllerContext.Provider>
139
121
  </AuthControllerContext.Provider>
@@ -3,7 +3,7 @@ import React, { PropsWithChildren } from "react";
3
3
  import { Route, Routes, useLocation } from "react-router-dom";
4
4
  import { CMSView } from "../types";
5
5
  import { DefaultHomePage, EntityCollectionView, NotFoundPage } from "../components";
6
- import { useBreadcrumbsContext, useNavigationContext } from "../hooks";
6
+ import { useBreadcrumbsContext, useNavigationController } from "../hooks";
7
7
  import { toArray } from "../util/arrays";
8
8
  import equal from "react-fast-compare"
9
9
 
@@ -23,7 +23,7 @@ export type NavigationRoutesProps = {
23
23
  /**
24
24
  * This component is in charge of rendering
25
25
  * all the related routes (entity collection root views, custom views
26
- * or the home route) related to a {@link NavigationContext}.
26
+ * or the home route) related to a {@link NavigationController}.
27
27
  * This component needs a parent {@link FireCMS}
28
28
  *
29
29
  * @constructor
@@ -37,7 +37,7 @@ export const NavigationRoutes = React.memo<NavigationRoutesProps>(
37
37
  }: NavigationRoutesProps) {
38
38
 
39
39
  const location = useLocation();
40
- const navigation = useNavigationContext();
40
+ const navigation = useNavigationController();
41
41
 
42
42
  if (!navigation)
43
43
  return <></>;
@@ -3,7 +3,7 @@ import equal from "react-fast-compare"
3
3
  import { Link } from "react-router-dom";
4
4
 
5
5
  import { Drawer as DefaultDrawer, DrawerProps } from "./Drawer";
6
- import { useLargeLayout, useNavigationContext } from "../hooks";
6
+ import { useLargeLayout, useNavigationController } from "../hooks";
7
7
  import { CircularProgressCenter, ErrorBoundary, FireCMSAppBar, FireCMSAppBarProps, FireCMSLogo } from "../components";
8
8
  import { cn, IconButton, Sheet, Tooltip } from "../ui";
9
9
  import { ChevronLeftIcon, MenuIcon } from "../icons";
@@ -85,7 +85,7 @@ export const Scaffold = React.memo<PropsWithChildren<ScaffoldProps>>(
85
85
 
86
86
  const largeLayout = useLargeLayout();
87
87
 
88
- const navigation = useNavigationContext();
88
+ const navigation = useNavigationController();
89
89
  const [drawerOpen, setDrawerOpen] = React.useState(false);
90
90
  const [onHover, setOnHover] = React.useState(false);
91
91
 
@@ -171,7 +171,7 @@ function StyledDrawer(props: {
171
171
  onMouseLeave: () => void
172
172
  }) {
173
173
 
174
- const navigation = useNavigationContext();
174
+ const navigation = useNavigationController();
175
175
 
176
176
  const width = !props.displayed ? 0 : (props.open ? DRAWER_WIDTH : 72);
177
177
  const innerDrawer = <div
@@ -1,4 +1,4 @@
1
- export { FireCMS } from "./FireCMS";
1
+ export * from "./FireCMS";
2
2
 
3
3
  export type { ScaffoldProps } from "./Scaffold";
4
4
  export { Scaffold } from "./Scaffold";
@@ -7,7 +7,7 @@ import { LabelWithIcon } from "../components";
7
7
  import {
8
8
  useEntityFetch,
9
9
  useFireCMSContext,
10
- useNavigationContext,
10
+ useNavigationController,
11
11
  useReferenceDialog,
12
12
  useSideEntityController
13
13
  } from "../../hooks";
@@ -49,12 +49,12 @@ export function ReferenceWidget<M extends Record<string, any>>({
49
49
  }) {
50
50
 
51
51
  const fireCMSContext = useFireCMSContext();
52
- const navigationContext = useNavigationContext();
52
+ const navigationController = useNavigationController();
53
53
  const sideEntityController = useSideEntityController();
54
54
 
55
55
  const collection: EntityCollection | undefined = useMemo(() => {
56
- return navigationContext.getCollection(path);
57
- }, [path, navigationContext]);
56
+ return navigationController.getCollection(path);
57
+ }, [path, navigationController]);
58
58
 
59
59
  if (!collection) {
60
60
  throw Error(`Couldn't find the corresponding collection for the path: ${path}`);
@@ -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) {