Skip to content

refactor: Add description to the roles options #4480

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 1 commit into from
Oct 11, 2022
Merged
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import MenuItem from "@material-ui/core/MenuItem"
import Select from "@material-ui/core/Select"
import Select, { SelectProps } from "@material-ui/core/Select"
import { makeStyles } from "@material-ui/core/styles"
import Table from "@material-ui/core/Table"
import TableBody from "@material-ui/core/TableBody"
Expand Down Expand Up @@ -117,6 +117,34 @@ const AddTemplateUserOrGroup: React.FC<AddTemplateUserOrGroupProps> = ({
)
}

const RoleSelect: FC<SelectProps> = (props) => {
const styles = useStyles()

return (
<Select
renderValue={(value) => <div className={styles.role}>{`${value}`}</div>}
variant="outlined"
className={styles.updateSelect}
{...props}
>
<MenuItem key="view" value="view" className={styles.menuItem}>
<div>
<div>View</div>
<div className={styles.menuItemSecondary}>Read, access</div>
</div>
</MenuItem>
<MenuItem key="admin" value="admin" className={styles.menuItem}>
<div>
<div>Admin</div>
<div className={styles.menuItemSecondary}>
Read, access, edit, push, and delete
</div>
</div>
</MenuItem>
</Select>
)
}

export interface TemplatePermissionsPageViewProps {
templateACL: TemplateACL | undefined
organizationId: string
Expand Down Expand Up @@ -216,10 +244,8 @@ export const TemplatePermissionsPageView: FC<
<TableCell>
<ChooseOne>
<Cond condition={canUpdatePermissions}>
<Select
<RoleSelect
value={group.role}
variant="outlined"
className={styles.updateSelect}
disabled={
updatingGroup && updatingGroup.id === group.id
}
Expand All @@ -229,14 +255,7 @@ export const TemplatePermissionsPageView: FC<
event.target.value as TemplateRole,
)
}}
>
<MenuItem key="view" value="view">
View
</MenuItem>
<MenuItem key="admin" value="admin">
Admin
</MenuItem>
</Select>
/>
</Cond>
<Cond>
<div className={styles.role}>{group.role}</div>
Expand Down Expand Up @@ -281,10 +300,8 @@ export const TemplatePermissionsPageView: FC<
<TableCell>
<ChooseOne>
<Cond condition={canUpdatePermissions}>
<Select
<RoleSelect
value={user.role}
variant="outlined"
className={styles.updateSelect}
disabled={
updatingUser && updatingUser.id === user.id
}
Expand All @@ -294,14 +311,7 @@ export const TemplatePermissionsPageView: FC<
event.target.value as TemplateRole,
)
}}
>
<MenuItem key="view" value="view">
View
</MenuItem>
<MenuItem key="admin" value="admin">
Admin
</MenuItem>
</Select>
/>
</Cond>
<Cond>
<div className={styles.role}>{user.role}</div>
Expand Down Expand Up @@ -353,15 +363,31 @@ export const useStyles = makeStyles((theme) => {
// Set a fixed width for the select. It avoids selects having different sizes
// depending on how many roles they have selected.
width: theme.spacing(25),

"& .MuiSelect-root": {
// Adjusting padding because it does not have label
paddingTop: theme.spacing(1.5),
paddingBottom: theme.spacing(1.5),

".secondary": {
display: "none",
},
},
},

role: {
textTransform: "capitalize",
},

menuItem: {
lineHeight: "140%",
paddingTop: theme.spacing(1.5),
paddingBottom: theme.spacing(1.5),
},

menuItemSecondary: {
fontSize: 14,
color: theme.palette.text.secondary,
},
}
})