@firecms/user_management 3.0.1 → 3.1.0-canary.8958c1b

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.
@@ -1,15 +1,12 @@
1
1
  import * as Yup from "yup";
2
2
  import { EntityCollection, Role } from "@firecms/core";
3
- export declare const RoleYupSchema: Yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
4
- id: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
5
- name: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
6
- }>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
7
- id: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
8
- name: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
9
- }>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
10
- id: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
11
- name: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
12
- }>>>;
3
+ export declare const RoleYupSchema: Yup.ObjectSchema<{
4
+ id: string;
5
+ name: string;
6
+ }, Yup.AnyObject, {
7
+ id: undefined;
8
+ name: undefined;
9
+ }, "">;
13
10
  export declare function RolesDetailsForm({ open, role, editable, handleClose, collections }: {
14
11
  open: boolean;
15
12
  editable?: boolean;
@@ -1,18 +1,14 @@
1
1
  import * as Yup from "yup";
2
2
  import { User } from "@firecms/core";
3
- export declare const UserYupSchema: Yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
4
- displayName: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
5
- email: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
6
- roles: import("yup/lib/array").OptionalArraySchema<Yup.AnySchema, import("yup/lib/types").AnyObject, any[] | undefined>;
7
- }>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
8
- displayName: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
9
- email: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
10
- roles: import("yup/lib/array").OptionalArraySchema<Yup.AnySchema, import("yup/lib/types").AnyObject, any[] | undefined>;
11
- }>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
12
- displayName: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
13
- email: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
14
- roles: import("yup/lib/array").OptionalArraySchema<Yup.AnySchema, import("yup/lib/types").AnyObject, any[] | undefined>;
15
- }>>>;
3
+ export declare const UserYupSchema: Yup.ObjectSchema<{
4
+ displayName: string;
5
+ email: string;
6
+ roles: any[] | undefined;
7
+ }, Yup.AnyObject, {
8
+ displayName: undefined;
9
+ email: undefined;
10
+ roles: undefined;
11
+ }, "">;
16
12
  export declare function UserDetailsForm({ open, user: userProp, handleClose }: {
17
13
  open: boolean;
18
14
  user?: User;
package/dist/index.es.js CHANGED
@@ -3,7 +3,7 @@ import equal from "react-fast-compare";
3
3
  import { removeUndefined, useAuthController, toSnakeCase, FieldCaption, ConfirmationDialog, useNavigationController, useSnackbarController, useCustomizationController, defaultDateFormat } from "@firecms/core";
4
4
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
5
5
  import { c } from "react-compiler-runtime";
6
- import { getColorSchemeForSeed, Chip, TextField, TableRow, TableCell, Checkbox, Tooltip, Button, Typography, DialogTitle, TableHeader, Paper, Table, TableBody, SelectItem, Select, DialogContent, LoadingButton, DialogActions, Dialog, IconButton, DeleteIcon, CenteredView, AddIcon, Container, MultiSelectItem, MultiSelect } from "@firecms/ui";
6
+ import { getColorSchemeForSeed, Chip, TextField, TableRow, TableCell, Checkbox, Tooltip, Button, Typography, DialogTitle, TableHeader, Paper, Table, TableBody, SelectItem, Select, DialogContent, LoadingButton, DialogActions, Dialog, IconButton, DeleteIcon, CenteredView, AddIcon, Container, MultiSelectItem, MultiSelect, Avatar } from "@firecms/ui";
7
7
  import * as Yup from "yup";
8
8
  import { useCreateFormex, getIn, Formex } from "@firecms/formex";
9
9
  import { format } from "date-fns";
@@ -348,11 +348,17 @@ function useBuildUserManagement({
348
348
  }
349
349
  const mgmtUser_0 = users.find((u_3) => u_3.email?.toLowerCase() === user_3?.email?.toLowerCase());
350
350
  if (mgmtUser_0) {
351
- if (mgmtUser_0.uid !== user_3.uid) {
352
- console.warn("User uid has changed, updating user in user management system");
351
+ const needsUidUpdate = mgmtUser_0.uid !== user_3.uid;
352
+ const needsPhotoUpdate = user_3.photoURL && mgmtUser_0.photoURL !== user_3.photoURL;
353
+ if (needsUidUpdate || needsPhotoUpdate) {
354
+ const updateReason = needsUidUpdate ? "uid" : "photoURL";
355
+ console.debug(`User ${updateReason} has changed, updating user in user management system`);
353
356
  saveUser({
354
357
  ...mgmtUser_0,
355
- uid: user_3.uid
358
+ uid: user_3.uid,
359
+ ...needsPhotoUpdate ? {
360
+ photoURL: user_3.photoURL
361
+ } : {}
356
362
  }).then(() => {
357
363
  console.debug("User updated in user management system", mgmtUser_0);
358
364
  }).catch((e_4) => {
@@ -1110,7 +1116,7 @@ function RolesDetailsForm(t0) {
1110
1116
  }
1111
1117
  let t80;
1112
1118
  if ($[144] !== handleClose) {
1113
- t80 = /* @__PURE__ */ jsx(Button, { variant: "text", color: "primary", onClick: () => {
1119
+ t80 = /* @__PURE__ */ jsx(Button, { variant: "text", onClick: () => {
1114
1120
  handleClose();
1115
1121
  }, children: "Cancel" });
1116
1122
  $[144] = handleClose;
@@ -1122,7 +1128,7 @@ function RolesDetailsForm(t0) {
1122
1128
  const t82 = isNewRole ? "Create role" : "Update";
1123
1129
  let t83;
1124
1130
  if ($[146] !== isSubmitting || $[147] !== t81 || $[148] !== t82) {
1125
- t83 = /* @__PURE__ */ jsx(LoadingButton, { variant: "filled", color: "primary", type: "submit", disabled: t81, loading: isSubmitting, children: t82 });
1131
+ t83 = /* @__PURE__ */ jsx(LoadingButton, { variant: "filled", type: "submit", disabled: t81, loading: isSubmitting, children: t82 });
1126
1132
  $[146] = isSubmitting;
1127
1133
  $[147] = t81;
1128
1134
  $[148] = t82;
@@ -1295,7 +1301,7 @@ function RolesTable(t0) {
1295
1301
  if ($[5] !== allowDefaultRolesCreation || $[6] !== roles || $[7] !== saveRole) {
1296
1302
  t3 = (!roles || roles.length === 0) && /* @__PURE__ */ jsx(TableRow, { children: /* @__PURE__ */ jsx(TableCell, { colspan: 4, children: /* @__PURE__ */ jsxs(CenteredView, { className: "flex flex-col gap-4 my-8 items-center", children: [
1297
1303
  /* @__PURE__ */ jsx(Typography, { variant: "label", children: "You don't have any roles yet." }),
1298
- allowDefaultRolesCreation && /* @__PURE__ */ jsx(Button, { variant: "outlined", onClick: () => {
1304
+ allowDefaultRolesCreation && /* @__PURE__ */ jsx(Button, { onClick: () => {
1299
1305
  DEFAULT_ROLES.forEach((role_0) => {
1300
1306
  saveRole(role_0);
1301
1307
  });
@@ -1721,7 +1727,7 @@ function UserDetailsForm(t0) {
1721
1727
  }
1722
1728
  let t25;
1723
1729
  if ($[53] !== handleClose) {
1724
- t25 = /* @__PURE__ */ jsx(Button, { variant: "text", color: "primary", onClick: () => {
1730
+ t25 = /* @__PURE__ */ jsx(Button, { variant: "text", onClick: () => {
1725
1731
  handleClose();
1726
1732
  }, children: "Cancel" });
1727
1733
  $[53] = handleClose;
@@ -1733,7 +1739,7 @@ function UserDetailsForm(t0) {
1733
1739
  const t27 = isNewUser ? "Create user" : "Update";
1734
1740
  let t28;
1735
1741
  if ($[55] !== isSubmitting || $[56] !== t26 || $[57] !== t27) {
1736
- t28 = /* @__PURE__ */ jsx(LoadingButton, { variant: "filled", color: "primary", type: "submit", disabled: t26, loading: isSubmitting, children: t27 });
1742
+ t28 = /* @__PURE__ */ jsx(LoadingButton, { variant: "filled", type: "submit", disabled: t26, loading: isSubmitting, children: t27 });
1737
1743
  $[55] = isSubmitting;
1738
1744
  $[56] = t26;
1739
1745
  $[57] = t27;
@@ -1832,11 +1838,12 @@ function UsersTable(t0) {
1832
1838
  let t1;
1833
1839
  if ($[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
1834
1840
  t1 = /* @__PURE__ */ jsxs(TableHeader, { children: [
1835
- /* @__PURE__ */ jsx(TableCell, { className: "truncate w-16" }),
1841
+ /* @__PURE__ */ jsx(TableCell, { className: "w-12" }),
1836
1842
  /* @__PURE__ */ jsx(TableCell, { children: "Email" }),
1837
1843
  /* @__PURE__ */ jsx(TableCell, { children: "Name" }),
1838
1844
  /* @__PURE__ */ jsx(TableCell, { children: "Roles" }),
1839
- /* @__PURE__ */ jsx(TableCell, { children: "Created on" })
1845
+ /* @__PURE__ */ jsx(TableCell, { children: "Created on" }),
1846
+ /* @__PURE__ */ jsx(TableCell, { className: "w-12" })
1840
1847
  ] });
1841
1848
  $[0] = t1;
1842
1849
  } else {
@@ -1852,14 +1859,15 @@ function UsersTable(t0) {
1852
1859
  return /* @__PURE__ */ jsxs(TableRow, { onClick: () => {
1853
1860
  onUserClicked(user);
1854
1861
  }, children: [
1855
- /* @__PURE__ */ jsx(TableCell, { className: "w-10", children: /* @__PURE__ */ jsx(Tooltip, { asChild: true, title: "Delete this user", children: /* @__PURE__ */ jsx(IconButton, { size: "small", onClick: (event) => {
1856
- event.stopPropagation();
1857
- return setUserToBeDeleted(user);
1858
- }, children: /* @__PURE__ */ jsx(DeleteIcon, {}) }) }) }),
1862
+ /* @__PURE__ */ jsx(TableCell, { className: "w-12", children: /* @__PURE__ */ jsx(Avatar, { src: user.photoURL ?? void 0, outerClassName: "w-8 h-8 min-w-8 min-h-8 p-0", className: "text-sm", hover: false, children: user.displayName ? user.displayName[0].toUpperCase() : user.email ? user.email[0].toUpperCase() : "U" }) }),
1859
1863
  /* @__PURE__ */ jsx(TableCell, { children: user.email }),
1860
1864
  /* @__PURE__ */ jsx(TableCell, { className: "font-medium align-left", children: user.displayName }),
1861
1865
  /* @__PURE__ */ jsx(TableCell, { className: "align-left", children: userRoles ? /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2", children: userRoles.map(_temp$1) }) : null }),
1862
- /* @__PURE__ */ jsx(TableCell, { children: formattedDate })
1866
+ /* @__PURE__ */ jsx(TableCell, { children: formattedDate }),
1867
+ /* @__PURE__ */ jsx(TableCell, { className: "w-12", children: /* @__PURE__ */ jsx(Tooltip, { asChild: true, title: "Delete this user", children: /* @__PURE__ */ jsx(IconButton, { size: "smallest", onClick: (event) => {
1868
+ event.stopPropagation();
1869
+ return setUserToBeDeleted(user);
1870
+ }, children: /* @__PURE__ */ jsx(DeleteIcon, { size: "small" }) }) }) })
1863
1871
  ] }, "row_" + user.uid);
1864
1872
  });
1865
1873
  $[1] = dateFormat;
@@ -1874,7 +1882,7 @@ function UsersTable(t0) {
1874
1882
  if ($[6] !== authController || $[7] !== saveUser || $[8] !== snackbarController || $[9] !== users) {
1875
1883
  t3 = (!users || users.length === 0) && /* @__PURE__ */ jsx(TableRow, { children: /* @__PURE__ */ jsx(TableCell, { colspan: 6, children: /* @__PURE__ */ jsxs(CenteredView, { className: "flex flex-col gap-4 my-8 items-center", children: [
1876
1884
  /* @__PURE__ */ jsx(Typography, { variant: "label", children: "There are no users yet" }),
1877
- /* @__PURE__ */ jsx(Button, { variant: "outlined", onClick: () => {
1885
+ /* @__PURE__ */ jsx(Button, { onClick: () => {
1878
1886
  if (!authController.user?.uid) {
1879
1887
  throw Error("UsersTable, authController misconfiguration");
1880
1888
  }
@@ -2242,7 +2250,7 @@ function IntroWidget(t0) {
2242
2250
  t5 = /* @__PURE__ */ jsxs(Paper, { className: "my-4 flex flex-col px-4 py-6 bg-white dark:bg-surface-accent-800 gap-2", children: [
2243
2251
  t1,
2244
2252
  t2,
2245
- /* @__PURE__ */ jsxs(Button, { variant: "outlined", onClick: t3, children: [
2253
+ /* @__PURE__ */ jsxs(Button, { onClick: t3, children: [
2246
2254
  t4,
2247
2255
  buttonLabel
2248
2256
  ] })