Skip to content

Commit a925871

Browse files
committed
Login view cleanup
1 parent 30ef9b2 commit a925871

File tree

26 files changed

+61
-55
lines changed

26 files changed

+61
-55
lines changed

examples/example_pro/src/FirestoreApp/CustomLoginView.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { useEffect, useRef, useState } from "react";
22
import { BooleanSwitchWithLabel, FirebaseLoginView, FirebaseLoginViewProps, Typography } from "@firecms/firebase_pro";
3+
import { Alert } from "@firecms/ui";
34

45
export function CustomLoginView(props: FirebaseLoginViewProps) {
56

@@ -20,9 +21,9 @@ export function CustomLoginView(props: FirebaseLoginViewProps) {
2021
<FirebaseLoginView
2122
{...props}
2223
disableSignupScreen={false}
23-
noUserComponent={<>
24+
noUserComponent={<Alert>
2425
Sample custom message when no user exists
25-
</>}
26+
</Alert>}
2627
disabled={!termsAccepted}
2728
additionalComponent={
2829
<>

examples/example_pro/tailwind.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export default {
88
content: [
99
"./index.html",
1010
"./src/**/*.{js,ts,jsx,tsx}",
11+
"../../packages/**/src/**/*.{js,ts,jsx,tsx}",
1112
"../../node_modules/firecms/src/**/*.{js,ts,jsx,tsx}",
1213
"../../node_modules/@firecms/**/src/**/*.{js,ts,jsx,tsx}",
1314
],
Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import fireCMSConfig from "firecms/tailwind.config.js";
22

33
export default {
4-
presets: [fireCMSConfig],
5-
content: [
6-
"./index.html",
7-
"./src/**/*.{js,ts,jsx,tsx}",
8-
"../../node_modules/firecms/src/**/*.{js,ts,jsx,tsx}",
9-
"../../node_modules/@firecms/**/src/**/*.{js,ts,jsx,tsx}",
10-
],
4+
presets: [fireCMSConfig],
5+
content: [
6+
"./index.html",
7+
"./src/**/*.{js,ts,jsx,tsx}",
8+
"../../packages/**/src/**/*.{js,ts,jsx,tsx}",
9+
"../../node_modules/firecms/src/**/*.{js,ts,jsx,tsx}",
10+
"../../node_modules/@firecms/**/src/**/*.{js,ts,jsx,tsx}",
11+
],
1112
};

packages/collection_editor/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,5 @@
8181
"publishConfig": {
8282
"access": "public"
8383
},
84-
"gitHead": "04fbd0c86fa6134b2ef84d40dc8ef36af7a28a8e"
84+
"gitHead": "30ef9b29f5f624fca64e11ffda6001a98f998102"
8585
}

packages/create_firecms_app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,5 @@
4545
"node_modules",
4646
"template/node_modules"
4747
],
48-
"gitHead": "04fbd0c86fa6134b2ef84d40dc8ef36af7a28a8e"
48+
"gitHead": "30ef9b29f5f624fca64e11ffda6001a98f998102"
4949
}

packages/data_enhancement/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,5 +91,5 @@
9191
"publishConfig": {
9292
"access": "public"
9393
},
94-
"gitHead": "04fbd0c86fa6134b2ef84d40dc8ef36af7a28a8e"
94+
"gitHead": "30ef9b29f5f624fca64e11ffda6001a98f998102"
9595
}

packages/data_import_export/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,5 +99,5 @@
9999
"publishConfig": {
100100
"access": "public"
101101
},
102-
"gitHead": "04fbd0c86fa6134b2ef84d40dc8ef36af7a28a8e"
102+
"gitHead": "30ef9b29f5f624fca64e11ffda6001a98f998102"
103103
}

packages/data_import_export/src/export_import/export.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ function processValueForExport(inputValue: any,
149149
} else {
150150
value = inputValue;
151151
}
152-
} else if (property.dataType === "reference" && inputValue.isEntityReference && inputValue.isEntityReference()) {
152+
} else if (property.dataType === "reference" && inputValue && inputValue.isEntityReference && inputValue.isEntityReference()) {
153153
const ref = inputValue ? inputValue as EntityReference : undefined;
154154
value = ref ? ref.pathWithId : null;
155155
} else if (property.dataType === "date" && inputValue instanceof Date) {

packages/editor/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,5 @@
5959
"typescript": "^5.3.3",
6060
"vite": "^5.1.1"
6161
},
62-
"gitHead": "04fbd0c86fa6134b2ef84d40dc8ef36af7a28a8e"
62+
"gitHead": "30ef9b29f5f624fca64e11ffda6001a98f998102"
6363
}

packages/firebase_firecms/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,5 @@
6464
"react-app/jest"
6565
]
6666
},
67-
"gitHead": "04fbd0c86fa6134b2ef84d40dc8ef36af7a28a8e"
67+
"gitHead": "30ef9b29f5f624fca64e11ffda6001a98f998102"
6868
}

packages/firebase_firecms/src/hooks/useFirestoreDelegate.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,10 @@ export function useFirestoreDelegate({
193193
}, [firebaseApp]);
194194

195195
const performTextSearch = useCallback(<M extends Record<string, any>>({
196-
path,
197-
searchString,
198-
onUpdate
199-
}: {
196+
path,
197+
searchString,
198+
onUpdate
199+
}: {
200200
path: string,
201201
searchString: string;
202202
onUpdate: (entities: Entity<M>[]) => void
@@ -715,6 +715,8 @@ function setDateToMidnight(input?: Timestamp): Timestamp | undefined {
715715
export function cmsToFirestoreModel(data: any, firestore: Firestore): any {
716716
if (data === undefined) {
717717
return deleteField();
718+
} else if (data === null) {
719+
return null;
718720
} else if (Array.isArray(data)) {
719721
return data.map(v => cmsToFirestoreModel(v, firestore));
720722
} else if (data.isEntityReference && data.isEntityReference()) {

packages/firebase_firecms_pro/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,5 @@
4848
"react-app/jest"
4949
]
5050
},
51-
"gitHead": "04fbd0c86fa6134b2ef84d40dc8ef36af7a28a8e"
51+
"gitHead": "30ef9b29f5f624fca64e11ffda6001a98f998102"
5252
}

packages/firebase_firecms_pro/src/components/FirebaseLoginView.tsx

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ function LoginForm({
428428

429429
const passwordRef = useRef<HTMLInputElement | null>(null);
430430

431-
const [loginState, setLoginState] = useState<LoginFormMode>("email"); // ["email", "password", "registration"
431+
const [loginState, setLoginState] = useState<LoginFormMode>("email"); // ["email", "password", "registration"]
432432
const [email, setEmail] = useState<string>();
433433
const [password, setPassword] = useState<string>();
434434
const [previouslyUsedMethodsForUser, setPreviouslyUsedMethodsForUser] = useState<string[] | undefined>();
@@ -495,15 +495,15 @@ function LoginForm({
495495
}
496496

497497
const label = loginState === "registration"
498-
? "Pick a password to create a new account for " + email
498+
? "Please enter your email and password to create an account"
499499
: (loginState === "password" ? "Please enter your password" : "Please enter your email");
500500

501-
const button = loginState === "registration" ? "Create account" : (loginState === "password" ? "Login" : "Login");
502-
503501
return (
504-
<form onSubmit={handleSubmit}>
502+
<form
503+
className={"w-full"}
504+
onSubmit={handleSubmit}>
505505

506-
<div className={"flex flex-col gap-1"}>
506+
<div className={"max-w-[480px] w-full flex flex-col gap-4"}>
507507
<IconButton
508508
onClick={onBackPressed}>
509509
<ArrowBackIcon className="w-5 h-5"/>
@@ -513,19 +513,15 @@ function LoginForm({
513513
{loginState === "registration" && noUserComponent}
514514
</div>
515515

516-
<div
517-
className={`p-4 ${loginState === "registration" && disableSignupScreen ? "hidden" : "flex"}`}>
518-
<Typography align={"center"}
519-
variant={"subtitle2"}>{label}</Typography>
520-
</div>
521-
522-
{loginState === "email" && <TextField placeholder="Email" autoFocus
523-
value={email ?? ""}
524-
disabled={authController.authLoading}
525-
type="email"
526-
onChange={(event) => setEmail(event.target.value)}/>}
516+
<Typography
517+
className={`${loginState === "registration" && disableSignupScreen ? "hidden" : "flex"}`}
518+
variant={"subtitle2"}>{label}</Typography>
527519

528-
{loginState === "registration" && noUserComponent}
520+
{(loginState === "email" || loginState === "registration") && <TextField placeholder="Email" autoFocus
521+
value={email ?? ""}
522+
disabled={authController.authLoading}
523+
type="email"
524+
onChange={(event) => setEmail(event.target.value)}/>}
529525

530526
<div
531527
className={`${loginState === "password" || (loginState === "registration" && !disableSignupScreen) ? "block" : "hidden"}`}>
@@ -538,18 +534,18 @@ function LoginForm({
538534
</div>
539535

540536
<div
541-
className={`${loginState === "registration" && disableSignupScreen ? "hidden" : "flex"} justify-end items-center w-full`}>
537+
className={`${loginState === "registration" && disableSignupScreen ? "hidden" : "flex"} justify-end items-center w-full flex gap-2`}>
542538

543539
{authController.authLoading &&
544540
<CircularProgress className="p-1" size={"small"}/>
545541
}
546542

547-
{loginState === "email" && <Button onClick={() => setLoginState("registration")}>
543+
{loginState === "email" && <Button variant="outlined" onClick={() => setLoginState("registration")}>
548544
New user
549545
</Button>}
550546

551547
<Button type="submit">
552-
{button}
548+
{loginState === "registration" ? "Create account" : (loginState === "password" ? "Login" : "Login")}
553549
</Button>
554550
</div>
555551

packages/firebase_firecms_pro/src/mongodb/components/MongoLoginView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ function LoginForm({
260260

261261
return (
262262
<form onSubmit={handleSubmit}>
263-
<div className="space-y-2">
263+
<div className="container space-y-2">
264264
<div className="w-full">
265265
<IconButton onClick={onBackPressed}>
266266
<ArrowBackIcon/>

packages/firebase_firecms_pro/src/mongodb/useMongoDataSource.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,8 @@ function valuesToMongoValues(values: EntityValues<any>) {
508508
}
509509

510510
function valueToMongoValue(value: any): any {
511+
if(value === null)
512+
return null;
511513
if (value.isEntityReference && value.isEntityReference()) {
512514
return {
513515
id: new BSON.ObjectId(value.id),

packages/firecms/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,5 +80,5 @@
8080
"react-app/jest"
8181
]
8282
},
83-
"gitHead": "04fbd0c86fa6134b2ef84d40dc8ef36af7a28a8e"
83+
"gitHead": "30ef9b29f5f624fca64e11ffda6001a98f998102"
8484
}

packages/firecms_cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,5 @@
6464
"node_modules",
6565
"template/node_modules"
6666
],
67-
"gitHead": "04fbd0c86fa6134b2ef84d40dc8ef36af7a28a8e"
67+
"gitHead": "30ef9b29f5f624fca64e11ffda6001a98f998102"
6868
}

packages/firecms_core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
"dist",
116116
"src"
117117
],
118-
"gitHead": "04fbd0c86fa6134b2ef84d40dc8ef36af7a28a8e",
118+
"gitHead": "30ef9b29f5f624fca64e11ffda6001a98f998102",
119119
"publishConfig": {
120120
"access": "public"
121121
}

packages/firecms_core/src/components/SelectableTable/filters/ReferenceFilterField.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export function ReferenceFilterField({
6060

6161
const selectedEntityIds = internalValue
6262
? (Array.isArray(internalValue) ? internalValue.map((ref) => {
63-
if (!(ref.isEntityReference && ref.isEntityReference())) {
63+
if (!(ref?.isEntityReference && ref?.isEntityReference())) {
6464
return null;
6565
}
6666
return ref.id;
@@ -74,7 +74,7 @@ export function ReferenceFilterField({
7474
let newValue = val;
7575
if (prevOpIsArray !== newOpIsArray) {
7676
// @ts-ignore
77-
newValue = newOpIsArray ? (newValue.isEntityReference && newValue.isEntityReference() ? [newValue] : []) : undefined
77+
newValue = newOpIsArray ? (newValue?.isEntityReference && newValue?.isEntityReference() ? [newValue] : []) : undefined
7878
}
7979

8080
setOperation(op);

packages/firecms_core/src/form/field_bindings/KeyValueFieldBinding.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ function getDataType(value: any): DataType | undefined {
546546
return "array";
547547
} else if (value instanceof Date) {
548548
return "date";
549-
} else if (value.isEntityReference && value.isEntityReference()) {
549+
} else if (value?.isEntityReference && value?.isEntityReference()) {
550550
return "reference";
551551
} else if (value instanceof GeoPoint) {
552552
return "geopoint";

packages/firecms_core/src/internal/useBuildDataSource.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,10 @@ export function useBuildDataSource({
330330
* bindings.
331331
* Also, Firestore references are replaced with {@link EntityReference}
332332
* @param data
333+
* @param buildReference
334+
* @param buildGeoPoint
335+
* @param buildDate
336+
* @param buildDelete
333337
* @group Firestore
334338
*/
335339
export function cmsToDelegateModel(data: any,
@@ -357,4 +361,3 @@ export function cmsToDelegateModel(data: any,
357361
}
358362
return data;
359363
}
360-

packages/formex/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,5 @@
6969
"react-app/jest"
7070
]
7171
},
72-
"gitHead": "04fbd0c86fa6134b2ef84d40dc8ef36af7a28a8e"
72+
"gitHead": "30ef9b29f5f624fca64e11ffda6001a98f998102"
7373
}

packages/schema_inference/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@
3131
"build": "vite build && tsc --emitDeclarationOnly -p tsconfig.prod.json",
3232
"clean": "rm -rf dist && find ./src -name '*.js' -type f | xargs rm -f"
3333
},
34-
"gitHead": "04fbd0c86fa6134b2ef84d40dc8ef36af7a28a8e"
34+
"gitHead": "30ef9b29f5f624fca64e11ffda6001a98f998102"
3535
}

packages/ui/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@
110110
"dist",
111111
"src"
112112
],
113-
"gitHead": "04fbd0c86fa6134b2ef84d40dc8ef36af7a28a8e",
113+
"gitHead": "30ef9b29f5f624fca64e11ffda6001a98f998102",
114114
"publishConfig": {
115115
"access": "public"
116116
}

packages/ui/src/components/Alert.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const getColorClasses = (severity: string) => {
2929
case "warning":
3030
return "bg-amber-50 dark:bg-amber-800 dark:text-amber-100 text-amber-900";
3131
case "info":
32-
return "bg-blue-50 dark:bg-blue-800 dark:text-blue-100 text-blue-900";
32+
return "bg-blue-100 dark:bg-blue-800 dark:text-blue-100 text-blue-900";
3333
case "success":
3434
return "bg-emerald-50 dark:bg-emerald-800 dark:text-emerald-100 text-emerald-900";
3535
case "base":

packages/ui/src/components/Tabs.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export function Tabs({
1919

2020
return <TabsPrimitive.Root value={value} onValueChange={onValueChange}>
2121
<TabsPrimitive.List className={cn(
22-
"flex text-sm font-medium text-center text-slate-800 dark:text-slate-200",
22+
"flex text-sm font-medium text-center text-slate-800 dark:text-slate-200 max-w-full overflow-auto no-scrollbar",
2323
className)
2424
}>
2525
{children}

0 commit comments

Comments
 (0)