1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import * as React from 'react';
6 import { MenuItem, Select, withStyles, StyleRulesCallback } from '@material-ui/core';
7 import RemoveRedEye from '@material-ui/icons/RemoveRedEye';
8 import Edit from '@material-ui/icons/Edit';
9 import Computer from '@material-ui/icons/Computer';
10 import { WithStyles } from '@material-ui/core/styles';
11 import { SelectProps } from '@material-ui/core/Select';
12 import { SelectItem } from './select-item';
14 export enum PermissionSelectValue {
20 type PermissionSelectClasses = 'value';
22 const PermissionSelectStyles: StyleRulesCallback<PermissionSelectClasses> = theme => ({
24 marginLeft: theme.spacing.unit,
28 export const PermissionSelect = withStyles(PermissionSelectStyles)(
29 ({ classes, ...props }: SelectProps & WithStyles<PermissionSelectClasses>) =>
32 renderValue={renderPermissionItem}
33 inputProps={{ classes }}>
34 <MenuItem value={PermissionSelectValue.READ}>
35 {renderPermissionItem(PermissionSelectValue.READ)}
37 <MenuItem value={PermissionSelectValue.WRITE}>
38 {renderPermissionItem(PermissionSelectValue.WRITE)}
40 <MenuItem value={PermissionSelectValue.MANAGE}>
41 {renderPermissionItem(PermissionSelectValue.MANAGE)}
45 const renderPermissionItem = (value: string) =>
46 <SelectItem {...{ value, icon: getIcon(value) }} />;
48 const getIcon = (value: string) => {
50 case PermissionSelectValue.READ:
52 case PermissionSelectValue.WRITE:
54 case PermissionSelectValue.MANAGE: