|
13 | 13 | * went with a simpler design. If we decide we really do need to display the
|
14 | 14 | * users like that, though, know that it will be painful
|
15 | 15 | */
|
| 16 | +import { useState } from "react"; |
16 | 17 | import { useTheme } from "@emotion/react";
|
17 | 18 | import { type User, type Role } from "api/typesGenerated";
|
18 | 19 |
|
19 | 20 | import { EditRolesButton } from "./EditRolesButton";
|
20 | 21 | import { Pill } from "components/Pill/Pill";
|
21 | 22 | import TableCell from "@mui/material/TableCell";
|
22 | 23 | import Stack from "@mui/material/Stack";
|
| 24 | +import Popover from "@mui/material/Popover"; |
23 | 25 |
|
24 | 26 | type UserRoleCellProps = {
|
25 | 27 | canEditUsers: boolean;
|
@@ -90,14 +92,54 @@ type OverflowRolePillProps = {
|
90 | 92 | function OverflowRolePill({ roles }: OverflowRolePillProps) {
|
91 | 93 | const theme = useTheme();
|
92 | 94 |
|
| 95 | + // 2023-10-18 - Temp code - Delete once new Popover component is ready |
| 96 | + const [anchorEl, setAnchorEl] = useState<HTMLDivElement | null>(null); |
| 97 | + |
93 | 98 | return (
|
94 |
| - <Pill |
95 |
| - text={`+${roles.length} more`} |
96 |
| - css={{ |
97 |
| - backgroundColor: theme.palette.background.paperLight, |
98 |
| - borderColor: theme.palette.divider, |
99 |
| - }} |
100 |
| - /> |
| 99 | + <> |
| 100 | + <div |
| 101 | + onPointerEnter={(event) => setAnchorEl(event.currentTarget)} |
| 102 | + onPointerLeave={() => setAnchorEl(null)} |
| 103 | + > |
| 104 | + <Pill |
| 105 | + text={`+${roles.length} more`} |
| 106 | + css={{ |
| 107 | + backgroundColor: theme.palette.background.paperLight, |
| 108 | + borderColor: theme.palette.divider, |
| 109 | + }} |
| 110 | + /> |
| 111 | + </div> |
| 112 | + |
| 113 | + <Popover |
| 114 | + aria-haspopup |
| 115 | + anchorEl={anchorEl} |
| 116 | + open={anchorEl !== null} |
| 117 | + anchorOrigin={{ vertical: "bottom", horizontal: "left" }} |
| 118 | + css={{ pointerEvents: "none" }} |
| 119 | + > |
| 120 | + <div |
| 121 | + css={{ |
| 122 | + display: "flex", |
| 123 | + flexFlow: "row wrap", |
| 124 | + columnGap: theme.spacing(1), |
| 125 | + rowGap: theme.spacing(1.5), |
| 126 | + padding: theme.spacing(1.5, 2), |
| 127 | + alignContent: "space-around", |
| 128 | + }} |
| 129 | + > |
| 130 | + {roles.map((role) => ( |
| 131 | + <Pill |
| 132 | + key={role.name} |
| 133 | + text={role.display_name || role.name} |
| 134 | + css={{ |
| 135 | + backgroundColor: theme.palette.background.paperLight, |
| 136 | + borderColor: theme.palette.divider, |
| 137 | + }} |
| 138 | + /> |
| 139 | + ))} |
| 140 | + </div> |
| 141 | + </Popover> |
| 142 | + </> |
101 | 143 | );
|
102 | 144 | }
|
103 | 145 |
|
|
0 commit comments