Skip to content

Commit

Permalink
Merge branch 'dataset_security_feature' of https://github.com/bcgov/b…
Browse files Browse the repository at this point in the history
…iohubbc-platform into dataset_security_feature
  • Loading branch information
NickPhura committed Dec 8, 2023
2 parents e827ac2 + 0ab7a28 commit b2aa40e
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 6 deletions.
28 changes: 22 additions & 6 deletions app/src/components/security/ManageSecurity.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,46 @@
import { mdiChevronDown, mdiChevronUp } from '@mdi/js';
import { mdiChevronDown, mdiChevronUp, mdiLock, mdiLockOpenVariantOutline } from '@mdi/js';
import Icon from '@mdi/react';
import { Button, Menu, MenuItem } from '@mui/material';
import React from 'react';
import ListItemIcon from '@mui/material/ListItemIcon';
import ListItemText from '@mui/material/ListItemText';
import React, { useState } from 'react';
import UnsecureDialog from './UnsecureDialog';

const ManageSecurity: React.FC = () => {
const ManageSecurity = () => {
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
const [isUnsecureDialogOpen, setIsUnsecuredDialogOpen] = useState(false);
const open = Boolean(anchorEl);
const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
setAnchorEl(event.currentTarget);
};
const handleClose = () => {
setAnchorEl(null);
};

return (
<>
<UnsecureDialog isOpen={isUnsecureDialogOpen} onClose={() => setIsUnsecuredDialogOpen(false)} />
<Button
color="primary"
data-testid="manage-security"
variant="outlined"
onClick={handleClick}
endIcon={open ? <Icon path={mdiChevronUp} size={1}/> : <Icon path={mdiChevronDown} size={1}/>}>
endIcon={open ? <Icon path={mdiChevronUp} size={1} /> : <Icon path={mdiChevronDown} size={1} />}>
Manage Security
</Button>
<Menu open={open} anchorEl={anchorEl} onClose={handleClose}>
<MenuItem>Secure Records</MenuItem>
<MenuItem>Unsecure Records</MenuItem>
<MenuItem>
<ListItemIcon>
<Icon path={mdiLock} size={1} />
</ListItemIcon>
<ListItemText>Secure Records</ListItemText>
</MenuItem>
<MenuItem onClick={() => setIsUnsecuredDialogOpen(true)}>
<ListItemIcon>
<Icon path={mdiLockOpenVariantOutline} size={1} />
</ListItemIcon>
<ListItemText>Unsecure Records</ListItemText>
</MenuItem>
</Menu>
</>
);
Expand Down
36 changes: 36 additions & 0 deletions app/src/components/security/UnsecureDialog.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { Alert, AlertTitle, Typography } from '@mui/material';
import YesNoDialog from 'components/dialog/YesNoDialog';

interface IUnsecureDialogProps {
isOpen: boolean;
onClose: () => void;
}
const UnsecureDialog = (props: IUnsecureDialogProps) => {
return (
<YesNoDialog
open={props.isOpen}
onYes={() => {
console.log('Unsecure these fools');
}}
onNo={props.onClose}
onClose={() => {}}
dialogTitle="Unsecure Records?"
dialogContent={
<Alert severity="error" sx={{ marginTop: 4 }}>
<AlertTitle color="black">
<strong>Open access to all records</strong>
</AlertTitle>
<Typography color={'black'}>
Users will be able to access and download all records included in this dataset
</Typography>
</Alert>
}
dialogText="Are you sure you want to unsecure this dataset?"
yesButtonProps={{ color: 'error' }}
yesButtonLabel="UNSECURE"
noButtonLabel="CANCEL"
/>
);
};

export default UnsecureDialog;

0 comments on commit b2aa40e

Please sign in to comment.