1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import React from 'react';
6 import { MenuItem, Select, withStyles, StyleRulesCallback } from '@material-ui/core';
7 import Lock from '@material-ui/icons/Lock';
8 import People from '@material-ui/icons/People';
9 import Public from '@material-ui/icons/Public';
10 import { WithStyles } from '@material-ui/core/styles';
11 import { SelectProps } from '@material-ui/core/Select';
12 import { SelectItem } from './select-item';
13 import { VisibilityLevel } from 'store/sharing-dialog/sharing-dialog-types';
16 type VisibilityLevelSelectClasses = 'value';
18 const VisibilityLevelSelectStyles: StyleRulesCallback<VisibilityLevelSelectClasses> = theme => ({
20 marginLeft: theme.spacing.unit,
23 export const VisibilityLevelSelect = withStyles(VisibilityLevelSelectStyles)(
24 ({ classes, ...props }: SelectProps & WithStyles<VisibilityLevelSelectClasses>) =>
27 renderValue={renderPermissionItem}
28 inputProps={{ classes }}>
29 <MenuItem value={VisibilityLevel.PUBLIC}>
30 {renderPermissionItem(VisibilityLevel.PUBLIC)}
32 <MenuItem value={VisibilityLevel.SHARED}>
33 {renderPermissionItem(VisibilityLevel.SHARED)}
35 <MenuItem value={VisibilityLevel.PRIVATE}>
36 {renderPermissionItem(VisibilityLevel.PRIVATE)}
40 const renderPermissionItem = (value: string) =>
41 <SelectItem {...{ value, icon: getIcon(value) }} />;
43 const getIcon = (value: string) => {
45 case VisibilityLevel.PUBLIC:
47 case VisibilityLevel.SHARED:
49 case VisibilityLevel.PRIVATE: