1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import * as React from 'react';
6 import { Grid, StyleRulesCallback, Divider, Typography } from '@material-ui/core';
7 import { Field, WrappedFieldProps } from 'redux-form';
8 import { WithStyles } from '@material-ui/core/styles';
9 import withStyles from '@material-ui/core/styles/withStyles';
10 import { VisibilityLevelSelect } from './visibility-level-select';
11 import { VisibilityLevel } from '~/store/sharing-dialog/sharing-dialog-types';
13 const sharingPublicAccessStyles: StyleRulesCallback<'root'> = theme => ({
15 padding: `${theme.spacing.unit * 2}px 0`,
19 const SharingPublicAccessForm = withStyles(sharingPublicAccessStyles)(
20 ({ classes, visibility }: WithStyles<'root'> & { visibility: VisibilityLevel }) =>
23 <Grid container alignItems='center' spacing={8} className={classes.root}>
25 <Typography variant='subtitle1'>
26 {renderVisibilityInfo(visibility)}
29 <Grid item xs={4} container wrap='nowrap'>
30 <Field name='visibility' component={VisibilityLevelSelectComponent} />
36 const renderVisibilityInfo = (visibility: VisibilityLevel) => {
38 case VisibilityLevel.PUBLIC:
39 return 'Anyone can access';
40 case VisibilityLevel.SHARED:
41 return 'Specific people can access';
42 case VisibilityLevel.PRIVATE:
43 return 'Only you can access';
49 export default ({ visibility }: { visibility: VisibilityLevel }) =>
50 <SharingPublicAccessForm {...{ visibility }} />;
52 const VisibilityLevelSelectComponent = ({ input }: WrappedFieldProps) =>
53 <VisibilityLevelSelect fullWidth disableUnderline {...input} />;