| 1 |
import * as React from "react"; |
| 2 |
import Lock from "@mui/icons-material/Lock"; |
| 3 |
import Public from "@mui/icons-material/Public"; |
| 4 |
import { Box } from "@mui/material"; |
| 5 |
|
| 6 |
export const PermissionReadWrite = React.forwardRef((props, ref) => <PermissionInternal icon={Public} ref={ref} {...props} />); |
| 7 |
|
| 8 |
export const PermissionDenyAll = React.forwardRef((props, ref) => <PermissionInternal icon={Lock} ref={ref} {...props} />); |
| 9 |
|
| 10 |
export const PermissionRead = React.forwardRef((props, ref) => <PermissionInternal icon={Public} text="R" ref={ref} {...props} />); |
| 11 |
|
| 12 |
export const PermissionWrite = React.forwardRef((props, ref) => <PermissionInternal icon={Public} text="W" ref={ref} {...props} />); |
| 13 |
|
| 14 |
const PermissionInternal = React.forwardRef((props, ref) => { |
| 15 |
const size = props.size ?? "medium"; |
| 16 |
const Icon = props.icon; |
| 17 |
return ( |
| 18 |
<Box |
| 19 |
ref={ref} |
| 20 |
{...props} |
| 21 |
style={{ |
| 22 |
position: "relative", |
| 23 |
display: "inline-flex", |
| 24 |
verticalAlign: "middle", |
| 25 |
height: "24px", |
| 26 |
}} |
| 27 |
> |
| 28 |
<Icon fontSize={size} sx={{ color: "gray" }} /> |
| 29 |
{props.text && ( |
| 30 |
<Box |
| 31 |
sx={{ |
| 32 |
position: "absolute", |
| 33 |
right: "-6px", |
| 34 |
bottom: "5px", |
| 35 |
fontSize: 10, |
| 36 |
fontWeight: 600, |
| 37 |
color: "gray", |
| 38 |
width: "8px", |
| 39 |
height: "8px", |
| 40 |
marginTop: "3px", |
| 41 |
}} |
| 42 |
> |
| 43 |
{props.text} |
| 44 |
</Box> |
| 45 |
)} |
| 46 |
</Box> |
| 47 |
); |
| 48 |
}); |