Skip to content

Commit aefb477

Browse files
refactor: Add description to the roles options (#4480)
1 parent 443173c commit aefb477

File tree

1 file changed

+49
-23
lines changed

1 file changed

+49
-23
lines changed

site/src/pages/TemplatePage/TemplatePermissionsPage/TemplatePermissionsPageView.tsx

Lines changed: 49 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import MenuItem from "@material-ui/core/MenuItem"
2-
import Select from "@material-ui/core/Select"
2+
import Select, { SelectProps } from "@material-ui/core/Select"
33
import { makeStyles } from "@material-ui/core/styles"
44
import Table from "@material-ui/core/Table"
55
import TableBody from "@material-ui/core/TableBody"
@@ -118,6 +118,34 @@ const AddTemplateUserOrGroup: React.FC<AddTemplateUserOrGroupProps> = ({
118118
)
119119
}
120120

121+
const RoleSelect: FC<SelectProps> = (props) => {
122+
const styles = useStyles()
123+
124+
return (
125+
<Select
126+
renderValue={(value) => <div className={styles.role}>{`${value}`}</div>}
127+
variant="outlined"
128+
className={styles.updateSelect}
129+
{...props}
130+
>
131+
<MenuItem key="view" value="view" className={styles.menuItem}>
132+
<div>
133+
<div>View</div>
134+
<div className={styles.menuItemSecondary}>Read, access</div>
135+
</div>
136+
</MenuItem>
137+
<MenuItem key="admin" value="admin" className={styles.menuItem}>
138+
<div>
139+
<div>Admin</div>
140+
<div className={styles.menuItemSecondary}>
141+
Read, access, edit, push, and delete
142+
</div>
143+
</div>
144+
</MenuItem>
145+
</Select>
146+
)
147+
}
148+
121149
export interface TemplatePermissionsPageViewProps {
122150
templateACL: TemplateACL | undefined
123151
organizationId: string
@@ -218,10 +246,8 @@ export const TemplatePermissionsPageView: FC<
218246
<TableCell>
219247
<ChooseOne>
220248
<Cond condition={canUpdatePermissions}>
221-
<Select
249+
<RoleSelect
222250
value={group.role}
223-
variant="outlined"
224-
className={styles.updateSelect}
225251
disabled={
226252
updatingGroup && updatingGroup.id === group.id
227253
}
@@ -231,14 +257,7 @@ export const TemplatePermissionsPageView: FC<
231257
event.target.value as TemplateRole,
232258
)
233259
}}
234-
>
235-
<MenuItem key="view" value="view">
236-
View
237-
</MenuItem>
238-
<MenuItem key="admin" value="admin">
239-
Admin
240-
</MenuItem>
241-
</Select>
260+
/>
242261
</Cond>
243262
<Cond>
244263
<div className={styles.role}>{group.role}</div>
@@ -283,10 +302,8 @@ export const TemplatePermissionsPageView: FC<
283302
<TableCell>
284303
<ChooseOne>
285304
<Cond condition={canUpdatePermissions}>
286-
<Select
305+
<RoleSelect
287306
value={user.role}
288-
variant="outlined"
289-
className={styles.updateSelect}
290307
disabled={
291308
updatingUser && updatingUser.id === user.id
292309
}
@@ -296,14 +313,7 @@ export const TemplatePermissionsPageView: FC<
296313
event.target.value as TemplateRole,
297314
)
298315
}}
299-
>
300-
<MenuItem key="view" value="view">
301-
View
302-
</MenuItem>
303-
<MenuItem key="admin" value="admin">
304-
Admin
305-
</MenuItem>
306-
</Select>
316+
/>
307317
</Cond>
308318
<Cond>
309319
<div className={styles.role}>{user.role}</div>
@@ -355,15 +365,31 @@ export const useStyles = makeStyles((theme) => {
355365
// Set a fixed width for the select. It avoids selects having different sizes
356366
// depending on how many roles they have selected.
357367
width: theme.spacing(25),
368+
358369
"& .MuiSelect-root": {
359370
// Adjusting padding because it does not have label
360371
paddingTop: theme.spacing(1.5),
361372
paddingBottom: theme.spacing(1.5),
373+
374+
".secondary": {
375+
display: "none",
376+
},
362377
},
363378
},
364379

365380
role: {
366381
textTransform: "capitalize",
367382
},
383+
384+
menuItem: {
385+
lineHeight: "140%",
386+
paddingTop: theme.spacing(1.5),
387+
paddingBottom: theme.spacing(1.5),
388+
},
389+
390+
menuItemSecondary: {
391+
fontSize: 14,
392+
color: theme.palette.text.secondary,
393+
},
368394
}
369395
})

0 commit comments

Comments
 (0)