@firecms/user_management 3.0.0 → 3.1.0-canary.1df3b2c
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/roles/RolesDetailsForm.d.ts +7 -10
- package/dist/components/roles/index.d.ts +1 -0
- package/dist/components/users/UserDetailsForm.d.ts +9 -13
- package/dist/index.es.js +51 -42
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +50 -41
- package/dist/index.umd.js.map +1 -1
- package/package.json +5 -5
- package/src/components/roles/RolesDetailsForm.tsx +0 -2
- package/src/components/roles/RolesTable.tsx +1 -1
- package/src/components/roles/index.ts +1 -0
- package/src/components/users/UserDetailsForm.tsx +0 -2
- package/src/components/users/UsersTable.tsx +56 -42
- package/src/hooks/useBuildUserManagement.tsx +13 -5
- package/src/useUserManagementPlugin.tsx +1 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firecms/user_management",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.0.
|
|
4
|
+
"version": "3.1.0-canary.1df3b2c",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
"types": "./dist/index.d.ts",
|
|
30
30
|
"source": "src/index.ts",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@firecms/core": "^3.0.
|
|
33
|
-
"@firecms/formex": "^3.0.
|
|
34
|
-
"@firecms/ui": "^3.0.
|
|
32
|
+
"@firecms/core": "^3.1.0-canary.1df3b2c",
|
|
33
|
+
"@firecms/formex": "^3.1.0-canary.1df3b2c",
|
|
34
|
+
"@firecms/ui": "^3.1.0-canary.1df3b2c",
|
|
35
35
|
"date-fns": "^3.6.0"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"src",
|
|
58
58
|
"bin"
|
|
59
59
|
],
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "5074584b15be0d0507a4dadc148f03d82e9fe495"
|
|
61
61
|
}
|
|
@@ -425,7 +425,6 @@ export function RolesDetailsForm({
|
|
|
425
425
|
{savingError.message ?? "There was an error saving this role"}
|
|
426
426
|
</Typography>}
|
|
427
427
|
<Button variant={"text"}
|
|
428
|
-
color={"primary"}
|
|
429
428
|
onClick={() => {
|
|
430
429
|
handleClose();
|
|
431
430
|
}}>
|
|
@@ -433,7 +432,6 @@ export function RolesDetailsForm({
|
|
|
433
432
|
</Button>
|
|
434
433
|
<LoadingButton
|
|
435
434
|
variant="filled"
|
|
436
|
-
color="primary"
|
|
437
435
|
type="submit"
|
|
438
436
|
disabled={!dirty}
|
|
439
437
|
loading={isSubmitting}
|
|
@@ -99,7 +99,7 @@ export function RolesTable({
|
|
|
99
99
|
<Typography variant={"label"}>
|
|
100
100
|
You don't have any roles yet.
|
|
101
101
|
</Typography>
|
|
102
|
-
{allowDefaultRolesCreation && <Button
|
|
102
|
+
{allowDefaultRolesCreation && <Button
|
|
103
103
|
onClick={() => {
|
|
104
104
|
DEFAULT_ROLES.forEach((role) => {
|
|
105
105
|
saveRole(role);
|
|
@@ -205,7 +205,6 @@ export function UserDetailsForm({
|
|
|
205
205
|
<DialogActions>
|
|
206
206
|
|
|
207
207
|
<Button variant={"text"}
|
|
208
|
-
color={"primary"}
|
|
209
208
|
onClick={() => {
|
|
210
209
|
handleClose();
|
|
211
210
|
}}>
|
|
@@ -214,7 +213,6 @@ export function UserDetailsForm({
|
|
|
214
213
|
|
|
215
214
|
<LoadingButton
|
|
216
215
|
variant="filled"
|
|
217
|
-
color="primary"
|
|
218
216
|
type="submit"
|
|
219
217
|
disabled={!dirty}
|
|
220
218
|
loading={isSubmitting}
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
useSnackbarController
|
|
12
12
|
} from "@firecms/core";
|
|
13
13
|
import {
|
|
14
|
+
Avatar,
|
|
14
15
|
Button,
|
|
15
16
|
CenteredView,
|
|
16
17
|
DeleteIcon,
|
|
@@ -53,11 +54,12 @@ export function UsersTable({ onUserClicked }: {
|
|
|
53
54
|
<Table className={"w-full"}>
|
|
54
55
|
|
|
55
56
|
<TableHeader>
|
|
56
|
-
<TableCell className="
|
|
57
|
+
<TableCell className="w-12"></TableCell>
|
|
57
58
|
<TableCell>Email</TableCell>
|
|
58
59
|
<TableCell>Name</TableCell>
|
|
59
60
|
<TableCell>Roles</TableCell>
|
|
60
61
|
<TableCell>Created on</TableCell>
|
|
62
|
+
<TableCell className="w-12"></TableCell>
|
|
61
63
|
</TableHeader>
|
|
62
64
|
<TableBody>
|
|
63
65
|
{users && users.map((user) => {
|
|
@@ -73,19 +75,17 @@ export function UsersTable({ onUserClicked }: {
|
|
|
73
75
|
onUserClicked(user);
|
|
74
76
|
}}
|
|
75
77
|
>
|
|
76
|
-
<TableCell className={"w-
|
|
77
|
-
<
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
</IconButton>
|
|
88
|
-
</Tooltip>
|
|
78
|
+
<TableCell className={"w-12"}>
|
|
79
|
+
<Avatar
|
|
80
|
+
src={user.photoURL ?? undefined}
|
|
81
|
+
outerClassName="w-8 h-8 min-w-8 min-h-8 p-0"
|
|
82
|
+
className="text-sm"
|
|
83
|
+
hover={false}
|
|
84
|
+
>
|
|
85
|
+
{user.displayName
|
|
86
|
+
? user.displayName[0].toUpperCase()
|
|
87
|
+
: (user.email ? user.email[0].toUpperCase() : "U")}
|
|
88
|
+
</Avatar>
|
|
89
89
|
</TableCell>
|
|
90
90
|
<TableCell>{user.email}</TableCell>
|
|
91
91
|
<TableCell className={"font-medium align-left"}>{user.displayName}</TableCell>
|
|
@@ -93,12 +93,26 @@ export function UsersTable({ onUserClicked }: {
|
|
|
93
93
|
{userRoles
|
|
94
94
|
? <div className="flex flex-wrap gap-2">
|
|
95
95
|
{userRoles.map(userRole =>
|
|
96
|
-
<RoleChip key={userRole?.id} role={userRole}/>
|
|
96
|
+
<RoleChip key={userRole?.id} role={userRole} />
|
|
97
97
|
)}
|
|
98
98
|
</div>
|
|
99
99
|
: null}
|
|
100
100
|
</TableCell>
|
|
101
101
|
<TableCell>{formattedDate}</TableCell>
|
|
102
|
+
<TableCell className={"w-12"}>
|
|
103
|
+
<Tooltip
|
|
104
|
+
asChild={true}
|
|
105
|
+
title={"Delete this user"}>
|
|
106
|
+
<IconButton
|
|
107
|
+
size={"smallest"}
|
|
108
|
+
onClick={(event) => {
|
|
109
|
+
event.stopPropagation();
|
|
110
|
+
return setUserToBeDeleted(user);
|
|
111
|
+
}}>
|
|
112
|
+
<DeleteIcon size={"small"} />
|
|
113
|
+
</IconButton>
|
|
114
|
+
</Tooltip>
|
|
115
|
+
</TableCell>
|
|
102
116
|
</TableRow>
|
|
103
117
|
);
|
|
104
118
|
})}
|
|
@@ -109,34 +123,34 @@ export function UsersTable({ onUserClicked }: {
|
|
|
109
123
|
<Typography variant={"label"}>
|
|
110
124
|
There are no users yet
|
|
111
125
|
</Typography>
|
|
112
|
-
<Button
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
+
<Button
|
|
127
|
+
onClick={() => {
|
|
128
|
+
if (!authController.user?.uid) {
|
|
129
|
+
throw Error("UsersTable, authController misconfiguration");
|
|
130
|
+
}
|
|
131
|
+
saveUser({
|
|
132
|
+
uid: authController.user?.uid,
|
|
133
|
+
email: authController.user?.email,
|
|
134
|
+
displayName: authController.user?.displayName,
|
|
135
|
+
photoURL: authController.user?.photoURL,
|
|
136
|
+
providerId: authController.user?.providerId,
|
|
137
|
+
isAnonymous: authController.user?.isAnonymous,
|
|
138
|
+
roles: [{ id: "admin", name: "Admin" }],
|
|
139
|
+
created_on: new Date()
|
|
140
|
+
})
|
|
141
|
+
.then(() => {
|
|
142
|
+
snackbarController.open({
|
|
143
|
+
type: "success",
|
|
144
|
+
message: "User added successfully"
|
|
145
|
+
})
|
|
126
146
|
})
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
})
|
|
147
|
+
.catch((error) => {
|
|
148
|
+
snackbarController.open({
|
|
149
|
+
type: "error",
|
|
150
|
+
message: "Error adding user: " + error.message,
|
|
132
151
|
})
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
type: "error",
|
|
136
|
-
message: "Error adding user: " + error.message,
|
|
137
|
-
})
|
|
138
|
-
});
|
|
139
|
-
}}>
|
|
152
|
+
});
|
|
153
|
+
}}>
|
|
140
154
|
|
|
141
155
|
Add the logged user as an admin
|
|
142
156
|
</Button>
|
|
@@ -172,6 +186,6 @@ export function UsersTable({ onUserClicked }: {
|
|
|
172
186
|
setUserToBeDeleted(undefined);
|
|
173
187
|
}}
|
|
174
188
|
title={<>Delete?</>}
|
|
175
|
-
body={<>Are you sure you want to delete this user?</>}/>
|
|
189
|
+
body={<>Are you sure you want to delete this user?</>} />
|
|
176
190
|
</div>);
|
|
177
191
|
}
|
|
@@ -298,12 +298,17 @@ export function useBuildUserManagement<CONTROLLER extends AuthController<any> =
|
|
|
298
298
|
|
|
299
299
|
const mgmtUser = users.find(u => u.email?.toLowerCase() === user?.email?.toLowerCase());
|
|
300
300
|
if (mgmtUser) {
|
|
301
|
-
// check if the uid
|
|
302
|
-
|
|
303
|
-
|
|
301
|
+
// check if the uid or photoURL needs to be updated in the user management system
|
|
302
|
+
const needsUidUpdate = mgmtUser.uid !== user.uid;
|
|
303
|
+
const needsPhotoUpdate = user.photoURL && mgmtUser.photoURL !== user.photoURL;
|
|
304
|
+
|
|
305
|
+
if (needsUidUpdate || needsPhotoUpdate) {
|
|
306
|
+
const updateReason = needsUidUpdate ? "uid" : "photoURL";
|
|
307
|
+
console.debug(`User ${updateReason} has changed, updating user in user management system`);
|
|
304
308
|
saveUser({
|
|
305
309
|
...mgmtUser,
|
|
306
|
-
uid: user.uid
|
|
310
|
+
uid: user.uid,
|
|
311
|
+
...(needsPhotoUpdate ? { photoURL: user.photoURL } : {})
|
|
307
312
|
}).then(() => {
|
|
308
313
|
console.debug("User updated in user management system", mgmtUser);
|
|
309
314
|
}).catch(e => {
|
|
@@ -322,7 +327,10 @@ export function useBuildUserManagement<CONTROLLER extends AuthController<any> =
|
|
|
322
327
|
|
|
323
328
|
const userRoleIds = userRoles?.map(r => r.id);
|
|
324
329
|
useEffect(() => {
|
|
325
|
-
console.debug("Setting user roles", {
|
|
330
|
+
console.debug("Setting user roles", {
|
|
331
|
+
userRoles,
|
|
332
|
+
roles
|
|
333
|
+
});
|
|
326
334
|
authController.setUserRoles?.(userRoles ?? []);
|
|
327
335
|
}, [userRoleIds]);
|
|
328
336
|
|
|
@@ -61,7 +61,7 @@ export function IntroWidget({
|
|
|
61
61
|
You have no users or roles defined. You can create default roles and add the current user as admin.
|
|
62
62
|
</Typography>
|
|
63
63
|
<Button
|
|
64
|
-
|
|
64
|
+
|
|
65
65
|
onClick={() => {
|
|
66
66
|
if (!authController.user?.uid) {
|
|
67
67
|
throw Error("UsersTable, authController misconfiguration");
|