@firecms/core 3.0.0-beta.4.pre.2 → 3.0.0-beta.5
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/README.md +1 -1
- package/dist/components/EntityCollectionTable/EntityCollectionRowActions.d.ts +1 -1
- package/dist/components/EntityPreview.d.ts +2 -2
- package/dist/contexts/AuthControllerContext.d.ts +1 -1
- package/dist/hooks/data/delete.d.ts +2 -2
- package/dist/hooks/data/save.d.ts +1 -1
- package/dist/hooks/data/useDataSource.d.ts +1 -1
- package/dist/hooks/data/useEntityFetch.d.ts +3 -3
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/useBuildNavigationController.d.ts +1 -2
- package/dist/hooks/useProjectLog.d.ts +2 -2
- package/dist/hooks/useValidateAuthenticator.d.ts +25 -0
- package/dist/index.es.js +2333 -2257
- 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/internal/useRestoreScroll.d.ts +1 -1
- package/dist/preview/PropertyPreviewProps.d.ts +1 -4
- package/dist/types/auth.d.ts +30 -1
- package/dist/types/collections.d.ts +3 -3
- package/dist/types/datasource.d.ts +1 -1
- package/dist/types/entity_callbacks.d.ts +2 -2
- package/dist/types/index.d.ts +1 -0
- package/dist/types/navigation.d.ts +4 -4
- package/dist/types/plugins.d.ts +2 -2
- package/dist/types/roles.d.ts +31 -0
- package/dist/types/storage.d.ts +11 -3
- package/dist/types/user.d.ts +5 -0
- package/dist/util/collections.d.ts +1 -1
- package/dist/util/useTraceUpdate.d.ts +1 -0
- package/package.json +10 -10
- package/src/components/EntityCollectionTable/fields/TableReferenceField.tsx +1 -1
- package/src/components/EntityPreview.tsx +5 -2
- package/src/components/HomePage/DefaultHomePage.tsx +1 -1
- package/src/components/HomePage/NavigationCard.tsx +1 -1
- package/src/components/ReferenceWidget.tsx +1 -1
- package/src/components/SelectableTable/filters/DateTimeFilterField.tsx +1 -1
- package/src/components/VirtualTable/fields/VirtualTableDateField.tsx +1 -1
- package/src/contexts/AuthControllerContext.tsx +1 -1
- package/src/core/FireCMS.tsx +1 -1
- package/src/form/EntityForm.tsx +1 -1
- package/src/form/field_bindings/DateTimeFieldBinding.tsx +1 -1
- package/src/hooks/data/delete.ts +3 -3
- package/src/hooks/data/save.ts +1 -1
- package/src/hooks/data/useDataSource.tsx +1 -1
- package/src/hooks/data/useEntityFetch.tsx +3 -3
- package/src/hooks/index.tsx +2 -0
- package/src/hooks/useBuildNavigationController.tsx +63 -43
- package/src/hooks/useProjectLog.tsx +7 -5
- package/src/hooks/useValidateAuthenticator.tsx +135 -0
- package/src/internal/useBuildSideEntityController.tsx +3 -0
- package/src/preview/PropertyPreviewProps.tsx +1 -11
- package/src/preview/components/BooleanPreview.tsx +4 -2
- package/src/preview/components/ReferencePreview.tsx +1 -1
- package/src/types/auth.tsx +40 -1
- package/src/types/collections.ts +3 -3
- package/src/types/datasource.ts +1 -1
- package/src/types/entity_callbacks.ts +2 -2
- package/src/types/index.ts +1 -0
- package/src/types/navigation.ts +6 -6
- package/src/types/plugins.tsx +2 -2
- package/src/types/roles.ts +41 -0
- package/src/types/storage.ts +12 -3
- package/src/types/user.ts +7 -0
- package/src/util/collections.ts +1 -1
- package/src/util/strings.ts +2 -2
- package/src/util/useTraceUpdate.tsx +2 -1
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Permissions } from "../index";
|
|
2
|
+
|
|
3
|
+
export type Role = {
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* ID of the role
|
|
7
|
+
*/
|
|
8
|
+
id: string;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Name of the role
|
|
12
|
+
*/
|
|
13
|
+
name: string;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* If this flag is true, the user can perform any action
|
|
17
|
+
*/
|
|
18
|
+
isAdmin?: boolean;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Default permissions for all collections for this role.
|
|
22
|
+
* You can override this values at the collection level using
|
|
23
|
+
* {@link collectionPermissions}
|
|
24
|
+
*/
|
|
25
|
+
defaultPermissions?: Permissions;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Record of stripped collection ids to their permissions.
|
|
29
|
+
* @see stripCollectionPath
|
|
30
|
+
*/
|
|
31
|
+
collectionPermissions?: Record<string, Permissions>;
|
|
32
|
+
|
|
33
|
+
config?: {
|
|
34
|
+
|
|
35
|
+
createCollections?: boolean;
|
|
36
|
+
|
|
37
|
+
editCollections?: boolean | "own";
|
|
38
|
+
|
|
39
|
+
deleteCollections?: boolean | "own";
|
|
40
|
+
}
|
|
41
|
+
}
|
package/src/types/storage.ts
CHANGED
|
@@ -6,6 +6,7 @@ export interface UploadFileProps {
|
|
|
6
6
|
fileName?: string,
|
|
7
7
|
path?: string,
|
|
8
8
|
metadata?: any,
|
|
9
|
+
bucket?: string
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
/**
|
|
@@ -16,6 +17,10 @@ export interface UploadFileResult {
|
|
|
16
17
|
* Storage path including the file name where the file was uploaded.
|
|
17
18
|
*/
|
|
18
19
|
path: string;
|
|
20
|
+
/**
|
|
21
|
+
* Bucket where the file was uploaded
|
|
22
|
+
*/
|
|
23
|
+
bucket: string;
|
|
19
24
|
}
|
|
20
25
|
|
|
21
26
|
/**
|
|
@@ -73,24 +78,28 @@ export interface StorageSource {
|
|
|
73
78
|
* @param fileName
|
|
74
79
|
* @param path
|
|
75
80
|
* @param metadata
|
|
81
|
+
* @param bucket
|
|
76
82
|
*/
|
|
77
83
|
uploadFile: ({
|
|
78
84
|
file,
|
|
79
85
|
fileName,
|
|
80
86
|
path,
|
|
81
|
-
metadata
|
|
87
|
+
metadata,
|
|
88
|
+
bucket
|
|
82
89
|
}: UploadFileProps) => Promise<UploadFileResult>;
|
|
83
90
|
|
|
84
91
|
/**
|
|
85
92
|
* Convert a storage path or URL into a download configuration
|
|
86
93
|
* @param path
|
|
94
|
+
* @param bucket
|
|
87
95
|
*/
|
|
88
|
-
getDownloadURL: (pathOrUrl: string) => Promise<DownloadConfig>;
|
|
96
|
+
getDownloadURL: (pathOrUrl: string, bucket?: string) => Promise<DownloadConfig>;
|
|
89
97
|
|
|
90
98
|
/**
|
|
91
99
|
* Get a file from a storage path.
|
|
92
100
|
* It returns null if the file does not exist.
|
|
93
101
|
* @param props
|
|
102
|
+
* @param bucket
|
|
94
103
|
*/
|
|
95
|
-
getFile: (path:string) => Promise<File | null>;
|
|
104
|
+
getFile: (path:string, bucket?: string) => Promise<File | null>;
|
|
96
105
|
}
|
package/src/types/user.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Role } from "./roles";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* This interface represents a user.
|
|
3
5
|
* It has some of the same fields as a Firebase User.
|
|
@@ -34,4 +36,9 @@ export type User = {
|
|
|
34
36
|
*/
|
|
35
37
|
readonly isAnonymous: boolean;
|
|
36
38
|
|
|
39
|
+
/**
|
|
40
|
+
*
|
|
41
|
+
*/
|
|
42
|
+
roles?: Role[];
|
|
43
|
+
|
|
37
44
|
};
|
package/src/util/collections.ts
CHANGED
|
@@ -58,7 +58,7 @@ export function resolveDefaultSelectedView(
|
|
|
58
58
|
* @param collections
|
|
59
59
|
* @param permissionsBuilder
|
|
60
60
|
*/
|
|
61
|
-
export const applyPermissionsFunctionIfEmpty = (collections: EntityCollection[], permissionsBuilder?: PermissionsBuilder): EntityCollection[] => {
|
|
61
|
+
export const applyPermissionsFunctionIfEmpty = (collections: EntityCollection[], permissionsBuilder?: PermissionsBuilder<any, any>): EntityCollection[] => {
|
|
62
62
|
|
|
63
63
|
return collections.map(collection => {
|
|
64
64
|
if (collection.permissions) {
|
package/src/util/strings.ts
CHANGED
|
@@ -56,8 +56,8 @@ export function unslugify(slug?: string): string {
|
|
|
56
56
|
const result = slug.replace(/[-_]/g, " ");
|
|
57
57
|
return result.replace(/\w\S*/g, function (txt) {
|
|
58
58
|
return txt.charAt(0).toUpperCase() + txt.substr(1);
|
|
59
|
-
});
|
|
59
|
+
}).trim();
|
|
60
60
|
} else {
|
|
61
|
-
return slug;
|
|
61
|
+
return slug.trim();
|
|
62
62
|
}
|
|
63
63
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useEffect, useRef } from "react";
|
|
2
2
|
|
|
3
|
-
function printChanged(props: any, prev: any, path = "", depth = 0, maxDepth: number) {
|
|
3
|
+
export function printChanged(props: any, prev: any, path: string | undefined = "", depth: number | undefined = 0, maxDepth: number | undefined = 10) {
|
|
4
4
|
if (depth > maxDepth) {
|
|
5
5
|
return;
|
|
6
6
|
}
|
|
@@ -17,6 +17,7 @@ function printChanged(props: any, prev: any, path = "", depth = 0, maxDepth: num
|
|
|
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
|
});
|