@firecms/user_management 3.0.0-canary.113 → 3.0.0-canary.115

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/index.umd.js CHANGED
@@ -230,28 +230,18 @@
230
230
  if (!usersPath) throw Error("useBuildUserManagement Firestore not initialised");
231
231
  console.debug("Persisting user", user);
232
232
  const roleIds = user.roles?.map((r) => r.id);
233
- const {
234
- uid,
235
- ...userData
236
- } = user;
233
+ const email = user.email?.toLowerCase().trim();
234
+ if (!email) throw Error("Email is required");
237
235
  const data = {
238
- ...userData,
236
+ ...user,
239
237
  roles: roleIds
240
238
  };
241
- if (uid) {
242
- return dataSourceDelegate.saveEntity({
243
- status: "existing",
244
- path: usersPath,
245
- entityId: uid,
246
- values: data
247
- }).then(() => user);
248
- } else {
249
- return dataSourceDelegate.saveEntity({
250
- status: "new",
251
- path: usersPath,
252
- values: data
253
- }).then(() => user);
254
- }
239
+ return dataSourceDelegate.saveEntity({
240
+ status: "existing",
241
+ path: usersPath,
242
+ entityId: email,
243
+ values: data
244
+ }).then(() => user);
255
245
  }, [usersPath, dataSourceDelegate?.initialised]);
256
246
  const saveRole = React.useCallback((role) => {
257
247
  if (!dataSourceDelegate) throw Error("useBuildUserManagement Firebase not initialised");
@@ -519,201 +509,234 @@
519
509
  /* @__PURE__ */ jsxRuntime.jsx(core.FieldCaption, { children: touched.id && Boolean(errors.id) ? errors.id : "ID of this role" })
520
510
  ] }),
521
511
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "col-span-12", children: [
522
- /* @__PURE__ */ jsxRuntime.jsx(
523
- ui.Paper,
524
- {
525
- className: "bg-inherit",
526
- children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Table, { children: [
527
- /* @__PURE__ */ jsxRuntime.jsxs(ui.TableHeader, { children: [
528
- /* @__PURE__ */ jsxRuntime.jsx(ui.TableCell, {}),
529
- /* @__PURE__ */ jsxRuntime.jsx(
530
- ui.TableCell,
531
- {
532
- align: "center",
533
- children: "Create entities"
534
- }
535
- ),
536
- /* @__PURE__ */ jsxRuntime.jsx(
537
- ui.TableCell,
538
- {
539
- align: "center",
540
- children: "Read entities"
541
- }
542
- ),
543
- /* @__PURE__ */ jsxRuntime.jsx(
544
- ui.TableCell,
545
- {
546
- align: "center",
547
- children: "Update entities"
548
- }
549
- ),
550
- /* @__PURE__ */ jsxRuntime.jsx(
551
- ui.TableCell,
552
- {
553
- align: "center",
554
- children: "Delete entities"
555
- }
556
- )
557
- ] }),
558
- /* @__PURE__ */ jsxRuntime.jsxs(ui.TableBody, { children: [
559
- /* @__PURE__ */ jsxRuntime.jsxs(ui.TableRow, { children: [
560
- /* @__PURE__ */ jsxRuntime.jsx(
561
- ui.TableCell,
562
- {
563
- scope: "row",
564
- children: /* @__PURE__ */ jsxRuntime.jsx("strong", { children: "All collections" })
565
- }
566
- ),
567
- /* @__PURE__ */ jsxRuntime.jsx(
568
- ui.TableCell,
512
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Paper, { className: "bg-inherit overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Table, { className: "w-full rounded-md", children: [
513
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.TableHeader, { className: "rounded-md", children: [
514
+ /* @__PURE__ */ jsxRuntime.jsx(ui.TableCell, {}),
515
+ /* @__PURE__ */ jsxRuntime.jsx(
516
+ ui.TableCell,
517
+ {
518
+ align: "center",
519
+ children: "Create entities"
520
+ }
521
+ ),
522
+ /* @__PURE__ */ jsxRuntime.jsx(
523
+ ui.TableCell,
524
+ {
525
+ align: "center",
526
+ children: "Read entities"
527
+ }
528
+ ),
529
+ /* @__PURE__ */ jsxRuntime.jsx(
530
+ ui.TableCell,
531
+ {
532
+ align: "center",
533
+ children: "Update entities"
534
+ }
535
+ ),
536
+ /* @__PURE__ */ jsxRuntime.jsx(
537
+ ui.TableCell,
538
+ {
539
+ align: "center",
540
+ children: "Delete entities"
541
+ }
542
+ ),
543
+ /* @__PURE__ */ jsxRuntime.jsx(
544
+ ui.TableCell,
545
+ {
546
+ align: "center"
547
+ }
548
+ )
549
+ ] }),
550
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.TableBody, { children: [
551
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.TableRow, { children: [
552
+ /* @__PURE__ */ jsxRuntime.jsx(
553
+ ui.TableCell,
554
+ {
555
+ scope: "row",
556
+ children: /* @__PURE__ */ jsxRuntime.jsx("strong", { children: "All collections" })
557
+ }
558
+ ),
559
+ /* @__PURE__ */ jsxRuntime.jsx(
560
+ ui.TableCell,
561
+ {
562
+ align: "center",
563
+ children: /* @__PURE__ */ jsxRuntime.jsx(
564
+ ui.Tooltip,
569
565
  {
570
- align: "center",
566
+ title: "Create entities in collections",
571
567
  children: /* @__PURE__ */ jsxRuntime.jsx(
572
- ui.Tooltip,
568
+ ui.Checkbox,
573
569
  {
574
- title: "Create entities in collections",
575
- children: /* @__PURE__ */ jsxRuntime.jsx(
576
- ui.Checkbox,
577
- {
578
- disabled: isAdmin || !editable,
579
- checked: (isAdmin || defaultCreate) ?? false,
580
- onCheckedChange: (checked) => setFieldValue("defaultPermissions.create", checked)
581
- }
582
- )
570
+ disabled: isAdmin || !editable,
571
+ checked: (isAdmin || defaultCreate) ?? false,
572
+ onCheckedChange: (checked) => setFieldValue("defaultPermissions.create", checked)
583
573
  }
584
574
  )
585
575
  }
586
- ),
587
- /* @__PURE__ */ jsxRuntime.jsx(
588
- ui.TableCell,
576
+ )
577
+ }
578
+ ),
579
+ /* @__PURE__ */ jsxRuntime.jsx(
580
+ ui.TableCell,
581
+ {
582
+ align: "center",
583
+ children: /* @__PURE__ */ jsxRuntime.jsx(
584
+ ui.Tooltip,
589
585
  {
590
- align: "center",
586
+ title: "Access all data in every collection",
591
587
  children: /* @__PURE__ */ jsxRuntime.jsx(
592
- ui.Tooltip,
588
+ ui.Checkbox,
593
589
  {
594
- title: "Access all data in every collection",
595
- children: /* @__PURE__ */ jsxRuntime.jsx(
596
- ui.Checkbox,
597
- {
598
- disabled: isAdmin || !editable,
599
- checked: (isAdmin || defaultRead) ?? false,
600
- onCheckedChange: (checked) => setFieldValue("defaultPermissions.read", checked)
601
- }
602
- )
590
+ disabled: isAdmin || !editable,
591
+ checked: (isAdmin || defaultRead) ?? false,
592
+ onCheckedChange: (checked) => setFieldValue("defaultPermissions.read", checked)
603
593
  }
604
594
  )
605
595
  }
606
- ),
607
- /* @__PURE__ */ jsxRuntime.jsx(
608
- ui.TableCell,
596
+ )
597
+ }
598
+ ),
599
+ /* @__PURE__ */ jsxRuntime.jsx(
600
+ ui.TableCell,
601
+ {
602
+ align: "center",
603
+ children: /* @__PURE__ */ jsxRuntime.jsx(
604
+ ui.Tooltip,
609
605
  {
610
- align: "center",
606
+ title: "Update data in any collection",
611
607
  children: /* @__PURE__ */ jsxRuntime.jsx(
612
- ui.Tooltip,
608
+ ui.Checkbox,
613
609
  {
614
- title: "Update data in any collection",
615
- children: /* @__PURE__ */ jsxRuntime.jsx(
616
- ui.Checkbox,
617
- {
618
- disabled: isAdmin || !editable,
619
- checked: (isAdmin || defaultEdit) ?? false,
620
- onCheckedChange: (checked) => setFieldValue("defaultPermissions.edit", checked)
621
- }
622
- )
610
+ disabled: isAdmin || !editable,
611
+ checked: (isAdmin || defaultEdit) ?? false,
612
+ onCheckedChange: (checked) => setFieldValue("defaultPermissions.edit", checked)
623
613
  }
624
614
  )
625
615
  }
626
- ),
627
- /* @__PURE__ */ jsxRuntime.jsx(
628
- ui.TableCell,
616
+ )
617
+ }
618
+ ),
619
+ /* @__PURE__ */ jsxRuntime.jsx(
620
+ ui.TableCell,
621
+ {
622
+ align: "center",
623
+ children: /* @__PURE__ */ jsxRuntime.jsx(
624
+ ui.Tooltip,
629
625
  {
630
- align: "center",
626
+ title: "Delete data in any collection",
631
627
  children: /* @__PURE__ */ jsxRuntime.jsx(
632
- ui.Tooltip,
628
+ ui.Checkbox,
633
629
  {
634
- title: "Delete data in any collection",
635
- children: /* @__PURE__ */ jsxRuntime.jsx(
636
- ui.Checkbox,
637
- {
638
- disabled: isAdmin || !editable,
639
- checked: (isAdmin || defaultDelete) ?? false,
640
- onCheckedChange: (checked) => setFieldValue("defaultPermissions.delete", checked)
641
- }
642
- )
630
+ disabled: isAdmin || !editable,
631
+ checked: (isAdmin || defaultDelete) ?? false,
632
+ onCheckedChange: (checked) => setFieldValue("defaultPermissions.delete", checked)
643
633
  }
644
634
  )
645
635
  }
646
636
  )
647
- ] }),
648
- collections && collections.map((col) => /* @__PURE__ */ jsxRuntime.jsxs(ui.TableRow, { children: [
649
- /* @__PURE__ */ jsxRuntime.jsx(
650
- ui.TableCell,
637
+ }
638
+ ),
639
+ /* @__PURE__ */ jsxRuntime.jsx(
640
+ ui.TableCell,
641
+ {
642
+ align: "center"
643
+ }
644
+ )
645
+ ] }),
646
+ collections && collections.map((col) => /* @__PURE__ */ jsxRuntime.jsxs(ui.TableRow, { children: [
647
+ /* @__PURE__ */ jsxRuntime.jsx(
648
+ ui.TableCell,
649
+ {
650
+ scope: "row",
651
+ children: col.name
652
+ }
653
+ ),
654
+ /* @__PURE__ */ jsxRuntime.jsx(
655
+ ui.TableCell,
656
+ {
657
+ align: "center",
658
+ children: /* @__PURE__ */ jsxRuntime.jsx(
659
+ ui.Checkbox,
651
660
  {
652
- scope: "row",
653
- children: col.name
661
+ disabled: isAdmin || defaultCreate || !editable,
662
+ checked: (isAdmin || defaultCreate || formex.getIn(values, `collectionPermissions.${col.path}.create`)) ?? false,
663
+ onCheckedChange: (checked) => setFieldValue(`collectionPermissions.${col.path}.create`, checked)
654
664
  }
655
- ),
656
- /* @__PURE__ */ jsxRuntime.jsx(
657
- ui.TableCell,
665
+ )
666
+ }
667
+ ),
668
+ /* @__PURE__ */ jsxRuntime.jsx(
669
+ ui.TableCell,
670
+ {
671
+ align: "center",
672
+ children: /* @__PURE__ */ jsxRuntime.jsx(
673
+ ui.Checkbox,
658
674
  {
659
- align: "center",
660
- children: /* @__PURE__ */ jsxRuntime.jsx(
661
- ui.Checkbox,
662
- {
663
- disabled: isAdmin || defaultCreate || !editable,
664
- checked: (isAdmin || defaultCreate || formex.getIn(values, `collectionPermissions.${col.path}.create`)) ?? false,
665
- onCheckedChange: (checked) => setFieldValue(`collectionPermissions.${col.path}.create`, checked)
666
- }
667
- )
675
+ disabled: isAdmin || defaultRead || !editable,
676
+ checked: (isAdmin || defaultRead || formex.getIn(values, `collectionPermissions.${col.path}.read`)) ?? false,
677
+ onCheckedChange: (checked) => setFieldValue(`collectionPermissions.${col.path}.read`, checked)
668
678
  }
669
- ),
670
- /* @__PURE__ */ jsxRuntime.jsx(
671
- ui.TableCell,
679
+ )
680
+ }
681
+ ),
682
+ /* @__PURE__ */ jsxRuntime.jsx(
683
+ ui.TableCell,
684
+ {
685
+ align: "center",
686
+ children: /* @__PURE__ */ jsxRuntime.jsx(
687
+ ui.Checkbox,
672
688
  {
673
- align: "center",
674
- children: /* @__PURE__ */ jsxRuntime.jsx(
675
- ui.Checkbox,
676
- {
677
- disabled: isAdmin || defaultRead || !editable,
678
- checked: (isAdmin || defaultRead || formex.getIn(values, `collectionPermissions.${col.path}.read`)) ?? false,
679
- onCheckedChange: (checked) => setFieldValue(`collectionPermissions.${col.path}.read`, checked)
680
- }
681
- )
689
+ disabled: isAdmin || defaultEdit || !editable,
690
+ checked: (isAdmin || defaultEdit || formex.getIn(values, `collectionPermissions.${col.path}.edit`)) ?? false,
691
+ onCheckedChange: (checked) => setFieldValue(`collectionPermissions.${col.path}.edit`, checked)
682
692
  }
683
- ),
684
- /* @__PURE__ */ jsxRuntime.jsx(
685
- ui.TableCell,
693
+ )
694
+ }
695
+ ),
696
+ /* @__PURE__ */ jsxRuntime.jsx(
697
+ ui.TableCell,
698
+ {
699
+ align: "center",
700
+ children: /* @__PURE__ */ jsxRuntime.jsx(
701
+ ui.Checkbox,
686
702
  {
687
- align: "center",
688
- children: /* @__PURE__ */ jsxRuntime.jsx(
689
- ui.Checkbox,
690
- {
691
- disabled: isAdmin || defaultEdit || !editable,
692
- checked: (isAdmin || defaultEdit || formex.getIn(values, `collectionPermissions.${col.path}.edit`)) ?? false,
693
- onCheckedChange: (checked) => setFieldValue(`collectionPermissions.${col.path}.edit`, checked)
694
- }
695
- )
703
+ disabled: isAdmin || defaultDelete || !editable,
704
+ checked: (isAdmin || defaultDelete || formex.getIn(values, `collectionPermissions.${col.path}.delete`)) ?? false,
705
+ onCheckedChange: (checked) => setFieldValue(`collectionPermissions.${col.path}.delete`, checked)
696
706
  }
697
- ),
698
- /* @__PURE__ */ jsxRuntime.jsx(
699
- ui.TableCell,
707
+ )
708
+ }
709
+ ),
710
+ /* @__PURE__ */ jsxRuntime.jsx(
711
+ ui.TableCell,
712
+ {
713
+ align: "center",
714
+ children: /* @__PURE__ */ jsxRuntime.jsx(
715
+ ui.Tooltip,
700
716
  {
701
- align: "center",
717
+ title: "Allow all permissions in this collections",
702
718
  children: /* @__PURE__ */ jsxRuntime.jsx(
703
- ui.Checkbox,
719
+ ui.Button,
704
720
  {
705
- disabled: isAdmin || defaultDelete || !editable,
706
- checked: (isAdmin || defaultDelete || formex.getIn(values, `collectionPermissions.${col.path}.delete`)) ?? false,
707
- onCheckedChange: (checked) => setFieldValue(`collectionPermissions.${col.path}.delete`, checked)
721
+ className: "color-inherit",
722
+ onClick: () => {
723
+ setFieldValue(`collectionPermissions.${col.path}.create`, true);
724
+ setFieldValue(`collectionPermissions.${col.path}.read`, true);
725
+ setFieldValue(`collectionPermissions.${col.path}.edit`, true);
726
+ setFieldValue(`collectionPermissions.${col.path}.delete`, true);
727
+ },
728
+ disabled: isAdmin || !editable,
729
+ variant: "text",
730
+ children: "All"
708
731
  }
709
732
  )
710
733
  }
711
734
  )
712
- ] }, col.name))
713
- ] })
714
- ] })
715
- }
716
- ),
735
+ }
736
+ )
737
+ ] }, col.name))
738
+ ] })
739
+ ] }) }),
717
740
  /* @__PURE__ */ jsxRuntime.jsx(core.FieldCaption, { children: "You can customise the permissions that the users related to this role can perform in the entities of each collection" })
718
741
  ] }),
719
742
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "col-span-12 md:col-span-4", children: [