@firecms/user_management 3.0.0-canary.114 → 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.es.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import React, { useEffect, useCallback, useContext, useState } from "react";
2
2
  import equal from "react-fast-compare";
3
3
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
4
- import { getColorSchemeForSeed, Chip, Dialog, DialogContent, Typography, TextField, Paper, Table, TableHeader, TableCell, TableBody, TableRow, Tooltip, Checkbox, Select, SelectItem, DialogActions, Button, LoadingButton, DoneIcon, IconButton, DeleteIcon, CenteredView, Container, AddIcon, MultiSelect, MultiSelectItem } from "@firecms/ui";
4
+ import { getColorSchemeForSeed, Chip, Dialog, DialogContent, Typography, TextField, Paper, Table, TableHeader, TableCell, TableBody, TableRow, Tooltip, Checkbox, Button, Select, SelectItem, DialogActions, LoadingButton, DoneIcon, IconButton, DeleteIcon, CenteredView, Container, AddIcon, MultiSelect, MultiSelectItem } from "@firecms/ui";
5
5
  import * as Yup from "yup";
6
6
  import { toSnakeCase, FieldCaption, DeleteConfirmationDialog, useNavigationController, useSnackbarController, useAuthController, useCustomizationController, defaultDateFormat } from "@firecms/core";
7
7
  import { useCreateFormex, getIn, Formex } from "@firecms/formex";
@@ -496,201 +496,234 @@ function RolesDetailsForm({
496
496
  /* @__PURE__ */ jsx(FieldCaption, { children: touched.id && Boolean(errors.id) ? errors.id : "ID of this role" })
497
497
  ] }),
498
498
  /* @__PURE__ */ jsxs("div", { className: "col-span-12", children: [
499
- /* @__PURE__ */ jsx(
500
- Paper,
501
- {
502
- className: "bg-inherit",
503
- children: /* @__PURE__ */ jsxs(Table, { children: [
504
- /* @__PURE__ */ jsxs(TableHeader, { children: [
505
- /* @__PURE__ */ jsx(TableCell, {}),
506
- /* @__PURE__ */ jsx(
507
- TableCell,
508
- {
509
- align: "center",
510
- children: "Create entities"
511
- }
512
- ),
513
- /* @__PURE__ */ jsx(
514
- TableCell,
515
- {
516
- align: "center",
517
- children: "Read entities"
518
- }
519
- ),
520
- /* @__PURE__ */ jsx(
521
- TableCell,
522
- {
523
- align: "center",
524
- children: "Update entities"
525
- }
526
- ),
527
- /* @__PURE__ */ jsx(
528
- TableCell,
529
- {
530
- align: "center",
531
- children: "Delete entities"
532
- }
533
- )
534
- ] }),
535
- /* @__PURE__ */ jsxs(TableBody, { children: [
536
- /* @__PURE__ */ jsxs(TableRow, { children: [
537
- /* @__PURE__ */ jsx(
538
- TableCell,
539
- {
540
- scope: "row",
541
- children: /* @__PURE__ */ jsx("strong", { children: "All collections" })
542
- }
543
- ),
544
- /* @__PURE__ */ jsx(
545
- TableCell,
499
+ /* @__PURE__ */ jsx(Paper, { className: "bg-inherit overflow-hidden", children: /* @__PURE__ */ jsxs(Table, { className: "w-full rounded-md", children: [
500
+ /* @__PURE__ */ jsxs(TableHeader, { className: "rounded-md", children: [
501
+ /* @__PURE__ */ jsx(TableCell, {}),
502
+ /* @__PURE__ */ jsx(
503
+ TableCell,
504
+ {
505
+ align: "center",
506
+ children: "Create entities"
507
+ }
508
+ ),
509
+ /* @__PURE__ */ jsx(
510
+ TableCell,
511
+ {
512
+ align: "center",
513
+ children: "Read entities"
514
+ }
515
+ ),
516
+ /* @__PURE__ */ jsx(
517
+ TableCell,
518
+ {
519
+ align: "center",
520
+ children: "Update entities"
521
+ }
522
+ ),
523
+ /* @__PURE__ */ jsx(
524
+ TableCell,
525
+ {
526
+ align: "center",
527
+ children: "Delete entities"
528
+ }
529
+ ),
530
+ /* @__PURE__ */ jsx(
531
+ TableCell,
532
+ {
533
+ align: "center"
534
+ }
535
+ )
536
+ ] }),
537
+ /* @__PURE__ */ jsxs(TableBody, { children: [
538
+ /* @__PURE__ */ jsxs(TableRow, { children: [
539
+ /* @__PURE__ */ jsx(
540
+ TableCell,
541
+ {
542
+ scope: "row",
543
+ children: /* @__PURE__ */ jsx("strong", { children: "All collections" })
544
+ }
545
+ ),
546
+ /* @__PURE__ */ jsx(
547
+ TableCell,
548
+ {
549
+ align: "center",
550
+ children: /* @__PURE__ */ jsx(
551
+ Tooltip,
546
552
  {
547
- align: "center",
553
+ title: "Create entities in collections",
548
554
  children: /* @__PURE__ */ jsx(
549
- Tooltip,
555
+ Checkbox,
550
556
  {
551
- title: "Create entities in collections",
552
- children: /* @__PURE__ */ jsx(
553
- Checkbox,
554
- {
555
- disabled: isAdmin || !editable,
556
- checked: (isAdmin || defaultCreate) ?? false,
557
- onCheckedChange: (checked) => setFieldValue("defaultPermissions.create", checked)
558
- }
559
- )
557
+ disabled: isAdmin || !editable,
558
+ checked: (isAdmin || defaultCreate) ?? false,
559
+ onCheckedChange: (checked) => setFieldValue("defaultPermissions.create", checked)
560
560
  }
561
561
  )
562
562
  }
563
- ),
564
- /* @__PURE__ */ jsx(
565
- TableCell,
563
+ )
564
+ }
565
+ ),
566
+ /* @__PURE__ */ jsx(
567
+ TableCell,
568
+ {
569
+ align: "center",
570
+ children: /* @__PURE__ */ jsx(
571
+ Tooltip,
566
572
  {
567
- align: "center",
573
+ title: "Access all data in every collection",
568
574
  children: /* @__PURE__ */ jsx(
569
- Tooltip,
575
+ Checkbox,
570
576
  {
571
- title: "Access all data in every collection",
572
- children: /* @__PURE__ */ jsx(
573
- Checkbox,
574
- {
575
- disabled: isAdmin || !editable,
576
- checked: (isAdmin || defaultRead) ?? false,
577
- onCheckedChange: (checked) => setFieldValue("defaultPermissions.read", checked)
578
- }
579
- )
577
+ disabled: isAdmin || !editable,
578
+ checked: (isAdmin || defaultRead) ?? false,
579
+ onCheckedChange: (checked) => setFieldValue("defaultPermissions.read", checked)
580
580
  }
581
581
  )
582
582
  }
583
- ),
584
- /* @__PURE__ */ jsx(
585
- TableCell,
583
+ )
584
+ }
585
+ ),
586
+ /* @__PURE__ */ jsx(
587
+ TableCell,
588
+ {
589
+ align: "center",
590
+ children: /* @__PURE__ */ jsx(
591
+ Tooltip,
586
592
  {
587
- align: "center",
593
+ title: "Update data in any collection",
588
594
  children: /* @__PURE__ */ jsx(
589
- Tooltip,
595
+ Checkbox,
590
596
  {
591
- title: "Update data in any collection",
592
- children: /* @__PURE__ */ jsx(
593
- Checkbox,
594
- {
595
- disabled: isAdmin || !editable,
596
- checked: (isAdmin || defaultEdit) ?? false,
597
- onCheckedChange: (checked) => setFieldValue("defaultPermissions.edit", checked)
598
- }
599
- )
597
+ disabled: isAdmin || !editable,
598
+ checked: (isAdmin || defaultEdit) ?? false,
599
+ onCheckedChange: (checked) => setFieldValue("defaultPermissions.edit", checked)
600
600
  }
601
601
  )
602
602
  }
603
- ),
604
- /* @__PURE__ */ jsx(
605
- TableCell,
603
+ )
604
+ }
605
+ ),
606
+ /* @__PURE__ */ jsx(
607
+ TableCell,
608
+ {
609
+ align: "center",
610
+ children: /* @__PURE__ */ jsx(
611
+ Tooltip,
606
612
  {
607
- align: "center",
613
+ title: "Delete data in any collection",
608
614
  children: /* @__PURE__ */ jsx(
609
- Tooltip,
615
+ Checkbox,
610
616
  {
611
- title: "Delete data in any collection",
612
- children: /* @__PURE__ */ jsx(
613
- Checkbox,
614
- {
615
- disabled: isAdmin || !editable,
616
- checked: (isAdmin || defaultDelete) ?? false,
617
- onCheckedChange: (checked) => setFieldValue("defaultPermissions.delete", checked)
618
- }
619
- )
617
+ disabled: isAdmin || !editable,
618
+ checked: (isAdmin || defaultDelete) ?? false,
619
+ onCheckedChange: (checked) => setFieldValue("defaultPermissions.delete", checked)
620
620
  }
621
621
  )
622
622
  }
623
623
  )
624
- ] }),
625
- collections && collections.map((col) => /* @__PURE__ */ jsxs(TableRow, { children: [
626
- /* @__PURE__ */ jsx(
627
- TableCell,
624
+ }
625
+ ),
626
+ /* @__PURE__ */ jsx(
627
+ TableCell,
628
+ {
629
+ align: "center"
630
+ }
631
+ )
632
+ ] }),
633
+ collections && collections.map((col) => /* @__PURE__ */ jsxs(TableRow, { children: [
634
+ /* @__PURE__ */ jsx(
635
+ TableCell,
636
+ {
637
+ scope: "row",
638
+ children: col.name
639
+ }
640
+ ),
641
+ /* @__PURE__ */ jsx(
642
+ TableCell,
643
+ {
644
+ align: "center",
645
+ children: /* @__PURE__ */ jsx(
646
+ Checkbox,
628
647
  {
629
- scope: "row",
630
- children: col.name
648
+ disabled: isAdmin || defaultCreate || !editable,
649
+ checked: (isAdmin || defaultCreate || getIn(values, `collectionPermissions.${col.path}.create`)) ?? false,
650
+ onCheckedChange: (checked) => setFieldValue(`collectionPermissions.${col.path}.create`, checked)
631
651
  }
632
- ),
633
- /* @__PURE__ */ jsx(
634
- TableCell,
652
+ )
653
+ }
654
+ ),
655
+ /* @__PURE__ */ jsx(
656
+ TableCell,
657
+ {
658
+ align: "center",
659
+ children: /* @__PURE__ */ jsx(
660
+ Checkbox,
635
661
  {
636
- align: "center",
637
- children: /* @__PURE__ */ jsx(
638
- Checkbox,
639
- {
640
- disabled: isAdmin || defaultCreate || !editable,
641
- checked: (isAdmin || defaultCreate || getIn(values, `collectionPermissions.${col.path}.create`)) ?? false,
642
- onCheckedChange: (checked) => setFieldValue(`collectionPermissions.${col.path}.create`, checked)
643
- }
644
- )
662
+ disabled: isAdmin || defaultRead || !editable,
663
+ checked: (isAdmin || defaultRead || getIn(values, `collectionPermissions.${col.path}.read`)) ?? false,
664
+ onCheckedChange: (checked) => setFieldValue(`collectionPermissions.${col.path}.read`, checked)
645
665
  }
646
- ),
647
- /* @__PURE__ */ jsx(
648
- TableCell,
666
+ )
667
+ }
668
+ ),
669
+ /* @__PURE__ */ jsx(
670
+ TableCell,
671
+ {
672
+ align: "center",
673
+ children: /* @__PURE__ */ jsx(
674
+ Checkbox,
649
675
  {
650
- align: "center",
651
- children: /* @__PURE__ */ jsx(
652
- Checkbox,
653
- {
654
- disabled: isAdmin || defaultRead || !editable,
655
- checked: (isAdmin || defaultRead || getIn(values, `collectionPermissions.${col.path}.read`)) ?? false,
656
- onCheckedChange: (checked) => setFieldValue(`collectionPermissions.${col.path}.read`, checked)
657
- }
658
- )
676
+ disabled: isAdmin || defaultEdit || !editable,
677
+ checked: (isAdmin || defaultEdit || getIn(values, `collectionPermissions.${col.path}.edit`)) ?? false,
678
+ onCheckedChange: (checked) => setFieldValue(`collectionPermissions.${col.path}.edit`, checked)
659
679
  }
660
- ),
661
- /* @__PURE__ */ jsx(
662
- TableCell,
680
+ )
681
+ }
682
+ ),
683
+ /* @__PURE__ */ jsx(
684
+ TableCell,
685
+ {
686
+ align: "center",
687
+ children: /* @__PURE__ */ jsx(
688
+ Checkbox,
663
689
  {
664
- align: "center",
665
- children: /* @__PURE__ */ jsx(
666
- Checkbox,
667
- {
668
- disabled: isAdmin || defaultEdit || !editable,
669
- checked: (isAdmin || defaultEdit || getIn(values, `collectionPermissions.${col.path}.edit`)) ?? false,
670
- onCheckedChange: (checked) => setFieldValue(`collectionPermissions.${col.path}.edit`, checked)
671
- }
672
- )
690
+ disabled: isAdmin || defaultDelete || !editable,
691
+ checked: (isAdmin || defaultDelete || getIn(values, `collectionPermissions.${col.path}.delete`)) ?? false,
692
+ onCheckedChange: (checked) => setFieldValue(`collectionPermissions.${col.path}.delete`, checked)
673
693
  }
674
- ),
675
- /* @__PURE__ */ jsx(
676
- TableCell,
694
+ )
695
+ }
696
+ ),
697
+ /* @__PURE__ */ jsx(
698
+ TableCell,
699
+ {
700
+ align: "center",
701
+ children: /* @__PURE__ */ jsx(
702
+ Tooltip,
677
703
  {
678
- align: "center",
704
+ title: "Allow all permissions in this collections",
679
705
  children: /* @__PURE__ */ jsx(
680
- Checkbox,
706
+ Button,
681
707
  {
682
- disabled: isAdmin || defaultDelete || !editable,
683
- checked: (isAdmin || defaultDelete || getIn(values, `collectionPermissions.${col.path}.delete`)) ?? false,
684
- onCheckedChange: (checked) => setFieldValue(`collectionPermissions.${col.path}.delete`, checked)
708
+ className: "color-inherit",
709
+ onClick: () => {
710
+ setFieldValue(`collectionPermissions.${col.path}.create`, true);
711
+ setFieldValue(`collectionPermissions.${col.path}.read`, true);
712
+ setFieldValue(`collectionPermissions.${col.path}.edit`, true);
713
+ setFieldValue(`collectionPermissions.${col.path}.delete`, true);
714
+ },
715
+ disabled: isAdmin || !editable,
716
+ variant: "text",
717
+ children: "All"
685
718
  }
686
719
  )
687
720
  }
688
721
  )
689
- ] }, col.name))
690
- ] })
691
- ] })
692
- }
693
- ),
722
+ }
723
+ )
724
+ ] }, col.name))
725
+ ] })
726
+ ] }) }),
694
727
  /* @__PURE__ */ jsx(FieldCaption, { children: "You can customise the permissions that the users related to this role can perform in the entities of each collection" })
695
728
  ] }),
696
729
  /* @__PURE__ */ jsxs("div", { className: "col-span-12 md:col-span-4", children: [