Update obligations

Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
Sacha Al Himdani
2025-09-23 14:02:18 +02:00
parent c54051dd8a
commit 98d7e7b7b9
39 changed files with 3746 additions and 394 deletions

View File

@@ -0,0 +1,213 @@
import { graphql } from "relay-runtime";
import {
Card,
IconPlusLarge,
Button,
Tr,
Td,
Table,
Thead,
Tbody,
Th,
IconChevronDown,
IconTrashCan,
TrButton,
Badge,
} from "@probo/ui";
import { useTranslate } from "@probo/i18n";
import type { LinkedObligationsCardFragment$key } from "./__generated__/LinkedObligationsCardFragment.graphql";
import { useFragment } from "react-relay";
import { useMemo, useState } from "react";
import { sprintf, getObligationStatusVariant, getObligationStatusLabel } from "@probo/helpers";
import { LinkedObligationDialog } from "./LinkedObligationsDialog";
import clsx from "clsx";
import { useParams } from "react-router";
import { useOrganizationId } from "/hooks/useOrganizationId";
const linkedObligationFragment = graphql`
fragment LinkedObligationsCardFragment on Obligation {
id
requirement
area
source
status
owner {
fullName
}
}
`;
type Mutation<Params> = (p: {
variables: {
input: {
obligationId: string;
} & Params;
connections: string[];
};
}) => void;
type Props<Params> = {
obligations: (LinkedObligationsCardFragment$key & { id: string })[];
connectionId: string;
disabled?: boolean;
variant?: "card" | "table";
params: Params;
onAttach: Mutation<Params>;
onDetach: Mutation<Params>;
};
export function LinkedObligationsCard<Params>(props: Props<Params>) {
const { __ } = useTranslate();
const [limit, setLimit] = useState<number | null>(
props.variant === "card" ? 4 : null
);
const onAttach = (obligationId: string) => {
props.onAttach({
variables: {
input: {
obligationId,
...props.params,
},
connections: [props.connectionId],
},
});
};
const onDetach = (obligationId: string) => {
props.onDetach({
variables: {
input: {
obligationId,
...props.params,
},
connections: [props.connectionId],
},
});
};
const obligations = useMemo(() => {
return limit ? props.obligations.slice(0, limit) : props.obligations;
}, [props.obligations, limit]);
const showMoreButton = limit !== null && props.obligations.length > limit;
const variant = props.variant ?? "table";
const Wrapper = variant === "card" ? Card : "div";
return (
<Wrapper padded className="space-y-[10px]">
{variant === "card" && (
<div className="flex justify-between">
<div className="text-lg font-semibold">{__("Obligations")}</div>
<LinkedObligationDialog
connectionId={props.connectionId}
disabled={props.disabled}
linkedObligations={props.obligations}
onLink={onAttach}
onUnlink={onDetach}
>
<Button variant="tertiary" icon={IconPlusLarge}>
{__("Link obligation")}
</Button>
</LinkedObligationDialog>
</div>
)}
<Table className={clsx(variant === "card" && "bg-invert")}>
<Thead>
<Tr>
<Th>{__("Area")}</Th>
<Th>{__("Source")}</Th>
<Th>{__("Status")}</Th>
<Th>{__("Owner")}</Th>
<Th></Th>
</Tr>
</Thead>
<Tbody>
{obligations.length === 0 && (
<Tr>
<Td colSpan={4} className="text-center text-txt-secondary">
{__("No obligations linked")}
</Td>
</Tr>
)}
{obligations.map((obligation) => (
<ObligationRow key={obligation.id} obligation={obligation} onClick={onDetach} />
))}
{variant === "table" && (
<LinkedObligationDialog
connectionId={props.connectionId}
disabled={props.disabled}
linkedObligations={props.obligations}
onLink={onAttach}
onUnlink={onDetach}
>
<TrButton colspan={5} icon={IconPlusLarge}>
{__("Link obligation")}
</TrButton>
</LinkedObligationDialog>
)}
</Tbody>
</Table>
{showMoreButton && (
<Button
variant="tertiary"
onClick={() => setLimit(null)}
className="mt-3 mx-auto"
icon={IconChevronDown}
>
{sprintf(__("Show %s more"), props.obligations.length - limit)}
</Button>
)}
</Wrapper>
);
}
function ObligationRow(props: {
obligation: LinkedObligationsCardFragment$key & { id: string };
onClick: (obligationId: string) => void;
}) {
const { __ } = useTranslate();
const obligation = useFragment(linkedObligationFragment, props.obligation);
const organizationId = useOrganizationId();
const { snapshotId } = useParams<{ snapshotId?: string }>();
const isSnapshotMode = Boolean(snapshotId);
const onDetach = () => {
props.onClick(obligation.id);
};
const detailsUrl = isSnapshotMode
? `/organizations/${organizationId}/snapshots/${snapshotId}/obligations/${obligation.id}`
: `/organizations/${organizationId}/obligations/${obligation.id}`;
return (
<Tr to={detailsUrl}>
<Td>
{obligation.area || __("No area specified")}
</Td>
<Td>
{obligation.source || __("No source specified")}
</Td>
<Td>
<Badge variant={getObligationStatusVariant(obligation.status)}>
{getObligationStatusLabel(obligation.status)}
</Badge>
</Td>
<Td>
{obligation.owner?.fullName || __("Unassigned")}
</Td>
<Td noLink width={50} className="text-end">
<Button
variant="secondary"
icon={IconTrashCan}
onClick={onDetach}
>
{__("Unlink")}
</Button>
</Td>
</Tr>
);
}

View File

@@ -0,0 +1,199 @@
import {
Button,
Dialog,
DialogContent,
DialogFooter,
IconMagnifyingGlass,
IconPlusLarge,
IconTrashCan,
InfiniteScrollTrigger,
Input,
Spinner,
Badge,
} from "@probo/ui";
import { useTranslate } from "@probo/i18n";
import { getObligationStatusVariant, getObligationStatusLabel } from "@probo/helpers";
import { Suspense, useMemo, useState, type ReactNode } from "react";
import { graphql } from "relay-runtime";
import { useLazyLoadQuery, usePaginationFragment } from "react-relay";
import type { LinkedObligationsDialogQuery } from "./__generated__/LinkedObligationsDialogQuery.graphql";
import { useOrganizationId } from "/hooks/useOrganizationId";
import type { NodeOf } from "/types";
import type {
LinkedObligationsDialogFragment$data,
LinkedObligationsDialogFragment$key,
} from "./__generated__/LinkedObligationsDialogFragment.graphql";
const obligationsQuery = graphql`
query LinkedObligationsDialogQuery($organizationId: ID!) {
organization: node(id: $organizationId) {
id
... on Organization {
...LinkedObligationsDialogFragment
}
}
}
`;
const obligationsFragment = graphql`
fragment LinkedObligationsDialogFragment on Organization
@refetchable(queryName: "LinkedObligationsDialogQuery_fragment")
@argumentDefinitions(
first: { type: "Int", defaultValue: 20 }
order: { type: "ObligationOrder", defaultValue: null }
after: { type: "CursorKey", defaultValue: null }
before: { type: "CursorKey", defaultValue: null }
last: { type: "Int", defaultValue: null }
) {
obligations(
first: $first
after: $after
last: $last
before: $before
orderBy: $order
) @connection(key: "LinkedObligationsDialogQuery_obligations") {
edges {
node {
id
requirement
area
source
status
owner {
fullName
}
}
}
}
}
`;
type Props = {
children: ReactNode;
connectionId: string;
disabled?: boolean;
linkedObligations?: { id: string }[];
onLink: (obligationId: string) => void;
onUnlink: (obligationId: string) => void;
};
export function LinkedObligationDialog({ children, ...props }: Props) {
const { __ } = useTranslate();
return (
<Dialog trigger={children} title={__("Link obligations")}>
<DialogContent>
<Suspense fallback={<Spinner centered />}>
<LinkedObligationsDialogContent {...props} />
</Suspense>
</DialogContent>
<DialogFooter exitLabel={__("Close")} />
</Dialog>
);
}
function LinkedObligationsDialogContent(props: Omit<Props, "children">) {
const organizationId = useOrganizationId();
const query = useLazyLoadQuery<LinkedObligationsDialogQuery>(obligationsQuery, {
organizationId,
}, { fetchPolicy: "network-only" });
const { data, loadNext, hasNext, isLoadingNext } = usePaginationFragment(
obligationsFragment,
query.organization as LinkedObligationsDialogFragment$key
);
const { __ } = useTranslate();
const [search, setSearch] = useState("");
const obligations = data.obligations?.edges?.map((edge) => edge.node) ?? [];
const linkedIds = useMemo(() => {
return new Set(props.linkedObligations?.map((o) => o.id) ?? []);
}, [props.linkedObligations]);
const filteredObligations = useMemo(() => {
return obligations.filter((obligation) =>
obligation.area?.toLowerCase().includes(search.toLowerCase()) ||
obligation.source?.toLowerCase().includes(search.toLowerCase()) ||
obligation.owner?.fullName?.toLowerCase().includes(search.toLowerCase())
);
}, [obligations, search]);
return (
<>
<div className="flex items-center gap-2 sticky top-0 relative py-4 bg-linear-to-b from-50% from-level-2 to-level-2/0 px-6">
<Input
icon={IconMagnifyingGlass}
placeholder={__("Search obligations...")}
onValueChange={setSearch}
/>
</div>
<div className="divide-y divide-border-low">
{filteredObligations.map((obligation) => (
<ObligationRow
key={obligation.id}
obligation={obligation}
linkedObligations={linkedIds}
onLink={props.onLink}
onUnlink={props.onUnlink}
disabled={props.disabled}
/>
))}
{hasNext && (
<InfiniteScrollTrigger
loading={isLoadingNext}
onView={() => loadNext(20)}
/>
)}
</div>
</>
);
}
type Obligation = NodeOf<LinkedObligationsDialogFragment$data["obligations"]>;
function ObligationRow(props: {
obligation: Obligation;
linkedObligations: Set<string>;
onLink: (obligationId: string) => void;
onUnlink: (obligationId: string) => void;
disabled?: boolean;
}) {
const { __ } = useTranslate();
const isLinked = props.linkedObligations.has(props.obligation.id);
const onToggle = () => {
if (isLinked) {
props.onUnlink(props.obligation.id);
} else {
props.onLink(props.obligation.id);
}
};
return (
<div className="flex items-center justify-between p-4 hover:bg-level-1">
<div className="flex-1 min-w-0">
<div className="flex items-center gap-3">
<div className="flex-1 min-w-0">
<div className="text-sm font-medium text-txt-primary truncate">
{props.obligation.area || __("No area specified")}
{props.obligation.source || __("No source specified")}
</div>
<div className="text-xs text-txt-secondary">
{props.obligation.owner?.fullName || __("Unassigned")}
</div>
</div>
<Badge variant={getObligationStatusVariant(props.obligation.status)}>
{getObligationStatusLabel(props.obligation.status)}
</Badge>
</div>
</div>
<Button
variant={isLinked ? "secondary" : "primary"}
icon={isLinked ? IconTrashCan : IconPlusLarge}
onClick={onToggle}
disabled={props.disabled}
className="ml-6"
>
{isLinked ? __("Unlink") : __("Link")}
</Button>
</div>
);
}

View File

@@ -0,0 +1,96 @@
/**
* @generated SignedSource<<1126620dba70ca7a331c00347217eaa8>>
* @lightSyntaxTransform
* @nogrep
*/
/* tslint:disable */
/* eslint-disable */
// @ts-nocheck
import { ReaderFragment } from 'relay-runtime';
export type ObligationStatus = "COMPLIANT" | "NON_COMPLIANT" | "PARTIALLY_COMPLIANT";
import { FragmentRefs } from "relay-runtime";
export type LinkedObligationsCardFragment$data = {
readonly area: string | null | undefined;
readonly id: string;
readonly owner: {
readonly fullName: string;
};
readonly requirement: string | null | undefined;
readonly source: string | null | undefined;
readonly status: ObligationStatus;
readonly " $fragmentType": "LinkedObligationsCardFragment";
};
export type LinkedObligationsCardFragment$key = {
readonly " $data"?: LinkedObligationsCardFragment$data;
readonly " $fragmentSpreads": FragmentRefs<"LinkedObligationsCardFragment">;
};
const node: ReaderFragment = {
"argumentDefinitions": [],
"kind": "Fragment",
"metadata": null,
"name": "LinkedObligationsCardFragment",
"selections": [
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "id",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "requirement",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "area",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "source",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "status",
"storageKey": null
},
{
"alias": null,
"args": null,
"concreteType": "People",
"kind": "LinkedField",
"name": "owner",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "fullName",
"storageKey": null
}
],
"storageKey": null
}
],
"type": "Obligation",
"abstractKey": null
};
(node as any).hash = "67ae0e6b0df090bb5a708bf7e029f4c5";
export default node;

View File

@@ -0,0 +1,260 @@
/**
* @generated SignedSource<<4569a09dbc9fbf80fb787da46d0d058f>>
* @lightSyntaxTransform
* @nogrep
*/
/* tslint:disable */
/* eslint-disable */
// @ts-nocheck
import { ReaderFragment } from 'relay-runtime';
export type ObligationStatus = "COMPLIANT" | "NON_COMPLIANT" | "PARTIALLY_COMPLIANT";
import { FragmentRefs } from "relay-runtime";
export type LinkedObligationsDialogFragment$data = {
readonly id: string;
readonly obligations: {
readonly edges: ReadonlyArray<{
readonly node: {
readonly area: string | null | undefined;
readonly id: string;
readonly owner: {
readonly fullName: string;
};
readonly requirement: string | null | undefined;
readonly source: string | null | undefined;
readonly status: ObligationStatus;
};
}>;
};
readonly " $fragmentType": "LinkedObligationsDialogFragment";
};
export type LinkedObligationsDialogFragment$key = {
readonly " $data"?: LinkedObligationsDialogFragment$data;
readonly " $fragmentSpreads": FragmentRefs<"LinkedObligationsDialogFragment">;
};
import LinkedObligationsDialogQuery_fragment_graphql from './LinkedObligationsDialogQuery_fragment.graphql';
const node: ReaderFragment = (function(){
var v0 = [
"obligations"
],
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": 20,
"kind": "LocalArgument",
"name": "first"
},
{
"defaultValue": null,
"kind": "LocalArgument",
"name": "last"
},
{
"defaultValue": null,
"kind": "LocalArgument",
"name": "order"
}
],
"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": LinkedObligationsDialogQuery_fragment_graphql,
"identifierInfo": {
"identifierField": "id",
"identifierQueryVariableName": "id"
}
}
},
"name": "LinkedObligationsDialogFragment",
"selections": [
{
"alias": "obligations",
"args": [
{
"kind": "Variable",
"name": "orderBy",
"variableName": "order"
}
],
"concreteType": "ObligationConnection",
"kind": "LinkedField",
"name": "__LinkedObligationsDialogQuery_obligations_connection",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"concreteType": "ObligationEdge",
"kind": "LinkedField",
"name": "edges",
"plural": true,
"selections": [
{
"alias": null,
"args": null,
"concreteType": "Obligation",
"kind": "LinkedField",
"name": "node",
"plural": false,
"selections": [
(v1/*: any*/),
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "requirement",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "area",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "source",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "status",
"storageKey": null
},
{
"alias": null,
"args": null,
"concreteType": "People",
"kind": "LinkedField",
"name": "owner",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "fullName",
"storageKey": null
}
],
"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": "endCursor",
"storageKey": null
},
{
"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
}
],
"storageKey": null
}
],
"storageKey": null
},
(v1/*: any*/)
],
"type": "Organization",
"abstractKey": null
};
})();
(node as any).hash = "6e686f2a4bce776146b1985df2863e73";
export default node;

View File

@@ -0,0 +1,278 @@
/**
* @generated SignedSource<<44ee1c9c1b8d060d03736d1703d2a68a>>
* @lightSyntaxTransform
* @nogrep
*/
/* tslint:disable */
/* eslint-disable */
// @ts-nocheck
import { ConcreteRequest } from 'relay-runtime';
import { FragmentRefs } from "relay-runtime";
export type LinkedObligationsDialogQuery$variables = {
organizationId: string;
};
export type LinkedObligationsDialogQuery$data = {
readonly organization: {
readonly id: string;
readonly " $fragmentSpreads": FragmentRefs<"LinkedObligationsDialogFragment">;
};
};
export type LinkedObligationsDialogQuery = {
response: LinkedObligationsDialogQuery$data;
variables: LinkedObligationsDialogQuery$variables;
};
const node: ConcreteRequest = (function(){
var v0 = [
{
"defaultValue": null,
"kind": "LocalArgument",
"name": "organizationId"
}
],
v1 = [
{
"kind": "Variable",
"name": "id",
"variableName": "organizationId"
}
],
v2 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "id",
"storageKey": null
},
v3 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "__typename",
"storageKey": null
},
v4 = [
{
"kind": "Literal",
"name": "first",
"value": 20
}
];
return {
"fragment": {
"argumentDefinitions": (v0/*: any*/),
"kind": "Fragment",
"metadata": null,
"name": "LinkedObligationsDialogQuery",
"selections": [
{
"alias": "organization",
"args": (v1/*: any*/),
"concreteType": null,
"kind": "LinkedField",
"name": "node",
"plural": false,
"selections": [
(v2/*: any*/),
{
"kind": "InlineFragment",
"selections": [
{
"args": null,
"kind": "FragmentSpread",
"name": "LinkedObligationsDialogFragment"
}
],
"type": "Organization",
"abstractKey": null
}
],
"storageKey": null
}
],
"type": "Query",
"abstractKey": null
},
"kind": "Request",
"operation": {
"argumentDefinitions": (v0/*: any*/),
"kind": "Operation",
"name": "LinkedObligationsDialogQuery",
"selections": [
{
"alias": "organization",
"args": (v1/*: any*/),
"concreteType": null,
"kind": "LinkedField",
"name": "node",
"plural": false,
"selections": [
(v3/*: any*/),
(v2/*: any*/),
{
"kind": "InlineFragment",
"selections": [
{
"alias": null,
"args": (v4/*: any*/),
"concreteType": "ObligationConnection",
"kind": "LinkedField",
"name": "obligations",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"concreteType": "ObligationEdge",
"kind": "LinkedField",
"name": "edges",
"plural": true,
"selections": [
{
"alias": null,
"args": null,
"concreteType": "Obligation",
"kind": "LinkedField",
"name": "node",
"plural": false,
"selections": [
(v2/*: any*/),
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "requirement",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "area",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "source",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "status",
"storageKey": null
},
{
"alias": null,
"args": null,
"concreteType": "People",
"kind": "LinkedField",
"name": "owner",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "fullName",
"storageKey": null
},
(v2/*: any*/)
],
"storageKey": null
},
(v3/*: 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": "endCursor",
"storageKey": null
},
{
"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
}
],
"storageKey": null
}
],
"storageKey": "obligations(first:20)"
},
{
"alias": null,
"args": (v4/*: any*/),
"filters": [
"orderBy"
],
"handle": "connection",
"key": "LinkedObligationsDialogQuery_obligations",
"kind": "LinkedHandle",
"name": "obligations"
}
],
"type": "Organization",
"abstractKey": null
}
],
"storageKey": null
}
]
},
"params": {
"cacheID": "8d4a5e57f79ae207dd1e27c436e49bd5",
"id": null,
"metadata": {},
"name": "LinkedObligationsDialogQuery",
"operationKind": "query",
"text": "query LinkedObligationsDialogQuery(\n $organizationId: ID!\n) {\n organization: node(id: $organizationId) {\n __typename\n id\n ... on Organization {\n ...LinkedObligationsDialogFragment\n }\n }\n}\n\nfragment LinkedObligationsDialogFragment on Organization {\n obligations(first: 20) {\n edges {\n node {\n id\n requirement\n area\n source\n status\n owner {\n fullName\n id\n }\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n hasPreviousPage\n startCursor\n }\n }\n id\n}\n"
}
};
})();
(node as any).hash = "afd36a8a7dbe29044d2aefc3e3820fc8";
export default node;

View File

@@ -0,0 +1,351 @@
/**
* @generated SignedSource<<3d2709f51866093bcc78ec14501dae31>>
* @lightSyntaxTransform
* @nogrep
*/
/* tslint:disable */
/* eslint-disable */
// @ts-nocheck
import { ConcreteRequest } from 'relay-runtime';
import { FragmentRefs } from "relay-runtime";
export type ObligationOrderField = "CREATED_AT" | "DUE_DATE" | "LAST_REVIEW_DATE" | "STATUS";
export type OrderDirection = "ASC" | "DESC";
export type ObligationOrder = {
direction: OrderDirection;
field: ObligationOrderField;
};
export type LinkedObligationsDialogQuery_fragment$variables = {
after?: any | null | undefined;
before?: any | null | undefined;
first?: number | null | undefined;
id: string;
last?: number | null | undefined;
order?: ObligationOrder | null | undefined;
};
export type LinkedObligationsDialogQuery_fragment$data = {
readonly node: {
readonly " $fragmentSpreads": FragmentRefs<"LinkedObligationsDialogFragment">;
};
};
export type LinkedObligationsDialogQuery_fragment = {
response: LinkedObligationsDialogQuery_fragment$data;
variables: LinkedObligationsDialogQuery_fragment$variables;
};
const node: ConcreteRequest = (function(){
var v0 = {
"defaultValue": null,
"kind": "LocalArgument",
"name": "after"
},
v1 = {
"defaultValue": null,
"kind": "LocalArgument",
"name": "before"
},
v2 = {
"defaultValue": 20,
"kind": "LocalArgument",
"name": "first"
},
v3 = {
"defaultValue": null,
"kind": "LocalArgument",
"name": "id"
},
v4 = {
"defaultValue": null,
"kind": "LocalArgument",
"name": "last"
},
v5 = {
"defaultValue": null,
"kind": "LocalArgument",
"name": "order"
},
v6 = [
{
"kind": "Variable",
"name": "id",
"variableName": "id"
}
],
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 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "id",
"storageKey": null
},
v13 = [
(v7/*: any*/),
(v8/*: any*/),
(v9/*: any*/),
(v10/*: any*/),
{
"kind": "Variable",
"name": "orderBy",
"variableName": "order"
}
];
return {
"fragment": {
"argumentDefinitions": [
(v0/*: any*/),
(v1/*: any*/),
(v2/*: any*/),
(v3/*: any*/),
(v4/*: any*/),
(v5/*: any*/)
],
"kind": "Fragment",
"metadata": null,
"name": "LinkedObligationsDialogQuery_fragment",
"selections": [
{
"alias": null,
"args": (v6/*: any*/),
"concreteType": null,
"kind": "LinkedField",
"name": "node",
"plural": false,
"selections": [
{
"args": [
(v7/*: any*/),
(v8/*: any*/),
(v9/*: any*/),
(v10/*: any*/),
{
"kind": "Variable",
"name": "order",
"variableName": "order"
}
],
"kind": "FragmentSpread",
"name": "LinkedObligationsDialogFragment"
}
],
"storageKey": null
}
],
"type": "Query",
"abstractKey": null
},
"kind": "Request",
"operation": {
"argumentDefinitions": [
(v0/*: any*/),
(v1/*: any*/),
(v2/*: any*/),
(v4/*: any*/),
(v5/*: any*/),
(v3/*: any*/)
],
"kind": "Operation",
"name": "LinkedObligationsDialogQuery_fragment",
"selections": [
{
"alias": null,
"args": (v6/*: any*/),
"concreteType": null,
"kind": "LinkedField",
"name": "node",
"plural": false,
"selections": [
(v11/*: any*/),
(v12/*: any*/),
{
"kind": "InlineFragment",
"selections": [
{
"alias": null,
"args": (v13/*: any*/),
"concreteType": "ObligationConnection",
"kind": "LinkedField",
"name": "obligations",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"concreteType": "ObligationEdge",
"kind": "LinkedField",
"name": "edges",
"plural": true,
"selections": [
{
"alias": null,
"args": null,
"concreteType": "Obligation",
"kind": "LinkedField",
"name": "node",
"plural": false,
"selections": [
(v12/*: any*/),
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "requirement",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "area",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "source",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "status",
"storageKey": null
},
{
"alias": null,
"args": null,
"concreteType": "People",
"kind": "LinkedField",
"name": "owner",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "fullName",
"storageKey": null
},
(v12/*: any*/)
],
"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": "endCursor",
"storageKey": null
},
{
"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
}
],
"storageKey": null
}
],
"storageKey": null
},
{
"alias": null,
"args": (v13/*: any*/),
"filters": [
"orderBy"
],
"handle": "connection",
"key": "LinkedObligationsDialogQuery_obligations",
"kind": "LinkedHandle",
"name": "obligations"
}
],
"type": "Organization",
"abstractKey": null
}
],
"storageKey": null
}
]
},
"params": {
"cacheID": "a4640b163a373e0420a9fb1108ce7b3a",
"id": null,
"metadata": {},
"name": "LinkedObligationsDialogQuery_fragment",
"operationKind": "query",
"text": "query LinkedObligationsDialogQuery_fragment(\n $after: CursorKey = null\n $before: CursorKey = null\n $first: Int = 20\n $last: Int = null\n $order: ObligationOrder = null\n $id: ID!\n) {\n node(id: $id) {\n __typename\n ...LinkedObligationsDialogFragment_16fISc\n id\n }\n}\n\nfragment LinkedObligationsDialogFragment_16fISc on Organization {\n obligations(first: $first, after: $after, last: $last, before: $before, orderBy: $order) {\n edges {\n node {\n id\n requirement\n area\n source\n status\n owner {\n fullName\n id\n }\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n hasPreviousPage\n startCursor\n }\n }\n id\n}\n"
}
};
})();
(node as any).hash = "6e686f2a4bce776146b1985df2863e73";
export default node;

View File

@@ -2,7 +2,7 @@ import { graphql } from "relay-runtime";
import { useMutation } from "react-relay";
import { useConfirm } from "@probo/ui";
import { useTranslate } from "@probo/i18n";
import { promisifyMutation, sprintf } from "@probo/helpers";
import { promisifyMutation } from "@probo/helpers";
import { useMutationWithToasts } from "../useMutationWithToasts";
export const ObligationsConnectionKey = "ObligationsPage_obligations";
@@ -24,7 +24,6 @@ export const obligationNodeQuery = graphql`
id
snapshotId
sourceId
referenceId
area
source
requirement
@@ -57,7 +56,6 @@ export const createObligationMutation = graphql`
obligationEdge @prependEdge(connections: $connections) {
node {
id
referenceId
area
source
requirement
@@ -82,7 +80,6 @@ export const updateObligationMutation = graphql`
updateObligation(input: $input) {
obligation {
id
referenceId
area
source
requirement
@@ -113,7 +110,7 @@ export const deleteObligationMutation = graphql`
`;
export const useDeleteObligation = (
obligation: { id: string; referenceId: string },
obligation: { id: string },
connectionId: string
) => {
const { __ } = useTranslate();
@@ -135,11 +132,8 @@ export const useDeleteObligation = (
},
}),
{
message: sprintf(
__(
"This will permanently delete the obligation %s. This action cannot be undone."
),
obligation.referenceId
message: __(
"This will permanently delete this obligation. This action cannot be undone."
),
}
);
@@ -152,7 +146,6 @@ export const useCreateObligation = (connectionId: string) => {
return (input: {
organizationId: string;
referenceId: string;
area?: string;
source?: string;
requirement?: string;
@@ -166,9 +159,6 @@ export const useCreateObligation = (connectionId: string) => {
if (!input.organizationId) {
return alert(__("Failed to create obligation: organization is required"));
}
if (!input.referenceId) {
return alert(__("Failed to create obligation: reference ID is required"));
}
if (!input.ownerId) {
return alert(__("Failed to create obligation: owner is required"));
}
@@ -177,7 +167,6 @@ export const useCreateObligation = (connectionId: string) => {
variables: {
input: {
organizationId: input.organizationId,
referenceId: input.referenceId,
area: input.area,
source: input.source,
requirement: input.requirement,
@@ -186,7 +175,7 @@ export const useCreateObligation = (connectionId: string) => {
ownerId: input.ownerId,
lastReviewDate: input.lastReviewDate,
dueDate: input.dueDate,
status: input.status || "OPEN",
status: input.status || "NON_COMPLIANT",
},
connections: [connectionId],
},
@@ -200,7 +189,6 @@ export const useUpdateObligation = () => {
return (input: {
id: string;
referenceId?: string;
area?: string;
source?: string;
requirement?: string;

View File

@@ -125,11 +125,15 @@ export const riskNodeQuery = graphql`
controlsInfo: controls(first: 0) {
totalCount
}
obligationsInfo: obligations(first: 0) {
totalCount
}
...useRiskFormFragment
...RiskOverviewTabFragment
...RiskMeasuresTabFragment
...RiskDocumentsTabFragment
...RiskControlsTabFragment
...RiskObligationsTabFragment
}
}
}

View File

@@ -1,5 +1,5 @@
/**
* @generated SignedSource<<0d77e4f7fb508d1c181575a45f0938d6>>
* @generated SignedSource<<6c659dc34af3bc7107a55d45f49075b5>>
* @lightSyntaxTransform
* @nogrep
*/
@@ -9,7 +9,7 @@
// @ts-nocheck
import { ConcreteRequest } from 'relay-runtime';
export type ObligationStatus = "CLOSED" | "IN_PROGRESS" | "OPEN";
export type ObligationStatus = "COMPLIANT" | "NON_COMPLIANT" | "PARTIALLY_COMPLIANT";
export type CreateObligationInput = {
actionsToBeImplemented?: string | null | undefined;
area?: string | null | undefined;
@@ -17,7 +17,6 @@ export type CreateObligationInput = {
lastReviewDate?: any | null | undefined;
organizationId: string;
ownerId: string;
referenceId: string;
regulator?: string | null | undefined;
requirement?: string | null | undefined;
source?: string | null | undefined;
@@ -41,7 +40,6 @@ export type ObligationGraphCreateMutation$data = {
readonly fullName: string;
readonly id: string;
};
readonly referenceId: string;
readonly regulator: string | null | undefined;
readonly requirement: string | null | undefined;
readonly source: string | null | undefined;
@@ -97,13 +95,6 @@ v4 = {
"plural": false,
"selections": [
(v3/*: any*/),
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "referenceId",
"storageKey": null
},
{
"alias": null,
"args": null,
@@ -258,16 +249,16 @@ return {
]
},
"params": {
"cacheID": "8b01fc75c0c24f32a7892b7b8e38be72",
"cacheID": "76eae037102523c7378b07856332c9ff",
"id": null,
"metadata": {},
"name": "ObligationGraphCreateMutation",
"operationKind": "mutation",
"text": "mutation ObligationGraphCreateMutation(\n $input: CreateObligationInput!\n) {\n createObligation(input: $input) {\n obligationEdge {\n node {\n id\n referenceId\n area\n source\n requirement\n actionsToBeImplemented\n regulator\n lastReviewDate\n dueDate\n status\n owner {\n id\n fullName\n }\n createdAt\n }\n }\n }\n}\n"
"text": "mutation ObligationGraphCreateMutation(\n $input: CreateObligationInput!\n) {\n createObligation(input: $input) {\n obligationEdge {\n node {\n id\n area\n source\n requirement\n actionsToBeImplemented\n regulator\n lastReviewDate\n dueDate\n status\n owner {\n id\n fullName\n }\n createdAt\n }\n }\n }\n}\n"
}
};
})();
(node as any).hash = "67433dcbb82e3abbde25e2a8105c2789";
(node as any).hash = "f3d8ddbef3566e26b3fe65543d93d07d";
export default node;

View File

@@ -1,5 +1,5 @@
/**
* @generated SignedSource<<7d2959d10f1bc8e80f8ab1d1ea4cb45f>>
* @generated SignedSource<<ae81a1ead15cdd5a41e897bcd60cd38b>>
* @lightSyntaxTransform
* @nogrep
*/
@@ -176,13 +176,6 @@ return {
"name": "sourceId",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "referenceId",
"storageKey": null
},
{
"alias": null,
"args": null,
@@ -347,12 +340,12 @@ return {
]
},
"params": {
"cacheID": "1d94cb0e6a84428954ab8402ed2ca0ef",
"cacheID": "761aab4336741b33cc256ec5527011e4",
"id": null,
"metadata": {},
"name": "ObligationGraphListQuery",
"operationKind": "query",
"text": "query ObligationGraphListQuery(\n $organizationId: ID!\n $snapshotId: ID\n) {\n node(id: $organizationId) {\n __typename\n ... on Organization {\n ...ObligationsPageFragment_3iomuz\n }\n id\n }\n}\n\nfragment ObligationsPageFragment_3iomuz on Organization {\n id\n obligations(first: 10, filter: {snapshotId: $snapshotId}) {\n totalCount\n edges {\n node {\n id\n snapshotId\n sourceId\n referenceId\n area\n source\n requirement\n status\n lastReviewDate\n dueDate\n actionsToBeImplemented\n regulator\n owner {\n id\n fullName\n }\n createdAt\n updatedAt\n __typename\n }\n cursor\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n}\n"
"text": "query ObligationGraphListQuery(\n $organizationId: ID!\n $snapshotId: ID\n) {\n node(id: $organizationId) {\n __typename\n ... on Organization {\n ...ObligationsPageFragment_3iomuz\n }\n id\n }\n}\n\nfragment ObligationsPageFragment_3iomuz on Organization {\n id\n obligations(first: 10, filter: {snapshotId: $snapshotId}) {\n totalCount\n edges {\n node {\n id\n snapshotId\n sourceId\n area\n source\n requirement\n status\n lastReviewDate\n dueDate\n actionsToBeImplemented\n regulator\n owner {\n id\n fullName\n }\n createdAt\n updatedAt\n __typename\n }\n cursor\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n}\n"
}
};
})();

View File

@@ -1,5 +1,5 @@
/**
* @generated SignedSource<<dcd6c4da574c7104ae239d1da692f71a>>
* @generated SignedSource<<d1b09bb9cf9c608b8b3ac1c2b55a109a>>
* @lightSyntaxTransform
* @nogrep
*/
@@ -9,7 +9,7 @@
// @ts-nocheck
import { ConcreteRequest } from 'relay-runtime';
export type ObligationStatus = "CLOSED" | "IN_PROGRESS" | "OPEN";
export type ObligationStatus = "COMPLIANT" | "NON_COMPLIANT" | "PARTIALLY_COMPLIANT";
export type ObligationGraphNodeQuery$variables = {
obligationId: string;
};
@@ -29,7 +29,6 @@ export type ObligationGraphNodeQuery$data = {
readonly fullName: string;
readonly id: string;
};
readonly referenceId?: string;
readonly regulator?: string | null | undefined;
readonly requirement?: string | null | undefined;
readonly snapshotId?: string | null | undefined;
@@ -84,66 +83,59 @@ v5 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "referenceId",
"name": "area",
"storageKey": null
},
v6 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "area",
"name": "source",
"storageKey": null
},
v7 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "source",
"name": "requirement",
"storageKey": null
},
v8 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "requirement",
"name": "actionsToBeImplemented",
"storageKey": null
},
v9 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "actionsToBeImplemented",
"name": "regulator",
"storageKey": null
},
v10 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "regulator",
"name": "lastReviewDate",
"storageKey": null
},
v11 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "lastReviewDate",
"name": "dueDate",
"storageKey": null
},
v12 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "dueDate",
"storageKey": null
},
v13 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "status",
"storageKey": null
},
v14 = {
v13 = {
"alias": null,
"args": null,
"concreteType": "People",
@@ -162,7 +154,7 @@ v14 = {
],
"storageKey": null
},
v15 = {
v14 = {
"alias": null,
"args": null,
"concreteType": "Organization",
@@ -181,14 +173,14 @@ v15 = {
],
"storageKey": null
},
v16 = {
v15 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "createdAt",
"storageKey": null
},
v17 = {
v16 = {
"alias": null,
"args": null,
"kind": "ScalarField",
@@ -227,8 +219,7 @@ return {
(v13/*: any*/),
(v14/*: any*/),
(v15/*: any*/),
(v16/*: any*/),
(v17/*: any*/)
(v16/*: any*/)
],
"type": "Obligation",
"abstractKey": null
@@ -278,8 +269,7 @@ return {
(v13/*: any*/),
(v14/*: any*/),
(v15/*: any*/),
(v16/*: any*/),
(v17/*: any*/)
(v16/*: any*/)
],
"type": "Obligation",
"abstractKey": null
@@ -290,16 +280,16 @@ return {
]
},
"params": {
"cacheID": "1cc13435272f22a8167b370cca105184",
"cacheID": "6fd1c9d6e9f9a5baa60e4d270fc16db7",
"id": null,
"metadata": {},
"name": "ObligationGraphNodeQuery",
"operationKind": "query",
"text": "query ObligationGraphNodeQuery(\n $obligationId: ID!\n) {\n node(id: $obligationId) {\n __typename\n ... on Obligation {\n id\n snapshotId\n sourceId\n referenceId\n area\n source\n requirement\n actionsToBeImplemented\n regulator\n lastReviewDate\n dueDate\n status\n owner {\n id\n fullName\n }\n organization {\n id\n name\n }\n createdAt\n updatedAt\n }\n id\n }\n}\n"
"text": "query ObligationGraphNodeQuery(\n $obligationId: ID!\n) {\n node(id: $obligationId) {\n __typename\n ... on Obligation {\n id\n snapshotId\n sourceId\n area\n source\n requirement\n actionsToBeImplemented\n regulator\n lastReviewDate\n dueDate\n status\n owner {\n id\n fullName\n }\n organization {\n id\n name\n }\n createdAt\n updatedAt\n }\n id\n }\n}\n"
}
};
})();
(node as any).hash = "f7c98b6669bae79c42892dd296e9dd07";
(node as any).hash = "ddefa1f2514f429a8ff174646bccf254";
export default node;

View File

@@ -1,5 +1,5 @@
/**
* @generated SignedSource<<7978f1bb5fdbb6129f0e6217574af621>>
* @generated SignedSource<<2fb713ad39d2976a25e4fee57edec2f3>>
* @lightSyntaxTransform
* @nogrep
*/
@@ -9,7 +9,7 @@
// @ts-nocheck
import { ConcreteRequest } from 'relay-runtime';
export type ObligationStatus = "CLOSED" | "IN_PROGRESS" | "OPEN";
export type ObligationStatus = "COMPLIANT" | "NON_COMPLIANT" | "PARTIALLY_COMPLIANT";
export type UpdateObligationInput = {
actionsToBeImplemented?: string | null | undefined;
area?: string | null | undefined;
@@ -17,7 +17,6 @@ export type UpdateObligationInput = {
id: string;
lastReviewDate?: any | null | undefined;
ownerId?: string | null | undefined;
referenceId?: string | null | undefined;
regulator?: string | null | undefined;
requirement?: string | null | undefined;
source?: string | null | undefined;
@@ -38,7 +37,6 @@ export type ObligationGraphUpdateMutation$data = {
readonly fullName: string;
readonly id: string;
};
readonly referenceId: string;
readonly regulator: string | null | undefined;
readonly requirement: string | null | undefined;
readonly source: string | null | undefined;
@@ -91,13 +89,6 @@ v2 = [
"plural": false,
"selections": [
(v1/*: any*/),
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "referenceId",
"storageKey": null
},
{
"alias": null,
"args": null,
@@ -205,16 +196,16 @@ return {
"selections": (v2/*: any*/)
},
"params": {
"cacheID": "f3f7c1657e914067e7543bf98c91c2d0",
"cacheID": "e42654b0cfd6ebeb8c78e8ec2f62c9c7",
"id": null,
"metadata": {},
"name": "ObligationGraphUpdateMutation",
"operationKind": "mutation",
"text": "mutation ObligationGraphUpdateMutation(\n $input: UpdateObligationInput!\n) {\n updateObligation(input: $input) {\n obligation {\n id\n referenceId\n area\n source\n requirement\n actionsToBeImplemented\n regulator\n lastReviewDate\n dueDate\n status\n owner {\n id\n fullName\n }\n updatedAt\n }\n }\n}\n"
"text": "mutation ObligationGraphUpdateMutation(\n $input: UpdateObligationInput!\n) {\n updateObligation(input: $input) {\n obligation {\n id\n area\n source\n requirement\n actionsToBeImplemented\n regulator\n lastReviewDate\n dueDate\n status\n owner {\n id\n fullName\n }\n updatedAt\n }\n }\n}\n"
}
};
})();
(node as any).hash = "4de068d83b83280ea680aad303c84098";
(node as any).hash = "68013ca15f0e4eaaa0b1ef877b4f528c";
export default node;

View File

@@ -1,5 +1,5 @@
/**
* @generated SignedSource<<9abcf06eed9cb70f62b2aed2b907e9e5>>
* @generated SignedSource<<f3eadb5ecfeb7b2304712f74b6ac8863>>
* @lightSyntaxTransform
* @nogrep
*/
@@ -30,6 +30,9 @@ export type RiskGraphNodeQuery$data = {
};
readonly name?: string;
readonly note?: string;
readonly obligationsInfo?: {
readonly totalCount: number;
};
readonly owner?: {
readonly fullName: string;
readonly id: string;
@@ -37,7 +40,7 @@ export type RiskGraphNodeQuery$data = {
readonly residualRiskScore?: number;
readonly snapshotId?: string | null | undefined;
readonly treatment?: RiskTreatment;
readonly " $fragmentSpreads": FragmentRefs<"RiskControlsTabFragment" | "RiskDocumentsTabFragment" | "RiskMeasuresTabFragment" | "RiskOverviewTabFragment" | "useRiskFormFragment">;
readonly " $fragmentSpreads": FragmentRefs<"RiskControlsTabFragment" | "RiskDocumentsTabFragment" | "RiskMeasuresTabFragment" | "RiskObligationsTabFragment" | "RiskOverviewTabFragment" | "useRiskFormFragment">;
};
};
export type RiskGraphNodeQuery = {
@@ -96,6 +99,13 @@ v6 = {
"storageKey": null
},
v7 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "fullName",
"storageKey": null
},
v8 = {
"alias": null,
"args": null,
"concreteType": "People",
@@ -104,45 +114,39 @@ v7 = {
"plural": false,
"selections": [
(v2/*: any*/),
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "fullName",
"storageKey": null
}
(v7/*: any*/)
],
"storageKey": null
},
v8 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "note",
"storageKey": null
},
v9 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "inherentRiskScore",
"name": "note",
"storageKey": null
},
v10 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "inherentRiskScore",
"storageKey": null
},
v11 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "residualRiskScore",
"storageKey": null
},
v11 = [
v12 = [
{
"kind": "Literal",
"name": "first",
"value": 0
}
],
v12 = [
v13 = [
{
"alias": null,
"args": null,
@@ -151,72 +155,82 @@ v12 = [
"storageKey": null
}
],
v13 = {
v14 = {
"alias": "measuresInfo",
"args": (v11/*: any*/),
"args": (v12/*: any*/),
"concreteType": "MeasureConnection",
"kind": "LinkedField",
"name": "measures",
"plural": false,
"selections": (v12/*: any*/),
"selections": (v13/*: any*/),
"storageKey": "measures(first:0)"
},
v14 = {
v15 = {
"alias": "documentsInfo",
"args": (v11/*: any*/),
"args": (v12/*: any*/),
"concreteType": "DocumentConnection",
"kind": "LinkedField",
"name": "documents",
"plural": false,
"selections": (v12/*: any*/),
"selections": (v13/*: any*/),
"storageKey": "documents(first:0)"
},
v15 = {
v16 = {
"alias": "controlsInfo",
"args": (v11/*: any*/),
"args": (v12/*: any*/),
"concreteType": "ControlConnection",
"kind": "LinkedField",
"name": "controls",
"plural": false,
"selections": (v12/*: any*/),
"selections": (v13/*: any*/),
"storageKey": "controls(first:0)"
},
v16 = {
v17 = {
"alias": "obligationsInfo",
"args": (v12/*: any*/),
"concreteType": "ObligationConnection",
"kind": "LinkedField",
"name": "obligations",
"plural": false,
"selections": (v13/*: any*/),
"storageKey": "obligations(first:0)"
},
v18 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "__typename",
"storageKey": null
},
v17 = [
v19 = [
{
"kind": "Literal",
"name": "first",
"value": 100
}
],
v18 = {
v20 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "cursor",
"storageKey": null
},
v19 = {
v21 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "endCursor",
"storageKey": null
},
v20 = {
v22 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "hasNextPage",
"storageKey": null
},
v21 = {
v23 = {
"alias": null,
"args": null,
"concreteType": "PageInfo",
@@ -224,12 +238,12 @@ v21 = {
"name": "pageInfo",
"plural": false,
"selections": [
(v19/*: any*/),
(v20/*: any*/)
(v21/*: any*/),
(v22/*: any*/)
],
"storageKey": null
},
v22 = {
v24 = {
"kind": "ClientExtension",
"selections": [
{
@@ -241,7 +255,14 @@ v22 = {
}
]
},
v23 = [
v25 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "status",
"storageKey": null
},
v26 = [
{
"kind": "Literal",
"name": "first",
@@ -271,13 +292,14 @@ return {
(v4/*: any*/),
(v5/*: any*/),
(v6/*: any*/),
(v7/*: any*/),
(v8/*: any*/),
(v9/*: any*/),
(v10/*: any*/),
(v13/*: any*/),
(v11/*: any*/),
(v14/*: any*/),
(v15/*: any*/),
(v16/*: any*/),
(v17/*: any*/),
{
"args": null,
"kind": "FragmentSpread",
@@ -302,6 +324,11 @@ return {
"args": null,
"kind": "FragmentSpread",
"name": "RiskControlsTabFragment"
},
{
"args": null,
"kind": "FragmentSpread",
"name": "RiskObligationsTabFragment"
}
],
"type": "Risk",
@@ -328,7 +355,7 @@ return {
"name": "node",
"plural": false,
"selections": [
(v16/*: any*/),
(v18/*: any*/),
(v2/*: any*/),
{
"kind": "InlineFragment",
@@ -337,13 +364,14 @@ return {
(v4/*: any*/),
(v5/*: any*/),
(v6/*: any*/),
(v7/*: any*/),
(v8/*: any*/),
(v9/*: any*/),
(v10/*: any*/),
(v13/*: any*/),
(v11/*: any*/),
(v14/*: any*/),
(v15/*: any*/),
(v16/*: any*/),
(v17/*: any*/),
{
"alias": null,
"args": null,
@@ -381,7 +409,7 @@ return {
},
{
"alias": null,
"args": (v17/*: any*/),
"args": (v19/*: any*/),
"concreteType": "MeasureConnection",
"kind": "LinkedField",
"name": "measures",
@@ -412,22 +440,22 @@ return {
"name": "state",
"storageKey": null
},
(v16/*: any*/)
(v18/*: any*/)
],
"storageKey": null
},
(v18/*: any*/)
(v20/*: any*/)
],
"storageKey": null
},
(v21/*: any*/),
(v22/*: any*/)
(v23/*: any*/),
(v24/*: any*/)
],
"storageKey": "measures(first:100)"
},
{
"alias": null,
"args": (v17/*: any*/),
"args": (v19/*: any*/),
"filters": null,
"handle": "connection",
"key": "Risk__measures",
@@ -436,7 +464,7 @@ return {
},
{
"alias": null,
"args": (v17/*: any*/),
"args": (v19/*: any*/),
"concreteType": "DocumentConnection",
"kind": "LinkedField",
"name": "documents",
@@ -511,13 +539,7 @@ return {
"plural": false,
"selections": [
(v2/*: any*/),
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "status",
"storageKey": null
}
(v25/*: any*/)
],
"storageKey": null
}
@@ -527,22 +549,22 @@ return {
],
"storageKey": "versions(first:1)"
},
(v16/*: any*/)
(v18/*: any*/)
],
"storageKey": null
},
(v18/*: any*/)
(v20/*: any*/)
],
"storageKey": null
},
(v21/*: any*/),
(v22/*: any*/)
(v23/*: any*/),
(v24/*: any*/)
],
"storageKey": "documents(first:100)"
},
{
"alias": null,
"args": (v17/*: any*/),
"args": (v19/*: any*/),
"filters": null,
"handle": "connection",
"key": "Risk__documents",
@@ -551,7 +573,7 @@ return {
},
{
"alias": null,
"args": (v23/*: any*/),
"args": (v26/*: any*/),
"concreteType": "ControlConnection",
"kind": "LinkedField",
"name": "controls",
@@ -595,11 +617,11 @@ return {
],
"storageKey": null
},
(v16/*: any*/)
(v18/*: any*/)
],
"storageKey": null
},
(v18/*: any*/)
(v20/*: any*/)
],
"storageKey": null
},
@@ -611,8 +633,8 @@ return {
"name": "pageInfo",
"plural": false,
"selections": [
(v19/*: any*/),
(v20/*: any*/),
(v21/*: any*/),
(v22/*: any*/),
{
"alias": null,
"args": null,
@@ -635,7 +657,7 @@ return {
},
{
"alias": null,
"args": (v23/*: any*/),
"args": (v26/*: any*/),
"filters": [
"orderBy",
"filter"
@@ -644,6 +666,88 @@ return {
"key": "RiskControlsTab_controls",
"kind": "LinkedHandle",
"name": "controls"
},
{
"alias": null,
"args": (v19/*: any*/),
"concreteType": "ObligationConnection",
"kind": "LinkedField",
"name": "obligations",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"concreteType": "ObligationEdge",
"kind": "LinkedField",
"name": "edges",
"plural": true,
"selections": [
{
"alias": null,
"args": null,
"concreteType": "Obligation",
"kind": "LinkedField",
"name": "node",
"plural": false,
"selections": [
(v2/*: any*/),
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "requirement",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "area",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "source",
"storageKey": null
},
(v25/*: any*/),
{
"alias": null,
"args": null,
"concreteType": "People",
"kind": "LinkedField",
"name": "owner",
"plural": false,
"selections": [
(v7/*: any*/),
(v2/*: any*/)
],
"storageKey": null
},
(v18/*: any*/)
],
"storageKey": null
},
(v20/*: any*/)
],
"storageKey": null
},
(v23/*: any*/),
(v24/*: any*/)
],
"storageKey": "obligations(first:100)"
},
{
"alias": null,
"args": (v19/*: any*/),
"filters": null,
"handle": "connection",
"key": "Risk__obligations",
"kind": "LinkedHandle",
"name": "obligations"
}
],
"type": "Risk",
@@ -655,16 +759,16 @@ return {
]
},
"params": {
"cacheID": "c3d393180d6273b2e910c7ebffb75df7",
"cacheID": "a909af9427061d9e06e22798cbe1ba14",
"id": null,
"metadata": {},
"name": "RiskGraphNodeQuery",
"operationKind": "query",
"text": "query RiskGraphNodeQuery(\n $riskId: ID!\n) {\n node(id: $riskId) {\n __typename\n ... on Risk {\n id\n snapshotId\n name\n description\n treatment\n owner {\n id\n fullName\n }\n note\n inherentRiskScore\n residualRiskScore\n measuresInfo: measures(first: 0) {\n totalCount\n }\n documentsInfo: documents(first: 0) {\n totalCount\n }\n controlsInfo: controls(first: 0) {\n totalCount\n }\n ...useRiskFormFragment\n ...RiskOverviewTabFragment\n ...RiskMeasuresTabFragment\n ...RiskDocumentsTabFragment\n ...RiskControlsTabFragment\n }\n id\n }\n}\n\nfragment LinkedDocumentsCardFragment on Document {\n id\n title\n createdAt\n documentType\n versions(first: 1) {\n edges {\n node {\n id\n status\n }\n }\n }\n}\n\nfragment LinkedMeasuresCardFragment on Measure {\n id\n name\n state\n}\n\nfragment RiskControlsTabFragment on Risk {\n id\n controls(first: 20) {\n edges {\n node {\n id\n sectionTitle\n name\n framework {\n id\n name\n }\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n hasPreviousPage\n startCursor\n }\n }\n}\n\nfragment RiskDocumentsTabFragment on Risk {\n id\n documents(first: 100) {\n edges {\n node {\n id\n ...LinkedDocumentsCardFragment\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n }\n }\n}\n\nfragment RiskMeasuresTabFragment on Risk {\n id\n measures(first: 100) {\n edges {\n node {\n id\n ...LinkedMeasuresCardFragment\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n }\n }\n}\n\nfragment RiskOverviewTabFragment on Risk {\n inherentLikelihood\n inherentImpact\n residualLikelihood\n residualImpact\n inherentRiskScore\n residualRiskScore\n}\n\nfragment useRiskFormFragment on Risk {\n id\n name\n category\n description\n treatment\n inherentLikelihood\n inherentImpact\n residualLikelihood\n residualImpact\n inherentRiskScore\n residualRiskScore\n note\n owner {\n id\n }\n}\n"
"text": "query RiskGraphNodeQuery(\n $riskId: ID!\n) {\n node(id: $riskId) {\n __typename\n ... on Risk {\n id\n snapshotId\n name\n description\n treatment\n owner {\n id\n fullName\n }\n note\n inherentRiskScore\n residualRiskScore\n measuresInfo: measures(first: 0) {\n totalCount\n }\n documentsInfo: documents(first: 0) {\n totalCount\n }\n controlsInfo: controls(first: 0) {\n totalCount\n }\n obligationsInfo: obligations(first: 0) {\n totalCount\n }\n ...useRiskFormFragment\n ...RiskOverviewTabFragment\n ...RiskMeasuresTabFragment\n ...RiskDocumentsTabFragment\n ...RiskControlsTabFragment\n ...RiskObligationsTabFragment\n }\n id\n }\n}\n\nfragment LinkedDocumentsCardFragment on Document {\n id\n title\n createdAt\n documentType\n versions(first: 1) {\n edges {\n node {\n id\n status\n }\n }\n }\n}\n\nfragment LinkedMeasuresCardFragment on Measure {\n id\n name\n state\n}\n\nfragment LinkedObligationsCardFragment on Obligation {\n id\n requirement\n area\n source\n status\n owner {\n fullName\n id\n }\n}\n\nfragment RiskControlsTabFragment on Risk {\n id\n controls(first: 20) {\n edges {\n node {\n id\n sectionTitle\n name\n framework {\n id\n name\n }\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n hasPreviousPage\n startCursor\n }\n }\n}\n\nfragment RiskDocumentsTabFragment on Risk {\n id\n documents(first: 100) {\n edges {\n node {\n id\n ...LinkedDocumentsCardFragment\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n }\n }\n}\n\nfragment RiskMeasuresTabFragment on Risk {\n id\n measures(first: 100) {\n edges {\n node {\n id\n ...LinkedMeasuresCardFragment\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n }\n }\n}\n\nfragment RiskObligationsTabFragment on Risk {\n id\n obligations(first: 100) {\n edges {\n node {\n id\n ...LinkedObligationsCardFragment\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n }\n }\n}\n\nfragment RiskOverviewTabFragment on Risk {\n inherentLikelihood\n inherentImpact\n residualLikelihood\n residualImpact\n inherentRiskScore\n residualRiskScore\n}\n\nfragment useRiskFormFragment on Risk {\n id\n name\n category\n description\n treatment\n inherentLikelihood\n inherentImpact\n residualLikelihood\n residualImpact\n inherentRiskScore\n residualRiskScore\n note\n owner {\n id\n }\n}\n"
}
};
})();
(node as any).hash = "43dcdf60f1d1b28414650fe5f9294faa";
(node as any).hash = "f173ffcac7b82f1b62394cb74d1a78ee";
export default node;

View File

@@ -31,12 +31,11 @@ import { PeopleSelectField } from "/components/form/PeopleSelectField";
import { useFormWithSchema } from "/hooks/useFormWithSchema";
import { Controller } from "react-hook-form";
import z from "zod";
import { getStatusVariant, getStatusLabel, formatDatetime, getStatusOptions, validateSnapshotConsistency } from "@probo/helpers";
import { getObligationStatusVariant, getObligationStatusLabel, formatDatetime, getObligationStatusOptions, validateSnapshotConsistency } from "@probo/helpers";
import { SnapshotBanner } from "/components/SnapshotBanner";
import type { ObligationGraphNodeQuery } from "/hooks/graph/__generated__/ObligationGraphNodeQuery.graphql";
const updateObligationSchema = z.object({
referenceId: z.string().min(1, "Reference ID is required"),
area: z.string().optional(),
source: z.string().optional(),
requirement: z.string().optional(),
@@ -44,7 +43,7 @@ const updateObligationSchema = z.object({
regulator: z.string().optional(),
lastReviewDate: z.string().optional(),
dueDate: z.string().optional(),
status: z.enum(["OPEN", "IN_PROGRESS", "CLOSED"]),
status: z.enum(["NON_COMPLIANT", "PARTIALLY_COMPLIANT", "COMPLIANT"]),
ownerId: z.string().min(1, "Owner is required"),
});
@@ -68,7 +67,7 @@ export default function ObligationDetailsPage(props: Props) {
validateSnapshotConsistency(obligation, snapshotId);
const updateObligation = useUpdateObligation();
const statusOptions = getStatusOptions(__);
const statusOptions = getObligationStatusOptions(__);
const connectionId = ConnectionHandler.getConnectionID(
organizationId,
@@ -76,7 +75,7 @@ export default function ObligationDetailsPage(props: Props) {
);
const deleteObligation = useDeleteObligation(
{ id: obligation?.id!, referenceId: obligation?.referenceId! },
{ id: obligation?.id! },
connectionId
);
@@ -84,7 +83,6 @@ export default function ObligationDetailsPage(props: Props) {
updateObligationSchema,
{
defaultValues: {
referenceId: obligation?.referenceId || "",
area: obligation?.area || "",
source: obligation?.source || "",
requirement: obligation?.requirement || "",
@@ -96,7 +94,7 @@ export default function ObligationDetailsPage(props: Props) {
dueDate: obligation?.dueDate
? new Date(obligation.dueDate).toISOString().split("T")[0]
: "",
status: obligation?.status || "OPEN",
status: obligation?.status ?? "NON_COMPLIANT",
ownerId: obligation?.owner?.id || "",
},
}
@@ -106,7 +104,6 @@ export default function ObligationDetailsPage(props: Props) {
try {
await updateObligation({
id: obligation.id!,
referenceId: formData.referenceId,
area: formData.area || undefined,
source: formData.source || undefined,
requirement: formData.requirement || undefined,
@@ -116,7 +113,6 @@ export default function ObligationDetailsPage(props: Props) {
dueDate: formatDatetime(formData.dueDate),
status: formData.status,
ownerId: formData.ownerId,
});
toast({
@@ -147,13 +143,13 @@ export default function ObligationDetailsPage(props: Props) {
<Breadcrumb
items={[
{ label: __("Obligations"), to: breadcrumbObligationsUrl },
{ label: obligation.referenceId! },
{ label: __("Obligation Details") },
]}
/>
<div className="flex items-center gap-3 mt-2">
<h1 className="text-2xl font-bold">{obligation.referenceId}</h1>
<Badge variant={getStatusVariant(obligation.status || "OPEN")}>
{getStatusLabel(obligation.status || "OPEN")}
<h1 className="text-2xl font-bold">{__("Obligation")}</h1>
<Badge variant={getObligationStatusVariant(obligation.status ?? "NON_COMPLIANT")}>
{getObligationStatusLabel(obligation.status ?? "NON_COMPLIANT")}
</Badge>
</div>
</div>
@@ -169,19 +165,6 @@ export default function ObligationDetailsPage(props: Props) {
<Card padded>
<form onSubmit={onSubmit} className="space-y-6">
<Field
label={__("Reference ID")}
error={formState.errors.referenceId?.message}
required
>
<Input
{...register("referenceId")}
placeholder={__("Enter reference ID")}
disabled={isSnapshotMode}
/>
</Field>
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
<Field

View File

@@ -28,7 +28,7 @@ import { useParams } from "react-router";
import { useOrganizationId } from "/hooks/useOrganizationId";
import { CreateObligationDialog } from "./dialogs/CreateObligationDialog";
import { deleteObligationMutation } from "../../../hooks/graph/ObligationGraph";
import { sprintf, promisifyMutation, getStatusVariant, getStatusLabel, formatDate } from "@probo/helpers";
import { promisifyMutation, getObligationStatusVariant, getObligationStatusLabel, formatDate } from "@probo/helpers";
import { SnapshotBanner } from "/components/SnapshotBanner";
import type { ObligationsPageQuery } from "./__generated__/ObligationsPageQuery.graphql";
import type {
@@ -64,7 +64,6 @@ const obligationsPageFragment = graphql`
id
snapshotId
sourceId
referenceId
area
source
requirement
@@ -152,7 +151,6 @@ export default function ObligationsPage({ queryRef }: ObligationsPageProps) {
<Table>
<Thead>
<Tr>
<Th>{__("Reference ID")}</Th>
<Th>{__("Area")}</Th>
<Th>{__("Source")}</Th>
<Th>{__("Status")}</Th>
@@ -218,11 +216,8 @@ function ObligationRow({
},
}),
{
message: sprintf(
__(
"This will permanently delete the obligation %s. This action cannot be undone."
),
obligation.referenceId
message: __(
"This will permanently delete this obligation. This action cannot be undone."
),
}
);
@@ -234,14 +229,11 @@ function ObligationRow({
return (
<Tr to={detailsUrl}>
<Td>
<span className="font-mono text-sm">{obligation.referenceId}</span>
</Td>
<Td>{obligation.area || "-"}</Td>
<Td>{obligation.source || "-"}</Td>
<Td>
<Badge variant={getStatusVariant(obligation.status || "OPEN")}>
{getStatusLabel(obligation.status || "OPEN")}
<Badge variant={getObligationStatusVariant(obligation.status || "NON_COMPLIANT")}>
{getObligationStatusLabel(obligation.status || "NON_COMPLIANT")}
</Badge>
</Td>
<Td>{obligation.owner?.fullName || "-"}</Td>

View File

@@ -1,5 +1,5 @@
/**
* @generated SignedSource<<5f839350ed835351175b07d38512ba37>>
* @generated SignedSource<<27cacc02131c03f5aeaaff764e3bb226>>
* @lightSyntaxTransform
* @nogrep
*/
@@ -9,7 +9,7 @@
// @ts-nocheck
import { ReaderFragment } from 'relay-runtime';
export type ObligationStatus = "CLOSED" | "IN_PROGRESS" | "OPEN";
export type ObligationStatus = "COMPLIANT" | "NON_COMPLIANT" | "PARTIALLY_COMPLIANT";
import { FragmentRefs } from "relay-runtime";
export type ObligationsPageFragment$data = {
readonly id: string;
@@ -27,7 +27,6 @@ export type ObligationsPageFragment$data = {
readonly fullName: string;
readonly id: string;
};
readonly referenceId: string;
readonly regulator: string | null | undefined;
readonly requirement: string | null | undefined;
readonly snapshotId: string | null | undefined;
@@ -171,13 +170,6 @@ return {
"name": "sourceId",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "referenceId",
"storageKey": null
},
{
"alias": null,
"args": null,
@@ -333,6 +325,6 @@ return {
};
})();
(node as any).hash = "0d7452faf6e02f97885a65819dfb112b";
(node as any).hash = "a5dda6d90c9205f7c7d6ea6d84d760f1";
export default node;

View File

@@ -1,5 +1,5 @@
/**
* @generated SignedSource<<f54af2ebc7ab4d39662c5619a23532ac>>
* @generated SignedSource<<445c6cc243eadbe9e5eacdec0161ee62>>
* @lightSyntaxTransform
* @nogrep
*/
@@ -176,13 +176,6 @@ return {
"name": "sourceId",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "referenceId",
"storageKey": null
},
{
"alias": null,
"args": null,
@@ -347,12 +340,12 @@ return {
]
},
"params": {
"cacheID": "7e61419b20d9cf30e5dd31b4500bc324",
"cacheID": "9a4d2f4ac3be91001f8c9bb602cd599f",
"id": null,
"metadata": {},
"name": "ObligationsPageQuery",
"operationKind": "query",
"text": "query ObligationsPageQuery(\n $organizationId: ID!\n $snapshotId: ID\n) {\n node(id: $organizationId) {\n __typename\n ... on Organization {\n ...ObligationsPageFragment_3iomuz\n }\n id\n }\n}\n\nfragment ObligationsPageFragment_3iomuz on Organization {\n id\n obligations(first: 10, filter: {snapshotId: $snapshotId}) {\n totalCount\n edges {\n node {\n id\n snapshotId\n sourceId\n referenceId\n area\n source\n requirement\n status\n lastReviewDate\n dueDate\n actionsToBeImplemented\n regulator\n owner {\n id\n fullName\n }\n createdAt\n updatedAt\n __typename\n }\n cursor\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n}\n"
"text": "query ObligationsPageQuery(\n $organizationId: ID!\n $snapshotId: ID\n) {\n node(id: $organizationId) {\n __typename\n ... on Organization {\n ...ObligationsPageFragment_3iomuz\n }\n id\n }\n}\n\nfragment ObligationsPageFragment_3iomuz on Organization {\n id\n obligations(first: 10, filter: {snapshotId: $snapshotId}) {\n totalCount\n edges {\n node {\n id\n snapshotId\n sourceId\n area\n source\n requirement\n status\n lastReviewDate\n dueDate\n actionsToBeImplemented\n regulator\n owner {\n id\n fullName\n }\n createdAt\n updatedAt\n __typename\n }\n cursor\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n}\n"
}
};
})();

View File

@@ -1,5 +1,5 @@
/**
* @generated SignedSource<<c1ff0a7d2abc83b2111d20abecaf6baf>>
* @generated SignedSource<<3b2a48df3fdef9f91bc4520ed2448423>>
* @lightSyntaxTransform
* @nogrep
*/
@@ -200,13 +200,6 @@ return {
"name": "sourceId",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "referenceId",
"storageKey": null
},
{
"alias": null,
"args": null,
@@ -371,16 +364,16 @@ return {
]
},
"params": {
"cacheID": "f34cf1412b7ff3e92971dfac07ca06ac",
"cacheID": "0500f4aee677d8d1ec53cd189e350395",
"id": null,
"metadata": {},
"name": "ObligationsPageRefetchQuery",
"operationKind": "query",
"text": "query ObligationsPageRefetchQuery(\n $after: CursorKey\n $first: Int = 10\n $snapshotId: ID = null\n $id: ID!\n) {\n node(id: $id) {\n __typename\n ...ObligationsPageFragment_35e0S5\n id\n }\n}\n\nfragment ObligationsPageFragment_35e0S5 on Organization {\n id\n obligations(first: $first, after: $after, filter: {snapshotId: $snapshotId}) {\n totalCount\n edges {\n node {\n id\n snapshotId\n sourceId\n referenceId\n area\n source\n requirement\n status\n lastReviewDate\n dueDate\n actionsToBeImplemented\n regulator\n owner {\n id\n fullName\n }\n createdAt\n updatedAt\n __typename\n }\n cursor\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n}\n"
"text": "query ObligationsPageRefetchQuery(\n $after: CursorKey\n $first: Int = 10\n $snapshotId: ID = null\n $id: ID!\n) {\n node(id: $id) {\n __typename\n ...ObligationsPageFragment_35e0S5\n id\n }\n}\n\nfragment ObligationsPageFragment_35e0S5 on Organization {\n id\n obligations(first: $first, after: $after, filter: {snapshotId: $snapshotId}) {\n totalCount\n edges {\n node {\n id\n snapshotId\n sourceId\n area\n source\n requirement\n status\n lastReviewDate\n dueDate\n actionsToBeImplemented\n regulator\n owner {\n id\n fullName\n }\n createdAt\n updatedAt\n __typename\n }\n cursor\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n}\n"
}
};
})();
(node as any).hash = "0d7452faf6e02f97885a65819dfb112b";
(node as any).hash = "a5dda6d90c9205f7c7d6ea6d84d760f1";
export default node;

View File

@@ -20,10 +20,9 @@ import { useFormWithSchema } from "/hooks/useFormWithSchema";
import { useCreateObligation } from "../../../../hooks/graph/ObligationGraph";
import { PeopleSelectField } from "/components/form/PeopleSelectField";
import { Controller } from "react-hook-form";
import { formatDatetime, getStatusOptions } from "@probo/helpers";
import { formatDatetime, getObligationStatusOptions } from "@probo/helpers";
const schema = z.object({
referenceId: z.string().min(1, "Reference ID is required"),
area: z.string().optional(),
source: z.string().optional(),
requirement: z.string().optional(),
@@ -32,7 +31,7 @@ const schema = z.object({
ownerId: z.string().min(1, "Owner is required"),
lastReviewDate: z.string().optional(),
dueDate: z.string().optional(),
status: z.enum(["OPEN", "IN_PROGRESS", "CLOSED"]),
status: z.enum(["NON_COMPLIANT", "PARTIALLY_COMPLIANT", "COMPLIANT"]),
});
type FormData = z.infer<typeof schema>;
@@ -53,11 +52,10 @@ export function CreateObligationDialog({
const dialogRef = useDialogRef();
const createObligation = useCreateObligation(connection || "");
const statusOptions = getStatusOptions(__);
const statusOptions = getObligationStatusOptions(__);
const { register, handleSubmit, formState, reset, control } = useFormWithSchema(schema, {
defaultValues: {
referenceId: "",
area: "",
source: "",
requirement: "",
@@ -66,7 +64,7 @@ export function CreateObligationDialog({
ownerId: "",
lastReviewDate: "",
dueDate: "",
status: "OPEN" as const,
status: "NON_COMPLIANT" as const,
},
});
@@ -74,7 +72,6 @@ export function CreateObligationDialog({
try {
await createObligation({
organizationId,
referenceId: formData.referenceId,
area: formData.area || undefined,
source: formData.source || undefined,
requirement: formData.requirement || undefined,
@@ -112,14 +109,6 @@ export function CreateObligationDialog({
>
<form onSubmit={onSubmit}>
<DialogContent padded className="space-y-4">
<Field
label={__("Reference ID")}
{...register("referenceId")}
placeholder="CR-001"
error={formState.errors.referenceId?.message}
required
/>
<div className="grid grid-cols-2 gap-4">
<Field
label={__("Area")}

View File

@@ -92,6 +92,7 @@ export default function RiskDetailPage(props: Props) {
const documentsCount = risk.documentsInfo?.totalCount ?? 0;
const measuresCount = risk.measuresInfo?.totalCount ?? 0;
const controlsCount = risk.controlsInfo?.totalCount ?? 0;
const obligationsCount = risk.obligationsInfo?.totalCount ?? 0;
const risksUrl = isSnapshotMode && snapshotId
? `/organizations/${organizationId}/snapshots/${snapshotId}/risks`
@@ -159,6 +160,10 @@ export default function RiskDetailPage(props: Props) {
{__("Controls")}
<TabBadge>{controlsCount}</TabBadge>
</TabLink>
<TabLink to={`${baseTabUrl}/obligations`}>
{__("Obligations")}
<TabBadge>{obligationsCount}</TabBadge>
</TabLink>
</>
)}
</Tabs>

View File

@@ -0,0 +1,87 @@
import { graphql, useFragment } from "react-relay";
import type { RiskObligationsTabFragment$key } from "./__generated__/RiskObligationsTabFragment.graphql";
import { useOutletContext } from "react-router";
import { LinkedObligationsCard } from "/components/obligations/LinkedObligationsCard";
import { useMutationWithIncrement } from "/hooks/useMutationWithIncrement";
export const obligationsFragment = graphql`
fragment RiskObligationsTabFragment on Risk {
id
obligations(first: 100) @connection(key: "Risk__obligations") {
__id
edges {
node {
id
...LinkedObligationsCardFragment
}
}
}
}
`;
const attachObligationMutation = graphql`
mutation RiskObligationsTabCreateMutation(
$input: CreateRiskObligationMappingInput!
$connections: [ID!]!
) {
createRiskObligationMapping(input: $input) {
obligationEdge @prependEdge(connections: $connections) {
node {
id
...LinkedObligationsCardFragment
}
}
}
}
`;
export const detachObligationMutation = graphql`
mutation RiskObligationsTabDetachMutation(
$input: DeleteRiskObligationMappingInput!
$connections: [ID!]!
) {
deleteRiskObligationMapping(input: $input) {
deletedObligationId @deleteEdge(connections: $connections)
}
}
`;
export default function RiskObligationsTab() {
const { risk } = useOutletContext<{
risk: RiskObligationsTabFragment$key & { id: string };
}>();
const data = useFragment(obligationsFragment, risk);
const connectionId = data.obligations.__id;
const obligations = data.obligations?.edges?.map((edge) => edge.node) ?? [];
const incrementOptions = {
id: data.id,
node: "obligations(first:0)",
};
const [detachObligation, isDetaching] = useMutationWithIncrement(
detachObligationMutation,
{
...incrementOptions,
value: -1,
},
);
const [attachObligation, isAttaching] = useMutationWithIncrement(
attachObligationMutation,
{
...incrementOptions,
value: 1,
},
);
const isLoading = isDetaching || isAttaching;
return (
<LinkedObligationsCard
disabled={isLoading}
obligations={obligations}
onAttach={attachObligation}
onDetach={detachObligation}
params={{ riskId: data.id }}
connectionId={connectionId}
variant="table"
/>
);
}

View File

@@ -0,0 +1,235 @@
/**
* @generated SignedSource<<545b2d50da8f79510029c5dba61ae821>>
* @lightSyntaxTransform
* @nogrep
*/
/* tslint:disable */
/* eslint-disable */
// @ts-nocheck
import { ConcreteRequest } from 'relay-runtime';
import { FragmentRefs } from "relay-runtime";
export type CreateRiskObligationMappingInput = {
obligationId: string;
riskId: string;
};
export type RiskObligationsTabCreateMutation$variables = {
connections: ReadonlyArray<string>;
input: CreateRiskObligationMappingInput;
};
export type RiskObligationsTabCreateMutation$data = {
readonly createRiskObligationMapping: {
readonly obligationEdge: {
readonly node: {
readonly id: string;
readonly " $fragmentSpreads": FragmentRefs<"LinkedObligationsCardFragment">;
};
};
};
};
export type RiskObligationsTabCreateMutation = {
response: RiskObligationsTabCreateMutation$data;
variables: RiskObligationsTabCreateMutation$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": "id",
"storageKey": null
};
return {
"fragment": {
"argumentDefinitions": [
(v0/*: any*/),
(v1/*: any*/)
],
"kind": "Fragment",
"metadata": null,
"name": "RiskObligationsTabCreateMutation",
"selections": [
{
"alias": null,
"args": (v2/*: any*/),
"concreteType": "CreateRiskObligationMappingPayload",
"kind": "LinkedField",
"name": "createRiskObligationMapping",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"concreteType": "ObligationEdge",
"kind": "LinkedField",
"name": "obligationEdge",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"concreteType": "Obligation",
"kind": "LinkedField",
"name": "node",
"plural": false,
"selections": [
(v3/*: any*/),
{
"args": null,
"kind": "FragmentSpread",
"name": "LinkedObligationsCardFragment"
}
],
"storageKey": null
}
],
"storageKey": null
}
],
"storageKey": null
}
],
"type": "Mutation",
"abstractKey": null
},
"kind": "Request",
"operation": {
"argumentDefinitions": [
(v1/*: any*/),
(v0/*: any*/)
],
"kind": "Operation",
"name": "RiskObligationsTabCreateMutation",
"selections": [
{
"alias": null,
"args": (v2/*: any*/),
"concreteType": "CreateRiskObligationMappingPayload",
"kind": "LinkedField",
"name": "createRiskObligationMapping",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"concreteType": "ObligationEdge",
"kind": "LinkedField",
"name": "obligationEdge",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"concreteType": "Obligation",
"kind": "LinkedField",
"name": "node",
"plural": false,
"selections": [
(v3/*: any*/),
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "requirement",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "area",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "source",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "status",
"storageKey": null
},
{
"alias": null,
"args": null,
"concreteType": "People",
"kind": "LinkedField",
"name": "owner",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "fullName",
"storageKey": null
},
(v3/*: any*/)
],
"storageKey": null
}
],
"storageKey": null
}
],
"storageKey": null
},
{
"alias": null,
"args": null,
"filters": null,
"handle": "prependEdge",
"key": "",
"kind": "LinkedHandle",
"name": "obligationEdge",
"handleArgs": [
{
"kind": "Variable",
"name": "connections",
"variableName": "connections"
}
]
}
],
"storageKey": null
}
]
},
"params": {
"cacheID": "8681d141acf6036709241ba71bfeae4c",
"id": null,
"metadata": {},
"name": "RiskObligationsTabCreateMutation",
"operationKind": "mutation",
"text": "mutation RiskObligationsTabCreateMutation(\n $input: CreateRiskObligationMappingInput!\n) {\n createRiskObligationMapping(input: $input) {\n obligationEdge {\n node {\n id\n ...LinkedObligationsCardFragment\n }\n }\n }\n}\n\nfragment LinkedObligationsCardFragment on Obligation {\n id\n requirement\n area\n source\n status\n owner {\n fullName\n id\n }\n}\n"
}
};
})();
(node as any).hash = "eee2e37b1adaae513ca23b8c82f055c9";
export default node;

View File

@@ -0,0 +1,133 @@
/**
* @generated SignedSource<<58dd326af2caac72cf50ed8f289a3cac>>
* @lightSyntaxTransform
* @nogrep
*/
/* tslint:disable */
/* eslint-disable */
// @ts-nocheck
import { ConcreteRequest } from 'relay-runtime';
export type DeleteRiskObligationMappingInput = {
obligationId: string;
riskId: string;
};
export type RiskObligationsTabDetachMutation$variables = {
connections: ReadonlyArray<string>;
input: DeleteRiskObligationMappingInput;
};
export type RiskObligationsTabDetachMutation$data = {
readonly deleteRiskObligationMapping: {
readonly deletedObligationId: string;
};
};
export type RiskObligationsTabDetachMutation = {
response: RiskObligationsTabDetachMutation$data;
variables: RiskObligationsTabDetachMutation$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": "deletedObligationId",
"storageKey": null
};
return {
"fragment": {
"argumentDefinitions": [
(v0/*: any*/),
(v1/*: any*/)
],
"kind": "Fragment",
"metadata": null,
"name": "RiskObligationsTabDetachMutation",
"selections": [
{
"alias": null,
"args": (v2/*: any*/),
"concreteType": "DeleteRiskObligationMappingPayload",
"kind": "LinkedField",
"name": "deleteRiskObligationMapping",
"plural": false,
"selections": [
(v3/*: any*/)
],
"storageKey": null
}
],
"type": "Mutation",
"abstractKey": null
},
"kind": "Request",
"operation": {
"argumentDefinitions": [
(v1/*: any*/),
(v0/*: any*/)
],
"kind": "Operation",
"name": "RiskObligationsTabDetachMutation",
"selections": [
{
"alias": null,
"args": (v2/*: any*/),
"concreteType": "DeleteRiskObligationMappingPayload",
"kind": "LinkedField",
"name": "deleteRiskObligationMapping",
"plural": false,
"selections": [
(v3/*: any*/),
{
"alias": null,
"args": null,
"filters": null,
"handle": "deleteEdge",
"key": "",
"kind": "ScalarHandle",
"name": "deletedObligationId",
"handleArgs": [
{
"kind": "Variable",
"name": "connections",
"variableName": "connections"
}
]
}
],
"storageKey": null
}
]
},
"params": {
"cacheID": "97b75f003c5e9518831c9699a2fcaff0",
"id": null,
"metadata": {},
"name": "RiskObligationsTabDetachMutation",
"operationKind": "mutation",
"text": "mutation RiskObligationsTabDetachMutation(\n $input: DeleteRiskObligationMappingInput!\n) {\n deleteRiskObligationMapping(input: $input) {\n deletedObligationId\n }\n}\n"
}
};
})();
(node as any).hash = "5923c7e9bcb08224ba1a60b0ad09642a";
export default node;

View File

@@ -0,0 +1,155 @@
/**
* @generated SignedSource<<1e3d6c1d36e2004b383479fb2e159c66>>
* @lightSyntaxTransform
* @nogrep
*/
/* tslint:disable */
/* eslint-disable */
// @ts-nocheck
import { ReaderFragment } from 'relay-runtime';
import { FragmentRefs } from "relay-runtime";
export type RiskObligationsTabFragment$data = {
readonly id: string;
readonly obligations: {
readonly __id: string;
readonly edges: ReadonlyArray<{
readonly node: {
readonly id: string;
readonly " $fragmentSpreads": FragmentRefs<"LinkedObligationsCardFragment">;
};
}>;
};
readonly " $fragmentType": "RiskObligationsTabFragment";
};
export type RiskObligationsTabFragment$key = {
readonly " $data"?: RiskObligationsTabFragment$data;
readonly " $fragmentSpreads": FragmentRefs<"RiskObligationsTabFragment">;
};
const node: ReaderFragment = (function(){
var v0 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "id",
"storageKey": null
};
return {
"argumentDefinitions": [],
"kind": "Fragment",
"metadata": {
"connection": [
{
"count": null,
"cursor": null,
"direction": "forward",
"path": [
"obligations"
]
}
]
},
"name": "RiskObligationsTabFragment",
"selections": [
(v0/*: any*/),
{
"alias": "obligations",
"args": null,
"concreteType": "ObligationConnection",
"kind": "LinkedField",
"name": "__Risk__obligations_connection",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"concreteType": "ObligationEdge",
"kind": "LinkedField",
"name": "edges",
"plural": true,
"selections": [
{
"alias": null,
"args": null,
"concreteType": "Obligation",
"kind": "LinkedField",
"name": "node",
"plural": false,
"selections": [
(v0/*: any*/),
{
"args": null,
"kind": "FragmentSpread",
"name": "LinkedObligationsCardFragment"
},
{
"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": "endCursor",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "hasNextPage",
"storageKey": null
}
],
"storageKey": null
},
{
"kind": "ClientExtension",
"selections": [
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "__id",
"storageKey": null
}
]
}
],
"storageKey": null
}
],
"type": "Risk",
"abstractKey": null
};
})();
(node as any).hash = "e987e7c6dcfb73b71f769469b32c2b64";
export default node;

View File

@@ -72,6 +72,13 @@ export const riskRoutes = [
() => import("/pages/organizations/risks/tabs/RiskControlsTab.tsx")
),
},
{
path: "obligations",
fallback: LinkCardSkeleton,
Component: lazy(
() => import("/pages/organizations/risks/tabs/RiskObligationsTab.tsx")
),
},
],
},
{