mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
refactor: Add description to the roles options (#4480)
This commit is contained in:
+49
-23
@@ -1,5 +1,5 @@
|
|||||||
import MenuItem from "@material-ui/core/MenuItem"
|
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 { makeStyles } from "@material-ui/core/styles"
|
||||||
import Table from "@material-ui/core/Table"
|
import Table from "@material-ui/core/Table"
|
||||||
import TableBody from "@material-ui/core/TableBody"
|
import TableBody from "@material-ui/core/TableBody"
|
||||||
@@ -118,6 +118,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 {
|
export interface TemplatePermissionsPageViewProps {
|
||||||
templateACL: TemplateACL | undefined
|
templateACL: TemplateACL | undefined
|
||||||
organizationId: string
|
organizationId: string
|
||||||
@@ -218,10 +246,8 @@ export const TemplatePermissionsPageView: FC<
|
|||||||
<TableCell>
|
<TableCell>
|
||||||
<ChooseOne>
|
<ChooseOne>
|
||||||
<Cond condition={canUpdatePermissions}>
|
<Cond condition={canUpdatePermissions}>
|
||||||
<Select
|
<RoleSelect
|
||||||
value={group.role}
|
value={group.role}
|
||||||
variant="outlined"
|
|
||||||
className={styles.updateSelect}
|
|
||||||
disabled={
|
disabled={
|
||||||
updatingGroup && updatingGroup.id === group.id
|
updatingGroup && updatingGroup.id === group.id
|
||||||
}
|
}
|
||||||
@@ -231,14 +257,7 @@ export const TemplatePermissionsPageView: FC<
|
|||||||
event.target.value as TemplateRole,
|
event.target.value as TemplateRole,
|
||||||
)
|
)
|
||||||
}}
|
}}
|
||||||
>
|
/>
|
||||||
<MenuItem key="view" value="view">
|
|
||||||
View
|
|
||||||
</MenuItem>
|
|
||||||
<MenuItem key="admin" value="admin">
|
|
||||||
Admin
|
|
||||||
</MenuItem>
|
|
||||||
</Select>
|
|
||||||
</Cond>
|
</Cond>
|
||||||
<Cond>
|
<Cond>
|
||||||
<div className={styles.role}>{group.role}</div>
|
<div className={styles.role}>{group.role}</div>
|
||||||
@@ -283,10 +302,8 @@ export const TemplatePermissionsPageView: FC<
|
|||||||
<TableCell>
|
<TableCell>
|
||||||
<ChooseOne>
|
<ChooseOne>
|
||||||
<Cond condition={canUpdatePermissions}>
|
<Cond condition={canUpdatePermissions}>
|
||||||
<Select
|
<RoleSelect
|
||||||
value={user.role}
|
value={user.role}
|
||||||
variant="outlined"
|
|
||||||
className={styles.updateSelect}
|
|
||||||
disabled={
|
disabled={
|
||||||
updatingUser && updatingUser.id === user.id
|
updatingUser && updatingUser.id === user.id
|
||||||
}
|
}
|
||||||
@@ -296,14 +313,7 @@ export const TemplatePermissionsPageView: FC<
|
|||||||
event.target.value as TemplateRole,
|
event.target.value as TemplateRole,
|
||||||
)
|
)
|
||||||
}}
|
}}
|
||||||
>
|
/>
|
||||||
<MenuItem key="view" value="view">
|
|
||||||
View
|
|
||||||
</MenuItem>
|
|
||||||
<MenuItem key="admin" value="admin">
|
|
||||||
Admin
|
|
||||||
</MenuItem>
|
|
||||||
</Select>
|
|
||||||
</Cond>
|
</Cond>
|
||||||
<Cond>
|
<Cond>
|
||||||
<div className={styles.role}>{user.role}</div>
|
<div className={styles.role}>{user.role}</div>
|
||||||
@@ -355,15 +365,31 @@ export const useStyles = makeStyles((theme) => {
|
|||||||
// Set a fixed width for the select. It avoids selects having different sizes
|
// Set a fixed width for the select. It avoids selects having different sizes
|
||||||
// depending on how many roles they have selected.
|
// depending on how many roles they have selected.
|
||||||
width: theme.spacing(25),
|
width: theme.spacing(25),
|
||||||
|
|
||||||
"& .MuiSelect-root": {
|
"& .MuiSelect-root": {
|
||||||
// Adjusting padding because it does not have label
|
// Adjusting padding because it does not have label
|
||||||
paddingTop: theme.spacing(1.5),
|
paddingTop: theme.spacing(1.5),
|
||||||
paddingBottom: theme.spacing(1.5),
|
paddingBottom: theme.spacing(1.5),
|
||||||
|
|
||||||
|
".secondary": {
|
||||||
|
display: "none",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
role: {
|
role: {
|
||||||
textTransform: "capitalize",
|
textTransform: "capitalize",
|
||||||
},
|
},
|
||||||
|
|
||||||
|
menuItem: {
|
||||||
|
lineHeight: "140%",
|
||||||
|
paddingTop: theme.spacing(1.5),
|
||||||
|
paddingBottom: theme.spacing(1.5),
|
||||||
|
},
|
||||||
|
|
||||||
|
menuItemSecondary: {
|
||||||
|
fontSize: 14,
|
||||||
|
color: theme.palette.text.secondary,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user