Rename control to mitigation

Signed-off-by: gearnode <bryan@frimin.fr>
This commit is contained in:
gearnode
2025-03-27 13:07:27 +01:00
parent be64c1c260
commit 483a620fe7
58 changed files with 4972 additions and 4200 deletions

View File

@@ -9,6 +9,10 @@ All notable changes to this project will be documented in this file.
- Add sidebar to show a task. - Add sidebar to show a task.
- Add task estimate edition. - Add task estimate edition.
### Changed
- Rename control in mitigation.
### Fixed ### Fixed
- Fix panic in GraphQL resolver are not reported. - Fix panic in GraphQL resolver are not reported.

View File

View File

@@ -69,7 +69,7 @@ const SidebarProvider = React.forwardRef<
const [openMobile, setOpenMobile] = React.useState(false); const [openMobile, setOpenMobile] = React.useState(false);
// This is the internal state of the sidebar. // This is the internal state of the sidebar.
// We use openProp and setOpenProp for control from outside the component. // We use openProp and setOpenProp for mitigation from outside the component.
const [_open, _setOpen] = React.useState(defaultOpen); const [_open, _setOpen] = React.useState(defaultOpen);
const open = openProp ?? _open; const open = openProp ?? _open;
const setOpen = React.useCallback( const setOpen = React.useCallback(

View File

@@ -14,7 +14,7 @@ import { Toaster } from "@/components/ui/toaster";
import { graphql, useLazyLoadQuery } from "react-relay"; import { graphql, useLazyLoadQuery } from "react-relay";
import { cn } from "@/lib/utils"; import { cn } from "@/lib/utils";
import { OrganizationLayoutOrganizationQuery } from "./__generated__/OrganizationLayoutOrganizationQuery.graphql"; import { OrganizationLayoutOrganizationQuery } from "./__generated__/OrganizationLayoutOrganizationQuery.graphql";
import { OrganizationLayoutBreadcrumbControlOverviewQuery } from "./__generated__/OrganizationLayoutBreadcrumbControlOverviewQuery.graphql"; import { OrganizationLayoutBreadcrumbMitigationOverviewQuery } from "./__generated__/OrganizationLayoutBreadcrumbMitigationOverviewQuery.graphql";
import { OrganizationLayoutBreadcrumbFrameworkOverviewQuery } from "./__generated__/OrganizationLayoutBreadcrumbFrameworkOverviewQuery.graphql"; import { OrganizationLayoutBreadcrumbFrameworkOverviewQuery } from "./__generated__/OrganizationLayoutBreadcrumbFrameworkOverviewQuery.graphql";
import { OrganizationLayoutBreadcrumbPeopleOverviewQuery } from "./__generated__/OrganizationLayoutBreadcrumbPeopleOverviewQuery.graphql"; import { OrganizationLayoutBreadcrumbPeopleOverviewQuery } from "./__generated__/OrganizationLayoutBreadcrumbPeopleOverviewQuery.graphql";
import { OrganizationLayoutBreadcrumbPolicyOverviewQuery } from "./__generated__/OrganizationLayoutBreadcrumbPolicyOverviewQuery.graphql"; import { OrganizationLayoutBreadcrumbPolicyOverviewQuery } from "./__generated__/OrganizationLayoutBreadcrumbPolicyOverviewQuery.graphql";
@@ -270,23 +270,23 @@ function BreadcrumbPeopleOverview() {
); );
} }
function BreadcrumbControlOverview() { function BreadcrumbMitigationOverview() {
const { organizationId, frameworkId, controlId } = useParams(); const { organizationId, frameworkId, mitigationId } = useParams();
const data = const data =
useLazyLoadQuery<OrganizationLayoutBreadcrumbControlOverviewQuery>( useLazyLoadQuery<OrganizationLayoutBreadcrumbMitigationOverviewQuery>(
graphql` graphql`
query OrganizationLayoutBreadcrumbControlOverviewQuery( query OrganizationLayoutBreadcrumbMitigationOverviewQuery(
$controlId: ID! $mitigationId: ID!
) { ) {
control: node(id: $controlId) { mitigation: node(id: $mitigationId) {
id id
... on Control { ... on Mitigation {
name name
} }
} }
} }
`, `,
{ controlId: controlId! } { mitigationId: mitigationId! }
); );
return ( return (
@@ -294,9 +294,9 @@ function BreadcrumbControlOverview() {
<BreadcrumbSeparator /> <BreadcrumbSeparator />
<BreadcrumbItem> <BreadcrumbItem>
<BreadCrumbNavLink <BreadCrumbNavLink
to={`/organizations/${organizationId}/frameworks/${frameworkId}/controls/${controlId}`} to={`/organizations/${organizationId}/frameworks/${frameworkId}/mitigations/${mitigationId}`}
> >
{data.control?.name} {data.mitigation?.name}
</BreadCrumbNavLink> </BreadCrumbNavLink>
</BreadcrumbItem> </BreadcrumbItem>
<Outlet /> <Outlet />
@@ -304,23 +304,23 @@ function BreadcrumbControlOverview() {
); );
} }
function BreadcrumbCreateControl() { function BreadcrumbCreateMitigation() {
return ( return (
<> <>
<BreadcrumbSeparator /> <BreadcrumbSeparator />
<BreadcrumbItem> <BreadcrumbItem>
<BreadcrumbPage>Create Control</BreadcrumbPage> <BreadcrumbPage>Create Mitigation</BreadcrumbPage>
</BreadcrumbItem> </BreadcrumbItem>
</> </>
); );
} }
function BreadcrumbUpdateControl() { function BreadcrumbUpdateMitigation() {
return ( return (
<> <>
<BreadcrumbSeparator /> <BreadcrumbSeparator />
<BreadcrumbItem> <BreadcrumbItem>
<BreadcrumbPage>Update Control</BreadcrumbPage> <BreadcrumbPage>Update Mitigation</BreadcrumbPage>
</BreadcrumbItem> </BreadcrumbItem>
</> </>
); );
@@ -423,20 +423,20 @@ export default function OrganizationLayout() {
} }
> >
<Route <Route
path="controls/create" path="mitigations/create"
element={<BreadcrumbCreateControl />} element={<BreadcrumbCreateMitigation />}
/> />
<Route <Route
path="controls/:controlId" path="mitigations/:mitigationId"
element={ element={
<Suspense> <Suspense>
<BreadcrumbControlOverview /> <BreadcrumbMitigationOverview />
</Suspense> </Suspense>
} }
> >
<Route <Route
path="update" path="update"
element={<BreadcrumbUpdateControl />} element={<BreadcrumbUpdateMitigation />}
/> />
</Route> </Route>
<Route <Route

View File

@@ -9,9 +9,9 @@ import { CreatePeoplePage } from "./people/CreatePeoplePage";
import { PeoplePage } from "./people/PeoplePage"; import { PeoplePage } from "./people/PeoplePage";
import { CreateFrameworkPage } from "./frameworks/CreateFrameworkPage"; import { CreateFrameworkPage } from "./frameworks/CreateFrameworkPage";
import { UpdateFrameworkPage } from "./frameworks/UpdateFrameworkPage"; import { UpdateFrameworkPage } from "./frameworks/UpdateFrameworkPage";
import { CreateControlPage } from "./frameworks/controls/CreateControlPage"; import { CreateMitigationPage } from "./frameworks/mitigations/CreateMitigationPage";
import { ControlPage } from "./frameworks/controls/ControlPage"; import { MitigationPage } from "./frameworks/mitigations/MitigationPage";
import { UpdateControlPage } from "./frameworks/controls/UpdateControlPage"; import { UpdateMitigationPage } from "./frameworks/mitigations/UpdateMitigationPage";
import { VendorPage } from "./vendors/VendorPage"; import { VendorPage } from "./vendors/VendorPage";
import { PolicyListPage } from "./policies/PolicyListPage"; import { PolicyListPage } from "./policies/PolicyListPage";
import { CreatePolicyPage } from "./policies/CreatePolicyPage"; import { CreatePolicyPage } from "./policies/CreatePolicyPage";
@@ -38,16 +38,16 @@ export function OrganizationsRoutes() {
element={<UpdateFrameworkPage />} element={<UpdateFrameworkPage />}
/> />
<Route <Route
path="frameworks/:frameworkId/controls/create" path="frameworks/:frameworkId/mitigations/create"
element={<CreateControlPage />} element={<CreateMitigationPage />}
/> />
<Route <Route
path="frameworks/:frameworkId/controls/:controlId" path="frameworks/:frameworkId/mitigations/:mitigationId"
element={<ControlPage />} element={<MitigationPage />}
/> />
<Route <Route
path="frameworks/:frameworkId/controls/:controlId/update" path="frameworks/:frameworkId/mitigations/:mitigationId/update"
element={<UpdateControlPage />} element={<UpdateMitigationPage />}
/> />
<Route path="vendors/:vendorId" element={<VendorPage />} /> <Route path="vendors/:vendorId" element={<VendorPage />} />
<Route path="policies" element={<PolicyListPage />} /> <Route path="policies" element={<PolicyListPage />} />

View File

@@ -1,5 +1,5 @@
/** /**
* @generated SignedSource<<ebdda8f7be44df65a5ba836693e48bea>> * @generated SignedSource<<e194a128ba01be3824345ec9386bc7e5>>
* @lightSyntaxTransform * @lightSyntaxTransform
* @nogrep * @nogrep
*/ */
@@ -9,18 +9,18 @@
// @ts-nocheck // @ts-nocheck
import { ConcreteRequest } from 'relay-runtime'; import { ConcreteRequest } from 'relay-runtime';
export type OrganizationLayoutBreadcrumbControlOverviewQuery$variables = { export type OrganizationLayoutBreadcrumbMitigationOverviewQuery$variables = {
controlId: string; mitigationId: string;
}; };
export type OrganizationLayoutBreadcrumbControlOverviewQuery$data = { export type OrganizationLayoutBreadcrumbMitigationOverviewQuery$data = {
readonly control: { readonly mitigation: {
readonly id: string; readonly id: string;
readonly name?: string; readonly name?: string;
}; };
}; };
export type OrganizationLayoutBreadcrumbControlOverviewQuery = { export type OrganizationLayoutBreadcrumbMitigationOverviewQuery = {
response: OrganizationLayoutBreadcrumbControlOverviewQuery$data; response: OrganizationLayoutBreadcrumbMitigationOverviewQuery$data;
variables: OrganizationLayoutBreadcrumbControlOverviewQuery$variables; variables: OrganizationLayoutBreadcrumbMitigationOverviewQuery$variables;
}; };
const node: ConcreteRequest = (function(){ const node: ConcreteRequest = (function(){
@@ -28,14 +28,14 @@ var v0 = [
{ {
"defaultValue": null, "defaultValue": null,
"kind": "LocalArgument", "kind": "LocalArgument",
"name": "controlId" "name": "mitigationId"
} }
], ],
v1 = [ v1 = [
{ {
"kind": "Variable", "kind": "Variable",
"name": "id", "name": "id",
"variableName": "controlId" "variableName": "mitigationId"
} }
], ],
v2 = { v2 = {
@@ -56,7 +56,7 @@ v3 = {
"storageKey": null "storageKey": null
} }
], ],
"type": "Control", "type": "Mitigation",
"abstractKey": null "abstractKey": null
}; };
return { return {
@@ -64,10 +64,10 @@ return {
"argumentDefinitions": (v0/*: any*/), "argumentDefinitions": (v0/*: any*/),
"kind": "Fragment", "kind": "Fragment",
"metadata": null, "metadata": null,
"name": "OrganizationLayoutBreadcrumbControlOverviewQuery", "name": "OrganizationLayoutBreadcrumbMitigationOverviewQuery",
"selections": [ "selections": [
{ {
"alias": "control", "alias": "mitigation",
"args": (v1/*: any*/), "args": (v1/*: any*/),
"concreteType": null, "concreteType": null,
"kind": "LinkedField", "kind": "LinkedField",
@@ -87,10 +87,10 @@ return {
"operation": { "operation": {
"argumentDefinitions": (v0/*: any*/), "argumentDefinitions": (v0/*: any*/),
"kind": "Operation", "kind": "Operation",
"name": "OrganizationLayoutBreadcrumbControlOverviewQuery", "name": "OrganizationLayoutBreadcrumbMitigationOverviewQuery",
"selections": [ "selections": [
{ {
"alias": "control", "alias": "mitigation",
"args": (v1/*: any*/), "args": (v1/*: any*/),
"concreteType": null, "concreteType": null,
"kind": "LinkedField", "kind": "LinkedField",
@@ -112,16 +112,16 @@ return {
] ]
}, },
"params": { "params": {
"cacheID": "2fa16d62f29015853c425704e3de3fd4", "cacheID": "12d02036b7f66c280ddd621941750d00",
"id": null, "id": null,
"metadata": {}, "metadata": {},
"name": "OrganizationLayoutBreadcrumbControlOverviewQuery", "name": "OrganizationLayoutBreadcrumbMitigationOverviewQuery",
"operationKind": "query", "operationKind": "query",
"text": "query OrganizationLayoutBreadcrumbControlOverviewQuery(\n $controlId: ID!\n) {\n control: node(id: $controlId) {\n __typename\n id\n ... on Control {\n name\n }\n }\n}\n" "text": "query OrganizationLayoutBreadcrumbMitigationOverviewQuery(\n $mitigationId: ID!\n) {\n mitigation: node(id: $mitigationId) {\n __typename\n id\n ... on Mitigation {\n name\n }\n }\n}\n"
} }
}; };
})(); })();
(node as any).hash = "202e114f9b94e9c0bf805b0ae8f69fcd"; (node as any).hash = "cd0a93d3c44467278a33729c4a46b0bf";
export default node; export default node;

View File

@@ -10,7 +10,7 @@ export function CreateFrameworkViewSkeleton() {
return ( return (
<PageTemplateSkeleton <PageTemplateSkeleton
title="Create Framework" title="Create Framework"
description="Create a new framework to organize your controls" description="Create a new framework to organize your mitigations"
> >
<div className="max-w-2xl aspect-square bg-muted rounded-xl animate-pulse" /> <div className="max-w-2xl aspect-square bg-muted rounded-xl animate-pulse" />
</PageTemplateSkeleton> </PageTemplateSkeleton>

View File

@@ -170,7 +170,7 @@ function CreateFrameworkViewContent() {
return ( return (
<PageTemplate <PageTemplate
title="Create Framework" title="Create Framework"
description="Create a new framework to organize your controls" description="Create a new framework to organize your mitigations"
> >
<Card className="max-w-2xl"> <Card className="max-w-2xl">
<form onSubmit={handleSubmit} className="p-6 space-y-6"> <form onSubmit={handleSubmit} className="p-6 space-y-6">

View File

@@ -37,7 +37,7 @@ const FrameworkListViewQuery = graphql`
id id
name name
description description
controls(first: 100) { mitigations(first: 100) {
edges { edges {
node { node {
id id
@@ -66,7 +66,7 @@ const FrameworkListViewImportFrameworkMutation = graphql`
id id
name name
description description
controls(first: 100) { mitigations(first: 100) {
edges { edges {
node { node {
id id
@@ -240,10 +240,10 @@ function FrameworkListViewContent({
<div className="space-y-6"> <div className="space-y-6">
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-2"> <div className="grid gap-4 md:grid-cols-2 lg:grid-cols-2">
{frameworks.map((framework) => { {frameworks.map((framework) => {
const validatedControls = framework.controls.edges.filter( const validatedControls = framework.mitigations.edges.filter(
(edge) => edge?.node?.state === "IMPLEMENTED" (edge) => edge?.node?.state === "IMPLEMENTED"
).length; ).length;
const totalControls = framework.controls.edges.length; const totalControls = framework.mitigations.edges.length;
return ( return (
<Link <Link
@@ -267,7 +267,7 @@ function FrameworkListViewContent({
} }
progress={ progress={
validatedControls === totalControls validatedControls === totalControls
? "All controls validated" ? "All mitigations validated"
: `${validatedControls}/${totalControls} Controls validated` : `${validatedControls}/${totalControls} Controls validated`
} }
/> />

View File

@@ -29,7 +29,7 @@ const FrameworkViewQuery = graphql`
... on Framework { ... on Framework {
name name
description description
controls(first: 100) @connection(key: "FrameworkView_controls") { mitigations(first: 100) @connection(key: "FrameworkView_mitigations") {
edges { edges {
node { node {
id id
@@ -46,7 +46,7 @@ const FrameworkViewQuery = graphql`
} }
`; `;
interface Control { interface Mitigation {
id?: string; id?: string;
name?: string; name?: string;
description?: string; description?: string;
@@ -61,7 +61,7 @@ interface Category {
name: string; name: string;
description: string; description: string;
progress: number; progress: number;
controls: Control[]; mitigations: Mitigation[];
doneCount: number; doneCount: number;
totalCount: number; totalCount: number;
} }
@@ -73,14 +73,15 @@ function FrameworkViewContent({
}) { }) {
const data = usePreloadedQuery(FrameworkViewQuery, queryRef); const data = usePreloadedQuery(FrameworkViewQuery, queryRef);
const framework = data.node; const framework = data.node;
const controls = framework.controls?.edges.map((edge) => edge?.node) ?? []; const mitigations =
framework.mitigations?.edges.map((edge) => edge?.node) ?? [];
const navigate = useNavigate(); const navigate = useNavigate();
const { organizationId } = useParams(); const { organizationId } = useParams();
// Monitor URL hash for changes and update state accordingly // Monitor URL hash for changes and update state accordingly
const [hashValue, setHashValue] = useState(window.location.hash); const [hashValue, setHashValue] = useState(window.location.hash);
// Get the active category from the hash (used when returning from a control) // Get the active category from the hash (used when returning from a mitigation)
const hashCategory = hashValue.substring(1) const hashCategory = hashValue.substring(1)
? decodeURIComponent(hashValue.substring(1)) ? decodeURIComponent(hashValue.substring(1))
: ""; : "";
@@ -110,7 +111,7 @@ function FrameworkViewContent({
}; };
}, []); }, []);
// Map control state to status for the new design // Map mitigation state to status for the new design
const mapStateToStatus = (state?: string): string => { const mapStateToStatus = (state?: string): string => {
if (!state) return "incomplete"; if (!state) return "incomplete";
switch (state) { switch (state) {
@@ -125,17 +126,17 @@ function FrameworkViewContent({
} }
}; };
const processedControls = controls.map((control) => ({ const processedControls = mitigations.map((mitigation) => ({
...control, ...mitigation,
status: mapStateToStatus(control.state), status: mapStateToStatus(mitigation.state),
})); }));
// Calculate global progress // Calculate global progress
const implementedCount = processedControls.filter( const implementedCount = processedControls.filter(
(control) => control.status === "complete" (mitigation) => mitigation.status === "complete"
).length; ).length;
const notApplicableCount = processedControls.filter( const notApplicableCount = processedControls.filter(
(control) => control.status === "not-applicable" (mitigation) => mitigation.status === "not-applicable"
).length; ).length;
const totalControls = processedControls.length; const totalControls = processedControls.length;
@@ -146,22 +147,22 @@ function FrameworkViewContent({
: 0; : 0;
// Get global status counts // Get global status counts
const globalStatusCounts = processedControls.reduce((acc, control) => { const globalStatusCounts = processedControls.reduce((acc, mitigation) => {
if (control.status) { if (mitigation.status) {
acc[control.status] = (acc[control.status] || 0) + 1; acc[mitigation.status] = (acc[mitigation.status] || 0) + 1;
} }
return acc; return acc;
}, {} as Record<string, number>); }, {} as Record<string, number>);
// Group controls by category // Group mitigations by category
const controlsByCategory = processedControls.reduce((acc, control) => { const controlsByCategory = processedControls.reduce((acc, mitigation) => {
if (!control?.category) return acc; if (!mitigation?.category) return acc;
if (!acc[control.category]) { if (!acc[mitigation.category]) {
acc[control.category] = []; acc[mitigation.category] = [];
} }
acc[control.category].push(control); acc[mitigation.category].push(mitigation);
return acc; return acc;
}, {} as Record<string, Control[]>); }, {} as Record<string, Mitigation[]>);
// Function to toggle a category's expanded state - now supports multiple expanded categories // Function to toggle a category's expanded state - now supports multiple expanded categories
const toggleCategory = (categoryId: string) => { const toggleCategory = (categoryId: string) => {
@@ -177,10 +178,10 @@ function FrameworkViewContent({
const categories: Category[] = Object.entries(controlsByCategory) const categories: Category[] = Object.entries(controlsByCategory)
.map(([categoryName, categoryControls]) => { .map(([categoryName, categoryControls]) => {
const catImplementedCount = categoryControls.filter( const catImplementedCount = categoryControls.filter(
(control) => control.status === "complete" (mitigation) => mitigation.status === "complete"
).length; ).length;
const catNotApplicableCount = categoryControls.filter( const catNotApplicableCount = categoryControls.filter(
(control) => control.status === "not-applicable" (mitigation) => mitigation.status === "not-applicable"
).length; ).length;
// Consider both "complete" and "not-applicable" as done for category progress // Consider both "complete" and "not-applicable" as done for category progress
const catDoneCount = catImplementedCount + catNotApplicableCount; const catDoneCount = catImplementedCount + catNotApplicableCount;
@@ -194,14 +195,14 @@ function FrameworkViewContent({
name: categoryName, name: categoryName,
description: `Controls related to ${categoryName.toLowerCase()}`, description: `Controls related to ${categoryName.toLowerCase()}`,
progress: progress, progress: progress,
controls: categoryControls.sort((a, b) => mitigations: categoryControls.sort((a, b) =>
(a.name || "").localeCompare(b.name || "") (a.name || "").localeCompare(b.name || "")
), ),
doneCount: catDoneCount, doneCount: catDoneCount,
totalCount: catTotalCount, totalCount: catTotalCount,
}; };
}) })
.filter((category) => category.controls.length > 0) .filter((category) => category.mitigations.length > 0)
.sort((a, b) => a.name.localeCompare(b.name)); .sort((a, b) => a.name.localeCompare(b.name));
const getStatusIcon = (status: string) => { const getStatusIcon = (status: string) => {
@@ -235,10 +236,10 @@ function FrameworkViewContent({
</Button> </Button>
<Button asChild> <Button asChild>
<Link <Link
to={`/organizations/${organizationId}/frameworks/${framework.id}/controls/create`} to={`/organizations/${organizationId}/frameworks/${framework.id}/mitigations/create`}
> >
<Plus className="mr-2 h-4 w-4" /> <Plus className="mr-2 h-4 w-4" />
Create Control Create Mitigation
</Link> </Link>
</Button> </Button>
</div> </div>
@@ -385,7 +386,7 @@ function FrameworkViewContent({
{isExpanded && ( {isExpanded && (
<CardContent className="p-0"> <CardContent className="p-0">
{category.controls.length > 0 ? ( {category.mitigations.length > 0 ? (
<div className="w-full"> <div className="w-full">
<table className="w-full"> <table className="w-full">
<thead> <thead>
@@ -396,16 +397,18 @@ function FrameworkViewContent({
<th className="w-24 px-4 py-2 text-left"> <th className="w-24 px-4 py-2 text-left">
Status Status
</th> </th>
<th className="px-4 py-2 text-left">Control</th> <th className="px-4 py-2 text-left">
Mitigation
</th>
</tr> </tr>
</thead> </thead>
<tbody className="divide-y"> <tbody className="divide-y">
{category.controls.map((control) => ( {category.mitigations.map((mitigation) => (
<tr <tr
key={control.id || Math.random().toString()} key={mitigation.id || Math.random().toString()}
className="hover:bg-muted/50 cursor-pointer" className="hover:bg-muted/50 cursor-pointer"
onClick={() => { onClick={() => {
if (control?.id) { if (mitigation?.id) {
// Always store just this category in the hash // Always store just this category in the hash
// This is what will be expanded when returning // This is what will be expanded when returning
const encoded = encodeURIComponent( const encoded = encodeURIComponent(
@@ -427,7 +430,7 @@ function FrameworkViewContent({
// Use a small timeout to ensure the hash change is processed by the browser // Use a small timeout to ensure the hash change is processed by the browser
setTimeout(() => { setTimeout(() => {
navigate( navigate(
`/organizations/${organizationId}/frameworks/${framework.id}/controls/${control.id}` `/organizations/${organizationId}/frameworks/${framework.id}/mitigations/${mitigation.id}`
); );
}, 100); }, 100);
} }
@@ -435,19 +438,19 @@ function FrameworkViewContent({
> >
<td className="w-24 px-4 py-3 align-middle"> <td className="w-24 px-4 py-3 align-middle">
<Badge variant="outline" className="text-xs"> <Badge variant="outline" className="text-xs">
{control.importance} {mitigation.importance}
</Badge> </Badge>
</td> </td>
<td className="w-24 px-4 py-3 align-middle"> <td className="w-24 px-4 py-3 align-middle">
<div className="flex items-center justify-center"> <div className="flex items-center justify-center">
{control.status {mitigation.status
? getStatusIcon(control.status) ? getStatusIcon(mitigation.status)
: null} : null}
</div> </div>
</td> </td>
<td className="px-4 py-3 align-middle"> <td className="px-4 py-3 align-middle">
<div className="font-medium"> <div className="font-medium">
{control.name} {mitigation.name}
</div> </div>
</td> </td>
</tr> </tr>
@@ -457,7 +460,7 @@ function FrameworkViewContent({
</div> </div>
) : ( ) : (
<div className="flex items-center justify-center p-6 text-center text-muted-foreground"> <div className="flex items-center justify-center p-6 text-center text-muted-foreground">
No controls in this category No mitigations in this category
</div> </div>
)} )}
</CardContent> </CardContent>

View File

@@ -1,5 +1,5 @@
/** /**
* @generated SignedSource<<0d36f3f459adaca2f0abab59d9208bf9>> * @generated SignedSource<<11936aad3da2565a509b1566774e0ecf>>
* @lightSyntaxTransform * @lightSyntaxTransform
* @nogrep * @nogrep
*/ */
@@ -9,7 +9,7 @@
// @ts-nocheck // @ts-nocheck
import { ConcreteRequest } from 'relay-runtime'; import { ConcreteRequest } from 'relay-runtime';
export type ControlState = "IMPLEMENTED" | "IN_PROGRESS" | "NOT_APPLICABLE" | "NOT_STARTED"; export type MitigationState = "IMPLEMENTED" | "IN_PROGRESS" | "NOT_APPLICABLE" | "NOT_STARTED";
export type ImportFrameworkInput = { export type ImportFrameworkInput = {
file: any; file: any;
organizationId: string; organizationId: string;
@@ -22,17 +22,17 @@ export type FrameworkListViewImportFrameworkMutation$data = {
readonly importFramework: { readonly importFramework: {
readonly frameworkEdge: { readonly frameworkEdge: {
readonly node: { readonly node: {
readonly controls: {
readonly edges: ReadonlyArray<{
readonly node: {
readonly id: string;
readonly state: ControlState;
};
}>;
};
readonly createdAt: string; readonly createdAt: string;
readonly description: string; readonly description: string;
readonly id: string; readonly id: string;
readonly mitigations: {
readonly edges: ReadonlyArray<{
readonly node: {
readonly id: string;
readonly state: MitigationState;
};
}>;
};
readonly name: string; readonly name: string;
readonly updatedAt: string; readonly updatedAt: string;
}; };
@@ -109,15 +109,15 @@ v4 = {
"value": 100 "value": 100
} }
], ],
"concreteType": "ControlConnection", "concreteType": "MitigationConnection",
"kind": "LinkedField", "kind": "LinkedField",
"name": "controls", "name": "mitigations",
"plural": false, "plural": false,
"selections": [ "selections": [
{ {
"alias": null, "alias": null,
"args": null, "args": null,
"concreteType": "ControlEdge", "concreteType": "MitigationEdge",
"kind": "LinkedField", "kind": "LinkedField",
"name": "edges", "name": "edges",
"plural": true, "plural": true,
@@ -125,7 +125,7 @@ v4 = {
{ {
"alias": null, "alias": null,
"args": null, "args": null,
"concreteType": "Control", "concreteType": "Mitigation",
"kind": "LinkedField", "kind": "LinkedField",
"name": "node", "name": "node",
"plural": false, "plural": false,
@@ -145,7 +145,7 @@ v4 = {
"storageKey": null "storageKey": null
} }
], ],
"storageKey": "controls(first:100)" "storageKey": "mitigations(first:100)"
}, },
{ {
"alias": null, "alias": null,
@@ -233,16 +233,16 @@ return {
] ]
}, },
"params": { "params": {
"cacheID": "b225cace8b9956333d0175a7e0a4c04d", "cacheID": "d2d34f8e054d753d956120ea14791f79",
"id": null, "id": null,
"metadata": {}, "metadata": {},
"name": "FrameworkListViewImportFrameworkMutation", "name": "FrameworkListViewImportFrameworkMutation",
"operationKind": "mutation", "operationKind": "mutation",
"text": "mutation FrameworkListViewImportFrameworkMutation(\n $input: ImportFrameworkInput!\n) {\n importFramework(input: $input) {\n frameworkEdge {\n node {\n id\n name\n description\n controls(first: 100) {\n edges {\n node {\n id\n state\n }\n }\n }\n createdAt\n updatedAt\n }\n }\n }\n}\n" "text": "mutation FrameworkListViewImportFrameworkMutation(\n $input: ImportFrameworkInput!\n) {\n importFramework(input: $input) {\n frameworkEdge {\n node {\n id\n name\n description\n mitigations(first: 100) {\n edges {\n node {\n id\n state\n }\n }\n }\n createdAt\n updatedAt\n }\n }\n }\n}\n"
} }
}; };
})(); })();
(node as any).hash = "fa1a8aa9d16bc50eac99392d3de59f6c"; (node as any).hash = "a812db41b10d16c25959a5a733fe6088";
export default node; export default node;

View File

@@ -1,5 +1,5 @@
/** /**
* @generated SignedSource<<c2ec2b3948d67ed6b924494adcae63aa>> * @generated SignedSource<<6b6bb27f3ae9e9cf720be1c3655c595e>>
* @lightSyntaxTransform * @lightSyntaxTransform
* @nogrep * @nogrep
*/ */
@@ -9,7 +9,7 @@
// @ts-nocheck // @ts-nocheck
import { ConcreteRequest } from 'relay-runtime'; import { ConcreteRequest } from 'relay-runtime';
export type ControlState = "IMPLEMENTED" | "IN_PROGRESS" | "NOT_APPLICABLE" | "NOT_STARTED"; export type MitigationState = "IMPLEMENTED" | "IN_PROGRESS" | "NOT_APPLICABLE" | "NOT_STARTED";
export type FrameworkListViewQuery$variables = { export type FrameworkListViewQuery$variables = {
organizationId: string; organizationId: string;
}; };
@@ -18,17 +18,17 @@ export type FrameworkListViewQuery$data = {
readonly frameworks?: { readonly frameworks?: {
readonly edges: ReadonlyArray<{ readonly edges: ReadonlyArray<{
readonly node: { readonly node: {
readonly controls: {
readonly edges: ReadonlyArray<{
readonly node: {
readonly id: string;
readonly state: ControlState;
};
}>;
};
readonly createdAt: string; readonly createdAt: string;
readonly description: string; readonly description: string;
readonly id: string; readonly id: string;
readonly mitigations: {
readonly edges: ReadonlyArray<{
readonly node: {
readonly id: string;
readonly state: MitigationState;
};
}>;
};
readonly name: string; readonly name: string;
readonly updatedAt: string; readonly updatedAt: string;
}; };
@@ -112,15 +112,15 @@ v5 = [
{ {
"alias": null, "alias": null,
"args": (v3/*: any*/), "args": (v3/*: any*/),
"concreteType": "ControlConnection", "concreteType": "MitigationConnection",
"kind": "LinkedField", "kind": "LinkedField",
"name": "controls", "name": "mitigations",
"plural": false, "plural": false,
"selections": [ "selections": [
{ {
"alias": null, "alias": null,
"args": null, "args": null,
"concreteType": "ControlEdge", "concreteType": "MitigationEdge",
"kind": "LinkedField", "kind": "LinkedField",
"name": "edges", "name": "edges",
"plural": true, "plural": true,
@@ -128,7 +128,7 @@ v5 = [
{ {
"alias": null, "alias": null,
"args": null, "args": null,
"concreteType": "Control", "concreteType": "Mitigation",
"kind": "LinkedField", "kind": "LinkedField",
"name": "node", "name": "node",
"plural": false, "plural": false,
@@ -148,7 +148,7 @@ v5 = [
"storageKey": null "storageKey": null
} }
], ],
"storageKey": "controls(first:100)" "storageKey": "mitigations(first:100)"
}, },
{ {
"alias": null, "alias": null,
@@ -291,7 +291,7 @@ return {
] ]
}, },
"params": { "params": {
"cacheID": "88bb77e2d10398380353d5a90ba5d6d6", "cacheID": "e5d4da21773770d146fb7d91e435caef",
"id": null, "id": null,
"metadata": { "metadata": {
"connection": [ "connection": [
@@ -308,11 +308,11 @@ return {
}, },
"name": "FrameworkListViewQuery", "name": "FrameworkListViewQuery",
"operationKind": "query", "operationKind": "query",
"text": "query FrameworkListViewQuery(\n $organizationId: ID!\n) {\n organization: node(id: $organizationId) {\n __typename\n ... on Organization {\n frameworks(first: 100) {\n edges {\n node {\n id\n name\n description\n controls(first: 100) {\n edges {\n node {\n id\n state\n }\n }\n }\n createdAt\n updatedAt\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n }\n }\n }\n id\n }\n}\n" "text": "query FrameworkListViewQuery(\n $organizationId: ID!\n) {\n organization: node(id: $organizationId) {\n __typename\n ... on Organization {\n frameworks(first: 100) {\n edges {\n node {\n id\n name\n description\n mitigations(first: 100) {\n edges {\n node {\n id\n state\n }\n }\n }\n createdAt\n updatedAt\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n }\n }\n }\n id\n }\n}\n"
} }
}; };
})(); })();
(node as any).hash = "e5d315fb00e4fee74b53685b6441ed54"; (node as any).hash = "8da147529de5e229e38b836bd584e484";
export default node; export default node;

View File

@@ -1,5 +1,5 @@
/** /**
* @generated SignedSource<<c36de2ad1593c2dfefe28d7d3bbbddba>> * @generated SignedSource<<1abc57788d51404af0931c7e120c01a7>>
* @lightSyntaxTransform * @lightSyntaxTransform
* @nogrep * @nogrep
*/ */
@@ -9,27 +9,27 @@
// @ts-nocheck // @ts-nocheck
import { ConcreteRequest } from 'relay-runtime'; import { ConcreteRequest } from 'relay-runtime';
export type ControlImportance = "ADVANCED" | "MANDATORY" | "PREFERRED"; export type MitigationImportance = "ADVANCED" | "MANDATORY" | "PREFERRED";
export type ControlState = "IMPLEMENTED" | "IN_PROGRESS" | "NOT_APPLICABLE" | "NOT_STARTED"; export type MitigationState = "IMPLEMENTED" | "IN_PROGRESS" | "NOT_APPLICABLE" | "NOT_STARTED";
export type FrameworkViewQuery$variables = { export type FrameworkViewQuery$variables = {
frameworkId: string; frameworkId: string;
}; };
export type FrameworkViewQuery$data = { export type FrameworkViewQuery$data = {
readonly node: { readonly node: {
readonly controls?: { readonly description?: string;
readonly id: string;
readonly mitigations?: {
readonly edges: ReadonlyArray<{ readonly edges: ReadonlyArray<{
readonly node: { readonly node: {
readonly category: string; readonly category: string;
readonly description: string; readonly description: string;
readonly id: string; readonly id: string;
readonly importance: ControlImportance; readonly importance: MitigationImportance;
readonly name: string; readonly name: string;
readonly state: ControlState; readonly state: MitigationState;
}; };
}>; }>;
}; };
readonly description?: string;
readonly id: string;
readonly name?: string; readonly name?: string;
}; };
}; };
@@ -85,7 +85,7 @@ v6 = [
{ {
"alias": null, "alias": null,
"args": null, "args": null,
"concreteType": "ControlEdge", "concreteType": "MitigationEdge",
"kind": "LinkedField", "kind": "LinkedField",
"name": "edges", "name": "edges",
"plural": true, "plural": true,
@@ -93,7 +93,7 @@ v6 = [
{ {
"alias": null, "alias": null,
"args": null, "args": null,
"concreteType": "Control", "concreteType": "Mitigation",
"kind": "LinkedField", "kind": "LinkedField",
"name": "node", "name": "node",
"plural": false, "plural": false,
@@ -191,11 +191,11 @@ return {
(v3/*: any*/), (v3/*: any*/),
(v4/*: any*/), (v4/*: any*/),
{ {
"alias": "controls", "alias": "mitigations",
"args": null, "args": null,
"concreteType": "ControlConnection", "concreteType": "MitigationConnection",
"kind": "LinkedField", "kind": "LinkedField",
"name": "__FrameworkView_controls_connection", "name": "__FrameworkView_mitigations_connection",
"plural": false, "plural": false,
"selections": (v6/*: any*/), "selections": (v6/*: any*/),
"storageKey": null "storageKey": null
@@ -235,21 +235,21 @@ return {
{ {
"alias": null, "alias": null,
"args": (v7/*: any*/), "args": (v7/*: any*/),
"concreteType": "ControlConnection", "concreteType": "MitigationConnection",
"kind": "LinkedField", "kind": "LinkedField",
"name": "controls", "name": "mitigations",
"plural": false, "plural": false,
"selections": (v6/*: any*/), "selections": (v6/*: any*/),
"storageKey": "controls(first:100)" "storageKey": "mitigations(first:100)"
}, },
{ {
"alias": null, "alias": null,
"args": (v7/*: any*/), "args": (v7/*: any*/),
"filters": null, "filters": null,
"handle": "connection", "handle": "connection",
"key": "FrameworkView_controls", "key": "FrameworkView_mitigations",
"kind": "LinkedHandle", "kind": "LinkedHandle",
"name": "controls" "name": "mitigations"
} }
], ],
"type": "Framework", "type": "Framework",
@@ -261,7 +261,7 @@ return {
] ]
}, },
"params": { "params": {
"cacheID": "f8edefde219c5fa1a5c7c85e287d846a", "cacheID": "c60a352d14662dd43ab93b9a4dcebee8",
"id": null, "id": null,
"metadata": { "metadata": {
"connection": [ "connection": [
@@ -271,18 +271,18 @@ return {
"direction": "forward", "direction": "forward",
"path": [ "path": [
"node", "node",
"controls" "mitigations"
] ]
} }
] ]
}, },
"name": "FrameworkViewQuery", "name": "FrameworkViewQuery",
"operationKind": "query", "operationKind": "query",
"text": "query FrameworkViewQuery(\n $frameworkId: ID!\n) {\n node(id: $frameworkId) {\n __typename\n id\n ... on Framework {\n name\n description\n controls(first: 100) {\n edges {\n node {\n id\n name\n description\n state\n category\n importance\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n }\n }\n }\n }\n}\n" "text": "query FrameworkViewQuery(\n $frameworkId: ID!\n) {\n node(id: $frameworkId) {\n __typename\n id\n ... on Framework {\n name\n description\n mitigations(first: 100) {\n edges {\n node {\n id\n name\n description\n state\n category\n importance\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n }\n }\n }\n }\n}\n"
} }
}; };
})(); })();
(node as any).hash = "9e8a9b37d956ec4c9dfba88e7b1120f3"; (node as any).hash = "f65af17f461e1c112573c0d14d08479d";
export default node; export default node;

View File

@@ -1,29 +1,32 @@
import { PageTemplateSkeleton } from "@/components/PageTemplate"; import { PageTemplateSkeleton } from "@/components/PageTemplate";
import { Suspense } from "react";
import { lazy } from "@probo/react-lazy";
import { useLocation } from "react-router";
import { ErrorBoundaryWithLocation } from "../../ErrorBoundary"; import { ErrorBoundaryWithLocation } from "../../ErrorBoundary";
import { Suspense } from "react";
import { useLocation } from "react-router";
import { lazy } from "@probo/react-lazy";
const UpdateControlView = lazy(() => import("./UpdateControlView")); const CreateMitigationView = lazy(() => import("./CreateMitigationView"));
export function UpdateControlViewSkeleton() { export function CreateMitigationViewSkeleton() {
return ( return (
<PageTemplateSkeleton <PageTemplateSkeleton
title="Update Control" title="Create Mitigation"
description="Update the control details" description="Create a new mitigation for your framework"
> >
<div className="max-w-2xl aspect-square bg-muted rounded-xl animate-pulse" /> <div className="max-w-2xl aspect-square bg-muted rounded-xl animate-pulse" />
</PageTemplateSkeleton> </PageTemplateSkeleton>
); );
} }
export function UpdateControlPage() { export function CreateMitigationPage() {
const location = useLocation(); const location = useLocation();
return ( return (
<Suspense key={location.pathname} fallback={<UpdateControlViewSkeleton />}> <Suspense
key={location.pathname}
fallback={<CreateMitigationViewSkeleton />}
>
<ErrorBoundaryWithLocation> <ErrorBoundaryWithLocation>
<UpdateControlView /> <CreateMitigationView />
</ErrorBoundaryWithLocation> </ErrorBoundaryWithLocation>
</Suspense> </Suspense>
); );

View File

@@ -17,19 +17,19 @@ import {
SelectValue, SelectValue,
} from "@/components/ui/select"; } from "@/components/ui/select";
import { import {
CreateControlViewCreateControlMutation, CreateMitigationViewCreateMitigationMutation,
ControlImportance, MitigationImportance,
} from "./__generated__/CreateControlViewCreateControlMutation.graphql"; } from "./__generated__/CreateMitigationViewCreateMitigationMutation.graphql";
import { PageTemplate } from "@/components/PageTemplate"; import { PageTemplate } from "@/components/PageTemplate";
import { CreateControlViewSkeleton } from "./CreateControlPage"; import { CreateMitigationViewSkeleton } from "./CreateMitigationPage";
const createControlMutation = graphql` const createMitigationMutation = graphql`
mutation CreateControlViewCreateControlMutation( mutation CreateMitigationViewCreateMitigationMutation(
$input: CreateControlInput! $input: CreateMitigationInput!
$connections: [ID!]! $connections: [ID!]!
) { ) {
createControl(input: $input) { createMitigation(input: $input) {
controlEdge @prependEdge(connections: $connections) { mitigationEdge @prependEdge(connections: $connections) {
node { node {
id id
name name
@@ -103,7 +103,7 @@ function EditableField({
); );
} }
function CreateControlViewContent() { function CreateMitigationViewContent() {
const { organizationId, frameworkId } = useParams(); const { organizationId, frameworkId } = useParams();
const navigate = useNavigate(); const navigate = useNavigate();
const { toast } = useToast(); const { toast } = useToast();
@@ -111,11 +111,13 @@ function CreateControlViewContent() {
name: "", name: "",
description: "", description: "",
category: "", category: "",
importance: "MANDATORY" as ControlImportance, importance: "MANDATORY" as MitigationImportance,
}); });
const [commit, isInFlight] = const [commit, isInFlight] =
useMutation<CreateControlViewCreateControlMutation>(createControlMutation); useMutation<CreateMitigationViewCreateMitigationMutation>(
createMitigationMutation
);
const handleFieldChange = (field: keyof typeof formData, value: unknown) => { const handleFieldChange = (field: keyof typeof formData, value: unknown) => {
setFormData((prev) => ({ setFormData((prev) => ({
@@ -138,7 +140,7 @@ function CreateControlViewContent() {
const connectionId = ConnectionHandler.getConnectionID( const connectionId = ConnectionHandler.getConnectionID(
frameworkId!, frameworkId!,
"FrameworkOverviewPage_controls" "FrameworkOverviewPage_mitigations"
); );
commit({ commit({
@@ -156,7 +158,7 @@ function CreateControlViewContent() {
if (errors) { if (errors) {
toast({ toast({
title: "Error", title: "Error",
description: errors[0]?.message || "Failed to create control", description: errors[0]?.message || "Failed to create mitigation",
variant: "destructive", variant: "destructive",
}); });
return; return;
@@ -164,17 +166,17 @@ function CreateControlViewContent() {
toast({ toast({
title: "Success", title: "Success",
description: "Control created successfully", description: "Mitigation created successfully",
}); });
navigate( navigate(
`/organizations/${organizationId}/frameworks/${frameworkId}/controls/${data.createControl.controlEdge.node.id}` `/organizations/${organizationId}/frameworks/${frameworkId}/mitigations/${data.createMitigation.mitigationEdge.node.id}`
); );
}, },
onError(error) { onError(error) {
toast({ toast({
title: "Error", title: "Error",
description: error.message || "Failed to create control", description: error.message || "Failed to create mitigation",
variant: "destructive", variant: "destructive",
}); });
}, },
@@ -183,8 +185,8 @@ function CreateControlViewContent() {
return ( return (
<PageTemplate <PageTemplate
title="Create Control" title="Create Mitigation"
description="Create a new control for your framework" description="Create a new mitigation for your framework"
> >
<Card className="max-w-2xl"> <Card className="max-w-2xl">
<form onSubmit={handleSubmit} className="p-6 space-y-6"> <form onSubmit={handleSubmit} className="p-6 space-y-6">
@@ -200,7 +202,7 @@ function CreateControlViewContent() {
value={formData.category} value={formData.category}
onChange={(value) => handleFieldChange("category", value)} onChange={(value) => handleFieldChange("category", value)}
required required
helpText="The category this control belongs to" helpText="The category this mitigation belongs to"
/> />
<EditableField <EditableField
@@ -209,7 +211,7 @@ function CreateControlViewContent() {
onChange={(value) => handleFieldChange("description", value)} onChange={(value) => handleFieldChange("description", value)}
required required
multiline multiline
helpText="Provide a detailed description of the control" helpText="Provide a detailed description of the mitigation"
/> />
<div className="space-y-2"> <div className="space-y-2">
@@ -219,7 +221,7 @@ function CreateControlViewContent() {
<Select <Select
value={formData.importance} value={formData.importance}
onValueChange={(value) => onValueChange={(value) =>
handleFieldChange("importance", value as ControlImportance) handleFieldChange("importance", value as MitigationImportance)
} }
> >
<SelectTrigger> <SelectTrigger>
@@ -246,7 +248,7 @@ function CreateControlViewContent() {
Cancel Cancel
</Button> </Button>
<Button type="submit" disabled={isInFlight}> <Button type="submit" disabled={isInFlight}>
{isInFlight ? "Creating..." : "Create Control"} {isInFlight ? "Creating..." : "Create Mitigation"}
</Button> </Button>
</div> </div>
</form> </form>
@@ -257,8 +259,8 @@ function CreateControlViewContent() {
export default function CreateControlView() { export default function CreateControlView() {
return ( return (
<Suspense fallback={<CreateControlViewSkeleton />}> <Suspense fallback={<CreateMitigationViewSkeleton />}>
<CreateControlViewContent /> <CreateMitigationViewContent />
</Suspense> </Suspense>
); );
} }

View File

@@ -5,9 +5,9 @@ import { lazy } from "@probo/react-lazy";
import { useLocation } from "react-router"; import { useLocation } from "react-router";
import { ErrorBoundaryWithLocation } from "../../ErrorBoundary"; import { ErrorBoundaryWithLocation } from "../../ErrorBoundary";
const ControlView = lazy(() => import("./ControlView")); const MitigationView = lazy(() => import("./MitigationView"));
export function ControlViewSkeleton() { export function MitigationViewSkeleton() {
return ( return (
<PageTemplateSkeleton <PageTemplateSkeleton
actions={ actions={
@@ -32,13 +32,13 @@ export function ControlViewSkeleton() {
); );
} }
export function ControlPage() { export function MitigationPage() {
const location = useLocation(); const location = useLocation();
return ( return (
<Suspense key={location.pathname} fallback={<ControlViewSkeleton />}> <Suspense key={location.pathname} fallback={<MitigationViewSkeleton />}>
<ErrorBoundaryWithLocation> <ErrorBoundaryWithLocation>
<ControlView /> <MitigationView />
</ErrorBoundaryWithLocation> </ErrorBoundaryWithLocation>
</Suspense> </Suspense>
); );

View File

@@ -71,18 +71,18 @@ import {
SheetClose, SheetClose,
} from "@/components/ui/sheet"; } from "@/components/ui/sheet";
import type { ControlViewQuery as ControlViewQueryType } from "./__generated__/ControlViewQuery.graphql"; import type { MitigationViewQuery as MitigationViewQueryType } from "./__generated__/MitigationViewQuery.graphql";
import type { ControlViewUpdateTaskStateMutation as ControlViewUpdateTaskStateMutationType } from "./__generated__/ControlViewUpdateTaskStateMutation.graphql"; import type { MitigationViewUpdateTaskStateMutation as MitigationViewUpdateTaskStateMutationType } from "./__generated__/MitigationViewUpdateTaskStateMutation.graphql";
import type { ControlViewCreateTaskMutation as ControlViewCreateTaskMutationType } from "./__generated__/ControlViewCreateTaskMutation.graphql"; import type { MitigationViewCreateTaskMutation as MitigationViewCreateTaskMutationType } from "./__generated__/MitigationViewCreateTaskMutation.graphql";
import type { ControlViewDeleteTaskMutation as ControlViewDeleteTaskMutationType } from "./__generated__/ControlViewDeleteTaskMutation.graphql"; import type { MitigationViewDeleteTaskMutation as MitigationViewDeleteTaskMutationType } from "./__generated__/MitigationViewDeleteTaskMutation.graphql";
import type { ControlViewUploadEvidenceMutation as ControlViewUploadEvidenceMutationType } from "./__generated__/ControlViewUploadEvidenceMutation.graphql"; import type { MitigationViewUploadEvidenceMutation as MitigationViewUploadEvidenceMutationType } from "./__generated__/MitigationViewUploadEvidenceMutation.graphql";
import type { ControlViewDeleteEvidenceMutation as ControlViewDeleteEvidenceMutationType } from "./__generated__/ControlViewDeleteEvidenceMutation.graphql"; import type { MitigationViewDeleteEvidenceMutation as MitigationViewDeleteEvidenceMutationType } from "./__generated__/MitigationViewDeleteEvidenceMutation.graphql";
import type { ControlViewAssignTaskMutation as ControlViewAssignTaskMutationType } from "./__generated__/ControlViewAssignTaskMutation.graphql"; import type { MitigationViewAssignTaskMutation as MitigationViewAssignTaskMutationType } from "./__generated__/MitigationViewAssignTaskMutation.graphql";
import type { ControlViewUnassignTaskMutation as ControlViewUnassignTaskMutationType } from "./__generated__/ControlViewUnassignTaskMutation.graphql"; import type { MitigationViewUnassignTaskMutation as MitigationViewUnassignTaskMutationType } from "./__generated__/MitigationViewUnassignTaskMutation.graphql";
import type { ControlViewOrganizationQuery$data } from "./__generated__/ControlViewOrganizationQuery.graphql"; import type { MitigationViewOrganizationQuery$data } from "./__generated__/MitigationViewOrganizationQuery.graphql";
import type { ControlViewUpdateControlStateMutation as ControlViewUpdateControlStateMutationType } from "./__generated__/ControlViewUpdateControlStateMutation.graphql"; import type { MitigationViewUpdateMitigationStateMutation as MitigationViewUpdateMitigationStateMutationType } from "./__generated__/MitigationViewUpdateMitigationStateMutation.graphql";
import { PageTemplate } from "@/components/PageTemplate"; import { PageTemplate } from "@/components/PageTemplate";
import { ControlViewSkeleton } from "./ControlPage"; import { MitigationViewSkeleton } from "./MitigationPage";
// Function to format ISO8601 duration to human-readable format // Function to format ISO8601 duration to human-readable format
const formatDuration = (isoDuration: string): string => { const formatDuration = (isoDuration: string): string => {
@@ -121,18 +121,18 @@ const formatDuration = (isoDuration: string): string => {
} }
}; };
const controlViewQuery = graphql` const mitigationViewQuery = graphql`
query ControlViewQuery($controlId: ID!) { query MitigationViewQuery($mitigationId: ID!) {
control: node(id: $controlId) { mitigation: node(id: $mitigationId) {
id id
... on Control { ... on Mitigation {
name name
description description
state state
importance importance
category category
version version
tasks(first: 100) @connection(key: "ControlView_tasks") { tasks(first: 100) @connection(key: "MitigationView_tasks") {
__id __id
edges { edges {
node { node {
@@ -147,7 +147,8 @@ const controlViewQuery = graphql`
fullName fullName
primaryEmailAddress primaryEmailAddress
} }
evidences(first: 50) @connection(key: "ControlView_evidences") { evidences(first: 50)
@connection(key: "MitigationView_evidences") {
__id __id
edges { edges {
node { node {
@@ -171,7 +172,7 @@ const controlViewQuery = graphql`
`; `;
const updateTaskStateMutation = graphql` const updateTaskStateMutation = graphql`
mutation ControlViewUpdateTaskStateMutation($input: UpdateTaskInput!) { mutation MitigationViewUpdateTaskStateMutation($input: UpdateTaskInput!) {
updateTask(input: $input) { updateTask(input: $input) {
task { task {
id id
@@ -184,7 +185,7 @@ const updateTaskStateMutation = graphql`
`; `;
const createTaskMutation = graphql` const createTaskMutation = graphql`
mutation ControlViewCreateTaskMutation( mutation MitigationViewCreateTaskMutation(
$input: CreateTaskInput! $input: CreateTaskInput!
$connections: [ID!]! $connections: [ID!]!
) { ) {
@@ -209,7 +210,7 @@ const createTaskMutation = graphql`
`; `;
const deleteTaskMutation = graphql` const deleteTaskMutation = graphql`
mutation ControlViewDeleteTaskMutation( mutation MitigationViewDeleteTaskMutation(
$input: DeleteTaskInput! $input: DeleteTaskInput!
$connections: [ID!]! $connections: [ID!]!
) { ) {
@@ -220,7 +221,7 @@ const deleteTaskMutation = graphql`
`; `;
const uploadEvidenceMutation = graphql` const uploadEvidenceMutation = graphql`
mutation ControlViewUploadEvidenceMutation( mutation MitigationViewUploadEvidenceMutation(
$input: UploadEvidenceInput! $input: UploadEvidenceInput!
$connections: [ID!]! $connections: [ID!]!
) { ) {
@@ -243,7 +244,7 @@ const uploadEvidenceMutation = graphql`
`; `;
const deleteEvidenceMutation = graphql` const deleteEvidenceMutation = graphql`
mutation ControlViewDeleteEvidenceMutation( mutation MitigationViewDeleteEvidenceMutation(
$input: DeleteEvidenceInput! $input: DeleteEvidenceInput!
$connections: [ID!]! $connections: [ID!]!
) { ) {
@@ -255,7 +256,7 @@ const deleteEvidenceMutation = graphql`
// Add a GraphQL query to fetch the fileUrl for an evidence item // Add a GraphQL query to fetch the fileUrl for an evidence item
const getEvidenceFileUrlQuery = graphql` const getEvidenceFileUrlQuery = graphql`
query ControlViewGetEvidenceFileUrlQuery($evidenceId: ID!) { query MitigationViewGetEvidenceFileUrlQuery($evidenceId: ID!) {
node(id: $evidenceId) { node(id: $evidenceId) {
... on Evidence { ... on Evidence {
id id
@@ -266,7 +267,7 @@ const getEvidenceFileUrlQuery = graphql`
`; `;
const assignTaskMutation = graphql` const assignTaskMutation = graphql`
mutation ControlViewAssignTaskMutation($input: AssignTaskInput!) { mutation MitigationViewAssignTaskMutation($input: AssignTaskInput!) {
assignTask(input: $input) { assignTask(input: $input) {
task { task {
id id
@@ -282,7 +283,7 @@ const assignTaskMutation = graphql`
`; `;
const unassignTaskMutation = graphql` const unassignTaskMutation = graphql`
mutation ControlViewUnassignTaskMutation($input: UnassignTaskInput!) { mutation MitigationViewUnassignTaskMutation($input: UnassignTaskInput!) {
unassignTask(input: $input) { unassignTask(input: $input) {
task { task {
id id
@@ -297,10 +298,12 @@ const unassignTaskMutation = graphql`
} }
`; `;
const updateControlStateMutation = graphql` const updateMitigationStateMutation = graphql`
mutation ControlViewUpdateControlStateMutation($input: UpdateControlInput!) { mutation MitigationViewUpdateMitigationStateMutation(
updateControl(input: $input) { $input: UpdateMitigationInput!
control { ) {
updateMitigation(input: $input) {
mitigation {
id id
state state
version version
@@ -310,12 +313,12 @@ const updateControlStateMutation = graphql`
`; `;
const organizationQuery = graphql` const organizationQuery = graphql`
query ControlViewOrganizationQuery($organizationId: ID!) { query MitigationViewOrganizationQuery($organizationId: ID!) {
organization: node(id: $organizationId) { organization: node(id: $organizationId) {
id id
... on Organization { ... on Organization {
peoples(first: 100, orderBy: { direction: ASC, field: FULL_NAME }) peoples(first: 100, orderBy: { direction: ASC, field: FULL_NAME })
@connection(key: "ControlView_peoples") { @connection(key: "MitigationView_peoples") {
edges { edges {
node { node {
id id
@@ -329,17 +332,17 @@ const organizationQuery = graphql`
} }
`; `;
function ControlViewContent({ function MitigationViewContent({
queryRef, queryRef,
}: { }: {
queryRef: PreloadedQuery<ControlViewQueryType>; queryRef: PreloadedQuery<MitigationViewQueryType>;
}) { }) {
const data = usePreloadedQuery<ControlViewQueryType>( const data = usePreloadedQuery<MitigationViewQueryType>(
controlViewQuery, mitigationViewQuery,
queryRef queryRef
); );
const { toast } = useToast(); const { toast } = useToast();
const { organizationId, frameworkId, controlId } = useParams(); const { organizationId, frameworkId, mitigationId } = useParams();
const navigate = useNavigate(); const navigate = useNavigate();
const environment = useRelayEnvironment(); const environment = useRelayEnvironment();
@@ -349,7 +352,7 @@ function ControlViewContent({
// Load organization data for people selector // Load organization data for people selector
const [organizationData, setOrganizationData] = const [organizationData, setOrganizationData] =
useState<ControlViewOrganizationQuery$data | null>(null); useState<MitigationViewOrganizationQuery$data | null>(null);
useEffect(() => { useEffect(() => {
if (organizationId) { if (organizationId) {
@@ -358,7 +361,7 @@ function ControlViewContent({
}) })
.toPromise() .toPromise()
.then((response) => { .then((response) => {
setOrganizationData(response as ControlViewOrganizationQuery$data); setOrganizationData(response as MitigationViewOrganizationQuery$data);
}) })
.catch((error) => { .catch((error) => {
console.error("Error fetching organization data:", error); console.error("Error fetching organization data:", error);
@@ -423,27 +426,29 @@ function ControlViewContent({
return "bg-gray-100 text-gray-800"; return "bg-gray-100 text-gray-800";
}; };
const [updateTask] = useMutation<ControlViewUpdateTaskStateMutationType>( const [updateTask] = useMutation<MitigationViewUpdateTaskStateMutationType>(
updateTaskStateMutation updateTaskStateMutation
); );
const [createTask] = const [createTask] =
useMutation<ControlViewCreateTaskMutationType>(createTaskMutation); useMutation<MitigationViewCreateTaskMutationType>(createTaskMutation);
const [deleteTask] = const [deleteTask] =
useMutation<ControlViewDeleteTaskMutationType>(deleteTaskMutation); useMutation<MitigationViewDeleteTaskMutationType>(deleteTaskMutation);
const [uploadEvidence] = useMutation<ControlViewUploadEvidenceMutationType>( const [uploadEvidence] =
uploadEvidenceMutation useMutation<MitigationViewUploadEvidenceMutationType>(
); uploadEvidenceMutation
const [deleteEvidence] = useMutation<ControlViewDeleteEvidenceMutationType>( );
deleteEvidenceMutation const [deleteEvidence] =
); useMutation<MitigationViewDeleteEvidenceMutationType>(
deleteEvidenceMutation
);
const [assignTask] = const [assignTask] =
useMutation<ControlViewAssignTaskMutationType>(assignTaskMutation); useMutation<MitigationViewAssignTaskMutationType>(assignTaskMutation);
const [unassignTask] = const [unassignTask] =
useMutation<ControlViewUnassignTaskMutationType>(unassignTaskMutation); useMutation<MitigationViewUnassignTaskMutationType>(unassignTaskMutation);
const [updateControlState] = const [updateMitigationState] =
useMutation<ControlViewUpdateControlStateMutationType>( useMutation<MitigationViewUpdateMitigationStateMutationType>(
updateControlStateMutation updateMitigationStateMutation
); );
const [isCreateTaskOpen, setIsCreateTaskOpen] = useState(false); const [isCreateTaskOpen, setIsCreateTaskOpen] = useState(false);
@@ -518,7 +523,7 @@ function ControlViewContent({
// Track if task panel is open // Track if task panel is open
const [isTaskPanelOpen, setIsTaskPanelOpen] = useState(false); const [isTaskPanelOpen, setIsTaskPanelOpen] = useState(false);
const tasks = data.control.tasks?.edges.map((edge) => edge.node) || []; const tasks = data.mitigation.tasks?.edges.map((edge) => edge.node) || [];
// Add useEffect to handle URL parameters for task selection // Add useEffect to handle URL parameters for task selection
useEffect(() => { useEffect(() => {
@@ -666,10 +671,10 @@ function ControlViewContent({
return; return;
} }
if (!data.control.id) { if (!data.mitigation.id) {
toast({ toast({
title: "Error creating task", title: "Error creating task",
description: "Control ID is missing", description: "Mitigation ID is missing",
variant: "destructive", variant: "destructive",
}); });
return; return;
@@ -679,9 +684,9 @@ function ControlViewContent({
createTask({ createTask({
variables: { variables: {
connections: [`${data.control.tasks?.__id}`], connections: [`${data.mitigation.tasks?.__id}`],
input: { input: {
controlId: data.control.id, mitigationId: data.mitigation.id,
name: newTaskName, name: newTaskName,
description: newTaskDescription, description: newTaskDescription,
timeEstimate: isoTimeEstimate === "" ? null : isoTimeEstimate, timeEstimate: isoTimeEstimate === "" ? null : isoTimeEstimate,
@@ -719,7 +724,7 @@ function ControlViewContent({
deleteTask({ deleteTask({
variables: { variables: {
connections: [`${data.control.tasks?.__id}`], connections: [`${data.mitigation.tasks?.__id}`],
input: { input: {
taskId: taskToDelete.id, taskId: taskToDelete.id,
}, },
@@ -742,9 +747,9 @@ function ControlViewContent({
}); });
}; };
const handleEditControl = () => { const handleEditMitigation = () => {
navigate( navigate(
`/organizations/${organizationId}/frameworks/${frameworkId}/controls/${controlId}/update` `/organizations/${organizationId}/frameworks/${frameworkId}/mitigations/${mitigationId}/update`
); );
}; };
@@ -1098,31 +1103,31 @@ function ControlViewContent({
}); });
}; };
// Function to handle control state change // Function to handle mitigation state change
const handleControlStateChange = (newState: string) => { const handleMitigationStateChange = (newState: string) => {
updateControlState({ updateMitigationState({
variables: { variables: {
input: { input: {
id: data.control.id, id: data.mitigation.id,
state: newState as state: newState as
| "NOT_STARTED" | "NOT_STARTED"
| "IN_PROGRESS" | "IN_PROGRESS"
| "IMPLEMENTED" | "IMPLEMENTED"
| "NOT_APPLICABLE", | "NOT_APPLICABLE",
expectedVersion: data.control.version!, expectedVersion: data.mitigation.version!,
}, },
}, },
onCompleted: () => { onCompleted: () => {
toast({ toast({
title: "Control state updated", title: "Mitigation state updated",
description: `Control state has been updated to ${formatState( description: `Mitigation state has been updated to ${formatState(
newState newState
)}.`, )}.`,
}); });
}, },
onError: (error) => { onError: (error) => {
toast({ toast({
title: "Error updating control state", title: "Error updating mitigation state",
description: error.message, description: error.message,
variant: "destructive", variant: "destructive",
}); });
@@ -1255,23 +1260,23 @@ function ControlViewContent({
return ( return (
<PageTemplate <PageTemplate
title={data.control.name ?? ""} title={data.mitigation.name ?? ""}
actions={ actions={
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">
<Button variant="outline" size="sm" onClick={handleEditControl}> <Button variant="outline" size="sm" onClick={handleEditMitigation}>
Edit Control Edit Mitigation
</Button> </Button>
<Select <Select
defaultValue={data.control.state} defaultValue={data.mitigation.state}
onValueChange={handleControlStateChange} onValueChange={handleMitigationStateChange}
> >
<SelectTrigger className="w-[160px] h-8 text-sm"> <SelectTrigger className="w-[160px] h-8 text-sm">
<div <div
className={`${getStateColor( className={`${getStateColor(
data.control.state data.mitigation.state
)} px-2 py-0.5 rounded-full text-sm w-full text-center`} )} px-2 py-0.5 rounded-full text-sm w-full text-center`}
> >
{formatState(data.control.state)} {formatState(data.mitigation.state)}
</div> </div>
</SelectTrigger> </SelectTrigger>
<SelectContent> <SelectContent>
@@ -1283,10 +1288,10 @@ function ControlViewContent({
</Select> </Select>
<div <div
className={`${getImportanceColor( className={`${getImportanceColor(
data.control.importance data.mitigation.importance
)} px-3 py-1 rounded-full text-sm`} )} px-3 py-1 rounded-full text-sm`}
> >
{formatImportance(data.control.importance)} {formatImportance(data.mitigation.importance)}
</div> </div>
</div> </div>
} }
@@ -1295,7 +1300,7 @@ function ControlViewContent({
<Card className="mt-4"> <Card className="mt-4">
<CardContent className="pt-6"> <CardContent className="pt-6">
<div className="prose prose-gray prose-sm md:prose-base text-gray-600 max-w-3xl"> <div className="prose prose-gray prose-sm md:prose-base text-gray-600 max-w-3xl">
<ReactMarkdown>{data.control.description}</ReactMarkdown> <ReactMarkdown>{data.mitigation.description}</ReactMarkdown>
</div> </div>
</CardContent> </CardContent>
</Card> </Card>
@@ -1320,8 +1325,8 @@ function ControlViewContent({
<DialogHeader> <DialogHeader>
<DialogTitle>Create New Task</DialogTitle> <DialogTitle>Create New Task</DialogTitle>
<DialogDescription> <DialogDescription>
Add a new task to this control. Click save when you&apos;re Add a new task to this mitigation. Click save when
done. you&apos;re done.
</DialogDescription> </DialogDescription>
</DialogHeader> </DialogHeader>
<div className="space-y-4 py-4"> <div className="space-y-4 py-4">
@@ -2530,24 +2535,24 @@ function ControlViewContent({
); );
} }
export default function ControlView() { export default function MitigationView() {
const { controlId } = useParams(); const { mitigationId } = useParams();
const [queryRef, loadQuery] = const [queryRef, loadQuery] =
useQueryLoader<ControlViewQueryType>(controlViewQuery); useQueryLoader<MitigationViewQueryType>(mitigationViewQuery);
useEffect(() => { useEffect(() => {
if (controlId) { if (mitigationId) {
loadQuery({ controlId }); loadQuery({ mitigationId });
} }
}, [controlId, loadQuery]); }, [mitigationId, loadQuery]);
if (!queryRef) { if (!queryRef) {
return <ControlViewSkeleton />; return <MitigationViewSkeleton />;
} }
return ( return (
<Suspense fallback={<ControlViewSkeleton />}> <Suspense fallback={<MitigationViewSkeleton />}>
<ControlViewContent queryRef={queryRef} /> <MitigationViewContent queryRef={queryRef} />
</Suspense> </Suspense>
); );
} }

View File

@@ -1,29 +1,32 @@
import { PageTemplateSkeleton } from "@/components/PageTemplate"; import { PageTemplateSkeleton } from "@/components/PageTemplate";
import { ErrorBoundaryWithLocation } from "../../ErrorBoundary";
import { Suspense } from "react"; import { Suspense } from "react";
import { useLocation } from "react-router";
import { lazy } from "@probo/react-lazy"; import { lazy } from "@probo/react-lazy";
import { useLocation } from "react-router";
import { ErrorBoundaryWithLocation } from "../../ErrorBoundary";
const CreateControlView = lazy(() => import("./CreateControlView")); const UpdateMitigationView = lazy(() => import("./UpdateMitigationView"));
export function CreateControlViewSkeleton() { export function UpdateMitigationViewSkeleton() {
return ( return (
<PageTemplateSkeleton <PageTemplateSkeleton
title="Create Control" title="Update Mitigation"
description="Create a new control for your framework" description="Update the mitigation details"
> >
<div className="max-w-2xl aspect-square bg-muted rounded-xl animate-pulse" /> <div className="max-w-2xl aspect-square bg-muted rounded-xl animate-pulse" />
</PageTemplateSkeleton> </PageTemplateSkeleton>
); );
} }
export function CreateControlPage() { export function UpdateMitigationPage() {
const location = useLocation(); const location = useLocation();
return ( return (
<Suspense key={location.pathname} fallback={<CreateControlViewSkeleton />}> <Suspense
key={location.pathname}
fallback={<UpdateMitigationViewSkeleton />}
>
<ErrorBoundaryWithLocation> <ErrorBoundaryWithLocation>
<CreateControlView /> <UpdateMitigationView />
</ErrorBoundaryWithLocation> </ErrorBoundaryWithLocation>
</Suspense> </Suspense>
); );

View File

@@ -22,18 +22,20 @@ import {
SelectTrigger, SelectTrigger,
SelectValue, SelectValue,
} from "@/components/ui/select"; } from "@/components/ui/select";
import type { UpdateControlViewUpdateControlMutation as UpdateControlViewUpdateControlMutationType } from "./__generated__/UpdateControlViewUpdateControlMutation.graphql";
import type { import type {
ControlState, MitigationState,
ControlImportance, MitigationImportance,
} from "./__generated__/UpdateControlViewUpdateControlMutation.graphql"; UpdateMitigationViewUpdateMitigationMutation,
} from "./__generated__/UpdateMitigationViewUpdateMitigationMutation.graphql";
import { PageTemplate } from "@/components/PageTemplate"; import { PageTemplate } from "@/components/PageTemplate";
import { UpdateControlViewSkeleton } from "./UpdateControlPage"; import { MitigationViewSkeleton } from "./MitigationPage";
const updateControlMutation = graphql` const updateMitigationMutation = graphql`
mutation UpdateControlViewUpdateControlMutation($input: UpdateControlInput!) { mutation UpdateMitigationViewUpdateMitigationMutation(
updateControl(input: $input) { $input: UpdateMitigationInput!
control { ) {
updateMitigation(input: $input) {
mitigation {
id id
name name
description description
@@ -46,10 +48,10 @@ const updateControlMutation = graphql`
} }
`; `;
const updateControlQuery = graphql` const updateMitigationQuery = graphql`
query UpdateControlViewQuery($controlId: ID!) { query UpdateMitigationViewQuery($mitigationId: ID!) {
node(id: $controlId) { node(id: $mitigationId) {
... on Control { ... on Mitigation {
id id
name name
description description
@@ -123,16 +125,16 @@ function EditableField({
); );
} }
function UpdateControlViewContent({ function UpdateMitigationViewContent({
queryRef, queryRef,
}: { }: {
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
queryRef: PreloadedQuery<any>; queryRef: PreloadedQuery<any>;
}) { }) {
const { organizationId, frameworkId, controlId } = useParams(); const { organizationId, frameworkId, mitigationId } = useParams();
const navigate = useNavigate(); const navigate = useNavigate();
const { toast } = useToast(); const { toast } = useToast();
const data = usePreloadedQuery(updateControlQuery, queryRef); const data = usePreloadedQuery(updateMitigationQuery, queryRef);
const [editedFields, setEditedFields] = useState<Set<string>>(new Set()); const [editedFields, setEditedFields] = useState<Set<string>>(new Set());
const [formData, setFormData] = useState({ const [formData, setFormData] = useState({
name: "", name: "",
@@ -155,8 +157,8 @@ function UpdateControlViewContent({
}, [data.node]); }, [data.node]);
const [commit, isInFlight] = const [commit, isInFlight] =
useMutation<UpdateControlViewUpdateControlMutationType>( useMutation<UpdateMitigationViewUpdateMitigationMutation>(
updateControlMutation updateMitigationMutation
); );
const handleFieldChange = (field: keyof typeof formData, value: string) => { const handleFieldChange = (field: keyof typeof formData, value: string) => {
@@ -169,7 +171,7 @@ function UpdateControlViewContent({
const handleCancel = () => { const handleCancel = () => {
navigate( navigate(
`/organizations/${organizationId}/frameworks/${frameworkId}/controls/${controlId}` `/organizations/${organizationId}/frameworks/${frameworkId}/mitigations/${mitigationId}`
); );
}; };
@@ -193,10 +195,10 @@ function UpdateControlViewContent({
name?: string; name?: string;
description?: string; description?: string;
category?: string; category?: string;
state?: ControlState; state?: MitigationState;
importance?: ControlImportance; importance?: MitigationImportance;
} = { } = {
id: controlId!, id: mitigationId!,
expectedVersion: data.node.version, expectedVersion: data.node.version,
}; };
@@ -210,10 +212,10 @@ function UpdateControlViewContent({
input.category = formData.category; input.category = formData.category;
} }
if (editedFields.has("state")) { if (editedFields.has("state")) {
input.state = formData.state as ControlState; input.state = formData.state as MitigationState;
} }
if (editedFields.has("importance")) { if (editedFields.has("importance")) {
input.importance = formData.importance as ControlImportance; input.importance = formData.importance as MitigationImportance;
} }
commit({ commit({
@@ -224,7 +226,7 @@ function UpdateControlViewContent({
if (errors) { if (errors) {
toast({ toast({
title: "Error", title: "Error",
description: errors[0]?.message || "Failed to update control", description: errors[0]?.message || "Failed to update mitigation",
variant: "destructive", variant: "destructive",
}); });
return; return;
@@ -232,17 +234,17 @@ function UpdateControlViewContent({
toast({ toast({
title: "Success", title: "Success",
description: "Control updated successfully", description: "Mitigation updated successfully",
}); });
navigate( navigate(
`/organizations/${organizationId}/frameworks/${frameworkId}/controls/${controlId}` `/organizations/${organizationId}/frameworks/${frameworkId}/mitigations/${mitigationId}`
); );
}, },
onError(error) { onError(error) {
toast({ toast({
title: "Error", title: "Error",
description: error.message || "Failed to update control", description: error.message || "Failed to update mitigation",
variant: "destructive", variant: "destructive",
}); });
}, },
@@ -251,8 +253,8 @@ function UpdateControlViewContent({
return ( return (
<PageTemplate <PageTemplate
title="Update Control" title="Update Mitigation"
description="Update the control details" description="Update the mitigation details"
> >
<Card className="max-w-2xl"> <Card className="max-w-2xl">
<form onSubmit={handleSubmit} className="p-6 space-y-6"> <form onSubmit={handleSubmit} className="p-6 space-y-6">
@@ -269,7 +271,7 @@ function UpdateControlViewContent({
onChange={(value) => handleFieldChange("description", value)} onChange={(value) => handleFieldChange("description", value)}
required required
multiline multiline
helpText="Provide a detailed description of the control" helpText="Provide a detailed description of the mitigation"
/> />
<EditableField <EditableField
@@ -323,7 +325,7 @@ function UpdateControlViewContent({
Cancel Cancel
</Button> </Button>
<Button type="submit" disabled={isInFlight || !hasChanges}> <Button type="submit" disabled={isInFlight || !hasChanges}>
{isInFlight ? "Updating..." : "Update Control"} {isInFlight ? "Updating..." : "Update Mitigation"}
</Button> </Button>
</div> </div>
</form> </form>
@@ -333,23 +335,23 @@ function UpdateControlViewContent({
} }
export default function UpdateControlView() { export default function UpdateControlView() {
const { controlId } = useParams(); const { mitigationId } = useParams();
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
const [queryRef, loadQuery] = useQueryLoader<any>(updateControlQuery); const [queryRef, loadQuery] = useQueryLoader<any>(updateMitigationQuery);
useEffect(() => { useEffect(() => {
if (controlId) { if (mitigationId) {
loadQuery({ controlId }); loadQuery({ mitigationId });
} }
}, [controlId, loadQuery]); }, [mitigationId, loadQuery]);
if (!queryRef) { if (!queryRef) {
return <UpdateControlViewSkeleton />; return <MitigationViewSkeleton />;
} }
return ( return (
<Suspense fallback={<UpdateControlViewSkeleton />}> <Suspense fallback={<MitigationViewSkeleton />}>
<UpdateControlViewContent queryRef={queryRef} /> <UpdateMitigationViewContent queryRef={queryRef} />
</Suspense> </Suspense>
); );
} }

View File

@@ -1,5 +1,5 @@
/** /**
* @generated SignedSource<<a38544ace1fb4fc6da394e8ea2c35787>> * @generated SignedSource<<22a6faa89009d6784bc9a89c2456f12e>>
* @lightSyntaxTransform * @lightSyntaxTransform
* @nogrep * @nogrep
*/ */
@@ -9,35 +9,35 @@
// @ts-nocheck // @ts-nocheck
import { ConcreteRequest } from 'relay-runtime'; import { ConcreteRequest } from 'relay-runtime';
export type ControlImportance = "ADVANCED" | "MANDATORY" | "PREFERRED"; export type MitigationImportance = "ADVANCED" | "MANDATORY" | "PREFERRED";
export type ControlState = "IMPLEMENTED" | "IN_PROGRESS" | "NOT_APPLICABLE" | "NOT_STARTED"; export type MitigationState = "IMPLEMENTED" | "IN_PROGRESS" | "NOT_APPLICABLE" | "NOT_STARTED";
export type CreateControlInput = { export type CreateMitigationInput = {
category: string; category: string;
description: string; description: string;
frameworkId: string; frameworkId: string;
importance: ControlImportance; importance: MitigationImportance;
name: string; name: string;
}; };
export type CreateControlViewCreateControlMutation$variables = { export type CreateMitigationViewCreateMitigationMutation$variables = {
connections: ReadonlyArray<string>; connections: ReadonlyArray<string>;
input: CreateControlInput; input: CreateMitigationInput;
}; };
export type CreateControlViewCreateControlMutation$data = { export type CreateMitigationViewCreateMitigationMutation$data = {
readonly createControl: { readonly createMitigation: {
readonly controlEdge: { readonly mitigationEdge: {
readonly node: { readonly node: {
readonly category: string; readonly category: string;
readonly description: string; readonly description: string;
readonly id: string; readonly id: string;
readonly name: string; readonly name: string;
readonly state: ControlState; readonly state: MitigationState;
}; };
}; };
}; };
}; };
export type CreateControlViewCreateControlMutation = { export type CreateMitigationViewCreateMitigationMutation = {
response: CreateControlViewCreateControlMutation$data; response: CreateMitigationViewCreateMitigationMutation$data;
variables: CreateControlViewCreateControlMutation$variables; variables: CreateMitigationViewCreateMitigationMutation$variables;
}; };
const node: ConcreteRequest = (function(){ const node: ConcreteRequest = (function(){
@@ -61,15 +61,15 @@ v2 = [
v3 = { v3 = {
"alias": null, "alias": null,
"args": null, "args": null,
"concreteType": "ControlEdge", "concreteType": "MitigationEdge",
"kind": "LinkedField", "kind": "LinkedField",
"name": "controlEdge", "name": "mitigationEdge",
"plural": false, "plural": false,
"selections": [ "selections": [
{ {
"alias": null, "alias": null,
"args": null, "args": null,
"concreteType": "Control", "concreteType": "Mitigation",
"kind": "LinkedField", "kind": "LinkedField",
"name": "node", "name": "node",
"plural": false, "plural": false,
@@ -123,14 +123,14 @@ return {
], ],
"kind": "Fragment", "kind": "Fragment",
"metadata": null, "metadata": null,
"name": "CreateControlViewCreateControlMutation", "name": "CreateMitigationViewCreateMitigationMutation",
"selections": [ "selections": [
{ {
"alias": null, "alias": null,
"args": (v2/*: any*/), "args": (v2/*: any*/),
"concreteType": "CreateControlPayload", "concreteType": "CreateMitigationPayload",
"kind": "LinkedField", "kind": "LinkedField",
"name": "createControl", "name": "createMitigation",
"plural": false, "plural": false,
"selections": [ "selections": [
(v3/*: any*/) (v3/*: any*/)
@@ -148,14 +148,14 @@ return {
(v0/*: any*/) (v0/*: any*/)
], ],
"kind": "Operation", "kind": "Operation",
"name": "CreateControlViewCreateControlMutation", "name": "CreateMitigationViewCreateMitigationMutation",
"selections": [ "selections": [
{ {
"alias": null, "alias": null,
"args": (v2/*: any*/), "args": (v2/*: any*/),
"concreteType": "CreateControlPayload", "concreteType": "CreateMitigationPayload",
"kind": "LinkedField", "kind": "LinkedField",
"name": "createControl", "name": "createMitigation",
"plural": false, "plural": false,
"selections": [ "selections": [
(v3/*: any*/), (v3/*: any*/),
@@ -166,7 +166,7 @@ return {
"handle": "prependEdge", "handle": "prependEdge",
"key": "", "key": "",
"kind": "LinkedHandle", "kind": "LinkedHandle",
"name": "controlEdge", "name": "mitigationEdge",
"handleArgs": [ "handleArgs": [
{ {
"kind": "Variable", "kind": "Variable",
@@ -181,16 +181,16 @@ return {
] ]
}, },
"params": { "params": {
"cacheID": "f0f7112f1eb67ed8e7f0fe38b427b0c5", "cacheID": "09c15768681bc81e7035ff20e90e81a0",
"id": null, "id": null,
"metadata": {}, "metadata": {},
"name": "CreateControlViewCreateControlMutation", "name": "CreateMitigationViewCreateMitigationMutation",
"operationKind": "mutation", "operationKind": "mutation",
"text": "mutation CreateControlViewCreateControlMutation(\n $input: CreateControlInput!\n) {\n createControl(input: $input) {\n controlEdge {\n node {\n id\n name\n description\n category\n state\n }\n }\n }\n}\n" "text": "mutation CreateMitigationViewCreateMitigationMutation(\n $input: CreateMitigationInput!\n) {\n createMitigation(input: $input) {\n mitigationEdge {\n node {\n id\n name\n description\n category\n state\n }\n }\n }\n}\n"
} }
}; };
})(); })();
(node as any).hash = "b9b19ec5600f99a2a8e75e0bd9f86355"; (node as any).hash = "42db1acd8c6e92678c9e6355a77e1eb6";
export default node; export default node;

View File

@@ -1,5 +1,5 @@
/** /**
* @generated SignedSource<<18bc7a503d34d2bcb4cdfb6b4cfc1912>> * @generated SignedSource<<acf83fd1c5826a38f85912ed91e79422>>
* @lightSyntaxTransform * @lightSyntaxTransform
* @nogrep * @nogrep
*/ */
@@ -13,10 +13,10 @@ export type AssignTaskInput = {
assignedToId: string; assignedToId: string;
taskId: string; taskId: string;
}; };
export type ControlViewAssignTaskMutation$variables = { export type MitigationViewAssignTaskMutation$variables = {
input: AssignTaskInput; input: AssignTaskInput;
}; };
export type ControlViewAssignTaskMutation$data = { export type MitigationViewAssignTaskMutation$data = {
readonly assignTask: { readonly assignTask: {
readonly task: { readonly task: {
readonly assignedTo: { readonly assignedTo: {
@@ -29,9 +29,9 @@ export type ControlViewAssignTaskMutation$data = {
}; };
}; };
}; };
export type ControlViewAssignTaskMutation = { export type MitigationViewAssignTaskMutation = {
response: ControlViewAssignTaskMutation$data; response: MitigationViewAssignTaskMutation$data;
variables: ControlViewAssignTaskMutation$variables; variables: MitigationViewAssignTaskMutation$variables;
}; };
const node: ConcreteRequest = (function(){ const node: ConcreteRequest = (function(){
@@ -118,7 +118,7 @@ return {
"argumentDefinitions": (v0/*: any*/), "argumentDefinitions": (v0/*: any*/),
"kind": "Fragment", "kind": "Fragment",
"metadata": null, "metadata": null,
"name": "ControlViewAssignTaskMutation", "name": "MitigationViewAssignTaskMutation",
"selections": (v2/*: any*/), "selections": (v2/*: any*/),
"type": "Mutation", "type": "Mutation",
"abstractKey": null "abstractKey": null
@@ -127,20 +127,20 @@ return {
"operation": { "operation": {
"argumentDefinitions": (v0/*: any*/), "argumentDefinitions": (v0/*: any*/),
"kind": "Operation", "kind": "Operation",
"name": "ControlViewAssignTaskMutation", "name": "MitigationViewAssignTaskMutation",
"selections": (v2/*: any*/) "selections": (v2/*: any*/)
}, },
"params": { "params": {
"cacheID": "0a406c0e166607d86896adc0dfb5618e", "cacheID": "b336b45b0dad20968af93b52cd0aac48",
"id": null, "id": null,
"metadata": {}, "metadata": {},
"name": "ControlViewAssignTaskMutation", "name": "MitigationViewAssignTaskMutation",
"operationKind": "mutation", "operationKind": "mutation",
"text": "mutation ControlViewAssignTaskMutation(\n $input: AssignTaskInput!\n) {\n assignTask(input: $input) {\n task {\n id\n version\n assignedTo {\n id\n fullName\n primaryEmailAddress\n }\n }\n }\n}\n" "text": "mutation MitigationViewAssignTaskMutation(\n $input: AssignTaskInput!\n) {\n assignTask(input: $input) {\n task {\n id\n version\n assignedTo {\n id\n fullName\n primaryEmailAddress\n }\n }\n }\n}\n"
} }
}; };
})(); })();
(node as any).hash = "1a9a18038c2f6ad39d3efe61d2d0e33d"; (node as any).hash = "6446830361465b47f185c50b2886a422";
export default node; export default node;

View File

@@ -1,5 +1,5 @@
/** /**
* @generated SignedSource<<93ac47858fbd7c339faac83f193cb21b>> * @generated SignedSource<<958545e211155678a1a43d8ef1717071>>
* @lightSyntaxTransform * @lightSyntaxTransform
* @nogrep * @nogrep
*/ */
@@ -12,16 +12,16 @@ import { ConcreteRequest } from 'relay-runtime';
export type TaskState = "DONE" | "TODO"; export type TaskState = "DONE" | "TODO";
export type CreateTaskInput = { export type CreateTaskInput = {
assignedToId?: string | null | undefined; assignedToId?: string | null | undefined;
controlId: string;
description: string; description: string;
mitigationId: string;
name: string; name: string;
timeEstimate?: any | null | undefined; timeEstimate?: any | null | undefined;
}; };
export type ControlViewCreateTaskMutation$variables = { export type MitigationViewCreateTaskMutation$variables = {
connections: ReadonlyArray<string>; connections: ReadonlyArray<string>;
input: CreateTaskInput; input: CreateTaskInput;
}; };
export type ControlViewCreateTaskMutation$data = { export type MitigationViewCreateTaskMutation$data = {
readonly createTask: { readonly createTask: {
readonly taskEdge: { readonly taskEdge: {
readonly node: { readonly node: {
@@ -40,9 +40,9 @@ export type ControlViewCreateTaskMutation$data = {
}; };
}; };
}; };
export type ControlViewCreateTaskMutation = { export type MitigationViewCreateTaskMutation = {
response: ControlViewCreateTaskMutation$data; response: MitigationViewCreateTaskMutation$data;
variables: ControlViewCreateTaskMutation$variables; variables: MitigationViewCreateTaskMutation$variables;
}; };
const node: ConcreteRequest = (function(){ const node: ConcreteRequest = (function(){
@@ -162,7 +162,7 @@ return {
], ],
"kind": "Fragment", "kind": "Fragment",
"metadata": null, "metadata": null,
"name": "ControlViewCreateTaskMutation", "name": "MitigationViewCreateTaskMutation",
"selections": [ "selections": [
{ {
"alias": null, "alias": null,
@@ -187,7 +187,7 @@ return {
(v0/*: any*/) (v0/*: any*/)
], ],
"kind": "Operation", "kind": "Operation",
"name": "ControlViewCreateTaskMutation", "name": "MitigationViewCreateTaskMutation",
"selections": [ "selections": [
{ {
"alias": null, "alias": null,
@@ -220,16 +220,16 @@ return {
] ]
}, },
"params": { "params": {
"cacheID": "f823a58c96ee652fd522df58de3710a1", "cacheID": "dedf546da903060c79209ab7695bde12",
"id": null, "id": null,
"metadata": {}, "metadata": {},
"name": "ControlViewCreateTaskMutation", "name": "MitigationViewCreateTaskMutation",
"operationKind": "mutation", "operationKind": "mutation",
"text": "mutation ControlViewCreateTaskMutation(\n $input: CreateTaskInput!\n) {\n createTask(input: $input) {\n taskEdge {\n node {\n id\n name\n description\n timeEstimate\n state\n version\n assignedTo {\n id\n fullName\n primaryEmailAddress\n }\n }\n }\n }\n}\n" "text": "mutation MitigationViewCreateTaskMutation(\n $input: CreateTaskInput!\n) {\n createTask(input: $input) {\n taskEdge {\n node {\n id\n name\n description\n timeEstimate\n state\n version\n assignedTo {\n id\n fullName\n primaryEmailAddress\n }\n }\n }\n }\n}\n"
} }
}; };
})(); })();
(node as any).hash = "5d50a685dad17446a0cab1891dc00374"; (node as any).hash = "683fe4d2a3d33e989a8b5593f99799a5";
export default node; export default node;

View File

@@ -1,5 +1,5 @@
/** /**
* @generated SignedSource<<5cc5a8fcb02623e685586d2f3510fb4a>> * @generated SignedSource<<c7cba05f3dbc917afc82d3a3dae6045c>>
* @lightSyntaxTransform * @lightSyntaxTransform
* @nogrep * @nogrep
*/ */
@@ -12,18 +12,18 @@ import { ConcreteRequest } from 'relay-runtime';
export type DeleteEvidenceInput = { export type DeleteEvidenceInput = {
evidenceId: string; evidenceId: string;
}; };
export type ControlViewDeleteEvidenceMutation$variables = { export type MitigationViewDeleteEvidenceMutation$variables = {
connections: ReadonlyArray<string>; connections: ReadonlyArray<string>;
input: DeleteEvidenceInput; input: DeleteEvidenceInput;
}; };
export type ControlViewDeleteEvidenceMutation$data = { export type MitigationViewDeleteEvidenceMutation$data = {
readonly deleteEvidence: { readonly deleteEvidence: {
readonly deletedEvidenceId: string; readonly deletedEvidenceId: string;
}; };
}; };
export type ControlViewDeleteEvidenceMutation = { export type MitigationViewDeleteEvidenceMutation = {
response: ControlViewDeleteEvidenceMutation$data; response: MitigationViewDeleteEvidenceMutation$data;
variables: ControlViewDeleteEvidenceMutation$variables; variables: MitigationViewDeleteEvidenceMutation$variables;
}; };
const node: ConcreteRequest = (function(){ const node: ConcreteRequest = (function(){
@@ -59,7 +59,7 @@ return {
], ],
"kind": "Fragment", "kind": "Fragment",
"metadata": null, "metadata": null,
"name": "ControlViewDeleteEvidenceMutation", "name": "MitigationViewDeleteEvidenceMutation",
"selections": [ "selections": [
{ {
"alias": null, "alias": null,
@@ -84,7 +84,7 @@ return {
(v0/*: any*/) (v0/*: any*/)
], ],
"kind": "Operation", "kind": "Operation",
"name": "ControlViewDeleteEvidenceMutation", "name": "MitigationViewDeleteEvidenceMutation",
"selections": [ "selections": [
{ {
"alias": null, "alias": null,
@@ -117,16 +117,16 @@ return {
] ]
}, },
"params": { "params": {
"cacheID": "594da4829274c817424f9b84ba99a5a6", "cacheID": "4770e84f6f87fb95b9f102cf8e572f44",
"id": null, "id": null,
"metadata": {}, "metadata": {},
"name": "ControlViewDeleteEvidenceMutation", "name": "MitigationViewDeleteEvidenceMutation",
"operationKind": "mutation", "operationKind": "mutation",
"text": "mutation ControlViewDeleteEvidenceMutation(\n $input: DeleteEvidenceInput!\n) {\n deleteEvidence(input: $input) {\n deletedEvidenceId\n }\n}\n" "text": "mutation MitigationViewDeleteEvidenceMutation(\n $input: DeleteEvidenceInput!\n) {\n deleteEvidence(input: $input) {\n deletedEvidenceId\n }\n}\n"
} }
}; };
})(); })();
(node as any).hash = "a6b5e90e931adf04f45be9403b291ad9"; (node as any).hash = "993f84f2e310e888a78200abb9b79ae0";
export default node; export default node;

View File

@@ -1,5 +1,5 @@
/** /**
* @generated SignedSource<<e6c50692038abaca7921b9f0810ddfaa>> * @generated SignedSource<<c91c57e5263b695d85ca6d95f14acc1d>>
* @lightSyntaxTransform * @lightSyntaxTransform
* @nogrep * @nogrep
*/ */
@@ -12,18 +12,18 @@ import { ConcreteRequest } from 'relay-runtime';
export type DeleteTaskInput = { export type DeleteTaskInput = {
taskId: string; taskId: string;
}; };
export type ControlViewDeleteTaskMutation$variables = { export type MitigationViewDeleteTaskMutation$variables = {
connections: ReadonlyArray<string>; connections: ReadonlyArray<string>;
input: DeleteTaskInput; input: DeleteTaskInput;
}; };
export type ControlViewDeleteTaskMutation$data = { export type MitigationViewDeleteTaskMutation$data = {
readonly deleteTask: { readonly deleteTask: {
readonly deletedTaskId: string; readonly deletedTaskId: string;
}; };
}; };
export type ControlViewDeleteTaskMutation = { export type MitigationViewDeleteTaskMutation = {
response: ControlViewDeleteTaskMutation$data; response: MitigationViewDeleteTaskMutation$data;
variables: ControlViewDeleteTaskMutation$variables; variables: MitigationViewDeleteTaskMutation$variables;
}; };
const node: ConcreteRequest = (function(){ const node: ConcreteRequest = (function(){
@@ -59,7 +59,7 @@ return {
], ],
"kind": "Fragment", "kind": "Fragment",
"metadata": null, "metadata": null,
"name": "ControlViewDeleteTaskMutation", "name": "MitigationViewDeleteTaskMutation",
"selections": [ "selections": [
{ {
"alias": null, "alias": null,
@@ -84,7 +84,7 @@ return {
(v0/*: any*/) (v0/*: any*/)
], ],
"kind": "Operation", "kind": "Operation",
"name": "ControlViewDeleteTaskMutation", "name": "MitigationViewDeleteTaskMutation",
"selections": [ "selections": [
{ {
"alias": null, "alias": null,
@@ -117,16 +117,16 @@ return {
] ]
}, },
"params": { "params": {
"cacheID": "36b910121f02343b2e920adda58d7032", "cacheID": "f586e9c07d233eb31a72c2564c448fe4",
"id": null, "id": null,
"metadata": {}, "metadata": {},
"name": "ControlViewDeleteTaskMutation", "name": "MitigationViewDeleteTaskMutation",
"operationKind": "mutation", "operationKind": "mutation",
"text": "mutation ControlViewDeleteTaskMutation(\n $input: DeleteTaskInput!\n) {\n deleteTask(input: $input) {\n deletedTaskId\n }\n}\n" "text": "mutation MitigationViewDeleteTaskMutation(\n $input: DeleteTaskInput!\n) {\n deleteTask(input: $input) {\n deletedTaskId\n }\n}\n"
} }
}; };
})(); })();
(node as any).hash = "3aa9ea0eca32df8e6fe0258ee1140e56"; (node as any).hash = "2d6cfcb4704b95bc89f9f4715488d133";
export default node; export default node;

View File

@@ -1,5 +1,5 @@
/** /**
* @generated SignedSource<<6097cb76bff61c342c2b6389a8e7f618>> * @generated SignedSource<<c39e6569df1609b4a9cf0a6c1673df3a>>
* @lightSyntaxTransform * @lightSyntaxTransform
* @nogrep * @nogrep
*/ */
@@ -9,18 +9,18 @@
// @ts-nocheck // @ts-nocheck
import { ConcreteRequest } from 'relay-runtime'; import { ConcreteRequest } from 'relay-runtime';
export type ControlViewGetEvidenceFileUrlQuery$variables = { export type MitigationViewGetEvidenceFileUrlQuery$variables = {
evidenceId: string; evidenceId: string;
}; };
export type ControlViewGetEvidenceFileUrlQuery$data = { export type MitigationViewGetEvidenceFileUrlQuery$data = {
readonly node: { readonly node: {
readonly fileUrl?: string | null | undefined; readonly fileUrl?: string | null | undefined;
readonly id?: string; readonly id?: string;
}; };
}; };
export type ControlViewGetEvidenceFileUrlQuery = { export type MitigationViewGetEvidenceFileUrlQuery = {
response: ControlViewGetEvidenceFileUrlQuery$data; response: MitigationViewGetEvidenceFileUrlQuery$data;
variables: ControlViewGetEvidenceFileUrlQuery$variables; variables: MitigationViewGetEvidenceFileUrlQuery$variables;
}; };
const node: ConcreteRequest = (function(){ const node: ConcreteRequest = (function(){
@@ -57,7 +57,7 @@ return {
"argumentDefinitions": (v0/*: any*/), "argumentDefinitions": (v0/*: any*/),
"kind": "Fragment", "kind": "Fragment",
"metadata": null, "metadata": null,
"name": "ControlViewGetEvidenceFileUrlQuery", "name": "MitigationViewGetEvidenceFileUrlQuery",
"selections": [ "selections": [
{ {
"alias": null, "alias": null,
@@ -87,7 +87,7 @@ return {
"operation": { "operation": {
"argumentDefinitions": (v0/*: any*/), "argumentDefinitions": (v0/*: any*/),
"kind": "Operation", "kind": "Operation",
"name": "ControlViewGetEvidenceFileUrlQuery", "name": "MitigationViewGetEvidenceFileUrlQuery",
"selections": [ "selections": [
{ {
"alias": null, "alias": null,
@@ -119,16 +119,16 @@ return {
] ]
}, },
"params": { "params": {
"cacheID": "b656f027db1774647bcd0eefad36f66f", "cacheID": "1dc81a5d665b9141b5cd62ef893ff0e1",
"id": null, "id": null,
"metadata": {}, "metadata": {},
"name": "ControlViewGetEvidenceFileUrlQuery", "name": "MitigationViewGetEvidenceFileUrlQuery",
"operationKind": "query", "operationKind": "query",
"text": "query ControlViewGetEvidenceFileUrlQuery(\n $evidenceId: ID!\n) {\n node(id: $evidenceId) {\n __typename\n ... on Evidence {\n id\n fileUrl\n }\n id\n }\n}\n" "text": "query MitigationViewGetEvidenceFileUrlQuery(\n $evidenceId: ID!\n) {\n node(id: $evidenceId) {\n __typename\n ... on Evidence {\n id\n fileUrl\n }\n id\n }\n}\n"
} }
}; };
})(); })();
(node as any).hash = "a06f8279b87274b3cec4a11f44a53f49"; (node as any).hash = "9d7bbfc81ce73246b671989102da3192";
export default node; export default node;

View File

@@ -1,5 +1,5 @@
/** /**
* @generated SignedSource<<be19ac6afdae6f9be1b869afbd0a0838>> * @generated SignedSource<<780c10208a633b2ce7cd34ccc580cf25>>
* @lightSyntaxTransform * @lightSyntaxTransform
* @nogrep * @nogrep
*/ */
@@ -9,10 +9,10 @@
// @ts-nocheck // @ts-nocheck
import { ConcreteRequest } from 'relay-runtime'; import { ConcreteRequest } from 'relay-runtime';
export type ControlViewOrganizationQuery$variables = { export type MitigationViewOrganizationQuery$variables = {
organizationId: string; organizationId: string;
}; };
export type ControlViewOrganizationQuery$data = { export type MitigationViewOrganizationQuery$data = {
readonly organization: { readonly organization: {
readonly id: string; readonly id: string;
readonly peoples?: { readonly peoples?: {
@@ -26,9 +26,9 @@ export type ControlViewOrganizationQuery$data = {
}; };
}; };
}; };
export type ControlViewOrganizationQuery = { export type MitigationViewOrganizationQuery = {
response: ControlViewOrganizationQuery$data; response: MitigationViewOrganizationQuery$data;
variables: ControlViewOrganizationQuery$variables; variables: MitigationViewOrganizationQuery$variables;
}; };
const node: ConcreteRequest = (function(){ const node: ConcreteRequest = (function(){
@@ -153,7 +153,7 @@ return {
"argumentDefinitions": (v0/*: any*/), "argumentDefinitions": (v0/*: any*/),
"kind": "Fragment", "kind": "Fragment",
"metadata": null, "metadata": null,
"name": "ControlViewOrganizationQuery", "name": "MitigationViewOrganizationQuery",
"selections": [ "selections": [
{ {
"alias": "organization", "alias": "organization",
@@ -174,10 +174,10 @@ return {
], ],
"concreteType": "PeopleConnection", "concreteType": "PeopleConnection",
"kind": "LinkedField", "kind": "LinkedField",
"name": "__ControlView_peoples_connection", "name": "__MitigationView_peoples_connection",
"plural": false, "plural": false,
"selections": (v5/*: any*/), "selections": (v5/*: any*/),
"storageKey": "__ControlView_peoples_connection(orderBy:{\"direction\":\"ASC\",\"field\":\"FULL_NAME\"})" "storageKey": "__MitigationView_peoples_connection(orderBy:{\"direction\":\"ASC\",\"field\":\"FULL_NAME\"})"
} }
], ],
"type": "Organization", "type": "Organization",
@@ -194,7 +194,7 @@ return {
"operation": { "operation": {
"argumentDefinitions": (v0/*: any*/), "argumentDefinitions": (v0/*: any*/),
"kind": "Operation", "kind": "Operation",
"name": "ControlViewOrganizationQuery", "name": "MitigationViewOrganizationQuery",
"selections": [ "selections": [
{ {
"alias": "organization", "alias": "organization",
@@ -226,7 +226,7 @@ return {
"orderBy" "orderBy"
], ],
"handle": "connection", "handle": "connection",
"key": "ControlView_peoples", "key": "MitigationView_peoples",
"kind": "LinkedHandle", "kind": "LinkedHandle",
"name": "peoples" "name": "peoples"
} }
@@ -240,7 +240,7 @@ return {
] ]
}, },
"params": { "params": {
"cacheID": "9a339515a618cf48b77e74890b016272", "cacheID": "3d1fc2d02bc6eea68edcabc6fc6f0b56",
"id": null, "id": null,
"metadata": { "metadata": {
"connection": [ "connection": [
@@ -255,13 +255,13 @@ return {
} }
] ]
}, },
"name": "ControlViewOrganizationQuery", "name": "MitigationViewOrganizationQuery",
"operationKind": "query", "operationKind": "query",
"text": "query ControlViewOrganizationQuery(\n $organizationId: ID!\n) {\n organization: node(id: $organizationId) {\n __typename\n id\n ... on Organization {\n peoples(first: 100, orderBy: {direction: ASC, field: FULL_NAME}) {\n edges {\n node {\n id\n fullName\n primaryEmailAddress\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n }\n }\n }\n }\n}\n" "text": "query MitigationViewOrganizationQuery(\n $organizationId: ID!\n) {\n organization: node(id: $organizationId) {\n __typename\n id\n ... on Organization {\n peoples(first: 100, orderBy: {direction: ASC, field: FULL_NAME}) {\n edges {\n node {\n id\n fullName\n primaryEmailAddress\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n }\n }\n }\n }\n}\n"
} }
}; };
})(); })();
(node as any).hash = "22507c997964e19a663c819b750e50c9"; (node as any).hash = "73abf70f60b6f5a07b25f3c83676e02f";
export default node; export default node;

View File

@@ -1,5 +1,5 @@
/** /**
* @generated SignedSource<<d90309f0abd5f91c5f38c3070e27758b>> * @generated SignedSource<<d54298db57548f693ed2ca2418c9128c>>
* @lightSyntaxTransform * @lightSyntaxTransform
* @nogrep * @nogrep
*/ */
@@ -9,22 +9,22 @@
// @ts-nocheck // @ts-nocheck
import { ConcreteRequest } from 'relay-runtime'; import { ConcreteRequest } from 'relay-runtime';
export type ControlImportance = "ADVANCED" | "MANDATORY" | "PREFERRED";
export type ControlState = "IMPLEMENTED" | "IN_PROGRESS" | "NOT_APPLICABLE" | "NOT_STARTED";
export type EvidenceState = "EXPIRED" | "INVALID" | "VALID"; export type EvidenceState = "EXPIRED" | "INVALID" | "VALID";
export type EvidenceType = "FILE" | "LINK"; export type EvidenceType = "FILE" | "LINK";
export type MitigationImportance = "ADVANCED" | "MANDATORY" | "PREFERRED";
export type MitigationState = "IMPLEMENTED" | "IN_PROGRESS" | "NOT_APPLICABLE" | "NOT_STARTED";
export type TaskState = "DONE" | "TODO"; export type TaskState = "DONE" | "TODO";
export type ControlViewQuery$variables = { export type MitigationViewQuery$variables = {
controlId: string; mitigationId: string;
}; };
export type ControlViewQuery$data = { export type MitigationViewQuery$data = {
readonly control: { readonly mitigation: {
readonly category?: string; readonly category?: string;
readonly description?: string; readonly description?: string;
readonly id: string; readonly id: string;
readonly importance?: ControlImportance; readonly importance?: MitigationImportance;
readonly name?: string; readonly name?: string;
readonly state?: ControlState; readonly state?: MitigationState;
readonly tasks?: { readonly tasks?: {
readonly __id: string; readonly __id: string;
readonly edges: ReadonlyArray<{ readonly edges: ReadonlyArray<{
@@ -61,9 +61,9 @@ export type ControlViewQuery$data = {
readonly version?: number; readonly version?: number;
}; };
}; };
export type ControlViewQuery = { export type MitigationViewQuery = {
response: ControlViewQuery$data; response: MitigationViewQuery$data;
variables: ControlViewQuery$variables; variables: MitigationViewQuery$variables;
}; };
const node: ConcreteRequest = (function(){ const node: ConcreteRequest = (function(){
@@ -71,14 +71,14 @@ var v0 = [
{ {
"defaultValue": null, "defaultValue": null,
"kind": "LocalArgument", "kind": "LocalArgument",
"name": "controlId" "name": "mitigationId"
} }
], ],
v1 = [ v1 = [
{ {
"kind": "Variable", "kind": "Variable",
"name": "id", "name": "id",
"variableName": "controlId" "variableName": "mitigationId"
} }
], ],
v2 = { v2 = {
@@ -305,10 +305,10 @@ return {
"argumentDefinitions": (v0/*: any*/), "argumentDefinitions": (v0/*: any*/),
"kind": "Fragment", "kind": "Fragment",
"metadata": null, "metadata": null,
"name": "ControlViewQuery", "name": "MitigationViewQuery",
"selections": [ "selections": [
{ {
"alias": "control", "alias": "mitigation",
"args": (v1/*: any*/), "args": (v1/*: any*/),
"concreteType": null, "concreteType": null,
"kind": "LinkedField", "kind": "LinkedField",
@@ -330,7 +330,7 @@ return {
"args": null, "args": null,
"concreteType": "TaskConnection", "concreteType": "TaskConnection",
"kind": "LinkedField", "kind": "LinkedField",
"name": "__ControlView_tasks_connection", "name": "__MitigationView_tasks_connection",
"plural": false, "plural": false,
"selections": [ "selections": [
{ {
@@ -361,7 +361,7 @@ return {
"args": null, "args": null,
"concreteType": "EvidenceConnection", "concreteType": "EvidenceConnection",
"kind": "LinkedField", "kind": "LinkedField",
"name": "__ControlView_evidences_connection", "name": "__MitigationView_evidences_connection",
"plural": false, "plural": false,
"selections": (v15/*: any*/), "selections": (v15/*: any*/),
"storageKey": null "storageKey": null
@@ -380,7 +380,7 @@ return {
"storageKey": null "storageKey": null
} }
], ],
"type": "Control", "type": "Mitigation",
"abstractKey": null "abstractKey": null
} }
], ],
@@ -394,10 +394,10 @@ return {
"operation": { "operation": {
"argumentDefinitions": (v0/*: any*/), "argumentDefinitions": (v0/*: any*/),
"kind": "Operation", "kind": "Operation",
"name": "ControlViewQuery", "name": "MitigationViewQuery",
"selections": [ "selections": [
{ {
"alias": "control", "alias": "mitigation",
"args": (v1/*: any*/), "args": (v1/*: any*/),
"concreteType": null, "concreteType": null,
"kind": "LinkedField", "kind": "LinkedField",
@@ -461,7 +461,7 @@ return {
"args": (v17/*: any*/), "args": (v17/*: any*/),
"filters": null, "filters": null,
"handle": "connection", "handle": "connection",
"key": "ControlView_evidences", "key": "MitigationView_evidences",
"kind": "LinkedHandle", "kind": "LinkedHandle",
"name": "evidences" "name": "evidences"
}, },
@@ -483,12 +483,12 @@ return {
"args": (v16/*: any*/), "args": (v16/*: any*/),
"filters": null, "filters": null,
"handle": "connection", "handle": "connection",
"key": "ControlView_tasks", "key": "MitigationView_tasks",
"kind": "LinkedHandle", "kind": "LinkedHandle",
"name": "tasks" "name": "tasks"
} }
], ],
"type": "Control", "type": "Mitigation",
"abstractKey": null "abstractKey": null
} }
], ],
@@ -497,7 +497,7 @@ return {
] ]
}, },
"params": { "params": {
"cacheID": "35556c446c544e8b281b572272daae6b", "cacheID": "8e9c3cef43daff0bdbfff4e33d7c70ad",
"id": null, "id": null,
"metadata": { "metadata": {
"connection": [ "connection": [
@@ -512,19 +512,19 @@ return {
"cursor": null, "cursor": null,
"direction": "forward", "direction": "forward",
"path": [ "path": [
"control", "mitigation",
"tasks" "tasks"
] ]
} }
] ]
}, },
"name": "ControlViewQuery", "name": "MitigationViewQuery",
"operationKind": "query", "operationKind": "query",
"text": "query ControlViewQuery(\n $controlId: ID!\n) {\n control: node(id: $controlId) {\n __typename\n id\n ... on Control {\n name\n description\n state\n importance\n category\n version\n tasks(first: 100) {\n edges {\n node {\n id\n name\n description\n state\n timeEstimate\n version\n assignedTo {\n id\n fullName\n primaryEmailAddress\n }\n evidences(first: 50) {\n edges {\n node {\n id\n mimeType\n filename\n size\n state\n type\n url\n createdAt\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n }\n }\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n }\n }\n }\n }\n}\n" "text": "query MitigationViewQuery(\n $mitigationId: ID!\n) {\n mitigation: node(id: $mitigationId) {\n __typename\n id\n ... on Mitigation {\n name\n description\n state\n importance\n category\n version\n tasks(first: 100) {\n edges {\n node {\n id\n name\n description\n state\n timeEstimate\n version\n assignedTo {\n id\n fullName\n primaryEmailAddress\n }\n evidences(first: 50) {\n edges {\n node {\n id\n mimeType\n filename\n size\n state\n type\n url\n createdAt\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n }\n }\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n }\n }\n }\n }\n}\n"
} }
}; };
})(); })();
(node as any).hash = "cf9ee1fdc5e0e09c6b883299af7ffa37"; (node as any).hash = "f0baeab367be46290f2f15df836ed153";
export default node; export default node;

View File

@@ -1,5 +1,5 @@
/** /**
* @generated SignedSource<<c9adac41c9c5084befb16e9c01a12900>> * @generated SignedSource<<9cb5a3f1c6f0c2a3265ecdc6ececd13d>>
* @lightSyntaxTransform * @lightSyntaxTransform
* @nogrep * @nogrep
*/ */
@@ -12,10 +12,10 @@ import { ConcreteRequest } from 'relay-runtime';
export type UnassignTaskInput = { export type UnassignTaskInput = {
taskId: string; taskId: string;
}; };
export type ControlViewUnassignTaskMutation$variables = { export type MitigationViewUnassignTaskMutation$variables = {
input: UnassignTaskInput; input: UnassignTaskInput;
}; };
export type ControlViewUnassignTaskMutation$data = { export type MitigationViewUnassignTaskMutation$data = {
readonly unassignTask: { readonly unassignTask: {
readonly task: { readonly task: {
readonly assignedTo: { readonly assignedTo: {
@@ -28,9 +28,9 @@ export type ControlViewUnassignTaskMutation$data = {
}; };
}; };
}; };
export type ControlViewUnassignTaskMutation = { export type MitigationViewUnassignTaskMutation = {
response: ControlViewUnassignTaskMutation$data; response: MitigationViewUnassignTaskMutation$data;
variables: ControlViewUnassignTaskMutation$variables; variables: MitigationViewUnassignTaskMutation$variables;
}; };
const node: ConcreteRequest = (function(){ const node: ConcreteRequest = (function(){
@@ -117,7 +117,7 @@ return {
"argumentDefinitions": (v0/*: any*/), "argumentDefinitions": (v0/*: any*/),
"kind": "Fragment", "kind": "Fragment",
"metadata": null, "metadata": null,
"name": "ControlViewUnassignTaskMutation", "name": "MitigationViewUnassignTaskMutation",
"selections": (v2/*: any*/), "selections": (v2/*: any*/),
"type": "Mutation", "type": "Mutation",
"abstractKey": null "abstractKey": null
@@ -126,20 +126,20 @@ return {
"operation": { "operation": {
"argumentDefinitions": (v0/*: any*/), "argumentDefinitions": (v0/*: any*/),
"kind": "Operation", "kind": "Operation",
"name": "ControlViewUnassignTaskMutation", "name": "MitigationViewUnassignTaskMutation",
"selections": (v2/*: any*/) "selections": (v2/*: any*/)
}, },
"params": { "params": {
"cacheID": "15ebb533fa8c9ef25aba306106a198eb", "cacheID": "e493ae65ba1e53627dd3f260e8814e41",
"id": null, "id": null,
"metadata": {}, "metadata": {},
"name": "ControlViewUnassignTaskMutation", "name": "MitigationViewUnassignTaskMutation",
"operationKind": "mutation", "operationKind": "mutation",
"text": "mutation ControlViewUnassignTaskMutation(\n $input: UnassignTaskInput!\n) {\n unassignTask(input: $input) {\n task {\n id\n version\n assignedTo {\n id\n fullName\n primaryEmailAddress\n }\n }\n }\n}\n" "text": "mutation MitigationViewUnassignTaskMutation(\n $input: UnassignTaskInput!\n) {\n unassignTask(input: $input) {\n task {\n id\n version\n assignedTo {\n id\n fullName\n primaryEmailAddress\n }\n }\n }\n}\n"
} }
}; };
})(); })();
(node as any).hash = "b0956d42397dc015e2ece4ff37a83857"; (node as any).hash = "3f5a0d2b753d0a759e3004c0b557c505";
export default node; export default node;

View File

@@ -1,5 +1,5 @@
/** /**
* @generated SignedSource<<42dcc8ca7d9ad288321e73fa5175db44>> * @generated SignedSource<<3aa56a1042b1f9492cfc5bd5d5f55d9d>>
* @lightSyntaxTransform * @lightSyntaxTransform
* @nogrep * @nogrep
*/ */
@@ -9,32 +9,32 @@
// @ts-nocheck // @ts-nocheck
import { ConcreteRequest } from 'relay-runtime'; import { ConcreteRequest } from 'relay-runtime';
export type ControlImportance = "ADVANCED" | "MANDATORY" | "PREFERRED"; export type MitigationImportance = "ADVANCED" | "MANDATORY" | "PREFERRED";
export type ControlState = "IMPLEMENTED" | "IN_PROGRESS" | "NOT_APPLICABLE" | "NOT_STARTED"; export type MitigationState = "IMPLEMENTED" | "IN_PROGRESS" | "NOT_APPLICABLE" | "NOT_STARTED";
export type UpdateControlInput = { export type UpdateMitigationInput = {
category?: string | null | undefined; category?: string | null | undefined;
description?: string | null | undefined; description?: string | null | undefined;
expectedVersion: number; expectedVersion: number;
id: string; id: string;
importance?: ControlImportance | null | undefined; importance?: MitigationImportance | null | undefined;
name?: string | null | undefined; name?: string | null | undefined;
state?: ControlState | null | undefined; state?: MitigationState | null | undefined;
}; };
export type ControlViewUpdateControlStateMutation$variables = { export type MitigationViewUpdateMitigationStateMutation$variables = {
input: UpdateControlInput; input: UpdateMitigationInput;
}; };
export type ControlViewUpdateControlStateMutation$data = { export type MitigationViewUpdateMitigationStateMutation$data = {
readonly updateControl: { readonly updateMitigation: {
readonly control: { readonly mitigation: {
readonly id: string; readonly id: string;
readonly state: ControlState; readonly state: MitigationState;
readonly version: number; readonly version: number;
}; };
}; };
}; };
export type ControlViewUpdateControlStateMutation = { export type MitigationViewUpdateMitigationStateMutation = {
response: ControlViewUpdateControlStateMutation$data; response: MitigationViewUpdateMitigationStateMutation$data;
variables: ControlViewUpdateControlStateMutation$variables; variables: MitigationViewUpdateMitigationStateMutation$variables;
}; };
const node: ConcreteRequest = (function(){ const node: ConcreteRequest = (function(){
@@ -55,17 +55,17 @@ v1 = [
"variableName": "input" "variableName": "input"
} }
], ],
"concreteType": "UpdateControlPayload", "concreteType": "UpdateMitigationPayload",
"kind": "LinkedField", "kind": "LinkedField",
"name": "updateControl", "name": "updateMitigation",
"plural": false, "plural": false,
"selections": [ "selections": [
{ {
"alias": null, "alias": null,
"args": null, "args": null,
"concreteType": "Control", "concreteType": "Mitigation",
"kind": "LinkedField", "kind": "LinkedField",
"name": "control", "name": "mitigation",
"plural": false, "plural": false,
"selections": [ "selections": [
{ {
@@ -101,7 +101,7 @@ return {
"argumentDefinitions": (v0/*: any*/), "argumentDefinitions": (v0/*: any*/),
"kind": "Fragment", "kind": "Fragment",
"metadata": null, "metadata": null,
"name": "ControlViewUpdateControlStateMutation", "name": "MitigationViewUpdateMitigationStateMutation",
"selections": (v1/*: any*/), "selections": (v1/*: any*/),
"type": "Mutation", "type": "Mutation",
"abstractKey": null "abstractKey": null
@@ -110,20 +110,20 @@ return {
"operation": { "operation": {
"argumentDefinitions": (v0/*: any*/), "argumentDefinitions": (v0/*: any*/),
"kind": "Operation", "kind": "Operation",
"name": "ControlViewUpdateControlStateMutation", "name": "MitigationViewUpdateMitigationStateMutation",
"selections": (v1/*: any*/) "selections": (v1/*: any*/)
}, },
"params": { "params": {
"cacheID": "b34b9c0ddec55d16efcc2f38e8334773", "cacheID": "4a85c6e15d6ff91ccaa7976f9b0a0c6f",
"id": null, "id": null,
"metadata": {}, "metadata": {},
"name": "ControlViewUpdateControlStateMutation", "name": "MitigationViewUpdateMitigationStateMutation",
"operationKind": "mutation", "operationKind": "mutation",
"text": "mutation ControlViewUpdateControlStateMutation(\n $input: UpdateControlInput!\n) {\n updateControl(input: $input) {\n control {\n id\n state\n version\n }\n }\n}\n" "text": "mutation MitigationViewUpdateMitigationStateMutation(\n $input: UpdateMitigationInput!\n) {\n updateMitigation(input: $input) {\n mitigation {\n id\n state\n version\n }\n }\n}\n"
} }
}; };
})(); })();
(node as any).hash = "3eaaab55403bfaf343d4a740ad0128e1"; (node as any).hash = "2eb2c1f791262f502df22ca0c16682a7";
export default node; export default node;

View File

@@ -1,5 +1,5 @@
/** /**
* @generated SignedSource<<f0b91a291608cee99d4b22fb2d19e847>> * @generated SignedSource<<4aed09b28d5d1ec083abfeeb874b9ce3>>
* @lightSyntaxTransform * @lightSyntaxTransform
* @nogrep * @nogrep
*/ */
@@ -18,10 +18,10 @@ export type UpdateTaskInput = {
taskId: string; taskId: string;
timeEstimate?: any | null | undefined; timeEstimate?: any | null | undefined;
}; };
export type ControlViewUpdateTaskStateMutation$variables = { export type MitigationViewUpdateTaskStateMutation$variables = {
input: UpdateTaskInput; input: UpdateTaskInput;
}; };
export type ControlViewUpdateTaskStateMutation$data = { export type MitigationViewUpdateTaskStateMutation$data = {
readonly updateTask: { readonly updateTask: {
readonly task: { readonly task: {
readonly id: string; readonly id: string;
@@ -31,9 +31,9 @@ export type ControlViewUpdateTaskStateMutation$data = {
}; };
}; };
}; };
export type ControlViewUpdateTaskStateMutation = { export type MitigationViewUpdateTaskStateMutation = {
response: ControlViewUpdateTaskStateMutation$data; response: MitigationViewUpdateTaskStateMutation$data;
variables: ControlViewUpdateTaskStateMutation$variables; variables: MitigationViewUpdateTaskStateMutation$variables;
}; };
const node: ConcreteRequest = (function(){ const node: ConcreteRequest = (function(){
@@ -107,7 +107,7 @@ return {
"argumentDefinitions": (v0/*: any*/), "argumentDefinitions": (v0/*: any*/),
"kind": "Fragment", "kind": "Fragment",
"metadata": null, "metadata": null,
"name": "ControlViewUpdateTaskStateMutation", "name": "MitigationViewUpdateTaskStateMutation",
"selections": (v1/*: any*/), "selections": (v1/*: any*/),
"type": "Mutation", "type": "Mutation",
"abstractKey": null "abstractKey": null
@@ -116,20 +116,20 @@ return {
"operation": { "operation": {
"argumentDefinitions": (v0/*: any*/), "argumentDefinitions": (v0/*: any*/),
"kind": "Operation", "kind": "Operation",
"name": "ControlViewUpdateTaskStateMutation", "name": "MitigationViewUpdateTaskStateMutation",
"selections": (v1/*: any*/) "selections": (v1/*: any*/)
}, },
"params": { "params": {
"cacheID": "f8f00bd63de4f5eac131954a8039b40e", "cacheID": "8de0d061237d4ebcbb366b8eefff6d94",
"id": null, "id": null,
"metadata": {}, "metadata": {},
"name": "ControlViewUpdateTaskStateMutation", "name": "MitigationViewUpdateTaskStateMutation",
"operationKind": "mutation", "operationKind": "mutation",
"text": "mutation ControlViewUpdateTaskStateMutation(\n $input: UpdateTaskInput!\n) {\n updateTask(input: $input) {\n task {\n id\n state\n timeEstimate\n version\n }\n }\n}\n" "text": "mutation MitigationViewUpdateTaskStateMutation(\n $input: UpdateTaskInput!\n) {\n updateTask(input: $input) {\n task {\n id\n state\n timeEstimate\n version\n }\n }\n}\n"
} }
}; };
})(); })();
(node as any).hash = "f53df99b24c2f5f233f8d865885718ea"; (node as any).hash = "81dca6c475859526370ef60b4757428b";
export default node; export default node;

View File

@@ -1,5 +1,5 @@
/** /**
* @generated SignedSource<<f6ace4744710269a7c6502726617efcb>> * @generated SignedSource<<9d4db1a6dc5ce7a35be41b6f42bc91d2>>
* @lightSyntaxTransform * @lightSyntaxTransform
* @nogrep * @nogrep
*/ */
@@ -19,11 +19,11 @@ export type UploadEvidenceInput = {
type: EvidenceType; type: EvidenceType;
url?: string | null | undefined; url?: string | null | undefined;
}; };
export type ControlViewUploadEvidenceMutation$variables = { export type MitigationViewUploadEvidenceMutation$variables = {
connections: ReadonlyArray<string>; connections: ReadonlyArray<string>;
input: UploadEvidenceInput; input: UploadEvidenceInput;
}; };
export type ControlViewUploadEvidenceMutation$data = { export type MitigationViewUploadEvidenceMutation$data = {
readonly uploadEvidence: { readonly uploadEvidence: {
readonly evidenceEdge: { readonly evidenceEdge: {
readonly node: { readonly node: {
@@ -40,9 +40,9 @@ export type ControlViewUploadEvidenceMutation$data = {
}; };
}; };
}; };
export type ControlViewUploadEvidenceMutation = { export type MitigationViewUploadEvidenceMutation = {
response: ControlViewUploadEvidenceMutation$data; response: MitigationViewUploadEvidenceMutation$data;
variables: ControlViewUploadEvidenceMutation$variables; variables: MitigationViewUploadEvidenceMutation$variables;
}; };
const node: ConcreteRequest = (function(){ const node: ConcreteRequest = (function(){
@@ -156,7 +156,7 @@ return {
], ],
"kind": "Fragment", "kind": "Fragment",
"metadata": null, "metadata": null,
"name": "ControlViewUploadEvidenceMutation", "name": "MitigationViewUploadEvidenceMutation",
"selections": [ "selections": [
{ {
"alias": null, "alias": null,
@@ -181,7 +181,7 @@ return {
(v0/*: any*/) (v0/*: any*/)
], ],
"kind": "Operation", "kind": "Operation",
"name": "ControlViewUploadEvidenceMutation", "name": "MitigationViewUploadEvidenceMutation",
"selections": [ "selections": [
{ {
"alias": null, "alias": null,
@@ -214,16 +214,16 @@ return {
] ]
}, },
"params": { "params": {
"cacheID": "62fbef44afc988cdedc94c7a0292a432", "cacheID": "30a6915055d3f6b63d96836b26f05a45",
"id": null, "id": null,
"metadata": {}, "metadata": {},
"name": "ControlViewUploadEvidenceMutation", "name": "MitigationViewUploadEvidenceMutation",
"operationKind": "mutation", "operationKind": "mutation",
"text": "mutation ControlViewUploadEvidenceMutation(\n $input: UploadEvidenceInput!\n) {\n uploadEvidence(input: $input) {\n evidenceEdge {\n node {\n id\n filename\n fileUrl\n mimeType\n type\n url\n size\n state\n createdAt\n }\n }\n }\n}\n" "text": "mutation MitigationViewUploadEvidenceMutation(\n $input: UploadEvidenceInput!\n) {\n uploadEvidence(input: $input) {\n evidenceEdge {\n node {\n id\n filename\n fileUrl\n mimeType\n type\n url\n size\n state\n createdAt\n }\n }\n }\n}\n"
} }
}; };
})(); })();
(node as any).hash = "1e2b47702f9a03efdca7fdfd44ebbccf"; (node as any).hash = "4cf5430a0971ba1ddf476765df614e30";
export default node; export default node;

View File

@@ -1,5 +1,5 @@
/** /**
* @generated SignedSource<<839284c6c29a5727d0ca521b1d804c5f>> * @generated SignedSource<<338c4c7afa073c41eacac21a2996d1f9>>
* @lightSyntaxTransform * @lightSyntaxTransform
* @nogrep * @nogrep
*/ */
@@ -9,25 +9,25 @@
// @ts-nocheck // @ts-nocheck
import { ConcreteRequest } from 'relay-runtime'; import { ConcreteRequest } from 'relay-runtime';
export type ControlImportance = "ADVANCED" | "MANDATORY" | "PREFERRED"; export type MitigationImportance = "ADVANCED" | "MANDATORY" | "PREFERRED";
export type ControlState = "IMPLEMENTED" | "IN_PROGRESS" | "NOT_APPLICABLE" | "NOT_STARTED"; export type MitigationState = "IMPLEMENTED" | "IN_PROGRESS" | "NOT_APPLICABLE" | "NOT_STARTED";
export type UpdateControlViewQuery$variables = { export type UpdateMitigationViewQuery$variables = {
controlId: string; mitigationId: string;
}; };
export type UpdateControlViewQuery$data = { export type UpdateMitigationViewQuery$data = {
readonly node: { readonly node: {
readonly category?: string; readonly category?: string;
readonly description?: string; readonly description?: string;
readonly id?: string; readonly id?: string;
readonly importance?: ControlImportance; readonly importance?: MitigationImportance;
readonly name?: string; readonly name?: string;
readonly state?: ControlState; readonly state?: MitigationState;
readonly version?: number; readonly version?: number;
}; };
}; };
export type UpdateControlViewQuery = { export type UpdateMitigationViewQuery = {
response: UpdateControlViewQuery$data; response: UpdateMitigationViewQuery$data;
variables: UpdateControlViewQuery$variables; variables: UpdateMitigationViewQuery$variables;
}; };
const node: ConcreteRequest = (function(){ const node: ConcreteRequest = (function(){
@@ -35,14 +35,14 @@ var v0 = [
{ {
"defaultValue": null, "defaultValue": null,
"kind": "LocalArgument", "kind": "LocalArgument",
"name": "controlId" "name": "mitigationId"
} }
], ],
v1 = [ v1 = [
{ {
"kind": "Variable", "kind": "Variable",
"name": "id", "name": "id",
"variableName": "controlId" "variableName": "mitigationId"
} }
], ],
v2 = { v2 = {
@@ -99,7 +99,7 @@ return {
"argumentDefinitions": (v0/*: any*/), "argumentDefinitions": (v0/*: any*/),
"kind": "Fragment", "kind": "Fragment",
"metadata": null, "metadata": null,
"name": "UpdateControlViewQuery", "name": "UpdateMitigationViewQuery",
"selections": [ "selections": [
{ {
"alias": null, "alias": null,
@@ -120,7 +120,7 @@ return {
(v7/*: any*/), (v7/*: any*/),
(v8/*: any*/) (v8/*: any*/)
], ],
"type": "Control", "type": "Mitigation",
"abstractKey": null "abstractKey": null
} }
], ],
@@ -134,7 +134,7 @@ return {
"operation": { "operation": {
"argumentDefinitions": (v0/*: any*/), "argumentDefinitions": (v0/*: any*/),
"kind": "Operation", "kind": "Operation",
"name": "UpdateControlViewQuery", "name": "UpdateMitigationViewQuery",
"selections": [ "selections": [
{ {
"alias": null, "alias": null,
@@ -162,7 +162,7 @@ return {
(v7/*: any*/), (v7/*: any*/),
(v8/*: any*/) (v8/*: any*/)
], ],
"type": "Control", "type": "Mitigation",
"abstractKey": null "abstractKey": null
} }
], ],
@@ -171,16 +171,16 @@ return {
] ]
}, },
"params": { "params": {
"cacheID": "d578024453f1901119a772154524070d", "cacheID": "c2e9133d77f3e090267b19f4ab270c72",
"id": null, "id": null,
"metadata": {}, "metadata": {},
"name": "UpdateControlViewQuery", "name": "UpdateMitigationViewQuery",
"operationKind": "query", "operationKind": "query",
"text": "query UpdateControlViewQuery(\n $controlId: ID!\n) {\n node(id: $controlId) {\n __typename\n ... on Control {\n id\n name\n description\n category\n importance\n state\n version\n }\n id\n }\n}\n" "text": "query UpdateMitigationViewQuery(\n $mitigationId: ID!\n) {\n node(id: $mitigationId) {\n __typename\n ... on Mitigation {\n id\n name\n description\n category\n importance\n state\n version\n }\n id\n }\n}\n"
} }
}; };
})(); })();
(node as any).hash = "e6a997a27a8e45c01ad415e73b794cae"; (node as any).hash = "3e977744beb9c403aa8be232c8112a9b";
export default node; export default node;

View File

@@ -1,5 +1,5 @@
/** /**
* @generated SignedSource<<5223ef96f75ea5f5d4b124d190dfd455>> * @generated SignedSource<<39cfe3277c49d7a0ff2099d6ad579e7d>>
* @lightSyntaxTransform * @lightSyntaxTransform
* @nogrep * @nogrep
*/ */
@@ -9,36 +9,36 @@
// @ts-nocheck // @ts-nocheck
import { ConcreteRequest } from 'relay-runtime'; import { ConcreteRequest } from 'relay-runtime';
export type ControlImportance = "ADVANCED" | "MANDATORY" | "PREFERRED"; export type MitigationImportance = "ADVANCED" | "MANDATORY" | "PREFERRED";
export type ControlState = "IMPLEMENTED" | "IN_PROGRESS" | "NOT_APPLICABLE" | "NOT_STARTED"; export type MitigationState = "IMPLEMENTED" | "IN_PROGRESS" | "NOT_APPLICABLE" | "NOT_STARTED";
export type UpdateControlInput = { export type UpdateMitigationInput = {
category?: string | null | undefined; category?: string | null | undefined;
description?: string | null | undefined; description?: string | null | undefined;
expectedVersion: number; expectedVersion: number;
id: string; id: string;
importance?: ControlImportance | null | undefined; importance?: MitigationImportance | null | undefined;
name?: string | null | undefined; name?: string | null | undefined;
state?: ControlState | null | undefined; state?: MitigationState | null | undefined;
}; };
export type UpdateControlViewUpdateControlMutation$variables = { export type UpdateMitigationViewUpdateMitigationMutation$variables = {
input: UpdateControlInput; input: UpdateMitigationInput;
}; };
export type UpdateControlViewUpdateControlMutation$data = { export type UpdateMitigationViewUpdateMitigationMutation$data = {
readonly updateControl: { readonly updateMitigation: {
readonly control: { readonly mitigation: {
readonly category: string; readonly category: string;
readonly description: string; readonly description: string;
readonly id: string; readonly id: string;
readonly importance: ControlImportance; readonly importance: MitigationImportance;
readonly name: string; readonly name: string;
readonly state: ControlState; readonly state: MitigationState;
readonly version: number; readonly version: number;
}; };
}; };
}; };
export type UpdateControlViewUpdateControlMutation = { export type UpdateMitigationViewUpdateMitigationMutation = {
response: UpdateControlViewUpdateControlMutation$data; response: UpdateMitigationViewUpdateMitigationMutation$data;
variables: UpdateControlViewUpdateControlMutation$variables; variables: UpdateMitigationViewUpdateMitigationMutation$variables;
}; };
const node: ConcreteRequest = (function(){ const node: ConcreteRequest = (function(){
@@ -59,17 +59,17 @@ v1 = [
"variableName": "input" "variableName": "input"
} }
], ],
"concreteType": "UpdateControlPayload", "concreteType": "UpdateMitigationPayload",
"kind": "LinkedField", "kind": "LinkedField",
"name": "updateControl", "name": "updateMitigation",
"plural": false, "plural": false,
"selections": [ "selections": [
{ {
"alias": null, "alias": null,
"args": null, "args": null,
"concreteType": "Control", "concreteType": "Mitigation",
"kind": "LinkedField", "kind": "LinkedField",
"name": "control", "name": "mitigation",
"plural": false, "plural": false,
"selections": [ "selections": [
{ {
@@ -133,7 +133,7 @@ return {
"argumentDefinitions": (v0/*: any*/), "argumentDefinitions": (v0/*: any*/),
"kind": "Fragment", "kind": "Fragment",
"metadata": null, "metadata": null,
"name": "UpdateControlViewUpdateControlMutation", "name": "UpdateMitigationViewUpdateMitigationMutation",
"selections": (v1/*: any*/), "selections": (v1/*: any*/),
"type": "Mutation", "type": "Mutation",
"abstractKey": null "abstractKey": null
@@ -142,20 +142,20 @@ return {
"operation": { "operation": {
"argumentDefinitions": (v0/*: any*/), "argumentDefinitions": (v0/*: any*/),
"kind": "Operation", "kind": "Operation",
"name": "UpdateControlViewUpdateControlMutation", "name": "UpdateMitigationViewUpdateMitigationMutation",
"selections": (v1/*: any*/) "selections": (v1/*: any*/)
}, },
"params": { "params": {
"cacheID": "1702f16b6cc6452422c0f72acee25359", "cacheID": "5ebe3d38712b444c98c08661b7431da3",
"id": null, "id": null,
"metadata": {}, "metadata": {},
"name": "UpdateControlViewUpdateControlMutation", "name": "UpdateMitigationViewUpdateMitigationMutation",
"operationKind": "mutation", "operationKind": "mutation",
"text": "mutation UpdateControlViewUpdateControlMutation(\n $input: UpdateControlInput!\n) {\n updateControl(input: $input) {\n control {\n id\n name\n description\n category\n importance\n state\n version\n }\n }\n}\n" "text": "mutation UpdateMitigationViewUpdateMitigationMutation(\n $input: UpdateMitigationInput!\n) {\n updateMitigation(input: $input) {\n mitigation {\n id\n name\n description\n category\n importance\n state\n version\n }\n }\n}\n"
} }
}; };
})(); })();
(node as any).hash = "e0f0940fe564406ef95473420b336128"; (node as any).hash = "c68d76d527359d182749b309d2d8d6dd";
export default node; export default node;

View File

@@ -14,7 +14,7 @@ export function PolicyListViewSkeleton() {
description="Manage your organization's policies" description="Manage your organization's policies"
actions={<div className="bg-muted animate-pulse h-9 w-1/6 rounded-lg" />} actions={<div className="bg-muted animate-pulse h-9 w-1/6 rounded-lg" />}
> >
{/* Search and filter controls skeleton */} {/* Search and filter mitigations skeleton */}
<div className="flex flex-col md:flex-row gap-4 mb-6"> <div className="flex flex-col md:flex-row gap-4 mb-6">
<div className="flex-1 h-10 bg-muted animate-pulse rounded" /> <div className="flex-1 h-10 bg-muted animate-pulse rounded" />
<div className="flex gap-2"> <div className="flex gap-2">

View File

@@ -232,7 +232,7 @@ function PolicyListViewContent({
</Button> </Button>
} }
> >
{/* Search and filter controls */} {/* Search and filter mitigations */}
<div className="flex flex-col md:flex-row gap-4 mb-6"> <div className="flex flex-col md:flex-row gap-4 mb-6">
<div className="relative flex-1"> <div className="relative flex-1">
<Search className="absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" /> <Search className="absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" />

View File

@@ -1,209 +0,0 @@
/**
* @generated SignedSource<<1e5aa858fdcd0179ebfd8ffba00b6bd7>>
* @lightSyntaxTransform
* @nogrep
*/
/* tslint:disable */
/* eslint-disable */
// @ts-nocheck
import { ConcreteRequest } from 'relay-runtime';
export type RiskTier = "CRITICAL" | "GENERAL" | "SIGNIFICANT";
export type ServiceCriticality = "HIGH" | "LOW" | "MEDIUM";
export type CreateVendorInput = {
description: string;
name: string;
organizationId: string;
privacyPolicyUrl?: string | null | undefined;
riskTier: RiskTier;
serviceCriticality: ServiceCriticality;
serviceStartAt: string;
serviceTerminationAt?: string | null | undefined;
statusPageUrl?: string | null | undefined;
termsOfServiceUrl?: string | null | undefined;
};
export type VendorListPageCreateVendorMutation$variables = {
connections: ReadonlyArray<string>;
input: CreateVendorInput;
};
export type VendorListPageCreateVendorMutation$data = {
readonly createVendor: {
readonly vendorEdge: {
readonly node: {
readonly createdAt: string;
readonly description: string;
readonly id: string;
readonly name: string;
readonly riskTier: RiskTier;
readonly updatedAt: string;
};
};
};
};
export type VendorListPageCreateVendorMutation = {
response: VendorListPageCreateVendorMutation$data;
variables: VendorListPageCreateVendorMutation$variables;
};
const node: ConcreteRequest = (function(){
var v0 = {
"defaultValue": null,
"kind": "LocalArgument",
"name": "connections"
},
v1 = {
"defaultValue": null,
"kind": "LocalArgument",
"name": "input"
},
v2 = [
{
"kind": "Variable",
"name": "input",
"variableName": "input"
}
],
v3 = {
"alias": null,
"args": null,
"concreteType": "VendorEdge",
"kind": "LinkedField",
"name": "vendorEdge",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"concreteType": "Vendor",
"kind": "LinkedField",
"name": "node",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "id",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "name",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "description",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "createdAt",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "updatedAt",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "riskTier",
"storageKey": null
}
],
"storageKey": null
}
],
"storageKey": null
};
return {
"fragment": {
"argumentDefinitions": [
(v0/*: any*/),
(v1/*: any*/)
],
"kind": "Fragment",
"metadata": null,
"name": "VendorListPageCreateVendorMutation",
"selections": [
{
"alias": null,
"args": (v2/*: any*/),
"concreteType": "CreateVendorPayload",
"kind": "LinkedField",
"name": "createVendor",
"plural": false,
"selections": [
(v3/*: any*/)
],
"storageKey": null
}
],
"type": "Mutation",
"abstractKey": null
},
"kind": "Request",
"operation": {
"argumentDefinitions": [
(v1/*: any*/),
(v0/*: any*/)
],
"kind": "Operation",
"name": "VendorListPageCreateVendorMutation",
"selections": [
{
"alias": null,
"args": (v2/*: any*/),
"concreteType": "CreateVendorPayload",
"kind": "LinkedField",
"name": "createVendor",
"plural": false,
"selections": [
(v3/*: any*/),
{
"alias": null,
"args": null,
"filters": null,
"handle": "prependEdge",
"key": "",
"kind": "LinkedHandle",
"name": "vendorEdge",
"handleArgs": [
{
"kind": "Variable",
"name": "connections",
"variableName": "connections"
}
]
}
],
"storageKey": null
}
]
},
"params": {
"cacheID": "7ab96ef77e598ee748273b37bb9b42d2",
"id": null,
"metadata": {},
"name": "VendorListPageCreateVendorMutation",
"operationKind": "mutation",
"text": "mutation VendorListPageCreateVendorMutation(\n $input: CreateVendorInput!\n) {\n createVendor(input: $input) {\n vendorEdge {\n node {\n id\n name\n description\n createdAt\n updatedAt\n riskTier\n }\n }\n }\n}\n"
}
};
})();
(node as any).hash = "603ba3f92a342a8e1fb20057612b7c79";
export default node;

View File

@@ -1,132 +0,0 @@
/**
* @generated SignedSource<<ff037e64f503f247a68922f86248bb10>>
* @lightSyntaxTransform
* @nogrep
*/
/* tslint:disable */
/* eslint-disable */
// @ts-nocheck
import { ConcreteRequest } from 'relay-runtime';
export type DeleteVendorInput = {
vendorId: string;
};
export type VendorListPageDeleteVendorMutation$variables = {
connections: ReadonlyArray<string>;
input: DeleteVendorInput;
};
export type VendorListPageDeleteVendorMutation$data = {
readonly deleteVendor: {
readonly deletedVendorId: string;
};
};
export type VendorListPageDeleteVendorMutation = {
response: VendorListPageDeleteVendorMutation$data;
variables: VendorListPageDeleteVendorMutation$variables;
};
const node: ConcreteRequest = (function(){
var v0 = {
"defaultValue": null,
"kind": "LocalArgument",
"name": "connections"
},
v1 = {
"defaultValue": null,
"kind": "LocalArgument",
"name": "input"
},
v2 = [
{
"kind": "Variable",
"name": "input",
"variableName": "input"
}
],
v3 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "deletedVendorId",
"storageKey": null
};
return {
"fragment": {
"argumentDefinitions": [
(v0/*: any*/),
(v1/*: any*/)
],
"kind": "Fragment",
"metadata": null,
"name": "VendorListPageDeleteVendorMutation",
"selections": [
{
"alias": null,
"args": (v2/*: any*/),
"concreteType": "DeleteVendorPayload",
"kind": "LinkedField",
"name": "deleteVendor",
"plural": false,
"selections": [
(v3/*: any*/)
],
"storageKey": null
}
],
"type": "Mutation",
"abstractKey": null
},
"kind": "Request",
"operation": {
"argumentDefinitions": [
(v1/*: any*/),
(v0/*: any*/)
],
"kind": "Operation",
"name": "VendorListPageDeleteVendorMutation",
"selections": [
{
"alias": null,
"args": (v2/*: any*/),
"concreteType": "DeleteVendorPayload",
"kind": "LinkedField",
"name": "deleteVendor",
"plural": false,
"selections": [
(v3/*: any*/),
{
"alias": null,
"args": null,
"filters": null,
"handle": "deleteEdge",
"key": "",
"kind": "ScalarHandle",
"name": "deletedVendorId",
"handleArgs": [
{
"kind": "Variable",
"name": "connections",
"variableName": "connections"
}
]
}
],
"storageKey": null
}
]
},
"params": {
"cacheID": "278e42c6c988a64d4c863198f02df901",
"id": null,
"metadata": {},
"name": "VendorListPageDeleteVendorMutation",
"operationKind": "mutation",
"text": "mutation VendorListPageDeleteVendorMutation(\n $input: DeleteVendorInput!\n) {\n deleteVendor(input: $input) {\n deletedVendorId\n }\n}\n"
}
};
})();
(node as any).hash = "20a320191535706246ae00aa05df991e";
export default node;

View File

@@ -1,335 +0,0 @@
/**
* @generated SignedSource<<167c602f1fa3a3720523424c44c8b734>>
* @lightSyntaxTransform
* @nogrep
*/
/* tslint:disable */
/* eslint-disable */
// @ts-nocheck
import { ConcreteRequest } from 'relay-runtime';
import { FragmentRefs } from "relay-runtime";
export type VendorListPagePaginationQuery$variables = {
after?: string | null | undefined;
before?: string | null | undefined;
first?: number | null | undefined;
id: string;
last?: number | null | undefined;
};
export type VendorListPagePaginationQuery$data = {
readonly node: {
readonly " $fragmentSpreads": FragmentRefs<"VendorListPage_vendors">;
};
};
export type VendorListPagePaginationQuery = {
response: VendorListPagePaginationQuery$data;
variables: VendorListPagePaginationQuery$variables;
};
const node: ConcreteRequest = (function(){
var v0 = {
"defaultValue": null,
"kind": "LocalArgument",
"name": "after"
},
v1 = {
"defaultValue": null,
"kind": "LocalArgument",
"name": "before"
},
v2 = {
"defaultValue": null,
"kind": "LocalArgument",
"name": "first"
},
v3 = {
"defaultValue": null,
"kind": "LocalArgument",
"name": "id"
},
v4 = {
"defaultValue": null,
"kind": "LocalArgument",
"name": "last"
},
v5 = [
{
"kind": "Variable",
"name": "id",
"variableName": "id"
}
],
v6 = {
"kind": "Variable",
"name": "after",
"variableName": "after"
},
v7 = {
"kind": "Variable",
"name": "before",
"variableName": "before"
},
v8 = {
"kind": "Variable",
"name": "first",
"variableName": "first"
},
v9 = {
"kind": "Variable",
"name": "last",
"variableName": "last"
},
v10 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "__typename",
"storageKey": null
},
v11 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "id",
"storageKey": null
},
v12 = [
(v6/*: any*/),
(v7/*: any*/),
(v8/*: any*/),
(v9/*: any*/),
{
"kind": "Literal",
"name": "orderBy",
"value": {
"direction": "ASC",
"field": "NAME"
}
}
];
return {
"fragment": {
"argumentDefinitions": [
(v0/*: any*/),
(v1/*: any*/),
(v2/*: any*/),
(v3/*: any*/),
(v4/*: any*/)
],
"kind": "Fragment",
"metadata": null,
"name": "VendorListPagePaginationQuery",
"selections": [
{
"alias": null,
"args": (v5/*: any*/),
"concreteType": null,
"kind": "LinkedField",
"name": "node",
"plural": false,
"selections": [
{
"args": [
(v6/*: any*/),
(v7/*: any*/),
(v8/*: any*/),
(v9/*: any*/)
],
"kind": "FragmentSpread",
"name": "VendorListPage_vendors"
}
],
"storageKey": null
}
],
"type": "Query",
"abstractKey": null
},
"kind": "Request",
"operation": {
"argumentDefinitions": [
(v0/*: any*/),
(v1/*: any*/),
(v2/*: any*/),
(v4/*: any*/),
(v3/*: any*/)
],
"kind": "Operation",
"name": "VendorListPagePaginationQuery",
"selections": [
{
"alias": null,
"args": (v5/*: any*/),
"concreteType": null,
"kind": "LinkedField",
"name": "node",
"plural": false,
"selections": [
(v10/*: any*/),
(v11/*: any*/),
{
"kind": "InlineFragment",
"selections": [
{
"alias": null,
"args": (v12/*: any*/),
"concreteType": "VendorConnection",
"kind": "LinkedField",
"name": "vendors",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"concreteType": "VendorEdge",
"kind": "LinkedField",
"name": "edges",
"plural": true,
"selections": [
{
"alias": null,
"args": null,
"concreteType": "Vendor",
"kind": "LinkedField",
"name": "node",
"plural": false,
"selections": [
(v11/*: any*/),
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "name",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "description",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "createdAt",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "updatedAt",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "riskTier",
"storageKey": null
},
(v10/*: any*/)
],
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "cursor",
"storageKey": null
}
],
"storageKey": null
},
{
"alias": null,
"args": null,
"concreteType": "PageInfo",
"kind": "LinkedField",
"name": "pageInfo",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "hasNextPage",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "hasPreviousPage",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "startCursor",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "endCursor",
"storageKey": null
}
],
"storageKey": null
},
{
"kind": "ClientExtension",
"selections": [
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "__id",
"storageKey": null
}
]
}
],
"storageKey": null
},
{
"alias": null,
"args": (v12/*: any*/),
"filters": [
"orderBy"
],
"handle": "connection",
"key": "VendorListPage_vendors",
"kind": "LinkedHandle",
"name": "vendors"
}
],
"type": "Organization",
"abstractKey": null
}
],
"storageKey": null
}
]
},
"params": {
"cacheID": "72074f9c6435d35453cfd0effbbd6add",
"id": null,
"metadata": {},
"name": "VendorListPagePaginationQuery",
"operationKind": "query",
"text": "query VendorListPagePaginationQuery(\n $after: CursorKey\n $before: CursorKey\n $first: Int\n $last: Int\n $id: ID!\n) {\n node(id: $id) {\n __typename\n ...VendorListPage_vendors_pbnwq\n id\n }\n}\n\nfragment VendorListPage_vendors_pbnwq on Organization {\n vendors(first: $first, after: $after, last: $last, before: $before, orderBy: {direction: ASC, field: NAME}) {\n edges {\n node {\n id\n name\n description\n createdAt\n updatedAt\n riskTier\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 = "beaab1664bed1fa776659595b1ef3c30";
export default node;

View File

@@ -1,337 +0,0 @@
/**
* @generated SignedSource<<3e49ccb0b233e4d7495387ecf23f2316>>
* @lightSyntaxTransform
* @nogrep
*/
/* tslint:disable */
/* eslint-disable */
// @ts-nocheck
import { ConcreteRequest } from 'relay-runtime';
import { FragmentRefs } from "relay-runtime";
export type VendorListPageQuery$variables = {
after?: string | null | undefined;
before?: string | null | undefined;
first?: number | null | undefined;
last?: number | null | undefined;
organizationId: string;
};
export type VendorListPageQuery$data = {
readonly organization: {
readonly id: string;
readonly " $fragmentSpreads": FragmentRefs<"VendorListPage_vendors">;
};
};
export type VendorListPageQuery = {
response: VendorListPageQuery$data;
variables: VendorListPageQuery$variables;
};
const node: ConcreteRequest = (function(){
var v0 = {
"defaultValue": null,
"kind": "LocalArgument",
"name": "after"
},
v1 = {
"defaultValue": null,
"kind": "LocalArgument",
"name": "before"
},
v2 = {
"defaultValue": null,
"kind": "LocalArgument",
"name": "first"
},
v3 = {
"defaultValue": null,
"kind": "LocalArgument",
"name": "last"
},
v4 = {
"defaultValue": null,
"kind": "LocalArgument",
"name": "organizationId"
},
v5 = [
{
"kind": "Variable",
"name": "id",
"variableName": "organizationId"
}
],
v6 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "id",
"storageKey": null
},
v7 = {
"kind": "Variable",
"name": "after",
"variableName": "after"
},
v8 = {
"kind": "Variable",
"name": "before",
"variableName": "before"
},
v9 = {
"kind": "Variable",
"name": "first",
"variableName": "first"
},
v10 = {
"kind": "Variable",
"name": "last",
"variableName": "last"
},
v11 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "__typename",
"storageKey": null
},
v12 = [
(v7/*: any*/),
(v8/*: any*/),
(v9/*: any*/),
(v10/*: any*/),
{
"kind": "Literal",
"name": "orderBy",
"value": {
"direction": "ASC",
"field": "NAME"
}
}
];
return {
"fragment": {
"argumentDefinitions": [
(v0/*: any*/),
(v1/*: any*/),
(v2/*: any*/),
(v3/*: any*/),
(v4/*: any*/)
],
"kind": "Fragment",
"metadata": null,
"name": "VendorListPageQuery",
"selections": [
{
"alias": "organization",
"args": (v5/*: any*/),
"concreteType": null,
"kind": "LinkedField",
"name": "node",
"plural": false,
"selections": [
(v6/*: any*/),
{
"args": [
(v7/*: any*/),
(v8/*: any*/),
(v9/*: any*/),
(v10/*: any*/)
],
"kind": "FragmentSpread",
"name": "VendorListPage_vendors"
}
],
"storageKey": null
}
],
"type": "Query",
"abstractKey": null
},
"kind": "Request",
"operation": {
"argumentDefinitions": [
(v4/*: any*/),
(v2/*: any*/),
(v0/*: any*/),
(v3/*: any*/),
(v1/*: any*/)
],
"kind": "Operation",
"name": "VendorListPageQuery",
"selections": [
{
"alias": "organization",
"args": (v5/*: any*/),
"concreteType": null,
"kind": "LinkedField",
"name": "node",
"plural": false,
"selections": [
(v11/*: any*/),
(v6/*: any*/),
{
"kind": "InlineFragment",
"selections": [
{
"alias": null,
"args": (v12/*: any*/),
"concreteType": "VendorConnection",
"kind": "LinkedField",
"name": "vendors",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"concreteType": "VendorEdge",
"kind": "LinkedField",
"name": "edges",
"plural": true,
"selections": [
{
"alias": null,
"args": null,
"concreteType": "Vendor",
"kind": "LinkedField",
"name": "node",
"plural": false,
"selections": [
(v6/*: any*/),
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "name",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "description",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "createdAt",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "updatedAt",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "riskTier",
"storageKey": null
},
(v11/*: any*/)
],
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "cursor",
"storageKey": null
}
],
"storageKey": null
},
{
"alias": null,
"args": null,
"concreteType": "PageInfo",
"kind": "LinkedField",
"name": "pageInfo",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "hasNextPage",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "hasPreviousPage",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "startCursor",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "endCursor",
"storageKey": null
}
],
"storageKey": null
},
{
"kind": "ClientExtension",
"selections": [
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "__id",
"storageKey": null
}
]
}
],
"storageKey": null
},
{
"alias": null,
"args": (v12/*: any*/),
"filters": [
"orderBy"
],
"handle": "connection",
"key": "VendorListPage_vendors",
"kind": "LinkedHandle",
"name": "vendors"
}
],
"type": "Organization",
"abstractKey": null
}
],
"storageKey": null
}
]
},
"params": {
"cacheID": "c2e401b2e573156b913d60ade59ea4ff",
"id": null,
"metadata": {},
"name": "VendorListPageQuery",
"operationKind": "query",
"text": "query VendorListPageQuery(\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 ...VendorListPage_vendors_pbnwq\n }\n}\n\nfragment VendorListPage_vendors_pbnwq on Organization {\n vendors(first: $first, after: $after, last: $last, before: $before, orderBy: {direction: ASC, field: NAME}) {\n edges {\n node {\n id\n name\n description\n createdAt\n updatedAt\n riskTier\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 = "1dc54deae9707bee0ab9beba6d844df3";
export default node;

View File

@@ -1,262 +0,0 @@
/**
* @generated SignedSource<<07023a3f17c448fc24762c05b3a7ff87>>
* @lightSyntaxTransform
* @nogrep
*/
/* tslint:disable */
/* eslint-disable */
// @ts-nocheck
import { ReaderFragment } from 'relay-runtime';
export type RiskTier = "CRITICAL" | "GENERAL" | "SIGNIFICANT";
import { FragmentRefs } from "relay-runtime";
export type VendorListPage_vendors$data = {
readonly id: string;
readonly vendors: {
readonly __id: string;
readonly edges: ReadonlyArray<{
readonly node: {
readonly createdAt: string;
readonly description: string;
readonly id: string;
readonly name: string;
readonly riskTier: RiskTier;
readonly updatedAt: string;
};
}>;
readonly pageInfo: {
readonly endCursor: string | null | undefined;
readonly hasNextPage: boolean;
readonly hasPreviousPage: boolean;
readonly startCursor: string | null | undefined;
};
};
readonly " $fragmentType": "VendorListPage_vendors";
};
export type VendorListPage_vendors$key = {
readonly " $data"?: VendorListPage_vendors$data;
readonly " $fragmentSpreads": FragmentRefs<"VendorListPage_vendors">;
};
const node: ReaderFragment = (function(){
var v0 = [
"vendors"
],
v1 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "id",
"storageKey": null
};
return {
"argumentDefinitions": [
{
"defaultValue": null,
"kind": "LocalArgument",
"name": "after"
},
{
"defaultValue": null,
"kind": "LocalArgument",
"name": "before"
},
{
"defaultValue": null,
"kind": "LocalArgument",
"name": "first"
},
{
"defaultValue": null,
"kind": "LocalArgument",
"name": "last"
}
],
"kind": "Fragment",
"metadata": {
"connection": [
{
"count": null,
"cursor": null,
"direction": "bidirectional",
"path": (v0/*: any*/)
}
],
"refetch": {
"connection": {
"forward": {
"count": "first",
"cursor": "after"
},
"backward": {
"count": "last",
"cursor": "before"
},
"path": (v0/*: any*/)
},
"fragmentPathInResult": [
"node"
],
"operation": require('./VendorListPagePaginationQuery.graphql'),
"identifierInfo": {
"identifierField": "id",
"identifierQueryVariableName": "id"
}
}
},
"name": "VendorListPage_vendors",
"selections": [
{
"alias": "vendors",
"args": [
{
"kind": "Literal",
"name": "orderBy",
"value": {
"direction": "ASC",
"field": "NAME"
}
}
],
"concreteType": "VendorConnection",
"kind": "LinkedField",
"name": "__VendorListPage_vendors_connection",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"concreteType": "VendorEdge",
"kind": "LinkedField",
"name": "edges",
"plural": true,
"selections": [
{
"alias": null,
"args": null,
"concreteType": "Vendor",
"kind": "LinkedField",
"name": "node",
"plural": false,
"selections": [
(v1/*: any*/),
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "name",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "description",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "createdAt",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "updatedAt",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "riskTier",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "__typename",
"storageKey": null
}
],
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "cursor",
"storageKey": null
}
],
"storageKey": null
},
{
"alias": null,
"args": null,
"concreteType": "PageInfo",
"kind": "LinkedField",
"name": "pageInfo",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "hasNextPage",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "hasPreviousPage",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "startCursor",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "endCursor",
"storageKey": null
}
],
"storageKey": null
},
{
"kind": "ClientExtension",
"selections": [
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "__id",
"storageKey": null
}
]
}
],
"storageKey": "__VendorListPage_vendors_connection(orderBy:{\"direction\":\"ASC\",\"field\":\"NAME\"})"
},
(v1/*: any*/)
],
"type": "Organization",
"abstractKey": null
};
})();
(node as any).hash = "beaab1664bed1fa776659595b1ef3c30";
export default node;

2
go.sum
View File

@@ -148,8 +148,6 @@ github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGC
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM= github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM=
go.gearno.de/crypto/uuid v0.1.0 h1:94BYg7GYItJ6yYZ1GJayb3VYhI9/FjxuR1nFaduR4hE= go.gearno.de/crypto/uuid v0.1.0 h1:94BYg7GYItJ6yYZ1GJayb3VYhI9/FjxuR1nFaduR4hE=
go.gearno.de/crypto/uuid v0.1.0/go.mod h1:fnIIvKO9QnsyLO3ZJLJT3r8KZv/p0FOeT5eZKilYWXg= go.gearno.de/crypto/uuid v0.1.0/go.mod h1:fnIIvKO9QnsyLO3ZJLJT3r8KZv/p0FOeT5eZKilYWXg=
go.gearno.de/kit v0.0.0-20250324091140-5078a54c3c53 h1:4dKq7+vYcc6/+dYlZ0GSsvPKL6u/CHy9Fl6IY+0nv18=
go.gearno.de/kit v0.0.0-20250324091140-5078a54c3c53/go.mod h1:cEDPOR+WVloqrYmGBoSpHlLqSmTCBjW1j02ntm0Yk9U=
go.gearno.de/kit v0.0.0-20250325104916-a9c1391b79f0 h1:X6TgcxxGPV0zbjgrLRgnqhqqzI9TQR1LraZl3VIiWd0= go.gearno.de/kit v0.0.0-20250325104916-a9c1391b79f0 h1:X6TgcxxGPV0zbjgrLRgnqhqqzI9TQR1LraZl3VIiWd0=
go.gearno.de/kit v0.0.0-20250325104916-a9c1391b79f0/go.mod h1:cEDPOR+WVloqrYmGBoSpHlLqSmTCBjW1j02ntm0Yk9U= go.gearno.de/kit v0.0.0-20250325104916-a9c1391b79f0/go.mod h1:cEDPOR+WVloqrYmGBoSpHlLqSmTCBjW1j02ntm0Yk9U=
go.gearno.de/x/panicf v0.1.1 h1:E3Cr9NB8Ry2EsvEG/1eHr7kplP3tEjTf5d56dTX64VQ= go.gearno.de/x/panicf v0.1.1 h1:E3Cr9NB8Ry2EsvEG/1eHr7kplP3tEjTf5d56dTX64VQ=

View File

@@ -28,47 +28,47 @@ import (
) )
type ( type (
Control struct { Mitigation struct {
ID gid.GID `db:"id"` ID gid.GID `db:"id"`
FrameworkID gid.GID `db:"framework_id"` FrameworkID gid.GID `db:"framework_id"`
Category string `db:"category"` Category string `db:"category"`
Name string `db:"name"` Name string `db:"name"`
Description string `db:"description"` Description string `db:"description"`
Importance ControlImportance `db:"importance"` Importance MitigationImportance `db:"importance"`
State ControlState `db:"state"` State MitigationState `db:"state"`
ContentRef string `db:"content_ref"` ContentRef string `db:"content_ref"`
CreatedAt time.Time `db:"created_at"` CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"` UpdatedAt time.Time `db:"updated_at"`
Version int `db:"version"` Version int `db:"version"`
Standards []string `db:"standards"` Standards []string `db:"standards"`
} }
Controls []*Control Mitigations []*Mitigation
UpdateControlParams struct { UpdateMitigationParams struct {
ExpectedVersion int ExpectedVersion int
Name *string Name *string
Description *string Description *string
Category *string Category *string
State *ControlState State *MitigationState
Importance *ControlImportance Importance *MitigationImportance
} }
) )
func (c Control) CursorKey(orderBy ControlOrderField) page.CursorKey { func (c Mitigation) CursorKey(orderBy MitigationOrderField) page.CursorKey {
switch orderBy { switch orderBy {
case ControlOrderFieldCreatedAt: case MitigationOrderFieldCreatedAt:
return page.NewCursorKey(c.ID, c.CreatedAt) return page.NewCursorKey(c.ID, c.CreatedAt)
} }
panic(fmt.Sprintf("unsupported order by: %s", orderBy)) panic(fmt.Sprintf("unsupported order by: %s", orderBy))
} }
func (c *Control) LoadByID( func (c *Mitigation) LoadByID(
ctx context.Context, ctx context.Context,
conn pg.Conn, conn pg.Conn,
scope Scoper, scope Scoper,
controlID gid.GID, mitigationID gid.GID,
) error { ) error {
q := ` q := `
SELECT SELECT
@@ -85,41 +85,41 @@ SELECT
standards, standards,
version version
FROM FROM
controls mitigations
WHERE WHERE
%s %s
AND id = @control_id AND id = @mitigation_id
LIMIT 1; LIMIT 1;
` `
q = fmt.Sprintf(q, scope.SQLFragment()) q = fmt.Sprintf(q, scope.SQLFragment())
args := pgx.StrictNamedArgs{"control_id": controlID} args := pgx.StrictNamedArgs{"mitigation_id": mitigationID}
maps.Copy(args, scope.SQLArguments()) maps.Copy(args, scope.SQLArguments())
rows, err := conn.Query(ctx, q, args) rows, err := conn.Query(ctx, q, args)
if err != nil { if err != nil {
return fmt.Errorf("cannot query controls: %w", err) return fmt.Errorf("cannot query mitigations: %w", err)
} }
control, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[Control]) mitigation, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[Mitigation])
if err != nil { if err != nil {
return fmt.Errorf("cannot collect controls: %w", err) return fmt.Errorf("cannot collect mitigations: %w", err)
} }
*c = control *c = mitigation
return nil return nil
} }
func (c Control) Insert( func (c Mitigation) Insert(
ctx context.Context, ctx context.Context,
conn pg.Conn, conn pg.Conn,
scope Scoper, scope Scoper,
) error { ) error {
q := ` q := `
INSERT INTO INSERT INTO
controls ( mitigations (
tenant_id, tenant_id,
id, id,
framework_id, framework_id,
@@ -136,7 +136,7 @@ INSERT INTO
) )
VALUES ( VALUES (
@tenant_id, @tenant_id,
@control_id, @mitigation_id,
@framework_id, @framework_id,
@category, @category,
@name, @name,
@@ -152,30 +152,30 @@ VALUES (
` `
args := pgx.StrictNamedArgs{ args := pgx.StrictNamedArgs{
"tenant_id": scope.GetTenantID(), "tenant_id": scope.GetTenantID(),
"control_id": c.ID, "mitigation_id": c.ID,
"framework_id": c.FrameworkID, "framework_id": c.FrameworkID,
"category": c.Category, "category": c.Category,
"name": c.Name, "name": c.Name,
"version": 0, "version": 0,
"description": c.Description, "description": c.Description,
"content_ref": c.ContentRef, "content_ref": c.ContentRef,
"created_at": c.CreatedAt, "created_at": c.CreatedAt,
"updated_at": c.UpdatedAt, "updated_at": c.UpdatedAt,
"state": c.State, "state": c.State,
"importance": c.Importance, "importance": c.Importance,
"standards": c.Standards, "standards": c.Standards,
} }
_, err := conn.Exec(ctx, q, args) _, err := conn.Exec(ctx, q, args)
return err return err
} }
func (c *Controls) LoadByFrameworkID( func (c *Mitigations) LoadByFrameworkID(
ctx context.Context, ctx context.Context,
conn pg.Conn, conn pg.Conn,
scope Scoper, scope Scoper,
frameworkID gid.GID, frameworkID gid.GID,
cursor *page.Cursor[ControlOrderField], cursor *page.Cursor[MitigationOrderField],
) error { ) error {
q := ` q := `
SELECT SELECT
@@ -192,7 +192,7 @@ SELECT
standards, standards,
version version
FROM FROM
controls mitigations
WHERE WHERE
%s %s
AND framework_id = @framework_id AND framework_id = @framework_id
@@ -206,27 +206,27 @@ WHERE
rows, err := conn.Query(ctx, q, args) rows, err := conn.Query(ctx, q, args)
if err != nil { if err != nil {
return fmt.Errorf("cannot query controls: %w", err) return fmt.Errorf("cannot query mitigations: %w", err)
} }
controls, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[Control]) mitigations, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[Mitigation])
if err != nil { if err != nil {
return fmt.Errorf("cannot collect controls: %w", err) return fmt.Errorf("cannot collect mitigations: %w", err)
} }
*c = controls *c = mitigations
return nil return nil
} }
func (c *Control) Update( func (c *Mitigation) Update(
ctx context.Context, ctx context.Context,
conn pg.Conn, conn pg.Conn,
scope Scoper, scope Scoper,
params UpdateControlParams, params UpdateMitigationParams,
) error { ) error {
q := ` q := `
UPDATE controls SET UPDATE mitigations SET
name = COALESCE(@name, name), name = COALESCE(@name, name),
description = COALESCE(@description, description), description = COALESCE(@description, description),
category = COALESCE(@category, category), category = COALESCE(@category, category),
@@ -235,7 +235,7 @@ UPDATE controls SET
updated_at = @updated_at, updated_at = @updated_at,
version = version + 1 version = version + 1
WHERE %s WHERE %s
AND id = @control_id AND id = @mitigation_id
AND version = @expected_version AND version = @expected_version
RETURNING RETURNING
id, id,
@@ -254,7 +254,7 @@ RETURNING
q = fmt.Sprintf(q, scope.SQLFragment()) q = fmt.Sprintf(q, scope.SQLFragment())
args := pgx.NamedArgs{ args := pgx.NamedArgs{
"control_id": c.ID, "mitigation_id": c.ID,
"expected_version": params.ExpectedVersion, "expected_version": params.ExpectedVersion,
"name": params.Name, "name": params.Name,
"description": params.Description, "description": params.Description,
@@ -268,15 +268,15 @@ RETURNING
rows, err := conn.Query(ctx, q, args) rows, err := conn.Query(ctx, q, args)
if err != nil { if err != nil {
return fmt.Errorf("cannot query controls: %w", err) return fmt.Errorf("cannot query mitigations: %w", err)
} }
control, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[Control]) mitigation, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[Mitigation])
if err != nil { if err != nil {
return fmt.Errorf("cannot collect controls: %w", err) return fmt.Errorf("cannot collect mitigations: %w", err)
} }
*c = control *c = mitigation
return nil return nil
} }

View File

@@ -20,48 +20,48 @@ import (
"fmt" "fmt"
) )
type ControlImportance uint8 type MitigationImportance uint8
const ( const (
ControlImportanceMandatory ControlImportance = iota MitigationImportanceMandatory MitigationImportance = iota
ControlImportancePreferred MitigationImportancePreferred
ControlImportanceAdvanced MitigationImportanceAdvanced
) )
func (i ControlImportance) String() string { func (i MitigationImportance) String() string {
return []string{"MANDATORY", "PREFERRED", "ADVANCED"}[i] return []string{"MANDATORY", "PREFERRED", "ADVANCED"}[i]
} }
func (i *ControlImportance) Scan(value interface{}) error { func (i *MitigationImportance) Scan(value interface{}) error {
switch v := value.(type) { switch v := value.(type) {
case uint8: case uint8:
*i = ControlImportance(v) *i = MitigationImportance(v)
case string: case string:
switch v { switch v {
case "MANDATORY": case "MANDATORY":
*i = ControlImportanceMandatory *i = MitigationImportanceMandatory
case "PREFERRED": case "PREFERRED":
*i = ControlImportancePreferred *i = MitigationImportancePreferred
case "ADVANCED": case "ADVANCED":
*i = ControlImportanceAdvanced *i = MitigationImportanceAdvanced
default: default:
return fmt.Errorf("invalid ControlImportance value: %q", v) return fmt.Errorf("invalid MitigationImportance value: %q", v)
} }
default: default:
return fmt.Errorf("unsupported type for ControlImportance: %T", value) return fmt.Errorf("unsupported type for MitigationImportance: %T", value)
} }
return nil return nil
} }
func (i ControlImportance) Value() (driver.Value, error) { func (i MitigationImportance) Value() (driver.Value, error) {
return i.String(), nil return i.String(), nil
} }
func (i ControlImportance) MarshalJSON() ([]byte, error) { func (i MitigationImportance) MarshalJSON() ([]byte, error) {
return json.Marshal(i.String()) return json.Marshal(i.String())
} }
func (i *ControlImportance) UnmarshalJSON(data []byte) error { func (i *MitigationImportance) UnmarshalJSON(data []byte) error {
var s string var s string
if err := json.Unmarshal(data, &s); err != nil { if err := json.Unmarshal(data, &s); err != nil {
return err return err
@@ -69,18 +69,18 @@ func (i *ControlImportance) UnmarshalJSON(data []byte) error {
switch s { switch s {
case "MANDATORY": case "MANDATORY":
*i = ControlImportanceMandatory *i = MitigationImportanceMandatory
case "PREFERRED": case "PREFERRED":
*i = ControlImportancePreferred *i = MitigationImportancePreferred
case "ADVANCED": case "ADVANCED":
*i = ControlImportanceAdvanced *i = MitigationImportanceAdvanced
default: default:
return fmt.Errorf("invalid ControlImportance value: %q", s) return fmt.Errorf("invalid MitigationImportance value: %q", s)
} }
return nil return nil
} }
func (i *ControlImportance) UnmarshalText(text []byte) error { func (i *MitigationImportance) UnmarshalText(text []byte) error {
var s string var s string
if err := json.Unmarshal(text, &s); err != nil { if err := json.Unmarshal(text, &s); err != nil {
return err return err
@@ -88,13 +88,13 @@ func (i *ControlImportance) UnmarshalText(text []byte) error {
switch s { switch s {
case "MANDATORY": case "MANDATORY":
*i = ControlImportanceMandatory *i = MitigationImportanceMandatory
case "PREFERRED": case "PREFERRED":
*i = ControlImportancePreferred *i = MitigationImportancePreferred
case "ADVANCED": case "ADVANCED":
*i = ControlImportanceAdvanced *i = MitigationImportanceAdvanced
default: default:
return fmt.Errorf("invalid ControlImportance value: %q", s) return fmt.Errorf("invalid MitigationImportance value: %q", s)
} }
return nil return nil
} }

View File

@@ -15,26 +15,26 @@
package coredata package coredata
type ( type (
ControlOrderField string MitigationOrderField string
) )
const ( const (
ControlOrderFieldCreatedAt ControlOrderField = "CREATED_AT" MitigationOrderFieldCreatedAt MitigationOrderField = "CREATED_AT"
) )
func (p ControlOrderField) Column() string { func (p MitigationOrderField) Column() string {
return string(p) return string(p)
} }
func (p ControlOrderField) String() string { func (p MitigationOrderField) String() string {
return string(p) return string(p)
} }
func (p ControlOrderField) MarshalText() ([]byte, error) { func (p MitigationOrderField) MarshalText() ([]byte, error) {
return []byte(p.String()), nil return []byte(p.String()), nil
} }
func (p *ControlOrderField) UnmarshalText(text []byte) error { func (p *MitigationOrderField) UnmarshalText(text []byte) error {
*p = ControlOrderField(text) *p = MitigationOrderField(text)
return nil return nil
} }

View File

@@ -20,65 +20,65 @@ import (
) )
type ( type (
ControlState uint8 MitigationState uint8
) )
const ( const (
ControlStateNotStarted ControlState = iota MitigationStateNotStarted MitigationState = iota
ControlStateInProgress MitigationStateInProgress
ControlStateNotApplicable MitigationStateNotApplicable
ControlStateImplemented MitigationStateImplemented
) )
func (cs ControlState) MarshalText() ([]byte, error) { func (cs MitigationState) MarshalText() ([]byte, error) {
return []byte(cs.String()), nil return []byte(cs.String()), nil
} }
func (cs *ControlState) UnmarshalText(data []byte) error { func (cs *MitigationState) UnmarshalText(data []byte) error {
val := string(data) val := string(data)
switch val { switch val {
case ControlStateNotStarted.String(): case MitigationStateNotStarted.String():
*cs = ControlStateNotStarted *cs = MitigationStateNotStarted
case ControlStateInProgress.String(): case MitigationStateInProgress.String():
*cs = ControlStateInProgress *cs = MitigationStateInProgress
case ControlStateNotApplicable.String(): case MitigationStateNotApplicable.String():
*cs = ControlStateNotApplicable *cs = MitigationStateNotApplicable
case ControlStateImplemented.String(): case MitigationStateImplemented.String():
*cs = ControlStateImplemented *cs = MitigationStateImplemented
default: default:
return fmt.Errorf("invalid ControlState value: %q", val) return fmt.Errorf("invalid MitigationState value: %q", val)
} }
return nil return nil
} }
func (cs ControlState) String() string { func (cs MitigationState) String() string {
var val string var val string
switch cs { switch cs {
case ControlStateNotStarted: case MitigationStateNotStarted:
val = "NOT_STARTED" val = "NOT_STARTED"
case ControlStateInProgress: case MitigationStateInProgress:
val = "IN_PROGRESS" val = "IN_PROGRESS"
case ControlStateNotApplicable: case MitigationStateNotApplicable:
val = "NOT_APPLICABLE" val = "NOT_APPLICABLE"
case ControlStateImplemented: case MitigationStateImplemented:
val = "IMPLEMENTED" val = "IMPLEMENTED"
} }
return val return val
} }
func (cs *ControlState) Scan(value any) error { func (cs *MitigationState) Scan(value any) error {
val, ok := value.(string) val, ok := value.(string)
if !ok { if !ok {
return fmt.Errorf("invalid scan source for ControlState, expected string got %T", value) return fmt.Errorf("invalid scan source for MitigationState, expected string got %T", value)
} }
return cs.UnmarshalText([]byte(val)) return cs.UnmarshalText([]byte(val))
} }
func (cs ControlState) Value() (driver.Value, error) { func (cs MitigationState) Value() (driver.Value, error) {
return cs.String(), nil return cs.String(), nil
} }

View File

@@ -17,7 +17,7 @@ package coredata
const ( const (
OrganizationEntityType uint16 = iota OrganizationEntityType uint16 = iota
FrameworkEntityType FrameworkEntityType
ControlEntityType MitigationEntityType
TaskEntityType TaskEntityType
EvidenceEntityType EvidenceEntityType
ControlStateTransitionEntityType ControlStateTransitionEntityType

View File

@@ -0,0 +1,97 @@
-- Rename control_state ENUM to mitigation_state
-- We need to create a new type and update all references since
-- PostgreSQL doesn't support renaming enum types directly
CREATE TYPE mitigation_state AS ENUM (
'NOT_STARTED',
'IN_PROGRESS',
'NOT_APPLICABLE',
'IMPLEMENTED'
);
-- Create new mitigation_importance type
CREATE TYPE mitigation_importance AS ENUM (
'MANDATORY',
'PREFERRED',
'ADVANCED'
);
-- Rename controls table to mitigations, adding the new columns with the new types
CREATE TABLE mitigations (
id TEXT PRIMARY KEY,
tenant_id TEXT NOT NULL,
framework_id TEXT NOT NULL,
name TEXT NOT NULL,
description TEXT NOT NULL,
content_ref TEXT NOT NULL,
category TEXT NOT NULL,
state mitigation_state NOT NULL,
importance mitigation_importance NOT NULL,
version INTEGER NOT NULL,
standards TEXT[] NOT NULL,
created_at TIMESTAMP WITH TIME ZONE NOT NULL,
updated_at TIMESTAMP WITH TIME ZONE NOT NULL
);
-- Copy data from controls to mitigations table
INSERT INTO mitigations (
id,
tenant_id,
framework_id,
name,
description,
content_ref,
category,
state,
importance,
version,
standards,
created_at,
updated_at
)
SELECT
id,
tenant_id,
framework_id,
name,
description,
content_ref,
category,
(state::TEXT)::mitigation_state,
(importance::TEXT)::mitigation_importance,
version,
standards,
created_at,
updated_at
FROM controls;
-- Update tasks to reference mitigations instead of controls
ALTER TABLE tasks RENAME COLUMN control_id TO mitigation_id;
-- Update foreign key constraint
ALTER TABLE tasks DROP CONSTRAINT fk_tasks_control_id;
ALTER TABLE tasks ADD CONSTRAINT fk_tasks_mitigation_id
FOREIGN KEY (mitigation_id) REFERENCES mitigations(id) ON DELETE CASCADE;
-- If we have any control_state_transitions table, rename it
-- Since the original migration file 20250310T161900Z.sql dropped it, this might not be necessary,
-- but including for completeness
DO $$
BEGIN
IF EXISTS (
SELECT FROM information_schema.tables
WHERE table_name = 'control_state_transitions'
) THEN
ALTER TABLE control_state_transitions RENAME TO mitigation_state_transitions;
ALTER TABLE mitigation_state_transitions RENAME COLUMN control_id TO mitigation_id;
ALTER TABLE mitigation_state_transitions
DROP CONSTRAINT IF EXISTS control_state_transitions_control_id_fkey;
ALTER TABLE mitigation_state_transitions
ADD CONSTRAINT mitigation_state_transitions_mitigation_id_fkey
FOREIGN KEY (mitigation_id) REFERENCES mitigations(id);
END IF;
END $$;
-- Drop old controls table and enum types after migration is complete
DROP TABLE controls;
DROP TYPE control_state;
DROP TYPE control_importance;

View File

@@ -30,16 +30,15 @@ import (
type ( type (
Task struct { Task struct {
ID gid.GID `db:"id"` ID gid.GID `db:"id"`
ControlID gid.GID `db:"control_id"` MitigationID gid.GID `db:"mitigation_id"`
Name string `db:"name"` Name string `db:"name"`
Description string `db:"description"` Description string `db:"description"`
State TaskState `db:"state"` State TaskState `db:"state"`
ContentRef string `db:"content_ref"` TimeEstimate *time.Duration `db:"time_estimate"`
AssignedToID *gid.GID `db:"assigned_to"`
CreatedAt time.Time `db:"created_at"` CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"` UpdatedAt time.Time `db:"updated_at"`
Version int `db:"version"` Version int `db:"version"`
AssignedTo *gid.GID `db:"assigned_to"`
TimeEstimate *time.Duration `db:"time_estimate"`
} }
Tasks []*Task Tasks []*Task
@@ -53,16 +52,16 @@ type (
} }
) )
func (t Task) CursorKey(orderBy TaskOrderField) page.CursorKey { func (c Task) CursorKey(orderBy TaskOrderField) page.CursorKey {
switch orderBy { switch orderBy {
case TaskOrderFieldCreatedAt: case TaskOrderFieldCreatedAt:
return page.NewCursorKey(t.ID, t.CreatedAt) return page.NewCursorKey(c.ID, c.CreatedAt)
} }
panic(fmt.Sprintf("unsupported order by: %s", orderBy)) panic(fmt.Sprintf("unsupported order by: %s", orderBy))
} }
func (t *Task) LoadByID( func (c *Task) LoadByID(
ctx context.Context, ctx context.Context,
conn pg.Conn, conn pg.Conn,
scope Scoper, scope Scoper,
@@ -71,13 +70,12 @@ func (t *Task) LoadByID(
q := ` q := `
SELECT SELECT
id, id,
control_id, mitigation_id,
name, name,
description, description,
time_estimate,
state, state,
assigned_to, time_estimate,
content_ref, assigned_to,
created_at, created_at,
updated_at, updated_at,
version version
@@ -96,104 +94,100 @@ LIMIT 1;
rows, err := conn.Query(ctx, q, args) rows, err := conn.Query(ctx, q, args)
if err != nil { if err != nil {
return fmt.Errorf("cannot query task: %w", err) return fmt.Errorf("cannot query tasks: %w", err)
} }
task, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[Task]) task, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[Task])
if err != nil { if err != nil {
return fmt.Errorf("cannot collect task: %w", err) return fmt.Errorf("cannot collect tasks: %w", err)
} }
*t = task *c = task
return nil return nil
} }
func (t Task) Insert( func (c Task) Insert(
ctx context.Context, ctx context.Context,
conn pg.Conn, conn pg.Conn,
scope Scoper, scope Scoper,
) error { ) error {
q := ` q := `
INSERT INTO tasks ( INSERT INTO
tenant_id, tasks (
id, tenant_id,
name, id,
control_id, mitigation_id,
description, name,
content_ref, description,
created_at, state,
updated_at, time_estimate,
version, assigned_to,
state, created_at,
time_estimate, updated_at,
assigned_to version
) )
VALUES ( VALUES (
@tenant_id, @tenant_id,
@task_id, @task_id,
@mitigation_id,
@name, @name,
@control_id,
@description, @description,
@content_ref, @state,
@time_estimate,
@assigned_to,
@created_at, @created_at,
@updated_at, @updated_at,
@version, @version
@state,
@time_estimate,
@assigned_to
); );
` `
args := pgx.StrictNamedArgs{ args := pgx.StrictNamedArgs{
"tenant_id": scope.GetTenantID(), "tenant_id": scope.GetTenantID(),
"task_id": t.ID, "task_id": c.ID,
"control_id": t.ControlID, "mitigation_id": c.MitigationID,
"name": t.Name, "name": c.Name,
"description": t.Description, "description": c.Description,
"content_ref": t.ContentRef, "state": c.State,
"created_at": t.CreatedAt, "time_estimate": c.TimeEstimate,
"updated_at": t.UpdatedAt, "assigned_to": c.AssignedToID,
"version": t.Version, "created_at": c.CreatedAt,
"state": t.State, "updated_at": c.UpdatedAt,
"time_estimate": t.TimeEstimate, "version": 0,
"assigned_to": t.AssignedTo,
} }
_, err := conn.Exec(ctx, q, args) _, err := conn.Exec(ctx, q, args)
return err return err
} }
func (t *Tasks) LoadByControlID( func (c *Tasks) LoadByMitigationID(
ctx context.Context, ctx context.Context,
conn pg.Conn, conn pg.Conn,
scope Scoper, scope Scoper,
controlID gid.GID, mitigationID gid.GID,
cursor *page.Cursor[TaskOrderField], cursor *page.Cursor[TaskOrderField],
) error { ) error {
q := ` q := `
SELECT SELECT
id, id,
control_id, mitigation_id,
name, name,
description, description,
state, state,
time_estimate, time_estimate,
content_ref, assigned_to,
created_at, created_at,
updated_at, updated_at,
version, version
assigned_to
FROM FROM
tasks tasks
WHERE WHERE
%s %s
AND control_id = @control_id AND mitigation_id = @mitigation_id
AND %s AND %s
` `
q = fmt.Sprintf(q, scope.SQLFragment(), cursor.SQLFragment()) q = fmt.Sprintf(q, scope.SQLFragment(), cursor.SQLFragment())
args := pgx.StrictNamedArgs{"control_id": controlID} args := pgx.StrictNamedArgs{"mitigation_id": mitigationID}
maps.Copy(args, scope.SQLArguments()) maps.Copy(args, scope.SQLArguments())
maps.Copy(args, cursor.SQLArguments()) maps.Copy(args, cursor.SQLArguments())
@@ -207,40 +201,44 @@ WHERE
return fmt.Errorf("cannot collect tasks: %w", err) return fmt.Errorf("cannot collect tasks: %w", err)
} }
*t = tasks *c = tasks
return nil return nil
} }
func (t *Task) Update( func (c *Task) Update(
ctx context.Context, ctx context.Context,
conn pg.Conn, conn pg.Conn,
scope Scoper, scope Scoper,
params UpdateTaskParams, params UpdateTaskParams,
) error { ) error {
q := ` q := `
UPDATE tasks UPDATE tasks SET
SET
name = COALESCE(@name, name), name = COALESCE(@name, name),
description = COALESCE(@description, description), description = COALESCE(@description, description),
state = COALESCE(@state, state), state = COALESCE(@state, state),
time_estimate = COALESCE(@time_estimate, time_estimate), time_estimate = COALESCE(@time_estimate, time_estimate),
updated_at = @updated_at, updated_at = @updated_at,
version = version + 1 version = version + 1
WHERE WHERE %s
%s
AND id = @task_id AND id = @task_id
AND version = @expected_version AND version = @expected_version
RETURNING RETURNING
state, id,
time_estimate, mitigation_id,
updated_at, name,
version; description,
state,
time_estimate,
assigned_to,
created_at,
updated_at,
version
` `
q = fmt.Sprintf(q, scope.SQLFragment()) q = fmt.Sprintf(q, scope.SQLFragment())
args := pgx.StrictNamedArgs{ args := pgx.NamedArgs{
"task_id": t.ID, "task_id": c.ID,
"expected_version": params.ExpectedVersion, "expected_version": params.ExpectedVersion,
"name": params.Name, "name": params.Name,
"description": params.Description, "description": params.Description,
@@ -248,75 +246,235 @@ RETURNING
"time_estimate": params.TimeEstimate, "time_estimate": params.TimeEstimate,
"updated_at": time.Now(), "updated_at": time.Now(),
} }
maps.Copy(args, scope.SQLArguments()) maps.Copy(args, scope.SQLArguments())
err := conn.QueryRow(ctx, q, args).Scan(&t.State, &t.TimeEstimate, &t.UpdatedAt, &t.Version) rows, err := conn.Query(ctx, q, args)
return err if err != nil {
return fmt.Errorf("cannot query tasks: %w", err)
}
task, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[Task])
if err != nil {
return fmt.Errorf("cannot collect tasks: %w", err)
}
*c = task
return nil
} }
func (t *Task) AssignTo( func (c *Task) AssignTo(
ctx context.Context, ctx context.Context,
conn pg.Conn, conn pg.Conn,
scope Scoper, scope Scoper,
assignedTo gid.GID, assignTo gid.GID,
) error { ) error {
q := ` q := `
UPDATE tasks UPDATE tasks SET
SET assigned_to = @assigned_to,
assigned_to = @assigned_to updated_at = @updated_at,
WHERE version = version + 1
%s WHERE %s
AND id = @task_id AND id = @task_id
RETURNING
id,
mitigation_id,
name,
description,
state,
time_estimate,
assigned_to,
created_at,
updated_at,
version
` `
q = fmt.Sprintf(q, scope.SQLFragment()) q = fmt.Sprintf(q, scope.SQLFragment())
args := pgx.StrictNamedArgs{ args := pgx.NamedArgs{
"task_id": t.ID, "task_id": c.ID,
"assigned_to": assignedTo, "assigned_to": assignTo,
"updated_at": time.Now(),
} }
maps.Copy(args, scope.SQLArguments()) maps.Copy(args, scope.SQLArguments())
_, err := conn.Exec(ctx, q, args) rows, err := conn.Query(ctx, q, args)
return err if err != nil {
return fmt.Errorf("cannot query tasks: %w", err)
}
task, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[Task])
if err != nil {
return fmt.Errorf("cannot collect tasks: %w", err)
}
*c = task
return nil
} }
func (t *Task) Unassign( func (c *Task) Unassign(
ctx context.Context, ctx context.Context,
conn pg.Conn, conn pg.Conn,
scope Scoper, scope Scoper,
) error { ) error {
q := ` q := `
UPDATE tasks UPDATE tasks SET
SET assigned_to = NULL,
assigned_to = NULL updated_at = @updated_at,
WHERE version = version + 1
%s WHERE %s
AND id = @task_id AND id = @task_id
RETURNING
id,
mitigation_id,
name,
description,
state,
time_estimate,
assigned_to,
created_at,
updated_at,
version
` `
q = fmt.Sprintf(q, scope.SQLFragment()) q = fmt.Sprintf(q, scope.SQLFragment())
args := pgx.StrictNamedArgs{ args := pgx.NamedArgs{
"task_id": t.ID, "task_id": c.ID,
"updated_at": time.Now(),
} }
maps.Copy(args, scope.SQLArguments()) maps.Copy(args, scope.SQLArguments())
_, err := conn.Exec(ctx, q, args) rows, err := conn.Query(ctx, q, args)
return err if err != nil {
return fmt.Errorf("cannot query tasks: %w", err)
}
task, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[Task])
if err != nil {
return fmt.Errorf("cannot collect tasks: %w", err)
}
*c = task
return nil
} }
func (t *Task) Delete( func (c *Task) Delete(
ctx context.Context, ctx context.Context,
conn pg.Conn, conn pg.Conn,
scope Scoper, scope Scoper,
) error { ) error {
q := `DELETE FROM tasks WHERE %s AND id = @task_id` q := `
DELETE FROM tasks
WHERE %s
AND id = @task_id
`
q = fmt.Sprintf(q, scope.SQLFragment()) q = fmt.Sprintf(q, scope.SQLFragment())
args := pgx.StrictNamedArgs{"task_id": t.ID} args := pgx.NamedArgs{
"task_id": c.ID,
}
maps.Copy(args, scope.SQLArguments()) maps.Copy(args, scope.SQLArguments())
_, err := conn.Exec(ctx, q, args) _, err := conn.Exec(ctx, q, args)
return err if err != nil {
return fmt.Errorf("cannot delete task: %w", err)
}
return nil
}
// Helper functions for task management
var (
ErrAssignTaskFailed = fmt.Errorf("failed to assign task")
ErrUnassignTaskFailed = fmt.Errorf("failed to unassign task")
ErrUpdateTaskFailed = fmt.Errorf("failed to update task")
ErrDeleteTaskFailed = fmt.Errorf("failed to delete task")
)
type TaskUpdate struct {
Name *string
Description *string
State *TaskState
TimeEstimate *time.Duration
}
func AssignTask(
ctx context.Context,
conn pg.Conn,
scope Scoper,
taskID gid.GID,
assignedToID gid.GID,
) (*Task, error) {
task := &Task{ID: taskID}
if err := task.LoadByID(ctx, conn, scope, taskID); err != nil {
return nil, ErrAssignTaskFailed
}
if err := task.AssignTo(ctx, conn, scope, assignedToID); err != nil {
return nil, ErrAssignTaskFailed
}
return task, nil
}
func UnassignTask(
ctx context.Context,
conn pg.Conn,
scope Scoper,
taskID gid.GID,
) (*Task, error) {
task := &Task{ID: taskID}
if err := task.LoadByID(ctx, conn, scope, taskID); err != nil {
return nil, ErrUnassignTaskFailed
}
if err := task.Unassign(ctx, conn, scope); err != nil {
return nil, ErrUnassignTaskFailed
}
return task, nil
}
func UpdateTask(
ctx context.Context,
conn pg.Conn,
scope Scoper,
taskID gid.GID,
expectedVersion int,
updates *TaskUpdate,
) (*Task, error) {
task := &Task{ID: taskID}
if err := task.Update(ctx, conn, scope, UpdateTaskParams{
ExpectedVersion: expectedVersion,
Name: updates.Name,
Description: updates.Description,
State: updates.State,
TimeEstimate: updates.TimeEstimate,
}); err != nil {
return nil, ErrUpdateTaskFailed
}
return task, nil
}
func DeleteTask(
ctx context.Context,
conn pg.Conn,
scope Scoper,
taskID gid.GID,
) error {
task := &Task{ID: taskID}
if err := task.Delete(ctx, conn, scope); err != nil {
return ErrDeleteTaskFailed
}
return nil
} }

View File

@@ -53,12 +53,12 @@ type (
Description string `json:"description"` Description string `json:"description"`
Version string `json:"version"` Version string `json:"version"`
Controls []struct { Controls []struct {
ContentRef string `json:"content-ref"` ContentRef string `json:"content-ref"`
Category string `json:"category"` Category string `json:"category"`
Importance coredata.ControlImportance `json:"importance"` Importance coredata.MitigationImportance `json:"importance"`
Standards []string `json:"standards"` Standards []string `json:"standards"`
Name string `json:"name"` Name string `json:"name"`
Description string `json:"description"` Description string `json:"description"`
Tasks []struct { Tasks []struct {
Name string `json:"name"` Name string `json:"name"`
Description string `json:"description"` Description string `json:"description"`
@@ -212,31 +212,31 @@ func (s FrameworkService) Import(
UpdatedAt: now, UpdatedAt: now,
} }
importedControls := coredata.Controls{} importedMitigations := coredata.Mitigations{}
importedTasks := coredata.Tasks{} importedTasks := coredata.Tasks{}
for _, control := range req.Data.Framework.Controls { for _, mitigation := range req.Data.Framework.Controls {
controlID, err := gid.NewGID(organizationID.TenantID(), coredata.ControlEntityType) controlID, err := gid.NewGID(organizationID.TenantID(), coredata.MitigationEntityType)
if err != nil { if err != nil {
return nil, fmt.Errorf("cannot create global id: %w", err) return nil, fmt.Errorf("cannot create global id: %w", err)
} }
importedControl := &coredata.Control{ importedControl := &coredata.Mitigation{
ID: controlID, ID: controlID,
FrameworkID: frameworkID, FrameworkID: frameworkID,
Category: control.Category, Category: mitigation.Category,
Importance: coredata.ControlImportance(control.Importance), Importance: coredata.MitigationImportance(mitigation.Importance),
Name: control.Name, Name: mitigation.Name,
Description: control.Description, Description: mitigation.Description,
State: coredata.ControlStateNotStarted, State: coredata.MitigationStateNotStarted,
ContentRef: control.ContentRef, ContentRef: mitigation.ContentRef,
CreatedAt: now, CreatedAt: now,
UpdatedAt: now, UpdatedAt: now,
Standards: control.Standards, Standards: mitigation.Standards,
} }
importedControls = append(importedControls, importedControl) importedMitigations = append(importedMitigations, importedControl)
for _, task := range control.Tasks { for _, task := range mitigation.Tasks {
taskID, err := gid.NewGID(organizationID.TenantID(), coredata.TaskEntityType) taskID, err := gid.NewGID(organizationID.TenantID(), coredata.TaskEntityType)
if err != nil { if err != nil {
return nil, fmt.Errorf("cannot create global id: %w", err) return nil, fmt.Errorf("cannot create global id: %w", err)
@@ -249,11 +249,10 @@ func (s FrameworkService) Import(
importedTasks = append(importedTasks, &coredata.Task{ importedTasks = append(importedTasks, &coredata.Task{
ID: taskID, ID: taskID,
ControlID: controlID, MitigationID: controlID,
Name: task.Name, Name: task.Name,
State: coredata.TaskStateTodo, State: coredata.TaskStateTodo,
Description: task.Description, Description: task.Description,
ContentRef: "",
CreatedAt: now, CreatedAt: now,
UpdatedAt: now, UpdatedAt: now,
TimeEstimate: timeEstimate, TimeEstimate: timeEstimate,
@@ -270,9 +269,9 @@ func (s FrameworkService) Import(
return fmt.Errorf("cannot insert framework: %w", err) return fmt.Errorf("cannot insert framework: %w", err)
} }
for _, importedControl := range importedControls { for _, importedMitigation := range importedMitigations {
if err := importedControl.Insert(ctx, tx, s.svc.scope); err != nil { if err := importedMitigation.Insert(ctx, tx, s.svc.scope); err != nil {
return fmt.Errorf("cannot insert control: %w", err) return fmt.Errorf("cannot insert mitigation: %w", err)
} }
} }

View File

@@ -26,40 +26,39 @@ import (
) )
type ( type (
ControlService struct { MitigationService struct {
svc *TenantService svc *TenantService
} }
CreateControlRequest struct { CreateMitigationRequest struct {
FrameworkID gid.GID FrameworkID gid.GID
Name string Name string
Description string Description string
ContentRef string
Category string Category string
Importance coredata.ControlImportance Importance coredata.MitigationImportance
} }
UpdateControlRequest struct { UpdateMitigationRequest struct {
ID gid.GID ID gid.GID
ExpectedVersion int ExpectedVersion int
Name *string Name *string
Description *string Description *string
Category *string Category *string
State *coredata.ControlState State *coredata.MitigationState
Importance *coredata.ControlImportance Importance *coredata.MitigationImportance
} }
) )
func (s ControlService) Get( func (s MitigationService) Get(
ctx context.Context, ctx context.Context,
controlID gid.GID, mitigationID gid.GID,
) (*coredata.Control, error) { ) (*coredata.Mitigation, error) {
control := &coredata.Control{} mitigation := &coredata.Mitigation{}
err := s.svc.pg.WithConn( err := s.svc.pg.WithConn(
ctx, ctx,
func(conn pg.Conn) error { func(conn pg.Conn) error {
return control.LoadByID(ctx, conn, s.svc.scope, controlID) return mitigation.LoadByID(ctx, conn, s.svc.scope, mitigationID)
}, },
) )
@@ -67,14 +66,14 @@ func (s ControlService) Get(
return nil, err return nil, err
} }
return control, nil return mitigation, nil
} }
func (s ControlService) Update( func (s MitigationService) Update(
ctx context.Context, ctx context.Context,
req UpdateControlRequest, req UpdateMitigationRequest,
) (*coredata.Control, error) { ) (*coredata.Mitigation, error) {
params := coredata.UpdateControlParams{ params := coredata.UpdateMitigationParams{
ExpectedVersion: req.ExpectedVersion, ExpectedVersion: req.ExpectedVersion,
Name: req.Name, Name: req.Name,
Description: req.Description, Description: req.Description,
@@ -83,31 +82,31 @@ func (s ControlService) Update(
Importance: req.Importance, Importance: req.Importance,
} }
control := &coredata.Control{ID: req.ID} mitigation := &coredata.Mitigation{ID: req.ID}
err := s.svc.pg.WithTx( err := s.svc.pg.WithTx(
ctx, ctx,
func(conn pg.Conn) error { func(conn pg.Conn) error {
return control.Update(ctx, conn, s.svc.scope, params) return mitigation.Update(ctx, conn, s.svc.scope, params)
}) })
if err != nil { if err != nil {
return nil, err return nil, err
} }
return control, nil return mitigation, nil
} }
func (s ControlService) ListForFrameworkID( func (s MitigationService) ListForFrameworkID(
ctx context.Context, ctx context.Context,
frameworkID gid.GID, frameworkID gid.GID,
cursor *page.Cursor[coredata.ControlOrderField], cursor *page.Cursor[coredata.MitigationOrderField],
) (*page.Page[*coredata.Control, coredata.ControlOrderField], error) { ) (*page.Page[*coredata.Mitigation, coredata.MitigationOrderField], error) {
var controls coredata.Controls var mitigations coredata.Mitigations
err := s.svc.pg.WithConn( err := s.svc.pg.WithConn(
ctx, ctx,
func(conn pg.Conn) error { func(conn pg.Conn) error {
return controls.LoadByFrameworkID( return mitigations.LoadByFrameworkID(
ctx, ctx,
conn, conn,
s.svc.scope, s.svc.scope,
@@ -121,30 +120,29 @@ func (s ControlService) ListForFrameworkID(
return nil, err return nil, err
} }
return page.NewPage(controls, cursor), nil return page.NewPage(mitigations, cursor), nil
} }
func (s ControlService) Create( func (s MitigationService) Create(
ctx context.Context, ctx context.Context,
req CreateControlRequest, req CreateMitigationRequest,
) (*coredata.Control, error) { ) (*coredata.Mitigation, error) {
now := time.Now() now := time.Now()
controlID, err := gid.NewGID(s.svc.scope.GetTenantID(), coredata.ControlEntityType) mitigationID, err := gid.NewGID(s.svc.scope.GetTenantID(), coredata.MitigationEntityType)
if err != nil { if err != nil {
return nil, fmt.Errorf("cannot create control global id: %w", err) return nil, fmt.Errorf("cannot create mitigation global id: %w", err)
} }
framework := &coredata.Framework{} framework := &coredata.Framework{}
control := &coredata.Control{ mitigation := &coredata.Mitigation{
ID: controlID, ID: mitigationID,
FrameworkID: req.FrameworkID, FrameworkID: req.FrameworkID,
Name: req.Name, Name: req.Name,
Description: req.Description, Description: req.Description,
Category: req.Category, Category: req.Category,
State: coredata.ControlStateNotStarted, State: coredata.MitigationStateNotStarted,
Importance: req.Importance,
ContentRef: req.ContentRef,
Standards: []string{}, Standards: []string{},
Importance: req.Importance,
CreatedAt: now, CreatedAt: now,
UpdatedAt: now, UpdatedAt: now,
} }
@@ -156,8 +154,8 @@ func (s ControlService) Create(
return fmt.Errorf("cannot load framework %q: %w", req.FrameworkID, err) return fmt.Errorf("cannot load framework %q: %w", req.FrameworkID, err)
} }
if err := control.Insert(ctx, conn, s.svc.scope); err != nil { if err := mitigation.Insert(ctx, conn, s.svc.scope); err != nil {
return fmt.Errorf("cannot insert control: %w", err) return fmt.Errorf("cannot insert mitigation: %w", err)
} }
return nil return nil
@@ -168,5 +166,5 @@ func (s ControlService) Create(
return nil, err return nil, err
} }
return control, nil return mitigation, nil
} }

View File

@@ -66,7 +66,7 @@ func (s OrganizationService) Create(
ctx, ctx,
func(conn pg.Conn) error { func(conn pg.Conn) error {
if err := organization.Insert(ctx, conn); err != nil { if err := organization.Insert(ctx, conn); err != nil {
return fmt.Errorf("cannot insert control: %w", err) return fmt.Errorf("cannot insert mitigation: %w", err)
} }
return nil return nil

View File

@@ -32,20 +32,18 @@ type (
} }
TenantService struct { TenantService struct {
pg *pg.Client pg *pg.Client
s3 *s3.Client s3 *s3.Client
bucket string bucket string
scope coredata.Scoper
scope coredata.Scoper
Policies *PolicyService
Controls *ControlService
Evidences *EvidenceService
Frameworks *FrameworkService Frameworks *FrameworkService
Mitigations *MitigationService
Tasks *TaskService Tasks *TaskService
Evidences *EvidenceService
Peoples *PeopleService Peoples *PeopleService
Organizations *OrganizationService
Vendors *VendorService Vendors *VendorService
Policies *PolicyService
Organizations *OrganizationService
} }
) )
@@ -76,14 +74,13 @@ func (s *Service) WithTenant(tenantID gid.TenantID) *TenantService {
scope: coredata.NewScope(tenantID), scope: coredata.NewScope(tenantID),
} }
tenantService.Policies = &PolicyService{svc: tenantService}
tenantService.Controls = &ControlService{svc: tenantService}
tenantService.Evidences = &EvidenceService{svc: tenantService}
tenantService.Frameworks = &FrameworkService{svc: tenantService} tenantService.Frameworks = &FrameworkService{svc: tenantService}
tenantService.Mitigations = &MitigationService{svc: tenantService}
tenantService.Tasks = &TaskService{svc: tenantService} tenantService.Tasks = &TaskService{svc: tenantService}
tenantService.Evidences = &EvidenceService{svc: tenantService}
tenantService.Peoples = &PeopleService{svc: tenantService} tenantService.Peoples = &PeopleService{svc: tenantService}
tenantService.Organizations = &OrganizationService{svc: tenantService}
tenantService.Vendors = &VendorService{svc: tenantService} tenantService.Vendors = &VendorService{svc: tenantService}
tenantService.Policies = &PolicyService{svc: tenantService}
tenantService.Organizations = &OrganizationService{svc: tenantService}
return tenantService return tenantService
} }

View File

@@ -16,6 +16,7 @@ package probo
import ( import (
"context" "context"
"errors"
"fmt" "fmt"
"time" "time"
@@ -31,16 +32,15 @@ type (
} }
CreateTaskRequest struct { CreateTaskRequest struct {
ControlID gid.GID MitigationID gid.GID
Name string Name string
ContentRef string
Description string Description string
TimeEstimate *time.Duration TimeEstimate *time.Duration
AssignedTo *gid.GID AssignedToID *gid.GID
} }
UpdateTaskRequest struct { UpdateTaskRequest struct {
ID gid.GID TaskID gid.GID
ExpectedVersion int ExpectedVersion int
Name *string Name *string
Description *string Description *string
@@ -53,173 +53,41 @@ func (s TaskService) Create(
ctx context.Context, ctx context.Context,
req CreateTaskRequest, req CreateTaskRequest,
) (*coredata.Task, error) { ) (*coredata.Task, error) {
now := time.Now() mitigation := &coredata.Mitigation{}
taskID, err := gid.NewGID(s.svc.scope.GetTenantID(), coredata.TaskEntityType)
if err != nil {
return nil, fmt.Errorf("cannot create task global id: %w", err)
}
control := &coredata.Control{}
task := &coredata.Task{
ID: taskID,
ControlID: req.ControlID,
Name: req.Name,
ContentRef: req.ContentRef,
State: coredata.TaskStateTodo,
Description: req.Description,
TimeEstimate: req.TimeEstimate,
AssignedTo: req.AssignedTo,
CreatedAt: now,
UpdatedAt: now,
}
err = s.svc.pg.WithTx(
ctx,
func(conn pg.Conn) error {
if err := control.LoadByID(ctx, conn, s.svc.scope, req.ControlID); err != nil {
return fmt.Errorf("cannot laod control %q: %w", req.ControlID, err)
}
if err := task.Insert(ctx, conn, s.svc.scope); err != nil {
return fmt.Errorf("cannot insert task: %w", err)
}
return nil
},
)
if err != nil {
return nil, err
}
return task, nil
}
func (s TaskService) Assign(
ctx context.Context,
taskID gid.GID,
assignedTo gid.GID,
) (*coredata.Task, error) {
task := &coredata.Task{ID: taskID}
err := s.svc.pg.WithTx( err := s.svc.pg.WithTx(
ctx, ctx,
func(conn pg.Conn) error { func(conn pg.Conn) error {
if err := task.LoadByID(ctx, conn, s.svc.scope, taskID); err != nil { if err := mitigation.LoadByID(ctx, conn, s.svc.scope, req.MitigationID); err != nil {
return fmt.Errorf("cannot load task %q: %w", taskID, err) return fmt.Errorf("cannot load mitigation %q: %w", req.MitigationID, err)
} }
task.AssignedTo = &assignedTo now := time.Now()
taskID, err := gid.NewGID(s.svc.scope.GetTenantID(), coredata.TaskEntityType)
if err := task.AssignTo(ctx, conn, s.svc.scope, assignedTo); err != nil { if err != nil {
return fmt.Errorf("cannot assign task %q to %q: %w", taskID, assignedTo, err) return fmt.Errorf("cannot generate id: %w", err)
} }
return nil task := &coredata.Task{
}, ID: taskID,
) MitigationID: req.MitigationID,
Name: req.Name,
if err != nil { Description: req.Description,
return nil, err TimeEstimate: req.TimeEstimate,
} AssignedToID: req.AssignedToID,
State: coredata.TaskStateTodo,
return task, nil CreatedAt: now,
} UpdatedAt: now,
func (s TaskService) Unassign(
ctx context.Context,
taskID gid.GID,
) (*coredata.Task, error) {
task := &coredata.Task{ID: taskID}
err := s.svc.pg.WithTx(
ctx,
func(conn pg.Conn) error {
if err := task.LoadByID(ctx, conn, s.svc.scope, taskID); err != nil {
return fmt.Errorf("cannot load task %q: %w", taskID, err)
} }
task.AssignedTo = nil return task.Insert(ctx, conn, s.svc.scope)
if err := task.Unassign(ctx, conn, s.svc.scope); err != nil {
return fmt.Errorf("cannot unassign task %q: %w", taskID, err)
}
return nil
}, },
) )
if err != nil { if err != nil {
return nil, err return nil, fmt.Errorf("cannot create task: %w", err)
} }
return task, nil return s.Get(ctx, req.MitigationID)
}
func (s TaskService) Update(
ctx context.Context,
req UpdateTaskRequest,
) (*coredata.Task, error) {
params := coredata.UpdateTaskParams{
ExpectedVersion: req.ExpectedVersion,
Name: req.Name,
Description: req.Description,
State: req.State,
TimeEstimate: req.TimeEstimate,
}
task := &coredata.Task{ID: req.ID}
err := s.svc.pg.WithTx(
ctx,
func(conn pg.Conn) error {
return task.Update(ctx, conn, s.svc.scope, params)
})
if err != nil {
return nil, err
}
return task, nil
}
func (s TaskService) ListForControlID(
ctx context.Context,
controlID gid.GID,
cursor *page.Cursor[coredata.TaskOrderField],
) (*page.Page[*coredata.Task, coredata.TaskOrderField], error) {
var tasks coredata.Tasks
err := s.svc.pg.WithConn(
ctx,
func(conn pg.Conn) error {
return tasks.LoadByControlID(
ctx,
conn,
s.svc.scope,
controlID,
cursor,
)
},
)
if err != nil {
return nil, err
}
return page.NewPage(tasks, cursor), nil
}
func (s TaskService) Delete(
ctx context.Context,
taskID gid.GID,
) error {
task := coredata.Task{ID: taskID}
return s.svc.pg.WithConn(
ctx,
func(conn pg.Conn) error {
return task.Delete(ctx, conn, s.svc.scope)
},
)
} }
func (s TaskService) Get( func (s TaskService) Get(
@@ -234,10 +102,140 @@ func (s TaskService) Get(
return task.LoadByID(ctx, conn, s.svc.scope, taskID) return task.LoadByID(ctx, conn, s.svc.scope, taskID)
}, },
) )
if err != nil { if err != nil {
return nil, err return nil, err
} }
return task, nil return task, nil
} }
func (s TaskService) Assign(
ctx context.Context,
taskID gid.GID,
assignedToID gid.GID,
) (*coredata.Task, error) {
task := &coredata.Task{}
err := s.svc.pg.WithTx(
ctx,
func(conn pg.Conn) error {
var assignErr error
task, assignErr = coredata.AssignTask(ctx, conn, s.svc.scope, taskID, assignedToID)
return assignErr
},
)
if err != nil {
if errors.Is(err, coredata.ErrAssignTaskFailed) {
return nil, errors.New("failed to assign task, please try again")
}
return nil, err
}
return task, nil
}
func (s TaskService) Unassign(
ctx context.Context,
taskID gid.GID,
) (*coredata.Task, error) {
task := &coredata.Task{}
err := s.svc.pg.WithTx(
ctx,
func(conn pg.Conn) error {
var unassignErr error
task, unassignErr = coredata.UnassignTask(ctx, conn, s.svc.scope, taskID)
return unassignErr
},
)
if err != nil {
if errors.Is(err, coredata.ErrUnassignTaskFailed) {
return nil, errors.New("failed to unassign task, please try again")
}
return nil, err
}
return task, nil
}
func (s TaskService) Update(
ctx context.Context,
req UpdateTaskRequest,
) (*coredata.Task, error) {
task := &coredata.Task{}
err := s.svc.pg.WithTx(
ctx,
func(conn pg.Conn) error {
var updateErr error
task, updateErr = coredata.UpdateTask(
ctx,
conn,
s.svc.scope,
req.TaskID,
req.ExpectedVersion,
&coredata.TaskUpdate{
Name: req.Name,
Description: req.Description,
State: req.State,
TimeEstimate: req.TimeEstimate,
},
)
return updateErr
},
)
if err != nil {
if errors.Is(err, coredata.ErrUpdateTaskFailed) {
return nil, errors.New("failed to update task, please try again")
}
return nil, err
}
return task, nil
}
func (s TaskService) Delete(
ctx context.Context,
taskID gid.GID,
) error {
err := s.svc.pg.WithTx(
ctx,
func(conn pg.Conn) error {
return coredata.DeleteTask(ctx, conn, s.svc.scope, taskID)
},
)
if err != nil {
if errors.Is(err, coredata.ErrDeleteTaskFailed) {
return errors.New("failed to delete task, please try again")
}
return err
}
return nil
}
func (s TaskService) ListForMitigationID(
ctx context.Context,
mitigationID gid.GID,
cursor *page.Cursor[coredata.TaskOrderField],
) (*page.Page[*coredata.Task, coredata.TaskOrderField], error) {
var tasks coredata.Tasks
err := s.svc.pg.WithConn(
ctx,
func(conn pg.Conn) error {
return tasks.LoadByMitigationID(
ctx,
conn,
s.svc.scope,
mitigationID,
cursor,
)
},
)
if err != nil {
return nil, err
}
return page.NewPage(tasks, cursor), nil
}

View File

@@ -21,23 +21,23 @@ interface Node {
id: ID! id: ID!
} }
enum ControlState enum MitigationState
@goModel(model: "github.com/getprobo/probo/pkg/coredata.ControlState") { @goModel(model: "github.com/getprobo/probo/pkg/coredata.MitigationState") {
NOT_STARTED NOT_STARTED
@goEnum( @goEnum(
value: "github.com/getprobo/probo/pkg/coredata.ControlStateNotStarted" value: "github.com/getprobo/probo/pkg/coredata.MitigationStateNotStarted"
) )
IN_PROGRESS IN_PROGRESS
@goEnum( @goEnum(
value: "github.com/getprobo/probo/pkg/coredata.ControlStateInProgress" value: "github.com/getprobo/probo/pkg/coredata.MitigationStateInProgress"
) )
NOT_APPLICABLE NOT_APPLICABLE
@goEnum( @goEnum(
value: "github.com/getprobo/probo/pkg/coredata.ControlStateNotApplicable" value: "github.com/getprobo/probo/pkg/coredata.MitigationStateNotApplicable"
) )
IMPLEMENTED IMPLEMENTED
@goEnum( @goEnum(
value: "github.com/getprobo/probo/pkg/coredata.ControlStateImplemented" value: "github.com/getprobo/probo/pkg/coredata.MitigationStateImplemented"
) )
} }
@@ -75,19 +75,21 @@ enum PeopleKind
) )
} }
enum ControlImportance enum MitigationImportance
@goModel(model: "github.com/getprobo/probo/pkg/coredata.ControlImportance") { @goModel(
model: "github.com/getprobo/probo/pkg/coredata.MitigationImportance"
) {
MANDATORY MANDATORY
@goEnum( @goEnum(
value: "github.com/getprobo/probo/pkg/coredata.ControlImportanceMandatory" value: "github.com/getprobo/probo/pkg/coredata.MitigationImportanceMandatory"
) )
PREFERRED PREFERRED
@goEnum( @goEnum(
value: "github.com/getprobo/probo/pkg/coredata.ControlImportancePreferred" value: "github.com/getprobo/probo/pkg/coredata.MitigationImportancePreferred"
) )
ADVANCED ADVANCED
@goEnum( @goEnum(
value: "github.com/getprobo/probo/pkg/coredata.ControlImportanceAdvanced" value: "github.com/getprobo/probo/pkg/coredata.MitigationImportanceAdvanced"
) )
} }
@@ -187,8 +189,10 @@ enum FrameworkOrderField
NAME NAME
} }
enum ControlOrderField enum MitigationOrderField
@goModel(model: "github.com/getprobo/probo/pkg/coredata.ControlOrderField") { @goModel(
model: "github.com/getprobo/probo/pkg/coredata.MitigationOrderField"
) {
NAME NAME
} }
@@ -231,12 +235,12 @@ input FrameworkOrder
field: FrameworkOrderField! field: FrameworkOrderField!
} }
input ControlOrder input MitigationOrder
@goModel( @goModel(
model: "github.com/getprobo/probo/pkg/server/api/console/v1/types.ControlOrderBy" model: "github.com/getprobo/probo/pkg/server/api/console/v1/types.MitigationOrderBy"
) { ) {
direction: OrderDirection! direction: OrderDirection!
field: ControlOrderField! field: MitigationOrderField!
} }
input TaskOrder input TaskOrder
@@ -327,36 +331,36 @@ type Framework implements Node {
name: String! name: String!
description: String! description: String!
controls( mitigations(
first: Int first: Int
after: CursorKey after: CursorKey
last: Int last: Int
before: CursorKey before: CursorKey
orderBy: ControlOrder orderBy: MitigationOrder
): ControlConnection! @goField(forceResolver: true) ): MitigationConnection! @goField(forceResolver: true)
createdAt: Datetime! createdAt: Datetime!
updatedAt: Datetime! updatedAt: Datetime!
} }
type ControlConnection { type MitigationConnection {
edges: [ControlEdge!]! edges: [MitigationEdge!]!
pageInfo: PageInfo! pageInfo: PageInfo!
} }
type ControlEdge { type MitigationEdge {
cursor: CursorKey! cursor: CursorKey!
node: Control! node: Mitigation!
} }
type Control implements Node { type Mitigation implements Node {
id: ID! id: ID!
version: Int! version: Int!
category: String! category: String!
name: String! name: String!
description: String! description: String!
state: ControlState! state: MitigationState!
importance: ControlImportance! importance: MitigationImportance!
tasks( tasks(
first: Int first: Int
@@ -503,8 +507,8 @@ type Mutation {
updateFramework(input: UpdateFrameworkInput!): UpdateFrameworkPayload! updateFramework(input: UpdateFrameworkInput!): UpdateFrameworkPayload!
importFramework(input: ImportFrameworkInput!): ImportFrameworkPayload! importFramework(input: ImportFrameworkInput!): ImportFrameworkPayload!
createControl(input: CreateControlInput!): CreateControlPayload! createMitigation(input: CreateMitigationInput!): CreateMitigationPayload!
updateControl(input: UpdateControlInput!): UpdateControlPayload! updateMitigation(input: UpdateMitigationInput!): UpdateMitigationPayload!
uploadEvidence(input: UploadEvidenceInput!): UploadEvidencePayload! uploadEvidence(input: UploadEvidenceInput!): UploadEvidencePayload!
deleteEvidence(input: DeleteEvidenceInput!): DeleteEvidencePayload! deleteEvidence(input: DeleteEvidenceInput!): DeleteEvidencePayload!
@@ -639,7 +643,7 @@ type DeleteOrganizationPayload {
} }
input CreateTaskInput { input CreateTaskInput {
controlId: ID! mitigationId: ID!
name: String! name: String!
description: String! description: String!
timeEstimate: Duration timeEstimate: Duration
@@ -675,16 +679,16 @@ type CreateFrameworkPayload {
frameworkEdge: FrameworkEdge! frameworkEdge: FrameworkEdge!
} }
input CreateControlInput { input CreateMitigationInput {
frameworkId: ID! frameworkId: ID!
name: String! name: String!
description: String! description: String!
category: String! category: String!
importance: ControlImportance! importance: MitigationImportance!
} }
type CreateControlPayload { type CreateMitigationPayload {
controlEdge: ControlEdge! mitigationEdge: MitigationEdge!
} }
type UpdateFrameworkPayload { type UpdateFrameworkPayload {
@@ -699,18 +703,18 @@ type UpdatePeoplePayload {
people: People! people: People!
} }
input UpdateControlInput { input UpdateMitigationInput {
id: ID! id: ID!
expectedVersion: Int! expectedVersion: Int!
name: String name: String
description: String description: String
category: String category: String
state: ControlState state: MitigationState
importance: ControlImportance importance: MitigationImportance
} }
type UpdateControlPayload { type UpdateMitigationPayload {
control: Control! mitigation: Mitigation!
} }
input UploadEvidenceInput { input UploadEvidenceInput {

File diff suppressed because it is too large Load Diff

View File

@@ -20,31 +20,31 @@ import (
) )
type ( type (
ControlOrderBy OrderBy[coredata.ControlOrderField] MitigationOrderBy OrderBy[coredata.MitigationOrderField]
) )
func NewControlConnection(p *page.Page[*coredata.Control, coredata.ControlOrderField]) *ControlConnection { func NewMitigationConnection(p *page.Page[*coredata.Mitigation, coredata.MitigationOrderField]) *MitigationConnection {
var edges = make([]*ControlEdge, len(p.Data)) var edges = make([]*MitigationEdge, len(p.Data))
for i := range edges { for i := range edges {
edges[i] = NewControlEdge(p.Data[i], p.Cursor.OrderBy.Field) edges[i] = NewMitigationEdge(p.Data[i], p.Cursor.OrderBy.Field)
} }
return &ControlConnection{ return &MitigationConnection{
Edges: edges, Edges: edges,
PageInfo: NewPageInfo(p), PageInfo: NewPageInfo(p),
} }
} }
func NewControlEdge(c *coredata.Control, orderBy coredata.ControlOrderField) *ControlEdge { func NewMitigationEdge(c *coredata.Mitigation, orderBy coredata.MitigationOrderField) *MitigationEdge {
return &ControlEdge{ return &MitigationEdge{
Cursor: c.CursorKey(orderBy), Cursor: c.CursorKey(orderBy),
Node: NewControl(c), Node: NewMitigation(c),
} }
} }
func NewControl(c *coredata.Control) *Control { func NewMitigation(c *coredata.Mitigation) *Mitigation {
return &Control{ return &Mitigation{
ID: c.ID, ID: c.ID,
Version: c.Version, Version: c.Version,
Category: c.Category, Category: c.Category,

View File

@@ -36,44 +36,6 @@ type ConfirmEmailPayload struct {
Success bool `json:"success"` Success bool `json:"success"`
} }
type Control struct {
ID gid.GID `json:"id"`
Version int `json:"version"`
Category string `json:"category"`
Name string `json:"name"`
Description string `json:"description"`
State coredata.ControlState `json:"state"`
Importance coredata.ControlImportance `json:"importance"`
Tasks *TaskConnection `json:"tasks"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
func (Control) IsNode() {}
func (this Control) GetID() gid.GID { return this.ID }
type ControlConnection struct {
Edges []*ControlEdge `json:"edges"`
PageInfo *PageInfo `json:"pageInfo"`
}
type ControlEdge struct {
Cursor page.CursorKey `json:"cursor"`
Node *Control `json:"node"`
}
type CreateControlInput struct {
FrameworkID gid.GID `json:"frameworkId"`
Name string `json:"name"`
Description string `json:"description"`
Category string `json:"category"`
Importance coredata.ControlImportance `json:"importance"`
}
type CreateControlPayload struct {
ControlEdge *ControlEdge `json:"controlEdge"`
}
type CreateFrameworkInput struct { type CreateFrameworkInput struct {
OrganizationID gid.GID `json:"organizationId"` OrganizationID gid.GID `json:"organizationId"`
Name string `json:"name"` Name string `json:"name"`
@@ -84,6 +46,18 @@ type CreateFrameworkPayload struct {
FrameworkEdge *FrameworkEdge `json:"frameworkEdge"` FrameworkEdge *FrameworkEdge `json:"frameworkEdge"`
} }
type CreateMitigationInput struct {
FrameworkID gid.GID `json:"frameworkId"`
Name string `json:"name"`
Description string `json:"description"`
Category string `json:"category"`
Importance coredata.MitigationImportance `json:"importance"`
}
type CreateMitigationPayload struct {
MitigationEdge *MitigationEdge `json:"mitigationEdge"`
}
type CreateOrganizationInput struct { type CreateOrganizationInput struct {
Name string `json:"name"` Name string `json:"name"`
} }
@@ -118,7 +92,7 @@ type CreatePolicyPayload struct {
} }
type CreateTaskInput struct { type CreateTaskInput struct {
ControlID gid.GID `json:"controlId"` MitigationID gid.GID `json:"mitigationId"`
Name string `json:"name"` Name string `json:"name"`
Description string `json:"description"` Description string `json:"description"`
TimeEstimate *time.Duration `json:"timeEstimate,omitempty"` TimeEstimate *time.Duration `json:"timeEstimate,omitempty"`
@@ -222,13 +196,13 @@ type EvidenceEdge struct {
} }
type Framework struct { type Framework struct {
ID gid.GID `json:"id"` ID gid.GID `json:"id"`
Version int `json:"version"` Version int `json:"version"`
Name string `json:"name"` Name string `json:"name"`
Description string `json:"description"` Description string `json:"description"`
Controls *ControlConnection `json:"controls"` Mitigations *MitigationConnection `json:"mitigations"`
CreatedAt time.Time `json:"createdAt"` CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"` UpdatedAt time.Time `json:"updatedAt"`
} }
func (Framework) IsNode() {} func (Framework) IsNode() {}
@@ -263,6 +237,32 @@ type InviteUserPayload struct {
Success bool `json:"success"` Success bool `json:"success"`
} }
type Mitigation struct {
ID gid.GID `json:"id"`
Version int `json:"version"`
Category string `json:"category"`
Name string `json:"name"`
Description string `json:"description"`
State coredata.MitigationState `json:"state"`
Importance coredata.MitigationImportance `json:"importance"`
Tasks *TaskConnection `json:"tasks"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
func (Mitigation) IsNode() {}
func (this Mitigation) GetID() gid.GID { return this.ID }
type MitigationConnection struct {
Edges []*MitigationEdge `json:"edges"`
PageInfo *PageInfo `json:"pageInfo"`
}
type MitigationEdge struct {
Cursor page.CursorKey `json:"cursor"`
Node *Mitigation `json:"node"`
}
type Mutation struct { type Mutation struct {
} }
@@ -404,20 +404,6 @@ type UnassignTaskPayload struct {
Task *Task `json:"task"` Task *Task `json:"task"`
} }
type UpdateControlInput struct {
ID gid.GID `json:"id"`
ExpectedVersion int `json:"expectedVersion"`
Name *string `json:"name,omitempty"`
Description *string `json:"description,omitempty"`
Category *string `json:"category,omitempty"`
State *coredata.ControlState `json:"state,omitempty"`
Importance *coredata.ControlImportance `json:"importance,omitempty"`
}
type UpdateControlPayload struct {
Control *Control `json:"control"`
}
type UpdateFrameworkInput struct { type UpdateFrameworkInput struct {
ID gid.GID `json:"id"` ID gid.GID `json:"id"`
ExpectedVersion int `json:"expectedVersion"` ExpectedVersion int `json:"expectedVersion"`
@@ -429,6 +415,20 @@ type UpdateFrameworkPayload struct {
Framework *Framework `json:"framework"` Framework *Framework `json:"framework"`
} }
type UpdateMitigationInput struct {
ID gid.GID `json:"id"`
ExpectedVersion int `json:"expectedVersion"`
Name *string `json:"name,omitempty"`
Description *string `json:"description,omitempty"`
Category *string `json:"category,omitempty"`
State *coredata.MitigationState `json:"state,omitempty"`
Importance *coredata.MitigationImportance `json:"importance,omitempty"`
}
type UpdateMitigationPayload struct {
Mitigation *Mitigation `json:"mitigation"`
}
type UpdateOrganizationInput struct { type UpdateOrganizationInput struct {
OrganizationID gid.GID `json:"organizationId"` OrganizationID gid.GID `json:"organizationId"`
Name *string `json:"name,omitempty"` Name *string `json:"name,omitempty"`

View File

@@ -19,31 +19,6 @@ import (
"github.com/vektah/gqlparser/v2/gqlerror" "github.com/vektah/gqlparser/v2/gqlerror"
) )
// Tasks is the resolver for the tasks field.
func (r *controlResolver) Tasks(ctx context.Context, obj *types.Control, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.TaskOrderBy) (*types.TaskConnection, error) {
svc := r.GetTenantServiceIfAuthorized(ctx, obj.ID.TenantID())
pageOrderBy := page.OrderBy[coredata.TaskOrderField]{
Field: coredata.TaskOrderFieldCreatedAt,
Direction: page.OrderDirectionDesc,
}
if orderBy != nil {
pageOrderBy = page.OrderBy[coredata.TaskOrderField]{
Field: orderBy.Field,
Direction: orderBy.Direction,
}
}
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
page, err := svc.Tasks.ListForControlID(ctx, obj.ID, cursor)
if err != nil {
return nil, fmt.Errorf("cannot list control tasks: %w", err)
}
return types.NewTaskConnection(page), nil
}
// FileURL is the resolver for the fileUrl field. // FileURL is the resolver for the fileUrl field.
func (r *evidenceResolver) FileURL(ctx context.Context, obj *types.Evidence) (*string, error) { func (r *evidenceResolver) FileURL(ctx context.Context, obj *types.Evidence) (*string, error) {
svc := r.GetTenantServiceIfAuthorized(ctx, obj.ID.TenantID()) svc := r.GetTenantServiceIfAuthorized(ctx, obj.ID.TenantID())
@@ -61,16 +36,40 @@ func (r *evidenceResolver) FileURL(ctx context.Context, obj *types.Evidence) (*s
return &result, nil return &result, nil
} }
// Controls is the resolver for the controls field. // Mitigations is the resolver for the mitigations field.
func (r *frameworkResolver) Controls(ctx context.Context, obj *types.Framework, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.ControlOrderBy) (*types.ControlConnection, error) { func (r *frameworkResolver) Mitigations(ctx context.Context, obj *types.Framework, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.MitigationOrderBy) (*types.MitigationConnection, error) {
svc := r.GetTenantServiceIfAuthorized(ctx, obj.ID.TenantID()) svc := r.GetTenantServiceIfAuthorized(ctx, obj.ID.TenantID())
pageOrderBy := page.OrderBy[coredata.ControlOrderField]{ pageOrderBy := page.OrderBy[coredata.MitigationOrderField]{
Field: coredata.ControlOrderFieldCreatedAt, Field: coredata.MitigationOrderFieldCreatedAt,
Direction: page.OrderDirectionDesc, Direction: page.OrderDirectionDesc,
} }
if orderBy != nil { if orderBy != nil {
pageOrderBy = page.OrderBy[coredata.ControlOrderField]{ pageOrderBy = page.OrderBy[coredata.MitigationOrderField]{
Field: orderBy.Field,
Direction: orderBy.Direction,
}
}
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
page, err := svc.Mitigations.ListForFrameworkID(ctx, obj.ID, cursor)
if err != nil {
return nil, fmt.Errorf("cannot list framework mitigations: %w", err)
}
return types.NewMitigationConnection(page), nil
}
// Tasks is the resolver for the tasks field.
func (r *mitigationResolver) Tasks(ctx context.Context, obj *types.Mitigation, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.TaskOrderBy) (*types.TaskConnection, error) {
svc := r.GetTenantServiceIfAuthorized(ctx, obj.ID.TenantID())
pageOrderBy := page.OrderBy[coredata.TaskOrderField]{
Field: coredata.TaskOrderFieldCreatedAt,
Direction: page.OrderDirectionDesc,
}
if orderBy != nil {
pageOrderBy = page.OrderBy[coredata.TaskOrderField]{
Field: orderBy.Field, Field: orderBy.Field,
Direction: orderBy.Direction, Direction: orderBy.Direction,
} }
@@ -78,12 +77,12 @@ func (r *frameworkResolver) Controls(ctx context.Context, obj *types.Framework,
cursor := types.NewCursor(first, after, last, before, pageOrderBy) cursor := types.NewCursor(first, after, last, before, pageOrderBy)
page, err := svc.Controls.ListForFrameworkID(ctx, obj.ID, cursor) page, err := svc.Tasks.ListForMitigationID(ctx, obj.ID, cursor)
if err != nil { if err != nil {
return nil, fmt.Errorf("cannot list framework controls: %w", err) return nil, fmt.Errorf("cannot list mitigation tasks: %w", err)
} }
return types.NewControlConnection(page), nil return types.NewTaskConnection(page), nil
} }
// CreateVendor is the resolver for the createVendor field. // CreateVendor is the resolver for the createVendor field.
@@ -260,10 +259,10 @@ func (r *mutationResolver) DeleteOrganization(ctx context.Context, input types.D
// CreateTask is the resolver for the createTask field. // CreateTask is the resolver for the createTask field.
func (r *mutationResolver) CreateTask(ctx context.Context, input types.CreateTaskInput) (*types.CreateTaskPayload, error) { func (r *mutationResolver) CreateTask(ctx context.Context, input types.CreateTaskInput) (*types.CreateTaskPayload, error) {
svc := r.GetTenantServiceIfAuthorized(ctx, input.ControlID.TenantID()) svc := r.GetTenantServiceIfAuthorized(ctx, input.MitigationID.TenantID())
task, err := svc.Tasks.Create(ctx, probo.CreateTaskRequest{ task, err := svc.Tasks.Create(ctx, probo.CreateTaskRequest{
ControlID: input.ControlID, MitigationID: input.MitigationID,
Name: input.Name, Name: input.Name,
Description: input.Description, Description: input.Description,
TimeEstimate: input.TimeEstimate, TimeEstimate: input.TimeEstimate,
@@ -282,7 +281,7 @@ func (r *mutationResolver) UpdateTask(ctx context.Context, input types.UpdateTas
svc := r.GetTenantServiceIfAuthorized(ctx, input.TaskID.TenantID()) svc := r.GetTenantServiceIfAuthorized(ctx, input.TaskID.TenantID())
task, err := svc.Tasks.Update(ctx, probo.UpdateTaskRequest{ task, err := svc.Tasks.Update(ctx, probo.UpdateTaskRequest{
ID: input.TaskID, TaskID: input.TaskID,
ExpectedVersion: input.ExpectedVersion, ExpectedVersion: input.ExpectedVersion,
Name: input.Name, Name: input.Name,
Description: input.Description, Description: input.Description,
@@ -396,11 +395,11 @@ func (r *mutationResolver) ImportFramework(ctx context.Context, input types.Impo
}, nil }, nil
} }
// CreateControl is the resolver for the createControl field. // CreateMitigation is the resolver for the createMitigation field.
func (r *mutationResolver) CreateControl(ctx context.Context, input types.CreateControlInput) (*types.CreateControlPayload, error) { func (r *mutationResolver) CreateMitigation(ctx context.Context, input types.CreateMitigationInput) (*types.CreateMitigationPayload, error) {
svc := r.GetTenantServiceIfAuthorized(ctx, input.FrameworkID.TenantID()) svc := r.GetTenantServiceIfAuthorized(ctx, input.FrameworkID.TenantID())
control, err := svc.Controls.Create(ctx, probo.CreateControlRequest{ mitigation, err := svc.Mitigations.Create(ctx, probo.CreateMitigationRequest{
FrameworkID: input.FrameworkID, FrameworkID: input.FrameworkID,
Name: input.Name, Name: input.Name,
Description: input.Description, Description: input.Description,
@@ -408,33 +407,33 @@ func (r *mutationResolver) CreateControl(ctx context.Context, input types.Create
Importance: input.Importance, Importance: input.Importance,
}) })
if err != nil { if err != nil {
return nil, fmt.Errorf("cannot create control: %w", err) panic(fmt.Errorf("cannot create mitigation: %w", err))
} }
return &types.CreateControlPayload{ return &types.CreateMitigationPayload{
ControlEdge: types.NewControlEdge(control, coredata.ControlOrderFieldCreatedAt), MitigationEdge: types.NewMitigationEdge(mitigation, coredata.MitigationOrderFieldCreatedAt),
}, nil }, nil
} }
// UpdateControl is the resolver for the updateControl field. // UpdateMitigation is the resolver for the updateMitigation field.
func (r *mutationResolver) UpdateControl(ctx context.Context, input types.UpdateControlInput) (*types.UpdateControlPayload, error) { func (r *mutationResolver) UpdateMitigation(ctx context.Context, input types.UpdateMitigationInput) (*types.UpdateMitigationPayload, error) {
svc := r.GetTenantServiceIfAuthorized(ctx, input.ID.TenantID()) svc := r.GetTenantServiceIfAuthorized(ctx, input.ID.TenantID())
control, err := svc.Controls.Update(ctx, probo.UpdateControlRequest{ mitigation, err := svc.Mitigations.Update(ctx, probo.UpdateMitigationRequest{
ID: input.ID, ID: input.ID,
ExpectedVersion: input.ExpectedVersion, ExpectedVersion: input.ExpectedVersion,
Name: input.Name, Name: input.Name,
Description: input.Description, Description: input.Description,
Category: input.Category, Category: input.Category,
State: input.State,
Importance: input.Importance, Importance: input.Importance,
State: input.State,
}) })
if err != nil { if err != nil {
return nil, fmt.Errorf("cannot update control: %w", err) panic(fmt.Errorf("cannot update mitigation: %w", err))
} }
return &types.UpdateControlPayload{ return &types.UpdateMitigationPayload{
Control: types.NewControl(control), Mitigation: types.NewMitigation(mitigation),
}, nil }, nil
} }
@@ -785,13 +784,13 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
} }
return types.NewFramework(framework), nil return types.NewFramework(framework), nil
case coredata.ControlEntityType: case coredata.MitigationEntityType:
control, err := svc.Controls.Get(ctx, id) mitigation, err := svc.Mitigations.Get(ctx, id)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return types.NewControl(control), nil return types.NewMitigation(mitigation), nil
case coredata.TaskEntityType: case coredata.TaskEntityType:
task, err := svc.Tasks.Get(ctx, id) task, err := svc.Tasks.Get(ctx, id)
if err != nil { if err != nil {
@@ -838,11 +837,11 @@ func (r *taskResolver) AssignedTo(ctx context.Context, obj *types.Task) (*types.
return nil, fmt.Errorf("cannot get task: %w", err) return nil, fmt.Errorf("cannot get task: %w", err)
} }
if task.AssignedTo == nil { if task.AssignedToID == nil {
return nil, nil return nil, nil
} }
people, err := svc.Peoples.Get(ctx, *task.AssignedTo) people, err := svc.Peoples.Get(ctx, *task.AssignedToID)
if err != nil { if err != nil {
return nil, fmt.Errorf("cannot get assigned to: %w", err) return nil, fmt.Errorf("cannot get assigned to: %w", err)
} }
@@ -899,15 +898,15 @@ func (r *viewerResolver) Organizations(ctx context.Context, obj *types.Viewer, f
}, nil }, nil
} }
// Control returns schema.ControlResolver implementation.
func (r *Resolver) Control() schema.ControlResolver { return &controlResolver{r} }
// Evidence returns schema.EvidenceResolver implementation. // Evidence returns schema.EvidenceResolver implementation.
func (r *Resolver) Evidence() schema.EvidenceResolver { return &evidenceResolver{r} } func (r *Resolver) Evidence() schema.EvidenceResolver { return &evidenceResolver{r} }
// Framework returns schema.FrameworkResolver implementation. // Framework returns schema.FrameworkResolver implementation.
func (r *Resolver) Framework() schema.FrameworkResolver { return &frameworkResolver{r} } func (r *Resolver) Framework() schema.FrameworkResolver { return &frameworkResolver{r} }
// Mitigation returns schema.MitigationResolver implementation.
func (r *Resolver) Mitigation() schema.MitigationResolver { return &mitigationResolver{r} }
// Mutation returns schema.MutationResolver implementation. // Mutation returns schema.MutationResolver implementation.
func (r *Resolver) Mutation() schema.MutationResolver { return &mutationResolver{r} } func (r *Resolver) Mutation() schema.MutationResolver { return &mutationResolver{r} }
@@ -926,9 +925,9 @@ func (r *Resolver) Task() schema.TaskResolver { return &taskResolver{r} }
// Viewer returns schema.ViewerResolver implementation. // Viewer returns schema.ViewerResolver implementation.
func (r *Resolver) Viewer() schema.ViewerResolver { return &viewerResolver{r} } func (r *Resolver) Viewer() schema.ViewerResolver { return &viewerResolver{r} }
type controlResolver struct{ *Resolver }
type evidenceResolver struct{ *Resolver } type evidenceResolver struct{ *Resolver }
type frameworkResolver struct{ *Resolver } type frameworkResolver struct{ *Resolver }
type mitigationResolver struct{ *Resolver }
type mutationResolver struct{ *Resolver } type mutationResolver struct{ *Resolver }
type organizationResolver struct{ *Resolver } type organizationResolver struct{ *Resolver }
type policyResolver struct{ *Resolver } type policyResolver struct{ *Resolver }