Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added templating and access requests buttons to the new model create screen #1563

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 65 additions & 7 deletions frontend/src/entry/CreateEntry.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ArrowBack, FileUpload, Lock, LockOpen } from '@mui/icons-material'
import { ArrowBack, FileUpload, FolderCopy, Gavel, Lock, LockOpen } from '@mui/icons-material'
import ExpandMoreIcon from '@mui/icons-material/ExpandMore'
import LoadingButton from '@mui/lab/LoadingButton'
import {
Expand All @@ -13,6 +13,7 @@ import {
Radio,
RadioGroup,
Stack,
Switch,
Tooltip,
Typography,
} from '@mui/material'
Expand Down Expand Up @@ -60,6 +61,8 @@ export default function CreateEntry({ createEntryKind, onBackClick }: CreateEntr
const [collaborators, setCollaborators] = useState<CollaboratorEntry[]>(
currentUser ? [{ entity: `${EntityKind.USER}:${currentUser?.dn}`, roles: ['owner'] }] : [],
)
const [ungovernedAccess, setungovernedAccess] = useState(false)
const [allowTemplating, setAllowTemplating] = useState(false)
const [errorMessage, setErrorMessage] = useState('')
const [loading, setLoading] = useState(false)

Expand All @@ -86,6 +89,8 @@ export default function CreateEntry({ createEntryKind, onBackClick }: CreateEntr
visibility,
collaborators,
settings: {
ungovernedAccess,
allowTemplating,
mirror: {
sourceModelId,
},
Expand All @@ -102,7 +107,7 @@ export default function CreateEntry({ createEntryKind, onBackClick }: CreateEntr
}
}

const privateLabel = () => {
const privateLabel = useMemo(() => {
return (
<Stack direction='row' justifyContent='center' alignItems='center' spacing={1}>
<Lock />
Expand All @@ -114,9 +119,9 @@ export default function CreateEntry({ createEntryKind, onBackClick }: CreateEntr
</Stack>
</Stack>
)
}
}, [createEntryKind])

const publicLabel = () => {
const publicLabel = useMemo(() => {
return (
<Stack direction='row' justifyContent='center' alignItems='center' spacing={1}>
<LockOpen />
Expand All @@ -128,7 +133,35 @@ export default function CreateEntry({ createEntryKind, onBackClick }: CreateEntr
</Stack>
</Stack>
)
}
}, [createEntryKind])

const allowTemplatingLabel = useMemo(() => {
return (
<Stack direction='row' justifyContent='center' alignItems='center' spacing={1}>
<FolderCopy />
<Stack sx={{ my: 1 }}>
<Typography fontWeight='bold'>Templating</Typography>
<Typography variant='caption'>
{`Allow this to be used as a template for another ${EntryKindLabel[createEntryKind]}`}
</Typography>
</Stack>
</Stack>
)
}, [createEntryKind])

const ungovernedAccessLabel = useMemo(() => {
return (
<Stack direction='row' justifyContent='center' alignItems='center' spacing={1}>
<Gavel />
<Stack sx={{ my: 1 }}>
<Typography fontWeight='bold'>Ungoverned Access Requests</Typography>
<Typography variant='caption'>
{`Allow users to request access without the need for authorisation from ${EntryKindLabel[createEntryKind]} owners`}
</Typography>
</Stack>
</Stack>
)
}, [createEntryKind])

if (isCurrentUserError) {
return <MessageAlert message={isCurrentUserError.info.message} severity='error' />
Expand Down Expand Up @@ -182,13 +215,13 @@ export default function CreateEntry({ createEntryKind, onBackClick }: CreateEntr
<FormControlLabel
value='public'
control={<Radio />}
label={publicLabel()}
label={publicLabel}
data-test='publicButtonSelector'
/>
<FormControlLabel
value='private'
control={<Radio />}
label={privateLabel()}
label={privateLabel}
data-test='privateButtonSelector'
/>
</RadioGroup>
Expand Down Expand Up @@ -224,6 +257,31 @@ export default function CreateEntry({ createEntryKind, onBackClick }: CreateEntr
]}
/>
</Box>
<Stack spacing={2}>
<Typography variant='h6' component='h2'>
Additional settings
</Typography>
<FormControlLabel
control={
<Switch
onChange={(e) => setungovernedAccess(e.target.checked)}
checked={ungovernedAccess}
size='small'
/>
}
label={ungovernedAccessLabel}
/>
<FormControlLabel
control={
<Switch
onChange={(event) => setAllowTemplating(event.target.checked)}
checked={allowTemplating}
size='small'
/>
}
label={allowTemplatingLabel}
/>
</Stack>
</AccordionDetails>
</Accordion>
<Box sx={{ textAlign: 'right' }}>
Expand Down
2 changes: 2 additions & 0 deletions frontend/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,8 @@ export interface EntryForm {
visibility: EntryVisibilityKeys
collaborators?: CollaboratorEntry[]
settings?: {
ungovernedAccess: boolean
allowTemplating: boolean
mirror?: {
sourceModelId?: string
destinationModelId?: string
Expand Down
Loading