@firecms/core 3.0.0-canary.126 → 3.0.0-canary.128
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/{DeleteConfirmationDialog.d.ts → ConfirmationDialog.d.ts} +1 -1
- package/dist/components/EntityCollectionView/utils.d.ts +3 -0
- package/dist/components/EntityPreview.d.ts +1 -1
- package/dist/components/index.d.ts +1 -1
- package/dist/hooks/useProjectLog.d.ts +7 -1
- package/dist/index.es.js +123 -60
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +123 -60
- package/dist/index.umd.js.map +1 -1
- package/dist/types/firecms.d.ts +4 -0
- package/package.json +5 -5
- package/src/components/ArrayContainer.tsx +1 -1
- package/src/components/{DeleteConfirmationDialog.tsx → ConfirmationDialog.tsx} +1 -1
- package/src/components/EntityCollectionView/EntityCollectionView.tsx +66 -39
- package/src/components/EntityCollectionView/utils.ts +19 -0
- package/src/components/EntityPreview.tsx +1 -1
- package/src/components/common/default_entity_actions.tsx +4 -0
- package/src/components/index.tsx +1 -1
- package/src/core/FireCMS.tsx +15 -6
- package/src/hooks/useProjectLog.tsx +16 -5
- package/src/types/firecms.tsx +5 -0
- package/src/util/make_properties_editable.ts +13 -5
package/dist/types/firecms.d.ts
CHANGED
|
@@ -62,6 +62,10 @@ export type FireCMSProps<UserType extends User, EC extends EntityCollection> = {
|
|
|
62
62
|
*/
|
|
63
63
|
loading: boolean;
|
|
64
64
|
}) => React.ReactNode;
|
|
65
|
+
/**
|
|
66
|
+
* If you have a custom API key, you can use it here.
|
|
67
|
+
*/
|
|
68
|
+
apiKey?: string;
|
|
65
69
|
/**
|
|
66
70
|
* Record of custom form fields to be used in the CMS.
|
|
67
71
|
* You can use the key to reference the custom field in
|
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.128",
|
|
5
5
|
"description": "Awesome Firebase/Firestore-based headless open-source CMS",
|
|
6
6
|
"funding": {
|
|
7
7
|
"url": "https://github.com/sponsors/firecmsco"
|
|
@@ -46,9 +46,9 @@
|
|
|
46
46
|
"./package.json": "./package.json"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@firecms/editor": "^3.0.0-canary.
|
|
50
|
-
"@firecms/formex": "^3.0.0-canary.
|
|
51
|
-
"@firecms/ui": "^3.0.0-canary.
|
|
49
|
+
"@firecms/editor": "^3.0.0-canary.128",
|
|
50
|
+
"@firecms/formex": "^3.0.0-canary.128",
|
|
51
|
+
"@firecms/ui": "^3.0.0-canary.128",
|
|
52
52
|
"@hello-pangea/dnd": "^16.6.0",
|
|
53
53
|
"@radix-ui/react-portal": "^1.1.1",
|
|
54
54
|
"clsx": "^2.1.1",
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
"dist",
|
|
101
101
|
"src"
|
|
102
102
|
],
|
|
103
|
-
"gitHead": "
|
|
103
|
+
"gitHead": "bc89d0f2a854db605146acc129aeee89d8e0d0a3",
|
|
104
104
|
"publishConfig": {
|
|
105
105
|
"access": "public"
|
|
106
106
|
},
|
|
@@ -279,7 +279,7 @@ export function ArrayItemOptions({
|
|
|
279
279
|
const iconRef = React.useRef<HTMLDivElement>(null);
|
|
280
280
|
useOutsideAlerter(iconRef, () => setMenuOpen(false));
|
|
281
281
|
|
|
282
|
-
return <div className={`pl-2 pt-1 pb-
|
|
282
|
+
return <div className={`pl-2 pt-1 pb-1 flex ${direction === "row" ? "flex-row-reverse" : "flex-col"} items-center`}
|
|
283
283
|
ref={iconRef}
|
|
284
284
|
{...provided.dragHandleProps}>
|
|
285
285
|
<Tooltip
|
|
@@ -7,7 +7,9 @@ import {
|
|
|
7
7
|
CollectionSize,
|
|
8
8
|
Entity,
|
|
9
9
|
EntityAction,
|
|
10
|
-
EntityCollection,
|
|
10
|
+
EntityCollection,
|
|
11
|
+
EntityReference,
|
|
12
|
+
EntityTableController,
|
|
11
13
|
FilterValues,
|
|
12
14
|
PartialEntityCollection,
|
|
13
15
|
PropertyOrBuilder,
|
|
@@ -45,7 +47,8 @@ import { EntityCollectionViewActions } from "./EntityCollectionViewActions";
|
|
|
45
47
|
import {
|
|
46
48
|
AddIcon,
|
|
47
49
|
Button,
|
|
48
|
-
cls,
|
|
50
|
+
cls,
|
|
51
|
+
focusedDisabled,
|
|
49
52
|
IconButton,
|
|
50
53
|
KeyboardTabIcon,
|
|
51
54
|
Markdown,
|
|
@@ -71,6 +74,7 @@ import { DeleteEntityDialog } from "../DeleteEntityDialog";
|
|
|
71
74
|
import { useAnalyticsController } from "../../hooks/useAnalyticsController";
|
|
72
75
|
import { useSelectionController } from "./useSelectionController";
|
|
73
76
|
import { EntityCollectionViewStartActions } from "./EntityCollectionViewStartActions";
|
|
77
|
+
import { addRecentId, getRecentIds } from "./utils";
|
|
74
78
|
|
|
75
79
|
const COLLECTION_GROUP_PARENT_ID = "collectionGroupParent";
|
|
76
80
|
|
|
@@ -467,11 +471,11 @@ export const EntityCollectionView = React.memo(
|
|
|
467
471
|
};
|
|
468
472
|
|
|
469
473
|
const tableRowActionsBuilder = useCallback(({
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
474
|
+
entity,
|
|
475
|
+
size,
|
|
476
|
+
width,
|
|
477
|
+
frozen
|
|
478
|
+
}: {
|
|
475
479
|
entity: Entity<any>,
|
|
476
480
|
size: CollectionSize,
|
|
477
481
|
width: number,
|
|
@@ -778,7 +782,10 @@ function EntityIdHeaderWidget({
|
|
|
778
782
|
}) {
|
|
779
783
|
const [openPopup, setOpenPopup] = React.useState(false);
|
|
780
784
|
const [searchString, setSearchString] = React.useState("");
|
|
785
|
+
const [recentIds, setRecentIds] = React.useState<string[]>(getRecentIds(collection.id));
|
|
781
786
|
const sideEntityController = useSideEntityController();
|
|
787
|
+
|
|
788
|
+
|
|
782
789
|
return (
|
|
783
790
|
<Tooltip title={!openPopup ? "Find by ID" : undefined} asChild={false}>
|
|
784
791
|
<Popover
|
|
@@ -791,38 +798,58 @@ function EntityIdHeaderWidget({
|
|
|
791
798
|
<IconButton size={"small"}>
|
|
792
799
|
<SearchIcon size={"small"}/>
|
|
793
800
|
</IconButton>
|
|
794
|
-
}
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
<
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
801
|
+
}>
|
|
802
|
+
<div className={cls("my-2 rounded-lg bg-gray-50 dark:bg-gray-950 text-gray-900 dark:text-white")}>
|
|
803
|
+
<form noValidate={true}
|
|
804
|
+
onSubmit={(e) => {
|
|
805
|
+
e.preventDefault();
|
|
806
|
+
if (!searchString) return;
|
|
807
|
+
setOpenPopup(false);
|
|
808
|
+
setRecentIds(addRecentId(collection.id, searchString.trim()));
|
|
809
|
+
return sideEntityController.open({
|
|
810
|
+
entityId: searchString.trim(),
|
|
811
|
+
path,
|
|
812
|
+
collection,
|
|
813
|
+
updateUrl: true
|
|
814
|
+
});
|
|
815
|
+
}}
|
|
816
|
+
className={"w-96 max-w-full"}>
|
|
817
|
+
|
|
818
|
+
<div className="flex p-2 w-full gap-2">
|
|
819
|
+
<input
|
|
820
|
+
autoFocus={openPopup}
|
|
821
|
+
placeholder={"Find entity by ID"}
|
|
822
|
+
// size={"small"}
|
|
823
|
+
onChange={(e) => {
|
|
824
|
+
setSearchString(e.target.value);
|
|
825
|
+
}}
|
|
826
|
+
value={searchString}
|
|
827
|
+
className={"rounded-lg bg-white dark:bg-gray-800 flex-grow bg-transparent outline-none p-2 " + focusedDisabled}/>
|
|
828
|
+
<Button variant={"text"}
|
|
829
|
+
disabled={!(searchString.trim())}
|
|
830
|
+
type={"submit"}
|
|
831
|
+
><KeyboardTabIcon/></Button>
|
|
832
|
+
</div>
|
|
833
|
+
</form>
|
|
834
|
+
{recentIds && recentIds.length > 0 && <div className="flex flex-col gap-2 p-2">
|
|
835
|
+
{recentIds.map(id => (
|
|
836
|
+
<ReferencePreview reference={new EntityReference(id, path)}
|
|
837
|
+
key={id}
|
|
838
|
+
hover={true}
|
|
839
|
+
onClick={() => {
|
|
840
|
+
setOpenPopup(false);
|
|
841
|
+
sideEntityController.open({
|
|
842
|
+
entityId: id,
|
|
843
|
+
path,
|
|
844
|
+
collection,
|
|
845
|
+
updateUrl: true
|
|
846
|
+
});
|
|
847
|
+
}}
|
|
848
|
+
includeEntityLink={false}
|
|
849
|
+
size={"small"}/>
|
|
850
|
+
))}
|
|
851
|
+
</div>}
|
|
852
|
+
</div>
|
|
826
853
|
</Popover>
|
|
827
854
|
|
|
828
855
|
</Tooltip>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export function addRecentId(collectionId: string, id: string) {
|
|
2
|
+
const recentIds = getRecentIds(collectionId);
|
|
3
|
+
const newRecentIds = [id, ...recentIds.filter(i => i !== id)];
|
|
4
|
+
if (newRecentIds.length > 5) {
|
|
5
|
+
newRecentIds.pop();
|
|
6
|
+
}
|
|
7
|
+
saveSearchedIdsLocally(collectionId, newRecentIds);
|
|
8
|
+
return newRecentIds;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function saveSearchedIdsLocally(collectionId: string, ids: string[]) {
|
|
12
|
+
localStorage.setItem("recent_id_searches::" + collectionId, JSON.stringify(ids));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function getRecentIds(collectionId: string): string[] {
|
|
16
|
+
const stored = localStorage.getItem("recent_id_searches::" + collectionId);
|
|
17
|
+
if (!stored) return [];
|
|
18
|
+
return JSON.parse(stored);
|
|
19
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ArchiveIcon, DeleteIcon, FileCopyIcon, KeyboardTabIcon, OpenInNewIcon } from "@firecms/ui";
|
|
2
2
|
import { EntityAction } from "../../types";
|
|
3
3
|
import { DeleteEntityDialog } from "../DeleteEntityDialog";
|
|
4
|
+
import { addRecentId } from "../EntityCollectionView/utils";
|
|
4
5
|
|
|
5
6
|
export const editEntityAction: EntityAction = {
|
|
6
7
|
icon: <KeyboardTabIcon/>,
|
|
@@ -19,6 +20,9 @@ export const editEntityAction: EntityAction = {
|
|
|
19
20
|
path: entity.path,
|
|
20
21
|
entityId: entity.id
|
|
21
22
|
});
|
|
23
|
+
if (collection) {
|
|
24
|
+
addRecentId(collection.id, entity.id);
|
|
25
|
+
}
|
|
22
26
|
const path = collection?.collectionGroup ? entity.path : (fullPath ?? entity.path);
|
|
23
27
|
context.sideEntityController.open({
|
|
24
28
|
entityId: entity.id,
|
package/src/components/index.tsx
CHANGED
package/src/core/FireCMS.tsx
CHANGED
|
@@ -48,6 +48,7 @@ export function FireCMS<UserType extends User, EC extends EntityCollection>(prop
|
|
|
48
48
|
entityViews,
|
|
49
49
|
components,
|
|
50
50
|
navigationController,
|
|
51
|
+
apiKey
|
|
51
52
|
} = props;
|
|
52
53
|
|
|
53
54
|
useLocaleConfig(locale);
|
|
@@ -82,7 +83,15 @@ export function FireCMS<UserType extends User, EC extends EntityCollection>(prop
|
|
|
82
83
|
onAnalyticsEvent
|
|
83
84
|
}), []);
|
|
84
85
|
|
|
85
|
-
const accessResponse = useProjectLog(
|
|
86
|
+
const accessResponse = useProjectLog({
|
|
87
|
+
apiKey,
|
|
88
|
+
authController,
|
|
89
|
+
dataSourceDelegate,
|
|
90
|
+
plugins
|
|
91
|
+
});
|
|
92
|
+
if (accessResponse?.message) {
|
|
93
|
+
console.warn(accessResponse.message);
|
|
94
|
+
}
|
|
86
95
|
|
|
87
96
|
if (navigationController.navigationLoadingError) {
|
|
88
97
|
return (
|
|
@@ -106,16 +115,16 @@ export function FireCMS<UserType extends User, EC extends EntityCollection>(prop
|
|
|
106
115
|
|
|
107
116
|
if (accessResponse?.blocked) {
|
|
108
117
|
return (
|
|
109
|
-
<CenteredView maxWidth={"md"} fullScreen={true}>
|
|
110
|
-
<Typography variant={"h4"}>
|
|
111
|
-
|
|
118
|
+
<CenteredView maxWidth={"md"} fullScreen={true} className={"flex flex-col gap-2"}>
|
|
119
|
+
<Typography variant={"h4"} gutterBottom>
|
|
120
|
+
License needed
|
|
112
121
|
</Typography>
|
|
113
122
|
<Typography>
|
|
114
|
-
|
|
123
|
+
You need a valid license to use FireCMS PRO. Please reach out at <a
|
|
115
124
|
href={"mailto:hello@firecms.co"}>hello@firecms.co</a> for more information.
|
|
116
125
|
</Typography>
|
|
117
126
|
{accessResponse?.message &&
|
|
118
|
-
<Typography>
|
|
127
|
+
<Typography>{accessResponse?.message}</Typography>}
|
|
119
128
|
</CenteredView>
|
|
120
129
|
);
|
|
121
130
|
}
|
|
@@ -9,7 +9,7 @@ export type AccessResponse = {
|
|
|
9
9
|
message?: string;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
async function makeRequest(authController: AuthController, dataSourceKey: string, pluginKeys: string[] | undefined) {
|
|
12
|
+
async function makeRequest(authController: AuthController, dataSourceKey: string, pluginKeys: string[] | undefined, apiKey?: string): Promise<AccessResponse> {
|
|
13
13
|
let idToken: string | null;
|
|
14
14
|
try {
|
|
15
15
|
idToken = await authController.getAuthToken();
|
|
@@ -25,6 +25,7 @@ async function makeRequest(authController: AuthController, dataSourceKey: string
|
|
|
25
25
|
Authorization: `Basic ${idToken}`
|
|
26
26
|
},
|
|
27
27
|
body: JSON.stringify({
|
|
28
|
+
apiKey,
|
|
28
29
|
email: authController.user?.email ?? null,
|
|
29
30
|
datasource: dataSourceKey,
|
|
30
31
|
plugins: pluginKeys
|
|
@@ -35,16 +36,26 @@ async function makeRequest(authController: AuthController, dataSourceKey: string
|
|
|
35
36
|
});
|
|
36
37
|
}
|
|
37
38
|
|
|
38
|
-
export
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
export interface UseProjectLogParams {
|
|
40
|
+
apiKey?: string;
|
|
41
|
+
authController: AuthController;
|
|
42
|
+
dataSourceDelegate: DataSourceDelegate;
|
|
43
|
+
plugins?: FireCMSPlugin<any, any, any>[];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function useProjectLog({
|
|
47
|
+
authController,
|
|
48
|
+
dataSourceDelegate,
|
|
49
|
+
plugins,
|
|
50
|
+
apiKey
|
|
51
|
+
}: UseProjectLogParams): AccessResponse | null {
|
|
41
52
|
const [accessResponse, setAccessResponse] = useState<AccessResponse | null>(null);
|
|
42
53
|
const accessedUserRef = useRef<string | null>(null);
|
|
43
54
|
const dataSourceKey = dataSourceDelegate.key;
|
|
44
55
|
const pluginKeys = plugins?.map(plugin => plugin.key);
|
|
45
56
|
useEffect(() => {
|
|
46
57
|
if (authController.user && authController.user.uid !== accessedUserRef.current && !authController.initialLoading) {
|
|
47
|
-
makeRequest(authController, dataSourceKey, pluginKeys).then(setAccessResponse);
|
|
58
|
+
makeRequest(authController, dataSourceKey, pluginKeys, apiKey).then(setAccessResponse);
|
|
48
59
|
accessedUserRef.current = authController.user.uid;
|
|
49
60
|
}
|
|
50
61
|
}, [authController, dataSourceKey, pluginKeys]);
|
package/src/types/firecms.tsx
CHANGED
|
@@ -67,6 +67,11 @@ export type FireCMSProps<UserType extends User, EC extends EntityCollection> = {
|
|
|
67
67
|
loading: boolean;
|
|
68
68
|
}) => React.ReactNode;
|
|
69
69
|
|
|
70
|
+
/**
|
|
71
|
+
* If you have a custom API key, you can use it here.
|
|
72
|
+
*/
|
|
73
|
+
apiKey?: string;
|
|
74
|
+
|
|
70
75
|
/**
|
|
71
76
|
* Record of custom form fields to be used in the CMS.
|
|
72
77
|
* You can use the key to reference the custom field in
|
|
@@ -4,9 +4,11 @@ import { isPropertyBuilder } from "./entities";
|
|
|
4
4
|
export function makePropertiesEditable(properties: Properties) {
|
|
5
5
|
Object.keys(properties).forEach((key) => {
|
|
6
6
|
const property = properties[key];
|
|
7
|
-
property
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
if (property) {
|
|
8
|
+
property.editable = true;
|
|
9
|
+
if (property.dataType === "map" && property.properties) {
|
|
10
|
+
makePropertiesEditable(property.properties as Properties);
|
|
11
|
+
}
|
|
10
12
|
}
|
|
11
13
|
});
|
|
12
14
|
return properties;
|
|
@@ -15,13 +17,19 @@ export function makePropertiesEditable(properties: Properties) {
|
|
|
15
17
|
export function makePropertiesNonEditable(properties: PropertiesOrBuilders): PropertiesOrBuilders {
|
|
16
18
|
return Object.entries(properties).reduce((acc, [key, property]) => {
|
|
17
19
|
if (!isPropertyBuilder(property) && property.dataType === "map" && property.properties) {
|
|
18
|
-
const updated = {
|
|
20
|
+
const updated = {
|
|
21
|
+
...property,
|
|
22
|
+
properties: makePropertiesNonEditable(property.properties as PropertiesOrBuilders)
|
|
23
|
+
};
|
|
19
24
|
acc[key] = updated;
|
|
20
25
|
}
|
|
21
26
|
if (isPropertyBuilder(property)) {
|
|
22
27
|
acc[key] = property;
|
|
23
28
|
} else {
|
|
24
|
-
acc[key] = {
|
|
29
|
+
acc[key] = {
|
|
30
|
+
...property,
|
|
31
|
+
editable: false
|
|
32
|
+
};
|
|
25
33
|
}
|
|
26
34
|
return acc;
|
|
27
35
|
}, {} as PropertiesOrBuilders);
|