@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @generated SignedSource<<a98cd84786da5d6229cb66bc24ad92d0>>
|
||||
* @generated SignedSource<<cfd9a630fcbe359cd0b4db0e940dd564>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
@@ -19,7 +19,6 @@ export type MitigationListViewQuery$data = {
|
||||
readonly organization: {
|
||||
readonly id: string;
|
||||
readonly mitigations?: {
|
||||
readonly __id: string;
|
||||
readonly edges: ReadonlyArray<{
|
||||
readonly node: {
|
||||
readonly category: string;
|
||||
@@ -177,18 +176,6 @@ v5 = [
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"kind": "ClientExtension",
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "__id",
|
||||
"storageKey": null
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
v6 = [
|
||||
@@ -314,6 +301,6 @@ return {
|
||||
};
|
||||
})();
|
||||
|
||||
(node as any).hash = "c2da6b42a986dd18cd18603c5f5809ad";
|
||||
(node as any).hash = "6b2de4417fd7175dd9ccd34549e097b7";
|
||||
|
||||
export default node;
|
||||
|
||||
@@ -14,6 +14,13 @@ import { Label } from "@/components/ui/label";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
import { useToast } from "@/hooks/use-toast";
|
||||
import { PageTemplate } from "@/components/PageTemplate";
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@/components/ui/select";
|
||||
|
||||
const createRiskMutation = graphql`
|
||||
mutation NewRiskViewCreateRiskMutation(
|
||||
@@ -26,6 +33,8 @@ const createRiskMutation = graphql`
|
||||
id
|
||||
name
|
||||
description
|
||||
probability
|
||||
impact
|
||||
createdAt
|
||||
updatedAt
|
||||
}
|
||||
@@ -39,11 +48,48 @@ export default function NewRiskView() {
|
||||
const { organizationId } = useParams<{ organizationId: string }>();
|
||||
const [name, setName] = useState("");
|
||||
const [description, setDescription] = useState("");
|
||||
const [probability, setProbability] = useState<string>("MEDIUM");
|
||||
const [impact, setImpact] = useState<string>("MEDIUM");
|
||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||
const { toast } = useToast();
|
||||
|
||||
const [commitMutation, isInFlight] = useMutation(createRiskMutation);
|
||||
|
||||
// Map string values to float values
|
||||
const probabilityToFloat = (value: string): number => {
|
||||
switch (value) {
|
||||
case "VERY_LOW":
|
||||
return 0.1;
|
||||
case "LOW":
|
||||
return 0.3;
|
||||
case "MEDIUM":
|
||||
return 0.5;
|
||||
case "HIGH":
|
||||
return 0.7;
|
||||
case "VERY_HIGH":
|
||||
return 0.9;
|
||||
default:
|
||||
return 0.5;
|
||||
}
|
||||
};
|
||||
|
||||
const impactToFloat = (value: string): number => {
|
||||
switch (value) {
|
||||
case "VERY_LOW":
|
||||
return 0.1;
|
||||
case "LOW":
|
||||
return 0.3;
|
||||
case "MEDIUM":
|
||||
return 0.5;
|
||||
case "HIGH":
|
||||
return 0.7;
|
||||
case "VERY_HIGH":
|
||||
return 0.9;
|
||||
default:
|
||||
return 0.5;
|
||||
}
|
||||
};
|
||||
|
||||
const handleSubmit = (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
|
||||
@@ -62,6 +108,8 @@ export default function NewRiskView() {
|
||||
organizationId: organizationId!,
|
||||
name,
|
||||
description,
|
||||
probability: probabilityToFloat(probability),
|
||||
impact: impactToFloat(impact),
|
||||
};
|
||||
|
||||
commitMutation({
|
||||
@@ -141,6 +189,40 @@ export default function NewRiskView() {
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="probability">Probability</Label>
|
||||
<Select value={probability} onValueChange={setProbability}>
|
||||
<SelectTrigger id="probability">
|
||||
<SelectValue placeholder="Select probability" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="VERY_LOW">Very Low</SelectItem>
|
||||
<SelectItem value="LOW">Low</SelectItem>
|
||||
<SelectItem value="MEDIUM">Medium</SelectItem>
|
||||
<SelectItem value="HIGH">High</SelectItem>
|
||||
<SelectItem value="VERY_HIGH">Very High</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="impact">Impact</Label>
|
||||
<Select value={impact} onValueChange={setImpact}>
|
||||
<SelectTrigger id="impact">
|
||||
<SelectValue placeholder="Select impact" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="VERY_LOW">Very Low</SelectItem>
|
||||
<SelectItem value="LOW">Low</SelectItem>
|
||||
<SelectItem value="MEDIUM">Medium</SelectItem>
|
||||
<SelectItem value="HIGH">High</SelectItem>
|
||||
<SelectItem value="VERY_HIGH">Very High</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex justify-end gap-3">
|
||||
<Button
|
||||
type="button"
|
||||
|
||||
@@ -71,6 +71,8 @@ const riskListFragment = graphql`
|
||||
node {
|
||||
id
|
||||
name
|
||||
probability
|
||||
impact
|
||||
description
|
||||
createdAt
|
||||
updatedAt
|
||||
@@ -275,6 +277,12 @@ function RiskListViewContent({
|
||||
<th className="h-12 px-4 text-left align-middle font-medium text-muted-foreground">
|
||||
Description
|
||||
</th>
|
||||
<th className="h-12 px-4 text-left align-middle font-medium text-muted-foreground">
|
||||
Probability
|
||||
</th>
|
||||
<th className="h-12 px-4 text-left align-middle font-medium text-muted-foreground">
|
||||
Impact %
|
||||
</th>
|
||||
<th className="h-12 px-4 text-left align-middle font-medium text-muted-foreground">
|
||||
Actions
|
||||
</th>
|
||||
@@ -284,7 +292,7 @@ function RiskListViewContent({
|
||||
{risks.length === 0 ? (
|
||||
<tr className="border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted">
|
||||
<td
|
||||
colSpan={3}
|
||||
colSpan={5}
|
||||
className="text-center p-4 align-middle text-muted-foreground"
|
||||
>
|
||||
No risks found. Create a new risk to get started.
|
||||
@@ -300,6 +308,12 @@ function RiskListViewContent({
|
||||
{risk.name}
|
||||
</td>
|
||||
<td className="p-4 align-middle">{risk.description}</td>
|
||||
<td className="p-4 align-middle">
|
||||
{(risk.probability * 100).toFixed(0)}%
|
||||
</td>
|
||||
<td className="p-4 align-middle">
|
||||
{(risk.impact * 100).toFixed(0)}%
|
||||
</td>
|
||||
<td className="p-4 align-middle">
|
||||
<Button
|
||||
variant="ghost"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @generated SignedSource<<c3a526641ca53f4ef760eacadc5c3685>>
|
||||
* @generated SignedSource<<6488a6430dca9def82544e0ac0ca0db8>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
@@ -11,8 +11,10 @@
|
||||
import { ConcreteRequest } from 'relay-runtime';
|
||||
export type CreateRiskInput = {
|
||||
description: string;
|
||||
impact: number;
|
||||
name: string;
|
||||
organizationId: string;
|
||||
probability: number;
|
||||
};
|
||||
export type NewRiskViewCreateRiskMutation$variables = {
|
||||
connections: ReadonlyArray<string>;
|
||||
@@ -25,7 +27,9 @@ export type NewRiskViewCreateRiskMutation$data = {
|
||||
readonly createdAt: string;
|
||||
readonly description: string;
|
||||
readonly id: string;
|
||||
readonly impact: number;
|
||||
readonly name: string;
|
||||
readonly probability: number;
|
||||
readonly updatedAt: string;
|
||||
};
|
||||
};
|
||||
@@ -91,6 +95,20 @@ v3 = {
|
||||
"name": "description",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "probability",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "impact",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
@@ -177,16 +195,16 @@ return {
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "ce3ac503734a6f0eb26f88813ed02858",
|
||||
"cacheID": "345bb376e4168b3b964b8a7ffa4ccbb9",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "NewRiskViewCreateRiskMutation",
|
||||
"operationKind": "mutation",
|
||||
"text": "mutation NewRiskViewCreateRiskMutation(\n $input: CreateRiskInput!\n) {\n createRisk(input: $input) {\n riskEdge {\n node {\n id\n name\n description\n createdAt\n updatedAt\n }\n }\n }\n}\n"
|
||||
"text": "mutation NewRiskViewCreateRiskMutation(\n $input: CreateRiskInput!\n) {\n createRisk(input: $input) {\n riskEdge {\n node {\n id\n name\n description\n probability\n impact\n createdAt\n updatedAt\n }\n }\n }\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
(node as any).hash = "c0d8d1f046ed41c7a429c54b32358d3f";
|
||||
(node as any).hash = "3cf30aab7c80cc9308343c6ec1577c5a";
|
||||
|
||||
export default node;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @generated SignedSource<<56b70bbecd785111cec0e7ff6ec2c226>>
|
||||
* @generated SignedSource<<e9f2db8dc7c26cc332a75299317684b7>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
@@ -186,6 +186,20 @@ return {
|
||||
"name": "name",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "probability",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "impact",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
@@ -294,16 +308,16 @@ return {
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "ea3c50c98dea1cce588bbb0e8705cbc4",
|
||||
"cacheID": "33b15ec024ff6f9963d539be971aef7b",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "RiskListViewPaginationQuery",
|
||||
"operationKind": "query",
|
||||
"text": "query RiskListViewPaginationQuery(\n $after: CursorKey\n $before: CursorKey\n $first: Int\n $last: Int\n $id: ID!\n) {\n node(id: $id) {\n __typename\n ...RiskListView_risks_pbnwq\n id\n }\n}\n\nfragment RiskListView_risks_pbnwq on Organization {\n risks(first: $first, after: $after, last: $last, before: $before) {\n edges {\n node {\n id\n name\n description\n createdAt\n updatedAt\n __typename\n }\n cursor\n }\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n }\n id\n}\n"
|
||||
"text": "query RiskListViewPaginationQuery(\n $after: CursorKey\n $before: CursorKey\n $first: Int\n $last: Int\n $id: ID!\n) {\n node(id: $id) {\n __typename\n ...RiskListView_risks_pbnwq\n id\n }\n}\n\nfragment RiskListView_risks_pbnwq on Organization {\n risks(first: $first, after: $after, last: $last, before: $before) {\n edges {\n node {\n id\n name\n probability\n impact\n description\n createdAt\n updatedAt\n __typename\n }\n cursor\n }\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n }\n id\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
(node as any).hash = "4a665835c97d7b93725e8bbe708d7cfb";
|
||||
(node as any).hash = "59f58f0b1c17242dea5e762b6337bf98";
|
||||
|
||||
export default node;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @generated SignedSource<<2812fb6e9c5db33d4c616daf9a11b012>>
|
||||
* @generated SignedSource<<f8cd1d0374c4a6de2b577c7fcb35c984>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
@@ -188,6 +188,20 @@ return {
|
||||
"name": "name",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "probability",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "impact",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
@@ -296,12 +310,12 @@ return {
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "7b0cab0d71217df4a49ea2245b2705a8",
|
||||
"cacheID": "78d7871004210dec73a83511b147856f",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "RiskListViewQuery",
|
||||
"operationKind": "query",
|
||||
"text": "query RiskListViewQuery(\n $organizationId: ID!\n $first: Int\n $after: CursorKey\n $last: Int\n $before: CursorKey\n) {\n organization: node(id: $organizationId) {\n __typename\n id\n ...RiskListView_risks_pbnwq\n }\n}\n\nfragment RiskListView_risks_pbnwq on Organization {\n risks(first: $first, after: $after, last: $last, before: $before) {\n edges {\n node {\n id\n name\n description\n createdAt\n updatedAt\n __typename\n }\n cursor\n }\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n }\n id\n}\n"
|
||||
"text": "query RiskListViewQuery(\n $organizationId: ID!\n $first: Int\n $after: CursorKey\n $last: Int\n $before: CursorKey\n) {\n organization: node(id: $organizationId) {\n __typename\n id\n ...RiskListView_risks_pbnwq\n }\n}\n\nfragment RiskListView_risks_pbnwq on Organization {\n risks(first: $first, after: $after, last: $last, before: $before) {\n edges {\n node {\n id\n name\n probability\n impact\n description\n createdAt\n updatedAt\n __typename\n }\n cursor\n }\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n }\n id\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @generated SignedSource<<5cb8bd63e484e9c8d842ddf05618d475>>
|
||||
* @generated SignedSource<<1d60fbe24f12a69953d5ade8fb94ec1e>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
@@ -19,7 +19,9 @@ export type RiskListView_risks$data = {
|
||||
readonly createdAt: string;
|
||||
readonly description: string;
|
||||
readonly id: string;
|
||||
readonly impact: number;
|
||||
readonly name: string;
|
||||
readonly probability: number;
|
||||
readonly updatedAt: string;
|
||||
};
|
||||
}>;
|
||||
@@ -137,6 +139,20 @@ return {
|
||||
"name": "name",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "probability",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "impact",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
@@ -239,6 +255,6 @@ return {
|
||||
};
|
||||
})();
|
||||
|
||||
(node as any).hash = "4a665835c97d7b93725e8bbe708d7cfb";
|
||||
(node as any).hash = "59f58f0b1c17242dea5e762b6337bf98";
|
||||
|
||||
export default node;
|
||||
|
||||
Reference in New Issue
Block a user