Skip to content

feat: add user groups column to users table #10284

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 44 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
cb51aa8
refactor: extract UserRoleCell into separate component
Parkreiner Oct 15, 2023
a33fe0c
wip: add placeholder Groups column
Parkreiner Oct 15, 2023
cfd1807
fix: remove redundant css styles
Parkreiner Oct 15, 2023
d278c20
refactor: update EditRolesButton to use Sets to detect selections
Parkreiner Oct 15, 2023
2fdbd65
wip: commit progress for updated roles column
Parkreiner Oct 16, 2023
0c9525e
wip: commit current role pill progress
Parkreiner Oct 16, 2023
2e2bf08
fix: update state sync logic
Parkreiner Oct 16, 2023
b8a73f5
Merge branch 'main' into mes/table-user-groups
Parkreiner Oct 17, 2023
52cb1bf
chore: add groupsByUserId query options factory
Parkreiner Oct 17, 2023
df9b25c
fix: update return value of select function
Parkreiner Oct 17, 2023
a29f395
chore: drill groups data down to cell component
Parkreiner Oct 17, 2023
fd8dafc
wip: commit current cell progress
Parkreiner Oct 17, 2023
3b11414
fix: remove redundant classes
Parkreiner Oct 17, 2023
083bb16
wip: commit current styling progress
Parkreiner Oct 17, 2023
0061dc0
fix: update line height for CTA
Parkreiner Oct 17, 2023
25767c6
fix: update spacing
Parkreiner Oct 17, 2023
c2aea9b
chore: add tooltip for Groups column header
Parkreiner Oct 17, 2023
534cf82
fix: remove tsbuild file
Parkreiner Oct 17, 2023
f8d8de5
refactor: consolidate tooltip components
Parkreiner Oct 18, 2023
3ec6823
fix: update font size defaults inside theme
Parkreiner Oct 18, 2023
85d4de0
fix: expand hoverable/clickable area of groups cell
Parkreiner Oct 18, 2023
376d20c
fix: remove possible undefined cases from HelpTooltip
Parkreiner Oct 18, 2023
b9d2b72
chore: add popover functionality to groups
Parkreiner Oct 18, 2023
dc2fedd
wip: commit progress on groups tooltip
Parkreiner Oct 18, 2023
1624981
fix: remove zero-height group name visual bug
Parkreiner Oct 18, 2023
81f252b
feat: get basic version of user group tooltips done
Parkreiner Oct 18, 2023
6cc07b4
perf: move sort order callback outside loop
Parkreiner Oct 18, 2023
f73ba71
fix: update spacing for tooltip
Parkreiner Oct 18, 2023
c646d9f
feat: make popovers entirely hover-based
Parkreiner Oct 18, 2023
c46b42a
fix: disable scroll locking for popover
Parkreiner Oct 18, 2023
3b36858
docs: add comments explaining some pitfalls with Popover component
Parkreiner Oct 18, 2023
49570b0
refactor: simplify userRoleCell implementation
Parkreiner Oct 18, 2023
d18641e
feat: complete main feature
Parkreiner Oct 18, 2023
40846c6
fix: prevent scroll lock for role tooltips
Parkreiner Oct 18, 2023
c678223
fix: change import to type import
Parkreiner Oct 18, 2023
c642ef8
refactor: simplify how groups are clustered
Parkreiner Oct 19, 2023
774e4d5
Merge branch 'main' into mes/table-user-groups
Parkreiner Oct 19, 2023
d2cc9cc
refactor: update UserRoleCell to use Popover
Parkreiner Oct 19, 2023
33af1ce
refactor: remove unnecessary fragment
Parkreiner Oct 19, 2023
ccb213f
chore: add id/aria support for Popover
Parkreiner Oct 19, 2023
88eaf4a
refactor: update UserGroupsCell to use Popover
Parkreiner Oct 19, 2023
271b704
chore: redo visual design for UserGroupsCell
Parkreiner Oct 19, 2023
8cf2324
fix: shrink UserGroupsCell text
Parkreiner Oct 19, 2023
2e4ce81
fix: update UsersTable test to include groups info
Parkreiner Oct 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: update UserRoleCell to use Popover
  • Loading branch information
Parkreiner committed Oct 19, 2023
commit d2cc9ccec44c5e3a5230efac82f09a897edbf721
9 changes: 3 additions & 6 deletions site/src/components/Popover/Popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,7 @@ export const usePopover = () => {
return context;
};

export const PopoverTrigger = (props: {
children: TriggerElement;
hover?: boolean;
}) => {
export const PopoverTrigger = (props: { children: TriggerElement }) => {
const popover = usePopover();

const clickProps = {
Expand Down Expand Up @@ -118,10 +115,10 @@ export const PopoverContent = (
<MuiPopover
disablePortal
css={(theme) => ({
// When it is on hover mode, and the moude is moving from the trigger to
// When it is on hover mode, and the mode is moving from the trigger to
// the popover, if there is any space, the popover will be closed. I
// found this is a limitation on how MUI structured the component. It is
// not a big issue for now but we can reavaluate it in the future.
// not a big issue for now but we can re-evaluate it in the future.
marginTop: hoverMode ? undefined : theme.spacing(1),
pointerEvents: hoverMode ? "none" : undefined,
"& .MuiPaper-root": {
Expand Down
64 changes: 29 additions & 35 deletions site/src/pages/UsersPage/UsersTable/UserRoleCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,19 @@
* went with a simpler design. If we decide we really do need to display the
* users like that, though, know that it will be painful
*/
import { useState } from "react";
import { useTheme } from "@emotion/react";
import { type User, type Role } from "api/typesGenerated";

import { EditRolesButton } from "./EditRolesButton";
import { Pill } from "components/Pill/Pill";
import TableCell from "@mui/material/TableCell";
import Stack from "@mui/material/Stack";
import Popover from "@mui/material/Popover";

import {
Popover,
PopoverTrigger,
PopoverContent,
} from "components/Popover/Popover";

type UserRoleCellProps = {
canEditUsers: boolean;
Expand Down Expand Up @@ -92,41 +96,31 @@ type OverflowRolePillProps = {
function OverflowRolePill({ roles }: OverflowRolePillProps) {
const theme = useTheme();

// 2023-10-18 - Temp code - Delete once new Popover component is ready
const [anchorEl, setAnchorEl] = useState<HTMLDivElement | null>(null);

return (
<>
<div
onPointerEnter={(event) => setAnchorEl(event.currentTarget)}
onPointerLeave={() => setAnchorEl(null)}
>
<Pill
text={`+${roles.length} more`}
css={{
backgroundColor: theme.palette.background.paperLight,
borderColor: theme.palette.divider,
}}
/>
</div>

<Popover
aria-haspopup
anchorEl={anchorEl}
open={anchorEl !== null}
anchorOrigin={{ vertical: "bottom", horizontal: "left" }}
disableScrollLock
disablePortal
css={{ pointerEvents: "none" }}
>
<div
<Popover mode="hover">
<PopoverTrigger>
<Pill
text={`+${roles.length} more`}
css={{
backgroundColor: theme.palette.background.paperLight,
borderColor: theme.palette.divider,
}}
/>
</PopoverTrigger>

<PopoverContent
disableRestoreFocus
disableScrollLock
css={{
display: "flex",
flexFlow: "row wrap",
columnGap: theme.spacing(1),
rowGap: theme.spacing(1.5),
padding: theme.spacing(1.5, 2),
alignContent: "space-around",
".MuiPaper-root": {
display: "flex",
flexFlow: "row wrap",
columnGap: theme.spacing(1),
rowGap: theme.spacing(1.5),
padding: theme.spacing(1.5, 2),
alignContent: "space-around",
},
}}
>
{roles.map((role) => (
Expand All @@ -139,7 +133,7 @@ function OverflowRolePill({ roles }: OverflowRolePillProps) {
}}
/>
))}
</div>
</PopoverContent>
</Popover>
</>
);
Expand Down