@firecms/user_management 3.0.0-canary.8 → 3.0.0-canary.9
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/UserManagementProvider.d.ts +4 -3
- package/dist/components/roles/RoleChip.d.ts +1 -1
- package/dist/components/roles/RolesDetailsForm.d.ts +1 -2
- package/dist/components/roles/RolesTable.d.ts +1 -1
- package/dist/components/roles/default_roles.d.ts +1 -1
- package/dist/components/users/UserDetailsForm.d.ts +2 -2
- package/dist/components/users/UsersTable.d.ts +2 -2
- package/dist/hooks/useUserManagement.d.ts +3 -2
- package/dist/index.es.js +9 -6
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/types/index.d.ts +1 -2
- package/dist/types/persisted_user.d.ts +5 -0
- package/dist/types/user_management.d.ts +2 -4
- package/dist/utils/permissions.d.ts +3 -4
- package/package.json +6 -8
- package/src/UserManagementProvider.tsx +4 -3
- package/src/components/roles/RoleChip.tsx +1 -1
- package/src/components/roles/RolesDetailsForm.tsx +1 -2
- package/src/components/roles/RolesTable.tsx +1 -2
- package/src/components/roles/RolesView.tsx +1 -2
- package/src/components/roles/default_roles.tsx +1 -1
- package/src/components/users/UserDetailsForm.tsx +11 -12
- package/src/components/users/UsersTable.tsx +6 -6
- package/src/components/users/UsersView.tsx +3 -3
- package/src/hooks/useBuildFirestoreUserManagement.tsx +11 -8
- package/src/hooks/useUserManagement.tsx +3 -3
- package/src/types/index.ts +1 -2
- package/src/types/persisted_user.ts +6 -0
- package/src/types/user_management.tsx +2 -4
- package/src/useUserManagementPlugin.tsx +1 -1
- package/src/utils/permissions.ts +3 -4
- package/dist/types/firecms_user.d.ts +0 -7
- package/dist/types/roles.d.ts +0 -31
- package/src/types/firecms_user.ts +0 -8
- package/src/types/roles.ts +0 -41
- package/tailwind.config.js +0 -68
@@ -1,7 +1,8 @@
|
|
1
1
|
import React, { PropsWithChildren } from "react";
|
2
|
-
import { UserManagement
|
2
|
+
import { UserManagement } from "./types";
|
3
|
+
import { User } from "@firecms/core";
|
3
4
|
export declare const UserManagementContext: React.Context<UserManagement<any>>;
|
4
|
-
export interface UserManagementProviderProps<U extends
|
5
|
+
export interface UserManagementProviderProps<U extends User = User> {
|
5
6
|
userManagement: UserManagement<U>;
|
6
7
|
}
|
7
|
-
export declare function UserManagementProvider<U extends
|
8
|
+
export declare function UserManagementProvider<U extends User = User>({ children, userManagement }: PropsWithChildren<UserManagementProviderProps<U>>): import("react/jsx-runtime").JSX.Element;
|
@@ -1,6 +1,5 @@
|
|
1
1
|
import * as Yup from "yup";
|
2
|
-
import { EntityCollection } from "@firecms/core";
|
3
|
-
import { Role } from "../../types";
|
2
|
+
import { EntityCollection, Role } from "@firecms/core";
|
4
3
|
export declare const RoleYupSchema: Yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
5
4
|
id: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
6
5
|
name: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import { Role } from "
|
1
|
+
import { Role } from "@firecms/core";
|
2
2
|
export declare const DEFAULT_ROLES: Role[];
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import * as Yup from "yup";
|
2
|
-
import {
|
2
|
+
import { User } from "@firecms/core";
|
3
3
|
export declare const UserYupSchema: Yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
4
4
|
displayName: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
5
5
|
email: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
@@ -15,6 +15,6 @@ export declare const UserYupSchema: Yup.ObjectSchema<import("yup/lib/object").As
|
|
15
15
|
}>>>;
|
16
16
|
export declare function UserDetailsForm({ open, user: userProp, handleClose }: {
|
17
17
|
open: boolean;
|
18
|
-
user?:
|
18
|
+
user?: User;
|
19
19
|
handleClose: () => void;
|
20
20
|
}): import("react/jsx-runtime").JSX.Element;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { User } from "@firecms/core";
|
2
2
|
export declare function UsersTable({ onUserClicked }: {
|
3
|
-
onUserClicked: (user:
|
3
|
+
onUserClicked: (user: User) => void;
|
4
4
|
}): import("react/jsx-runtime").JSX.Element;
|
@@ -1,2 +1,3 @@
|
|
1
|
-
import { UserManagement } from "../types
|
2
|
-
|
1
|
+
import { UserManagement } from "../types";
|
2
|
+
import { User } from "@firecms/core";
|
3
|
+
export declare const useUserManagement: <USER extends User>() => UserManagement<USER>;
|
package/dist/index.es.js
CHANGED
@@ -170,11 +170,14 @@ function yn({
|
|
170
170
|
if (!b || !i)
|
171
171
|
throw Error("useFirestoreConfigurationPersistence Firestore not initialised");
|
172
172
|
console.debug("Persisting user", C);
|
173
|
-
const D = C.roles
|
173
|
+
const D = C.roles?.map((Ue) => Ue.id), {
|
174
174
|
uid: W,
|
175
175
|
...X
|
176
176
|
} = C;
|
177
|
-
return ae(G(b, i, W), {
|
177
|
+
return ae(G(b, i, W), {
|
178
|
+
...X,
|
179
|
+
roles: D
|
180
|
+
}, { merge: !0 }).then(() => C);
|
178
181
|
}, [i]), S = E((C) => {
|
179
182
|
const b = N.current;
|
180
183
|
if (!b || !n)
|
@@ -880,10 +883,10 @@ const Ze = A.memo(
|
|
880
883
|
roles: V.array().min(1)
|
881
884
|
});
|
882
885
|
function nn(t, i, n, d, r) {
|
883
|
-
const m = n.filter((v) => v.roles
|
884
|
-
if ((!r || !We(r.roles, i.roles)) && !f)
|
886
|
+
const m = n.filter((v) => v.roles?.map((c) => c.id).includes("admin")), f = t.roles?.map((v) => v.id).includes("admin");
|
887
|
+
if ((!r || !We(r.roles ?? [], i.roles ?? [])) && !f)
|
885
888
|
throw new Error("Only admins can change roles");
|
886
|
-
if (r && r.roles
|
889
|
+
if (r && r.roles?.map((v) => v.id).includes("admin") && !i.roles?.map((v) => v.id).includes("admin") && m.length === 1)
|
887
890
|
throw new Error("There must be at least one admin");
|
888
891
|
return !0;
|
889
892
|
}
|
@@ -1002,7 +1005,7 @@ function tn({
|
|
1002
1005
|
Ae,
|
1003
1006
|
{
|
1004
1007
|
label: "Roles",
|
1005
|
-
value: g.roles
|
1008
|
+
value: g.roles?.map((h) => h.id) ?? [],
|
1006
1009
|
onMultiValueChange: (h) => y("roles", h.map((x) => p.find((U) => U.id === x))),
|
1007
1010
|
renderValue: (h) => {
|
1008
1011
|
const x = p.find((U) => U.id === h);
|