1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import React from 'react';
6 import { CustomStyleRulesCallback } from 'common/custom-theme';
7 import { MenuItem, Select } from '@mui/material';
8 import withStyles from '@mui/styles/withStyles';
9 import Lock from '@mui/icons-material/Lock';
10 import People from '@mui/icons-material/People';
11 import Public from '@mui/icons-material/Public';
12 import { WithStyles } from '@mui/styles';
13 import { SelectProps } from '@mui/material/Select';
14 import { SelectItem } from './select-item';
15 import { VisibilityLevel } from 'store/sharing-dialog/sharing-dialog-types';
18 type VisibilityLevelSelectClasses = 'root';
20 const VisibilityLevelSelectStyles: CustomStyleRulesCallback<VisibilityLevelSelectClasses> = theme => ({
24 export const VisibilityLevelSelect = withStyles(VisibilityLevelSelectStyles)(
25 ({ classes, includePublic, ...props }: { includePublic: boolean } & SelectProps & WithStyles<VisibilityLevelSelectClasses>) =>
29 renderValue={renderPermissionItem}
30 inputProps={{ classes }}>
31 {includePublic && <MenuItem value={VisibilityLevel.PUBLIC}>
32 {renderPermissionItem(VisibilityLevel.PUBLIC)}
34 <MenuItem value={VisibilityLevel.ALL_USERS}>
35 {renderPermissionItem(VisibilityLevel.ALL_USERS)}
37 <MenuItem value={VisibilityLevel.SHARED}>
38 {renderPermissionItem(VisibilityLevel.SHARED)}
40 <MenuItem value={VisibilityLevel.PRIVATE}>
41 {renderPermissionItem(VisibilityLevel.PRIVATE)}
45 const renderPermissionItem = (value: string) =>
46 <SelectItem {...{ value, icon: getIcon(value) }} />;
48 const getIcon = (value: string) => {
50 case VisibilityLevel.PUBLIC:
52 case VisibilityLevel.ALL_USERS:
54 case VisibilityLevel.SHARED:
56 case VisibilityLevel.PRIVATE: