@firecms/core 3.0.0-canary.17 → 3.0.0-canary.19
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/components/EntityPreview.d.ts +2 -2
- package/dist/hooks/useValidateAuthenticator.d.ts +3 -3
- package/dist/index.es.js +13 -14
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +5 -5
- package/dist/index.umd.js.map +1 -1
- package/dist/types/auth.d.ts +1 -1
- package/dist/types/navigation.d.ts +4 -4
- package/package.json +4 -4
- package/src/components/EntityCollectionTable/fields/TableReferenceField.tsx +1 -1
- package/src/components/EntityPreview.tsx +5 -2
- package/src/components/HomePage/NavigationCard.tsx +1 -1
- package/src/components/ReferenceWidget.tsx +1 -1
- package/src/hooks/useBuildNavigationController.tsx +3 -5
- package/src/hooks/useValidateAuthenticator.tsx +22 -22
- package/src/preview/components/ReferencePreview.tsx +1 -1
- package/src/types/auth.tsx +1 -1
- package/src/types/navigation.ts +6 -6
- package/src/util/useTraceUpdate.tsx +1 -0
package/dist/types/auth.d.ts
CHANGED
|
@@ -56,7 +56,7 @@ export type AuthController<UserType extends User = any, ExtraData extends any =
|
|
|
56
56
|
* Implement this function to allow access to specific users.
|
|
57
57
|
* @group Hooks and utilities
|
|
58
58
|
*/
|
|
59
|
-
export type Authenticator<UserType extends User = User, Controller extends AuthController<UserType> = AuthController<UserType>> = (
|
|
59
|
+
export type Authenticator<UserType extends User = User, Controller extends AuthController<UserType> = AuthController<UserType>> = (props: {
|
|
60
60
|
/**
|
|
61
61
|
* Logged-in user or null
|
|
62
62
|
*/
|
|
@@ -6,7 +6,7 @@ import { EntityReference } from "./entities";
|
|
|
6
6
|
* attributes.
|
|
7
7
|
* @group Models
|
|
8
8
|
*/
|
|
9
|
-
export type NavigationController = {
|
|
9
|
+
export type NavigationController<EC extends EntityCollection = EntityCollection<any>> = {
|
|
10
10
|
/**
|
|
11
11
|
* List of the mapped collections in the CMS.
|
|
12
12
|
* Each entry relates to a collection in the root database.
|
|
@@ -47,15 +47,15 @@ export type NavigationController = {
|
|
|
47
47
|
* Get the collection configuration for a given path.
|
|
48
48
|
* The collection is resolved from the given path or alias.
|
|
49
49
|
*/
|
|
50
|
-
getCollection:
|
|
50
|
+
getCollection: (pathOrAlias: string, entityId?: string, includeUserOverride?: boolean) => EC | undefined;
|
|
51
51
|
/**
|
|
52
52
|
* Get the collection configuration from its parent path segments.
|
|
53
53
|
*/
|
|
54
|
-
getCollectionFromIds:
|
|
54
|
+
getCollectionFromIds: (ids: string[]) => EC | undefined;
|
|
55
55
|
/**
|
|
56
56
|
* Get the collection configuration from its parent path segments.
|
|
57
57
|
*/
|
|
58
|
-
getCollectionFromPaths:
|
|
58
|
+
getCollectionFromPaths: (pathSegments: string[]) => EC | undefined;
|
|
59
59
|
/**
|
|
60
60
|
* Default path under the navigation routes of the CMS will be created
|
|
61
61
|
*/
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firecms/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.0.0-canary.
|
|
4
|
+
"version": "3.0.0-canary.19",
|
|
5
5
|
"description": "Awesome Firebase/Firestore-based headless open-source CMS",
|
|
6
6
|
"funding": {
|
|
7
7
|
"url": "https://github.com/sponsors/firecmsco"
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"./package.json": "./package.json"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@firecms/formex": "^3.0.0-canary.
|
|
50
|
-
"@firecms/ui": "^3.0.0-canary.
|
|
49
|
+
"@firecms/formex": "^3.0.0-canary.19",
|
|
50
|
+
"@firecms/ui": "^3.0.0-canary.19",
|
|
51
51
|
"@fontsource/ibm-plex-mono": "^5.0.12",
|
|
52
52
|
"@fontsource/roboto": "^5.0.12",
|
|
53
53
|
"@hello-pangea/dnd": "^16.5.0",
|
|
@@ -115,7 +115,7 @@
|
|
|
115
115
|
"dist",
|
|
116
116
|
"src"
|
|
117
117
|
],
|
|
118
|
-
"gitHead": "
|
|
118
|
+
"gitHead": "599f60d49fe738eca60a14df9ca577773acd4c1b",
|
|
119
119
|
"publishConfig": {
|
|
120
120
|
"access": "public"
|
|
121
121
|
}
|
|
@@ -29,7 +29,7 @@ export function TableReferenceField(props: TableReferenceFieldProps) {
|
|
|
29
29
|
|
|
30
30
|
const navigationController = useNavigationController();
|
|
31
31
|
const { path } = props;
|
|
32
|
-
const collection = navigationController.getCollection
|
|
32
|
+
const collection = navigationController.getCollection(path);
|
|
33
33
|
if (!collection) {
|
|
34
34
|
if (customizationController.components?.missingReference) {
|
|
35
35
|
return <customizationController.components.missingReference path={path}/>;
|
|
@@ -49,7 +49,7 @@ export function EntityPreview({
|
|
|
49
49
|
|
|
50
50
|
const navigationController = useNavigationController();
|
|
51
51
|
|
|
52
|
-
const collection = collectionProp ?? navigationController.getCollection
|
|
52
|
+
const collection = collectionProp ?? navigationController.getCollection(entity.path);
|
|
53
53
|
|
|
54
54
|
if (!collection) {
|
|
55
55
|
throw Error(`Couldn't find the corresponding collection view for the path: ${entity.path}`);
|
|
@@ -168,9 +168,10 @@ export function EntityPreview({
|
|
|
168
168
|
</EntityPreviewContainer>;
|
|
169
169
|
}
|
|
170
170
|
|
|
171
|
-
type EntityPreviewContainerProps = {
|
|
171
|
+
export type EntityPreviewContainerProps = {
|
|
172
172
|
children: React.ReactNode;
|
|
173
173
|
hover?: boolean;
|
|
174
|
+
fullwidth?: boolean;
|
|
174
175
|
size: PreviewSize;
|
|
175
176
|
className?: string;
|
|
176
177
|
style?: React.CSSProperties;
|
|
@@ -184,6 +185,7 @@ const EntityPreviewContainerInner = React.forwardRef<HTMLDivElement, EntityPrevi
|
|
|
184
185
|
size,
|
|
185
186
|
style,
|
|
186
187
|
className,
|
|
188
|
+
fullwidth = true,
|
|
187
189
|
...props
|
|
188
190
|
}, ref) => {
|
|
189
191
|
return <div
|
|
@@ -195,6 +197,7 @@ const EntityPreviewContainerInner = React.forwardRef<HTMLDivElement, EntityPrevi
|
|
|
195
197
|
}}
|
|
196
198
|
className={cn(
|
|
197
199
|
"bg-white dark:bg-gray-900",
|
|
200
|
+
fullwidth ? "w-full" : "",
|
|
198
201
|
"items-center",
|
|
199
202
|
hover ? "hover:bg-slate-50 dark:hover:bg-gray-800 group-hover:bg-slate-50 dark:group-hover:bg-gray-800" : "",
|
|
200
203
|
size === "tiny" ? "p-1" : "p-2",
|
|
@@ -50,7 +50,7 @@ export function ReferenceWidget<M extends Record<string, any>>({
|
|
|
50
50
|
|
|
51
51
|
const collection: EntityCollection | undefined = useMemo(() => {
|
|
52
52
|
return navigationController.getCollection(path);
|
|
53
|
-
}, [path, navigationController]);
|
|
53
|
+
}, [path, navigationController.getCollection]);
|
|
54
54
|
|
|
55
55
|
// if (!collection) {
|
|
56
56
|
// throw Error(`Couldn't find the corresponding collection for the path: ${path}`);
|
|
@@ -171,6 +171,7 @@ export function useBuildNavigationController<EC extends EntityCollection, UserTy
|
|
|
171
171
|
resolveCMSViews(adminViewsProp, authController, dataSourceDelegate)
|
|
172
172
|
]
|
|
173
173
|
);
|
|
174
|
+
|
|
174
175
|
if (
|
|
175
176
|
!equal(collectionsRef.current, resolvedCollections) ||
|
|
176
177
|
!equal(viewsRef.current, resolvedViews) ||
|
|
@@ -205,7 +206,7 @@ export function useBuildNavigationController<EC extends EntityCollection, UserTy
|
|
|
205
206
|
refreshNavigation();
|
|
206
207
|
}, [refreshNavigation]);
|
|
207
208
|
|
|
208
|
-
const getCollection = useCallback(
|
|
209
|
+
const getCollection = useCallback((
|
|
209
210
|
idOrPath: string,
|
|
210
211
|
entityId?: string,
|
|
211
212
|
includeUserOverride = false
|
|
@@ -238,10 +239,7 @@ export function useBuildNavigationController<EC extends EntityCollection, UserTy
|
|
|
238
239
|
|
|
239
240
|
return { ...overriddenCollection, ...result } as EC;
|
|
240
241
|
|
|
241
|
-
}, [
|
|
242
|
-
basePath,
|
|
243
|
-
baseCollectionPath,
|
|
244
|
-
]);
|
|
242
|
+
}, [userConfigPersistence]);
|
|
245
243
|
|
|
246
244
|
const getCollectionFromPaths = useCallback(<EC extends EntityCollection>(pathSegments: string[]): EC | undefined => {
|
|
247
245
|
|
|
@@ -11,33 +11,33 @@ import { AppCheckTokenResult, AuthController, Authenticator, DataSourceDelegate,
|
|
|
11
11
|
* @param getAppCheckToken
|
|
12
12
|
* @param appCheckForceRefresh
|
|
13
13
|
* @param storageSource
|
|
14
|
-
* @param
|
|
14
|
+
* @param dataSourceDelegate
|
|
15
15
|
*/
|
|
16
16
|
export function useValidateAuthenticator<UserType extends User = User, Controller extends AuthController<UserType> = AuthController<UserType>>({
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
17
|
+
disabled,
|
|
18
|
+
authController,
|
|
19
|
+
authenticator,
|
|
20
|
+
getAppCheckToken,
|
|
21
|
+
appCheckForceRefresh = false,
|
|
22
|
+
storageSource,
|
|
23
|
+
dataSourceDelegate
|
|
24
|
+
}:
|
|
25
|
+
{
|
|
26
|
+
disabled?: boolean,
|
|
27
|
+
authController: Controller,
|
|
28
|
+
authenticator?: boolean | Authenticator<UserType, Controller>,
|
|
29
|
+
getAppCheckToken?: (forceRefresh: boolean) => Promise<AppCheckTokenResult> | undefined,
|
|
30
|
+
appCheckForceRefresh?: boolean,
|
|
31
|
+
dataSourceDelegate: DataSourceDelegate;
|
|
32
|
+
storageSource: StorageSource;
|
|
33
|
+
}): {
|
|
34
34
|
canAccessMainView: boolean,
|
|
35
35
|
authLoading: boolean,
|
|
36
36
|
notAllowedError: any,
|
|
37
37
|
authVerified: boolean,
|
|
38
38
|
} {
|
|
39
39
|
|
|
40
|
-
const authenticationEnabled = Boolean(
|
|
40
|
+
const authenticationEnabled = Boolean(authenticator);
|
|
41
41
|
|
|
42
42
|
const [authLoading, setAuthLoading] = useState<boolean>(authenticationEnabled);
|
|
43
43
|
const [notAllowedError, setNotAllowedError] = useState<any>(false);
|
|
@@ -92,10 +92,10 @@ export function useValidateAuthenticator<UserType extends User = User, Controlle
|
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
if (
|
|
95
|
+
if (authenticator instanceof Function && delegateUser && !equal(checkedUserRef.current?.uid, delegateUser.uid)) {
|
|
96
96
|
setAuthLoading(true);
|
|
97
97
|
try {
|
|
98
|
-
const allowed = await
|
|
98
|
+
const allowed = await authenticator({
|
|
99
99
|
user: delegateUser,
|
|
100
100
|
authController,
|
|
101
101
|
dataSourceDelegate,
|
|
@@ -120,7 +120,7 @@ export function useValidateAuthenticator<UserType extends User = User, Controlle
|
|
|
120
120
|
setAuthVerified(true);
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
}, [disabled, authController,
|
|
123
|
+
}, [disabled, authController, authenticator, getAppCheckToken, appCheckForceRefresh, dataSourceDelegate, storageSource]);
|
|
124
124
|
|
|
125
125
|
useEffect(() => {
|
|
126
126
|
checkAuthentication();
|
|
@@ -64,7 +64,7 @@ function ReferencePreviewInternal<M extends Record<string, any>>({
|
|
|
64
64
|
|
|
65
65
|
const navigationController = useNavigationController();
|
|
66
66
|
|
|
67
|
-
const collection = navigationController.getCollection
|
|
67
|
+
const collection = navigationController.getCollection(reference.path);
|
|
68
68
|
if (!collection) {
|
|
69
69
|
if (customizationController.components?.missingReference) {
|
|
70
70
|
return <customizationController.components.missingReference path={reference.path}/>;
|
package/src/types/auth.tsx
CHANGED
|
@@ -73,7 +73,7 @@ export type AuthController<UserType extends User = any, ExtraData extends any =
|
|
|
73
73
|
* Implement this function to allow access to specific users.
|
|
74
74
|
* @group Hooks and utilities
|
|
75
75
|
*/
|
|
76
|
-
export type Authenticator<UserType extends User = User, Controller extends AuthController<UserType> = AuthController<UserType>> = (
|
|
76
|
+
export type Authenticator<UserType extends User = User, Controller extends AuthController<UserType> = AuthController<UserType>> = (props: {
|
|
77
77
|
|
|
78
78
|
/**
|
|
79
79
|
* Logged-in user or null
|
package/src/types/navigation.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { EntityReference } from "./entities";
|
|
|
7
7
|
* attributes.
|
|
8
8
|
* @group Models
|
|
9
9
|
*/
|
|
10
|
-
export type NavigationController = {
|
|
10
|
+
export type NavigationController<EC extends EntityCollection = EntityCollection<any>> = {
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* List of the mapped collections in the CMS.
|
|
@@ -56,18 +56,18 @@ export type NavigationController = {
|
|
|
56
56
|
* Get the collection configuration for a given path.
|
|
57
57
|
* The collection is resolved from the given path or alias.
|
|
58
58
|
*/
|
|
59
|
-
getCollection:
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
getCollection: (pathOrAlias: string,
|
|
60
|
+
entityId?: string,
|
|
61
|
+
includeUserOverride?: boolean) => EC | undefined;
|
|
62
62
|
/**
|
|
63
63
|
* Get the collection configuration from its parent path segments.
|
|
64
64
|
*/
|
|
65
|
-
getCollectionFromIds:
|
|
65
|
+
getCollectionFromIds: (ids: string[]) => EC | undefined;
|
|
66
66
|
|
|
67
67
|
/**
|
|
68
68
|
* Get the collection configuration from its parent path segments.
|
|
69
69
|
*/
|
|
70
|
-
getCollectionFromPaths:
|
|
70
|
+
getCollectionFromPaths: (pathSegments: string[]) => EC | undefined;
|
|
71
71
|
|
|
72
72
|
/**
|
|
73
73
|
* Default path under the navigation routes of the CMS will be created
|
|
@@ -17,6 +17,7 @@ export function printChanged(props: any, prev: any, path: string | undefined = "
|
|
|
17
17
|
export function useTraceUpdate(props: any, maxDepth = 3) {
|
|
18
18
|
const prev = useRef(props);
|
|
19
19
|
useEffect(() => {
|
|
20
|
+
console.log("Changed props:");
|
|
20
21
|
printChanged(props, prev.current, "", 0, maxDepth);
|
|
21
22
|
prev.current = props;
|
|
22
23
|
});
|