-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a 'select all' option for columns and rows in the group permissio…
…ns edit page
- Loading branch information
SteveGT96
committed
Oct 29, 2024
1 parent
f3bda7a
commit f4ae4ab
Showing
8 changed files
with
137 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 11 additions & 31 deletions
42
src/components/accessories/admin/users/editPermissions/AclPermissionCheckbox.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,39 @@ | ||
import { Checkbox, Popper } from "@mui/material"; | ||
import { Checkbox, Tooltip } from "@mui/material"; | ||
import React from "react"; | ||
import { useTranslation } from "react-i18next"; | ||
import { PermissionDTO } from "../../../../../generated"; | ||
import { PermissionActionEnum } from "./permission.utils"; | ||
|
||
interface IProps { | ||
permission: PermissionDTO; | ||
groupPermissions: Array<PermissionDTO>; | ||
onChange: (permission: PermissionDTO, action: PermissionActionEnum) => void; | ||
onChange: ( | ||
permissions: [PermissionDTO], | ||
action: PermissionActionEnum | ||
) => void; | ||
} | ||
|
||
export const AclPermissionCheckbox = ({ | ||
permission, | ||
groupPermissions, | ||
onChange, | ||
}: IProps) => { | ||
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null); | ||
const open = Boolean(anchorEl); | ||
const id = open ? "simple-popper" : undefined; | ||
const { t } = useTranslation(); | ||
const checked = | ||
groupPermissions?.some((p) => p.id === permission.id) || false; | ||
return ( | ||
<> | ||
<Tooltip title={t(`permission.${permission.name!.split(".")[1]}`)}> | ||
<Checkbox | ||
aria-describedby={id} | ||
aria-describedby={permission.name} | ||
checked={checked} | ||
onChange={(_ev, val) => | ||
onChange( | ||
permission, | ||
[permission], | ||
checked ? PermissionActionEnum.REVOKE : PermissionActionEnum.ASSIGN | ||
) | ||
} | ||
name={permission.id.toString()} | ||
onMouseEnter={(event: React.MouseEvent<HTMLElement>) => { | ||
setAnchorEl(anchorEl ? null : event.currentTarget); | ||
}} | ||
onMouseLeave={() => setAnchorEl(null)} | ||
/> | ||
<Popper | ||
id={id} | ||
open={open} | ||
placement="right" | ||
disablePortal | ||
anchorEl={anchorEl} | ||
style={{ zIndex: 1 }} | ||
> | ||
<span | ||
style={{ | ||
backgroundColor: "#fc1812", | ||
color: "#fff", | ||
padding: "5px", | ||
}} | ||
> | ||
{permission.name || "unknown"} | ||
</span> | ||
</Popper> | ||
</> | ||
</Tooltip> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters