@firecms/core 3.0.0-alpha.45 → 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.
- package/dist/hooks/index.d.ts +0 -2
- package/dist/index.es.js +10388 -10379
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +13 -13
- package/dist/index.umd.js.map +1 -1
- package/dist/types/firecms.d.ts +25 -6
- package/package.json +2 -2
- package/src/components/EntityCollectionView/EntityCollectionViewActions.tsx +3 -3
- package/src/core/FireCMS.tsx +28 -4
- package/src/hooks/index.tsx +0 -2
- package/src/{hooks → internal}/useBuildDataSource.ts +2 -4
- package/src/{hooks → internal}/useBuildNavigationController.tsx +2 -1
- package/src/types/firecms.tsx +27 -7
- /package/dist/{hooks → internal}/useBuildDataSource.d.ts +0 -0
- /package/dist/{hooks → internal}/useBuildNavigationController.d.ts +0 -0
package/dist/types/firecms.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { User } from "./user";
|
|
3
3
|
import { AuthController } from "./auth";
|
|
4
|
-
import {
|
|
4
|
+
import { DataSourceDelegate } from "./datasource";
|
|
5
5
|
import { EntityCollection, EntityCustomView } from "./collections";
|
|
6
|
-
import { CMSView
|
|
6
|
+
import { CMSView } from "./navigation";
|
|
7
7
|
import { FireCMSContext } from "./firecms_context";
|
|
8
8
|
import { PropertyConfig } from "./property_config";
|
|
9
9
|
import { Locale } from "./locales";
|
|
@@ -62,6 +62,18 @@ 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;
|
|
65
77
|
/**
|
|
66
78
|
* Record of custom form fields to be used in the CMS.
|
|
67
79
|
* You can use the key to reference the custom field in
|
|
@@ -88,7 +100,7 @@ export type FireCMSProps<UserType extends User, EC extends EntityCollection> = {
|
|
|
88
100
|
/**
|
|
89
101
|
* Connector to your database
|
|
90
102
|
*/
|
|
91
|
-
|
|
103
|
+
dataSourceDelegate: DataSourceDelegate;
|
|
92
104
|
/**
|
|
93
105
|
* Connector to your file upload/fetch implementation
|
|
94
106
|
*/
|
|
@@ -98,10 +110,17 @@ export type FireCMSProps<UserType extends User, EC extends EntityCollection> = {
|
|
|
98
110
|
*/
|
|
99
111
|
authController: AuthController<UserType>;
|
|
100
112
|
/**
|
|
101
|
-
*
|
|
102
|
-
*
|
|
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`.
|
|
103
122
|
*/
|
|
104
|
-
|
|
123
|
+
baseCollectionPath?: string;
|
|
105
124
|
/**
|
|
106
125
|
* Use this controller to access the configuration that is stored locally,
|
|
107
126
|
* and not defined in code
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firecms/core",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.46",
|
|
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": "
|
|
136
|
+
"gitHead": "53ef13adab3db13baeea2ad7953e37cf3552fd62",
|
|
137
137
|
"publishConfig": {
|
|
138
138
|
"access": "public"
|
|
139
139
|
}
|
|
@@ -111,11 +111,11 @@ export function EntityCollectionViewActions<M extends Record<string, any>>({
|
|
|
111
111
|
));
|
|
112
112
|
|
|
113
113
|
if (plugins) {
|
|
114
|
-
plugins.forEach(plugin => {
|
|
114
|
+
plugins.forEach((plugin, i) => {
|
|
115
115
|
if (plugin.collections?.CollectionActions) {
|
|
116
116
|
actions.push(...toArray(plugin.collections?.CollectionActions)
|
|
117
|
-
.map((Action,
|
|
118
|
-
<ErrorBoundary key={`plugin_actions_${i}`}>
|
|
117
|
+
.map((Action, j) => (
|
|
118
|
+
<ErrorBoundary key={`plugin_actions_${i}_${j}`}>
|
|
119
119
|
<Action {...actionProps} {...plugin.collections?.collectionActionsProps}/>
|
|
120
120
|
</ErrorBoundary>
|
|
121
121
|
)));
|
package/src/core/FireCMS.tsx
CHANGED
|
@@ -16,7 +16,8 @@ import { SideDialogsControllerContext } from "../contexts/SideDialogsControllerC
|
|
|
16
16
|
import { useLocaleConfig } from "../internal/useLocaleConfig";
|
|
17
17
|
import { CenteredView } from "../ui";
|
|
18
18
|
import { DialogsProvider } from "../contexts/DialogsProvider";
|
|
19
|
-
|
|
19
|
+
import { useBuildNavigationController } from "../internal/useBuildNavigationController";
|
|
20
|
+
import { useBuildDataSource } from "../internal/useBuildDataSource";
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
23
|
* If you are using independent components of the CMS
|
|
@@ -41,17 +42,40 @@ export function FireCMS<UserType extends User, EC extends EntityCollection>(prop
|
|
|
41
42
|
locale,
|
|
42
43
|
authController,
|
|
43
44
|
storageSource,
|
|
44
|
-
|
|
45
|
-
navigationController,
|
|
45
|
+
dataSourceDelegate,
|
|
46
46
|
plugins,
|
|
47
47
|
onAnalyticsEvent,
|
|
48
48
|
propertyConfigs,
|
|
49
49
|
entityViews,
|
|
50
|
-
components
|
|
50
|
+
components,
|
|
51
|
+
baseCollectionPath,
|
|
52
|
+
basePath,
|
|
53
|
+
collections,
|
|
54
|
+
views
|
|
51
55
|
} = props;
|
|
52
56
|
|
|
53
57
|
useLocaleConfig(locale);
|
|
54
58
|
|
|
59
|
+
const navigationController = useBuildNavigationController({
|
|
60
|
+
basePath,
|
|
61
|
+
baseCollectionPath,
|
|
62
|
+
authController,
|
|
63
|
+
collections,
|
|
64
|
+
views,
|
|
65
|
+
userConfigPersistence,
|
|
66
|
+
dataSource: dataSourceDelegate,
|
|
67
|
+
plugins
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Controller in charge of fetching and persisting data
|
|
72
|
+
*/
|
|
73
|
+
const dataSource = useBuildDataSource({
|
|
74
|
+
delegate: dataSourceDelegate,
|
|
75
|
+
propertyConfigs,
|
|
76
|
+
navigationController
|
|
77
|
+
});
|
|
78
|
+
|
|
55
79
|
const sideDialogsController = useBuildSideDialogsController();
|
|
56
80
|
const sideEntityController = useBuildSideEntityController(navigationController, sideDialogsController);
|
|
57
81
|
|
package/src/hooks/index.tsx
CHANGED
|
@@ -62,8 +62,6 @@ export function useBuildDataSource({
|
|
|
62
62
|
order
|
|
63
63
|
}: FetchCollectionProps<M>
|
|
64
64
|
): Promise<Entity<M>[]> => {
|
|
65
|
-
|
|
66
|
-
const collection = collectionProp ?? navigationController.getCollection(path);
|
|
67
65
|
return delegate.fetchCollection<M>({
|
|
68
66
|
path,
|
|
69
67
|
filter,
|
|
@@ -125,7 +123,7 @@ export function useBuildDataSource({
|
|
|
125
123
|
onError,
|
|
126
124
|
isCollectionGroup
|
|
127
125
|
});
|
|
128
|
-
}, [delegate])
|
|
126
|
+
}, [delegate, navigationController.getCollection])
|
|
129
127
|
: undefined,
|
|
130
128
|
|
|
131
129
|
/**
|
|
@@ -240,7 +238,7 @@ export function useBuildDataSource({
|
|
|
240
238
|
values: delegate.delegateToCMSModel(updatedFirestoreValues)
|
|
241
239
|
} as Entity<M>;
|
|
242
240
|
});
|
|
243
|
-
}, [delegate.saveEntity]),
|
|
241
|
+
}, [delegate.saveEntity, navigationController.getCollection]),
|
|
244
242
|
|
|
245
243
|
/**
|
|
246
244
|
* Delete an entity
|
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
resolvePermissions
|
|
25
25
|
} from "../util";
|
|
26
26
|
import { getParentReferencesFromPath } from "../util/parent_references_from_path";
|
|
27
|
+
import { useTraceUpdate } from "../util/useTraceUpdate";
|
|
27
28
|
|
|
28
29
|
const DEFAULT_BASE_PATH = "/";
|
|
29
30
|
const DEFAULT_COLLECTION_PATH = "/c";
|
|
@@ -134,7 +135,7 @@ export function useBuildNavigationController<EC extends EntityCollection, UserTy
|
|
|
134
135
|
|
|
135
136
|
setNavigationLoading(false);
|
|
136
137
|
setInitialised(true);
|
|
137
|
-
}, [baseCollections, authController.user, authController.initialLoading,
|
|
138
|
+
}, [baseCollections, authController.user, authController.initialLoading, plugins, baseViews, computeTopNavigation]);
|
|
138
139
|
|
|
139
140
|
useEffect(() => {
|
|
140
141
|
refreshNavigation();
|
package/src/types/firecms.tsx
CHANGED
|
@@ -3,7 +3,7 @@ import { User } from "./user";
|
|
|
3
3
|
import { AuthController } from "./auth";
|
|
4
4
|
import { DataSource, DataSourceDelegate } from "./datasource";
|
|
5
5
|
import { EntityCollection, EntityCustomView } from "./collections";
|
|
6
|
-
import { CMSView
|
|
6
|
+
import { CMSView } from "./navigation";
|
|
7
7
|
import { FireCMSContext } from "./firecms_context";
|
|
8
8
|
import { PropertyConfig } from "./property_config";
|
|
9
9
|
import { Locale } from "./locales";
|
|
@@ -67,6 +67,20 @@ export type FireCMSProps<UserType extends User, EC extends EntityCollection> = {
|
|
|
67
67
|
loading: boolean;
|
|
68
68
|
}) => React.ReactNode;
|
|
69
69
|
|
|
70
|
+
/**
|
|
71
|
+
* List of the mapped collections in the CMS.
|
|
72
|
+
* Each entry relates to a collection in the root database.
|
|
73
|
+
* Each of the navigation entries in this field
|
|
74
|
+
* generates an entry in the main menu.
|
|
75
|
+
*/
|
|
76
|
+
collections?: EC[] | EntityCollectionsBuilder<EC>;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Custom additional views created by the developer, added to the main
|
|
80
|
+
* navigation
|
|
81
|
+
*/
|
|
82
|
+
views?: CMSView[] | CMSViewsBuilder;
|
|
83
|
+
|
|
70
84
|
/**
|
|
71
85
|
* Record of custom form fields to be used in the CMS.
|
|
72
86
|
* You can use the key to reference the custom field in
|
|
@@ -98,7 +112,7 @@ export type FireCMSProps<UserType extends User, EC extends EntityCollection> = {
|
|
|
98
112
|
/**
|
|
99
113
|
* Connector to your database
|
|
100
114
|
*/
|
|
101
|
-
|
|
115
|
+
dataSourceDelegate: DataSourceDelegate;
|
|
102
116
|
|
|
103
117
|
/**
|
|
104
118
|
* Connector to your file upload/fetch implementation
|
|
@@ -111,10 +125,18 @@ export type FireCMSProps<UserType extends User, EC extends EntityCollection> = {
|
|
|
111
125
|
authController: AuthController<UserType>;
|
|
112
126
|
|
|
113
127
|
/**
|
|
114
|
-
*
|
|
115
|
-
*
|
|
128
|
+
* Path under the navigation routes of the CMS will be created. Defaults to `/`.
|
|
129
|
+
* Internally FireCMS uses `react-router` to create the routes, the base path is attached to the
|
|
130
|
+
* `BrowserRouter` component. If you are using FireCMS in a subpath of your website, you can use
|
|
131
|
+
* this prop to specify the base path.
|
|
116
132
|
*/
|
|
117
|
-
|
|
133
|
+
basePath?: string;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Path under the collection routes of the CMS will be created.
|
|
137
|
+
* Defaults to `/c`.
|
|
138
|
+
*/
|
|
139
|
+
baseCollectionPath?: string;
|
|
118
140
|
|
|
119
141
|
/**
|
|
120
142
|
* Use this controller to access the configuration that is stored locally,
|
|
@@ -150,6 +172,4 @@ export type FireCMSProps<UserType extends User, EC extends EntityCollection> = {
|
|
|
150
172
|
|
|
151
173
|
}
|
|
152
174
|
|
|
153
|
-
|
|
154
|
-
|
|
155
175
|
};
|
|
File without changes
|
|
File without changes
|