Skip to content

Commit bad3e5f

Browse files
committed
v3.0.0-canary.203
1 parent d2c2f37 commit bad3e5f

File tree

36 files changed

+921
-435
lines changed

36 files changed

+921
-435
lines changed

examples/example/package.json

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
{
22
"name": "firecms-example",
3-
"version": "3.0.0-canary.202",
3+
"version": "3.0.0-canary.203",
44
"private": true,
55
"type": "module",
66
"dependencies": {
7-
"@firecms/collection_editor": "^3.0.0-canary.202",
8-
"@firecms/core": "^3.0.0-canary.202",
9-
"@firecms/data_enhancement": "^3.0.0-canary.202",
10-
"@firecms/data_export": "^3.0.0-canary.202",
11-
"@firecms/data_import": "^3.0.0-canary.202",
12-
"@firecms/data_import_export": "^3.0.0-canary.202",
13-
"@firecms/editor": "^3.0.0-canary.202",
14-
"@firecms/schema_inference": "^3.0.0-canary.202",
15-
"@firecms/ui": "^3.0.0-canary.202",
16-
"@firecms/user_management": "^3.0.0-canary.202",
7+
"@firecms/collection_editor": "^3.0.0-canary.203",
8+
"@firecms/core": "^3.0.0-canary.203",
9+
"@firecms/data_enhancement": "^3.0.0-canary.203",
10+
"@firecms/data_export": "^3.0.0-canary.203",
11+
"@firecms/data_import": "^3.0.0-canary.203",
12+
"@firecms/data_import_export": "^3.0.0-canary.203",
13+
"@firecms/editor": "^3.0.0-canary.203",
14+
"@firecms/schema_inference": "^3.0.0-canary.203",
15+
"@firecms/ui": "^3.0.0-canary.203",
16+
"@firecms/user_management": "^3.0.0-canary.203",
1717
"@fontsource/jetbrains-mono": "^5.1.2",
1818
"clsx": "^2.1.1",
1919
"firebase": "^10.14.1",

examples/example_cloud/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "firecms-example-cloud",
33
"private": true,
44
"type": "module",
5-
"version": "3.0.0-canary.202",
5+
"version": "3.0.0-canary.203",
66
"scripts": {
77
"dev": "vite",
88
"clean": "rm -rf dist && find ./src -name '*.js' -type f | xargs rm -f",
@@ -13,7 +13,7 @@
1313
"deploy:staging": "vite build && firecms deploy --project=firecms-demo-27150 --env-dev"
1414
},
1515
"dependencies": {
16-
"@firecms/cloud": "^3.0.0-canary.202",
16+
"@firecms/cloud": "^3.0.0-canary.203",
1717
"@fontsource/jetbrains-mono": "^5.1.2",
1818
"firebase": "^10.14.1",
1919
"react": "18.3.1",

examples/example_next/package.json

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "firecms-example-next",
3-
"version": "3.0.0-canary.202",
3+
"version": "3.0.0-canary.203",
44
"private": true,
55
"type": "module",
66
"scripts": {
@@ -10,17 +10,17 @@
1010
"lint": "next lint"
1111
},
1212
"dependencies": {
13-
"@firecms/collection_editor": "^3.0.0-canary.202",
14-
"@firecms/collection_editor_firebase": "^3.0.0-canary.202",
15-
"@firecms/core": "^3.0.0-canary.202",
16-
"@firecms/data_enhancement": "^3.0.0-canary.202",
17-
"@firecms/data_export": "^3.0.0-canary.202",
18-
"@firecms/data_import": "^3.0.0-canary.202",
19-
"@firecms/editor": "^3.0.0-canary.202",
20-
"@firecms/firebase": "^3.0.0-canary.202",
21-
"@firecms/schema_inference": "^3.0.0-canary.202",
22-
"@firecms/ui": "^3.0.0-canary.202",
23-
"@firecms/user_management": "^3.0.0-canary.202",
13+
"@firecms/collection_editor": "^3.0.0-canary.203",
14+
"@firecms/collection_editor_firebase": "^3.0.0-canary.203",
15+
"@firecms/core": "^3.0.0-canary.203",
16+
"@firecms/data_enhancement": "^3.0.0-canary.203",
17+
"@firecms/data_export": "^3.0.0-canary.203",
18+
"@firecms/data_import": "^3.0.0-canary.203",
19+
"@firecms/editor": "^3.0.0-canary.203",
20+
"@firecms/firebase": "^3.0.0-canary.203",
21+
"@firecms/schema_inference": "^3.0.0-canary.203",
22+
"@firecms/ui": "^3.0.0-canary.203",
23+
"@firecms/user_management": "^3.0.0-canary.203",
2424
"@fontsource/jetbrains-mono": "^5.1.2",
2525
"@fontsource/playfair-display": "^5.1.1",
2626
"@fontsource/poppins": "^5.1.1",

examples/example_pro/package.json

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
{
22
"name": "firecms-example-pro",
3-
"version": "3.0.0-canary.202",
3+
"version": "3.0.0-canary.203",
44
"private": true,
55
"type": "module",
66
"dependencies": {
77
"@apollo/client": "^3.12.6",
8-
"@firecms/collection_editor": "^3.0.0-canary.202",
9-
"@firecms/collection_editor_firebase": "^3.0.0-canary.202",
10-
"@firecms/core": "^3.0.0-canary.202",
11-
"@firecms/data_enhancement": "^3.0.0-canary.202",
12-
"@firecms/data_export": "^3.0.0-canary.202",
13-
"@firecms/data_import": "^3.0.0-canary.202",
14-
"@firecms/datatalk": "^3.0.0-canary.202",
15-
"@firecms/editor": "^3.0.0-canary.202",
16-
"@firecms/formex": "^3.0.0-canary.202",
17-
"@firecms/schema_inference": "^3.0.0-canary.202",
18-
"@firecms/ui": "^3.0.0-canary.202",
19-
"@firecms/user_management": "^3.0.0-canary.202",
8+
"@firecms/collection_editor": "^3.0.0-canary.203",
9+
"@firecms/collection_editor_firebase": "^3.0.0-canary.203",
10+
"@firecms/core": "^3.0.0-canary.203",
11+
"@firecms/data_enhancement": "^3.0.0-canary.203",
12+
"@firecms/data_export": "^3.0.0-canary.203",
13+
"@firecms/data_import": "^3.0.0-canary.203",
14+
"@firecms/datatalk": "^3.0.0-canary.203",
15+
"@firecms/editor": "^3.0.0-canary.203",
16+
"@firecms/formex": "^3.0.0-canary.203",
17+
"@firecms/schema_inference": "^3.0.0-canary.203",
18+
"@firecms/ui": "^3.0.0-canary.203",
19+
"@firecms/user_management": "^3.0.0-canary.203",
2020
"@fontsource/comic-neue": "^5.1.1",
2121
"@fontsource/jetbrains-mono": "^5.1.2",
2222
"@fontsource/noto-serif": "^5.1.1",
+160
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
import React, { useCallback, useMemo } from "react";
2+
3+
import {
4+
AppBar,
5+
Authenticator,
6+
CircularProgressCenter,
7+
Drawer,
8+
FireCMS,
9+
ModeControllerProvider,
10+
NavigationRoutes,
11+
Scaffold,
12+
SideDialogs,
13+
SnackbarProvider,
14+
useBuildLocalConfigurationPersistence,
15+
useBuildModeController,
16+
useBuildNavigationController,
17+
useValidateAuthenticator
18+
} from "@firecms/core";
19+
import {
20+
FirebaseAuthController,
21+
FirebaseLoginView,
22+
FirebaseSignInProvider,
23+
FirebaseUserWrapper,
24+
useFirebaseAuthController,
25+
useFirebaseStorageSource,
26+
useFirestoreDelegate,
27+
useInitialiseFirebase,
28+
} from "@firecms/firebase";
29+
import { CenteredView } from "@firecms/ui";
30+
31+
import { firebaseConfig } from "./firebase_config";
32+
import {chatbotsCollection} from "./collections/chatbots";
33+
34+
export function App() {
35+
36+
// Use your own authentication logic here
37+
const myAuthenticator: Authenticator<FirebaseUserWrapper> = useCallback(async ({
38+
user,
39+
authController
40+
}) => {
41+
42+
if (user?.email?.includes("flanders")) {
43+
// You can throw an error to prevent access
44+
throw Error("Stupid Flanders!");
45+
}
46+
47+
const idTokenResult = await user?.firebaseUser?.getIdTokenResult();
48+
const userIsAdmin = idTokenResult?.claims.admin || user?.email?.endsWith("@firecms.co");
49+
50+
console.log("Allowing access to", user);
51+
52+
// we allow access to every user in this case
53+
return true;
54+
}, []);
55+
56+
const collections = useMemo(() => [
57+
chatbotsCollection,
58+
], []);
59+
60+
const {
61+
firebaseApp,
62+
firebaseConfigLoading,
63+
configError
64+
} = useInitialiseFirebase({
65+
firebaseConfig
66+
});
67+
68+
// Controller used to manage the dark or light color mode
69+
const modeController = useBuildModeController();
70+
71+
const signInOptions: FirebaseSignInProvider[] = ["google.com", "password"];
72+
73+
// Controller for managing authentication
74+
const authController: FirebaseAuthController = useFirebaseAuthController({
75+
firebaseApp,
76+
signInOptions
77+
});
78+
79+
// Controller for saving some user preferences locally.
80+
const userConfigPersistence = useBuildLocalConfigurationPersistence();
81+
82+
// Delegate used for fetching and saving data in Firestore
83+
const firestoreDelegate = useFirestoreDelegate({
84+
firebaseApp
85+
});
86+
87+
// Controller used for saving and fetching files in storage
88+
const storageSource = useFirebaseStorageSource({
89+
firebaseApp
90+
});
91+
92+
const {
93+
authLoading,
94+
canAccessMainView,
95+
notAllowedError
96+
} = useValidateAuthenticator({
97+
authController,
98+
authenticator: myAuthenticator,
99+
dataSourceDelegate: firestoreDelegate,
100+
storageSource
101+
});
102+
103+
const navigationController = useBuildNavigationController({
104+
collections,
105+
authController,
106+
dataSourceDelegate: firestoreDelegate
107+
});
108+
109+
if (firebaseConfigLoading || !firebaseApp) {
110+
return <>
111+
<CircularProgressCenter/>
112+
</>;
113+
}
114+
115+
if (configError) {
116+
return <CenteredView>{configError}</CenteredView>;
117+
}
118+
119+
return (
120+
<SnackbarProvider>
121+
<ModeControllerProvider value={modeController}>
122+
<FireCMS
123+
navigationController={navigationController}
124+
authController={authController}
125+
userConfigPersistence={userConfigPersistence}
126+
dataSourceDelegate={firestoreDelegate}
127+
storageSource={storageSource}
128+
>
129+
{({
130+
context,
131+
loading
132+
}) => {
133+
134+
if (loading || authLoading) {
135+
return <CircularProgressCenter size={"large"}/>;
136+
}
137+
138+
if (!canAccessMainView) {
139+
return <FirebaseLoginView authController={authController}
140+
firebaseApp={firebaseApp}
141+
signInOptions={signInOptions}
142+
notAllowedError={notAllowedError}/>;
143+
}
144+
145+
return <Scaffold
146+
autoOpenDrawer={false}>
147+
<AppBar title={"My demo app"}/>
148+
<Drawer/>
149+
<NavigationRoutes/>
150+
<SideDialogs/>
151+
</Scaffold>;
152+
}}
153+
</FireCMS>
154+
</ModeControllerProvider>
155+
</SnackbarProvider>
156+
);
157+
158+
}
159+
160+
export default App;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import React from "react";
2+
import { EntityCustomViewParams, PropertyFieldBinding} from "@firecms/core";
3+
import { Container } from "@firecms/ui";
4+
5+
export function ChatbotPromptView({
6+
formContext
7+
}: EntityCustomViewParams) {
8+
return (
9+
<Container className={"my-16 flex flex-col gap-4 w-full"}>
10+
<PropertyFieldBinding context={formContext}
11+
property={{
12+
dataType: "string",
13+
name: "Prompt",
14+
multiline: true
15+
}}
16+
propertyKey={"prompt"}/>
17+
<PropertyFieldBinding context={formContext}
18+
property={{
19+
dataType: "string",
20+
name: "Restrictions",
21+
multiline: true
22+
}}
23+
propertyKey={"restrictions"}/>
24+
25+
</Container>
26+
)
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import {
2+
buildCollection
3+
} from "@firecms/core";
4+
5+
import { chatbotCollectionProperties } from "./chatbots_properties";
6+
import {ChatbotWithNoPrompt} from "./models";
7+
import { ChatbotPromptView } from "./chatbot_prompt_view";
8+
9+
10+
export const chatbotsCollection = buildCollection<ChatbotWithNoPrompt>({
11+
name: "Chatbots",
12+
singularName: "Chatbot",
13+
textSearchEnabled: true,
14+
path: "chatbots",
15+
id: "chatbots",
16+
icon: "chat",
17+
exportable: false,
18+
entityViews: [
19+
{
20+
key: "prompt_editor",
21+
name: "Prompt Editor",
22+
includeActions: true,
23+
Builder: ChatbotPromptView
24+
}
25+
],
26+
editable: true,
27+
hideIdFromForm: true,
28+
openEntityMode: "side_panel",
29+
hideIdFromCollection: true,
30+
subcollections: [],
31+
group: "Main",
32+
permissions: {
33+
read: true,
34+
edit: true,
35+
create: true,
36+
delete: true
37+
},
38+
properties: chatbotCollectionProperties
39+
});

0 commit comments

Comments
 (0)