-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ui-only WIP on redoing how action items are reported and the outcome …
…of a threat model
- Loading branch information
Showing
18 changed files
with
375 additions
and
264 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { | ||
KeyboardArrowDownRounded, | ||
KeyboardArrowUpRounded, | ||
} from "@mui/icons-material"; | ||
import { Badge, Box, Collapse, IconButton, Paper } from "@mui/material"; | ||
import { useState } from "react"; | ||
|
||
export function CollapsePaper({ | ||
title, | ||
count, | ||
children, | ||
defaultExpanded = false, | ||
sx, | ||
}) { | ||
const [expanded, setExpanded] = useState(defaultExpanded); | ||
|
||
return ( | ||
<Paper elevation={16} sx={sx}> | ||
<Box | ||
display="flex" | ||
alignItems="center" | ||
sx={{ paddingLeft: "10px", "&:hover": { cursor: "pointer" } }} | ||
onClick={(e) => { | ||
if (e.target === e.currentTarget) { | ||
setExpanded(!expanded); | ||
} | ||
}} | ||
> | ||
<Badge | ||
badgeContent={count} | ||
onClick={() => setExpanded(!expanded)} | ||
sx={{ | ||
alignItems: "center", | ||
gap: "10px", | ||
"& span": { | ||
position: "relative", | ||
transform: "scale(1)", | ||
backgroundColor: "dimgray", | ||
}, | ||
}} | ||
> | ||
{title} | ||
</Badge> | ||
<IconButton | ||
disableRipple | ||
size="large" | ||
sx={{ | ||
marginLeft: "auto", | ||
}} | ||
onClick={() => setExpanded(!expanded)} | ||
> | ||
{expanded ? <KeyboardArrowUpRounded /> : <KeyboardArrowDownRounded />} | ||
</IconButton> | ||
</Box> | ||
<Collapse in={expanded} timeout="auto" unmountOnExit> | ||
{children} | ||
</Collapse> | ||
</Paper> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { Chip, IconButton } from "@mui/material"; | ||
import EmailIcon from "@mui/icons-material/Email"; | ||
import ChatIcon from "@mui/icons-material/Chat"; | ||
|
||
export function UserChip({ user }) { | ||
return ( | ||
<Chip | ||
size="small" | ||
sx={{ | ||
color: (theme) => theme.palette.review.text, | ||
}} | ||
variant="outlined" | ||
label={user.name} | ||
icon={ | ||
<> | ||
{user?.slackUrl && ( | ||
<IconButton | ||
href={user?.slackUrl} | ||
target="_blank" | ||
rel="noreferrer" | ||
color="inherit" | ||
size="small" | ||
> | ||
<ChatIcon /> | ||
</IconButton> | ||
)} | ||
{user?.mail && ( | ||
<IconButton | ||
href={`mailto:${user?.mail}`} | ||
target="_blank" | ||
rel="noreferrer" | ||
color="inherit" | ||
size="small" | ||
> | ||
<EmailIcon /> | ||
</IconButton> | ||
)} | ||
</> | ||
} | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { useListThreatsQuery } from "../../../api/gram/threats"; | ||
import { useModelID } from "./useModelID"; | ||
|
||
export function useActionItems() { | ||
const modelId = useModelID(); | ||
const { data: threats } = useListThreatsQuery({ modelId }); | ||
|
||
const actionItems = threats?.threats | ||
? Object.keys(threats?.threats) | ||
.map((componentId) => ({ | ||
componentId, | ||
threats: threats?.threats[componentId].filter( | ||
(th) => th.isActionItem | ||
), | ||
})) | ||
.filter(({ threats }) => threats && threats.length > 0) | ||
: []; | ||
|
||
console.log(actionItems); | ||
|
||
return actionItems; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { ColorSlider } from "../../elements/ColorSlider"; | ||
|
||
export function ImpactSlider({ onChange, ...props }) { | ||
const marks = [ | ||
{ | ||
label: "Very low", | ||
description: `➢ Users can not interact with the service <1h | ||
➢ No regulatory sanctions/fines`, | ||
}, | ||
{ | ||
label: "Low", | ||
description: `➢ Users can not interact with the service <1-4h | ||
➢ Incident reviewed by authorities but dismissed`, | ||
}, | ||
{ | ||
label: "Medium", | ||
description: `➢ Users can not interact with the service <4-10h | ||
➢ Incident reviewed by authorities and regulatory warning`, | ||
}, | ||
{ | ||
label: "High", | ||
description: `➢ Users can not interact with the service <10-16h | ||
➢ Incident reviewed by authorities and sanctions/fines imposed`, | ||
}, | ||
{ | ||
label: "Very high", | ||
description: `➢ Users can not interact with the service >16h | ||
➢ Incident reviewed by authorities and sanctions/fines threaten operations / Loss of licence`, | ||
}, | ||
]; | ||
|
||
return ( | ||
<ColorSlider | ||
defaultValue={1} | ||
step={null} // restricts to only these steps | ||
marks={marks} | ||
onChange={(e) => onChange(marks[e.target.value])} | ||
{...props} | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { ColorSlider } from "../../elements/ColorSlider"; | ||
|
||
export function LikelihoodSlider({ onChange, ...props }) { | ||
const marks = [ | ||
{ | ||
label: "Rare", | ||
description: `➢ This will probably never happen/recur | ||
➢ Every 25 years`, | ||
}, | ||
{ | ||
label: "Unlikely", | ||
description: `➢ This is not likely to happen/recur but could | ||
➢ Every 10 years`, | ||
}, | ||
{ | ||
label: "Occasional", | ||
description: `➢ This is unexpected to happen/recur but is certainly possible to occur | ||
➢ Every 5 years`, | ||
}, | ||
{ | ||
label: "Likely", | ||
description: `➢ This will probably happen/recur but is not a persisting issue. | ||
➢ Every 3 years`, | ||
}, | ||
{ | ||
label: "Almost certain", | ||
description: `➢ This will undoubtedly happen/recur | ||
➢ Every year`, | ||
}, | ||
]; | ||
|
||
return ( | ||
<ColorSlider | ||
defaultValue={1} | ||
marks={marks} | ||
onChange={(e) => onChange(marks[e.target.value])} | ||
{...props} | ||
/> | ||
); | ||
} |
Oops, something went wrong.