Add compliance registries
Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
251
apps/console/src/hooks/graph/ComplianceRegistryGraph.ts
Normal file
251
apps/console/src/hooks/graph/ComplianceRegistryGraph.ts
Normal file
@@ -0,0 +1,251 @@
|
||||
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 { useMutationWithToasts } from "../useMutationWithToasts";
|
||||
|
||||
export const ComplianceRegistriesConnectionKey = "ComplianceRegistriesPage_complianceRegistries";
|
||||
|
||||
export const complianceRegistriesQuery = graphql`
|
||||
query ComplianceRegistryGraphListQuery($organizationId: ID!) {
|
||||
node(id: $organizationId) {
|
||||
... on Organization {
|
||||
...ComplianceRegistriesPageFragment
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const complianceRegistryNodeQuery = graphql`
|
||||
query ComplianceRegistryGraphNodeQuery($complianceRegistryId: ID!) {
|
||||
node(id: $complianceRegistryId) {
|
||||
... on ComplianceRegistry {
|
||||
id
|
||||
referenceId
|
||||
area
|
||||
source
|
||||
requirement
|
||||
actionsToBeImplemented
|
||||
regulator
|
||||
lastReviewDate
|
||||
dueDate
|
||||
status
|
||||
audit {
|
||||
id
|
||||
name
|
||||
framework {
|
||||
id
|
||||
name
|
||||
}
|
||||
}
|
||||
owner {
|
||||
id
|
||||
fullName
|
||||
}
|
||||
organization {
|
||||
id
|
||||
name
|
||||
}
|
||||
createdAt
|
||||
updatedAt
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const createComplianceRegistryMutation = graphql`
|
||||
mutation ComplianceRegistryGraphCreateMutation(
|
||||
$input: CreateComplianceRegistryInput!
|
||||
$connections: [ID!]!
|
||||
) {
|
||||
createComplianceRegistry(input: $input) {
|
||||
complianceRegistryEdge @prependEdge(connections: $connections) {
|
||||
node {
|
||||
id
|
||||
referenceId
|
||||
area
|
||||
source
|
||||
requirement
|
||||
actionsToBeImplemented
|
||||
regulator
|
||||
lastReviewDate
|
||||
dueDate
|
||||
status
|
||||
audit {
|
||||
id
|
||||
name
|
||||
framework {
|
||||
name
|
||||
}
|
||||
}
|
||||
owner {
|
||||
id
|
||||
fullName
|
||||
}
|
||||
createdAt
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const updateComplianceRegistryMutation = graphql`
|
||||
mutation ComplianceRegistryGraphUpdateMutation($input: UpdateComplianceRegistryInput!) {
|
||||
updateComplianceRegistry(input: $input) {
|
||||
complianceRegistry {
|
||||
id
|
||||
referenceId
|
||||
area
|
||||
source
|
||||
requirement
|
||||
actionsToBeImplemented
|
||||
regulator
|
||||
lastReviewDate
|
||||
dueDate
|
||||
status
|
||||
owner {
|
||||
id
|
||||
fullName
|
||||
}
|
||||
audit {
|
||||
id
|
||||
name
|
||||
framework {
|
||||
id
|
||||
name
|
||||
}
|
||||
}
|
||||
updatedAt
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const deleteComplianceRegistryMutation = graphql`
|
||||
mutation ComplianceRegistryGraphDeleteMutation(
|
||||
$input: DeleteComplianceRegistryInput!
|
||||
$connections: [ID!]!
|
||||
) {
|
||||
deleteComplianceRegistry(input: $input) {
|
||||
deletedComplianceRegistryId @deleteEdge(connections: $connections)
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const useDeleteComplianceRegistry = (
|
||||
registry: { id: string; referenceId: string },
|
||||
connectionId: string
|
||||
) => {
|
||||
const { __ } = useTranslate();
|
||||
const [mutate] = useMutationWithToasts(deleteComplianceRegistryMutation, {
|
||||
successMessage: __("Compliance registry entry deleted successfully"),
|
||||
errorMessage: __("Failed to delete compliance registry entry"),
|
||||
});
|
||||
const confirm = useConfirm();
|
||||
|
||||
return () => {
|
||||
confirm(
|
||||
() =>
|
||||
mutate({
|
||||
variables: {
|
||||
input: {
|
||||
complianceRegistryId: registry.id,
|
||||
},
|
||||
connections: [connectionId],
|
||||
},
|
||||
}),
|
||||
{
|
||||
message: sprintf(
|
||||
__(
|
||||
"This will permanently delete the compliance registry entry %s. This action cannot be undone."
|
||||
),
|
||||
registry.referenceId
|
||||
),
|
||||
}
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
export const useCreateComplianceRegistry = (connectionId: string) => {
|
||||
const [mutate] = useMutation(createComplianceRegistryMutation);
|
||||
const { __ } = useTranslate();
|
||||
|
||||
return (input: {
|
||||
organizationId: string;
|
||||
referenceId: string;
|
||||
area?: string;
|
||||
source?: string;
|
||||
auditId: string;
|
||||
requirement?: string;
|
||||
actionsToBeImplemented?: string;
|
||||
regulator?: string;
|
||||
ownerId: string;
|
||||
lastReviewDate?: string;
|
||||
dueDate?: string;
|
||||
status: string;
|
||||
}) => {
|
||||
if (!input.organizationId) {
|
||||
return alert(__("Failed to create compliance registry entry: organization is required"));
|
||||
}
|
||||
if (!input.referenceId) {
|
||||
return alert(__("Failed to create compliance registry entry: reference ID is required"));
|
||||
}
|
||||
if (!input.auditId) {
|
||||
return alert(__("Failed to create compliance registry entry: audit is required"));
|
||||
}
|
||||
if (!input.ownerId) {
|
||||
return alert(__("Failed to create compliance registry entry: owner is required"));
|
||||
}
|
||||
|
||||
return promisifyMutation(mutate)({
|
||||
variables: {
|
||||
input: {
|
||||
organizationId: input.organizationId,
|
||||
referenceId: input.referenceId,
|
||||
area: input.area,
|
||||
source: input.source,
|
||||
auditId: input.auditId,
|
||||
requirement: input.requirement,
|
||||
actionsToBeImplemented: input.actionsToBeImplemented,
|
||||
regulator: input.regulator,
|
||||
ownerId: input.ownerId,
|
||||
lastReviewDate: input.lastReviewDate,
|
||||
dueDate: input.dueDate,
|
||||
status: input.status || "OPEN",
|
||||
},
|
||||
connections: [connectionId],
|
||||
},
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
export const useUpdateComplianceRegistry = () => {
|
||||
const [mutate] = useMutation(updateComplianceRegistryMutation);
|
||||
const { __ } = useTranslate();
|
||||
|
||||
return (input: {
|
||||
id: string;
|
||||
referenceId?: string;
|
||||
area?: string;
|
||||
source?: string;
|
||||
auditId?: string;
|
||||
requirement?: string;
|
||||
actionsToBeImplemented?: string;
|
||||
regulator?: string;
|
||||
ownerId?: string;
|
||||
lastReviewDate?: string;
|
||||
dueDate?: string;
|
||||
status?: string;
|
||||
}) => {
|
||||
if (!input.id) {
|
||||
return alert(__("Failed to update compliance registry entry: registry ID is required"));
|
||||
}
|
||||
|
||||
return promisifyMutation(mutate)({
|
||||
variables: {
|
||||
input,
|
||||
},
|
||||
});
|
||||
};
|
||||
};
|
||||
382
apps/console/src/hooks/graph/__generated__/ComplianceRegistryGraphCreateMutation.graphql.ts
generated
Normal file
382
apps/console/src/hooks/graph/__generated__/ComplianceRegistryGraphCreateMutation.graphql.ts
generated
Normal file
@@ -0,0 +1,382 @@
|
||||
/**
|
||||
* @generated SignedSource<<a3f34af85b45563725a110a4e6b6cbfb>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @ts-nocheck
|
||||
|
||||
import { ConcreteRequest } from 'relay-runtime';
|
||||
export type ComplianceRegistryStatus = "CLOSED" | "IN_PROGRESS" | "OPEN";
|
||||
export type CreateComplianceRegistryInput = {
|
||||
actionsToBeImplemented?: string | null | undefined;
|
||||
area?: string | null | undefined;
|
||||
auditId: string;
|
||||
dueDate?: any | null | undefined;
|
||||
lastReviewDate?: any | null | undefined;
|
||||
organizationId: string;
|
||||
ownerId: string;
|
||||
referenceId: string;
|
||||
regulator?: string | null | undefined;
|
||||
requirement?: string | null | undefined;
|
||||
source?: string | null | undefined;
|
||||
status: ComplianceRegistryStatus;
|
||||
};
|
||||
export type ComplianceRegistryGraphCreateMutation$variables = {
|
||||
connections: ReadonlyArray<string>;
|
||||
input: CreateComplianceRegistryInput;
|
||||
};
|
||||
export type ComplianceRegistryGraphCreateMutation$data = {
|
||||
readonly createComplianceRegistry: {
|
||||
readonly complianceRegistryEdge: {
|
||||
readonly node: {
|
||||
readonly actionsToBeImplemented: string | null | undefined;
|
||||
readonly area: string | null | undefined;
|
||||
readonly audit: {
|
||||
readonly framework: {
|
||||
readonly name: string;
|
||||
};
|
||||
readonly id: string;
|
||||
readonly name: string | null | undefined;
|
||||
};
|
||||
readonly createdAt: any;
|
||||
readonly dueDate: any | null | undefined;
|
||||
readonly id: string;
|
||||
readonly lastReviewDate: any | null | undefined;
|
||||
readonly owner: {
|
||||
readonly fullName: string;
|
||||
readonly id: string;
|
||||
};
|
||||
readonly referenceId: string;
|
||||
readonly regulator: string | null | undefined;
|
||||
readonly requirement: string | null | undefined;
|
||||
readonly source: string | null | undefined;
|
||||
readonly status: ComplianceRegistryStatus;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
export type ComplianceRegistryGraphCreateMutation = {
|
||||
response: ComplianceRegistryGraphCreateMutation$data;
|
||||
variables: ComplianceRegistryGraphCreateMutation$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
|
||||
},
|
||||
v4 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "referenceId",
|
||||
"storageKey": null
|
||||
},
|
||||
v5 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "area",
|
||||
"storageKey": null
|
||||
},
|
||||
v6 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "source",
|
||||
"storageKey": null
|
||||
},
|
||||
v7 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "requirement",
|
||||
"storageKey": null
|
||||
},
|
||||
v8 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "actionsToBeImplemented",
|
||||
"storageKey": null
|
||||
},
|
||||
v9 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "regulator",
|
||||
"storageKey": null
|
||||
},
|
||||
v10 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "lastReviewDate",
|
||||
"storageKey": null
|
||||
},
|
||||
v11 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "dueDate",
|
||||
"storageKey": null
|
||||
},
|
||||
v12 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "status",
|
||||
"storageKey": null
|
||||
},
|
||||
v13 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "name",
|
||||
"storageKey": null
|
||||
},
|
||||
v14 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "People",
|
||||
"kind": "LinkedField",
|
||||
"name": "owner",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v3/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "fullName",
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
},
|
||||
v15 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "createdAt",
|
||||
"storageKey": null
|
||||
};
|
||||
return {
|
||||
"fragment": {
|
||||
"argumentDefinitions": [
|
||||
(v0/*: any*/),
|
||||
(v1/*: any*/)
|
||||
],
|
||||
"kind": "Fragment",
|
||||
"metadata": null,
|
||||
"name": "ComplianceRegistryGraphCreateMutation",
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": (v2/*: any*/),
|
||||
"concreteType": "CreateComplianceRegistryPayload",
|
||||
"kind": "LinkedField",
|
||||
"name": "createComplianceRegistry",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "ComplianceRegistryEdge",
|
||||
"kind": "LinkedField",
|
||||
"name": "complianceRegistryEdge",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "ComplianceRegistry",
|
||||
"kind": "LinkedField",
|
||||
"name": "node",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v3/*: any*/),
|
||||
(v4/*: any*/),
|
||||
(v5/*: any*/),
|
||||
(v6/*: any*/),
|
||||
(v7/*: any*/),
|
||||
(v8/*: any*/),
|
||||
(v9/*: any*/),
|
||||
(v10/*: any*/),
|
||||
(v11/*: any*/),
|
||||
(v12/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "Audit",
|
||||
"kind": "LinkedField",
|
||||
"name": "audit",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v3/*: any*/),
|
||||
(v13/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "Framework",
|
||||
"kind": "LinkedField",
|
||||
"name": "framework",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v13/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
},
|
||||
(v14/*: any*/),
|
||||
(v15/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"type": "Mutation",
|
||||
"abstractKey": null
|
||||
},
|
||||
"kind": "Request",
|
||||
"operation": {
|
||||
"argumentDefinitions": [
|
||||
(v1/*: any*/),
|
||||
(v0/*: any*/)
|
||||
],
|
||||
"kind": "Operation",
|
||||
"name": "ComplianceRegistryGraphCreateMutation",
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": (v2/*: any*/),
|
||||
"concreteType": "CreateComplianceRegistryPayload",
|
||||
"kind": "LinkedField",
|
||||
"name": "createComplianceRegistry",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "ComplianceRegistryEdge",
|
||||
"kind": "LinkedField",
|
||||
"name": "complianceRegistryEdge",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "ComplianceRegistry",
|
||||
"kind": "LinkedField",
|
||||
"name": "node",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v3/*: any*/),
|
||||
(v4/*: any*/),
|
||||
(v5/*: any*/),
|
||||
(v6/*: any*/),
|
||||
(v7/*: any*/),
|
||||
(v8/*: any*/),
|
||||
(v9/*: any*/),
|
||||
(v10/*: any*/),
|
||||
(v11/*: any*/),
|
||||
(v12/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "Audit",
|
||||
"kind": "LinkedField",
|
||||
"name": "audit",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v3/*: any*/),
|
||||
(v13/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "Framework",
|
||||
"kind": "LinkedField",
|
||||
"name": "framework",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v13/*: any*/),
|
||||
(v3/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
},
|
||||
(v14/*: any*/),
|
||||
(v15/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"filters": null,
|
||||
"handle": "prependEdge",
|
||||
"key": "",
|
||||
"kind": "LinkedHandle",
|
||||
"name": "complianceRegistryEdge",
|
||||
"handleArgs": [
|
||||
{
|
||||
"kind": "Variable",
|
||||
"name": "connections",
|
||||
"variableName": "connections"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "68c793eb099ce3e917992b3f8c22d551",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "ComplianceRegistryGraphCreateMutation",
|
||||
"operationKind": "mutation",
|
||||
"text": "mutation ComplianceRegistryGraphCreateMutation(\n $input: CreateComplianceRegistryInput!\n) {\n createComplianceRegistry(input: $input) {\n complianceRegistryEdge {\n node {\n id\n referenceId\n area\n source\n requirement\n actionsToBeImplemented\n regulator\n lastReviewDate\n dueDate\n status\n audit {\n id\n name\n framework {\n name\n id\n }\n }\n owner {\n id\n fullName\n }\n createdAt\n }\n }\n }\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
(node as any).hash = "50e1966d2f9cc1ed347a77f8f024125c";
|
||||
|
||||
export default node;
|
||||
132
apps/console/src/hooks/graph/__generated__/ComplianceRegistryGraphDeleteMutation.graphql.ts
generated
Normal file
132
apps/console/src/hooks/graph/__generated__/ComplianceRegistryGraphDeleteMutation.graphql.ts
generated
Normal file
@@ -0,0 +1,132 @@
|
||||
/**
|
||||
* @generated SignedSource<<0d815d748a76df90cc5305fa28913125>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @ts-nocheck
|
||||
|
||||
import { ConcreteRequest } from 'relay-runtime';
|
||||
export type DeleteComplianceRegistryInput = {
|
||||
complianceRegistryId: string;
|
||||
};
|
||||
export type ComplianceRegistryGraphDeleteMutation$variables = {
|
||||
connections: ReadonlyArray<string>;
|
||||
input: DeleteComplianceRegistryInput;
|
||||
};
|
||||
export type ComplianceRegistryGraphDeleteMutation$data = {
|
||||
readonly deleteComplianceRegistry: {
|
||||
readonly deletedComplianceRegistryId: string;
|
||||
};
|
||||
};
|
||||
export type ComplianceRegistryGraphDeleteMutation = {
|
||||
response: ComplianceRegistryGraphDeleteMutation$data;
|
||||
variables: ComplianceRegistryGraphDeleteMutation$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": "deletedComplianceRegistryId",
|
||||
"storageKey": null
|
||||
};
|
||||
return {
|
||||
"fragment": {
|
||||
"argumentDefinitions": [
|
||||
(v0/*: any*/),
|
||||
(v1/*: any*/)
|
||||
],
|
||||
"kind": "Fragment",
|
||||
"metadata": null,
|
||||
"name": "ComplianceRegistryGraphDeleteMutation",
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": (v2/*: any*/),
|
||||
"concreteType": "DeleteComplianceRegistryPayload",
|
||||
"kind": "LinkedField",
|
||||
"name": "deleteComplianceRegistry",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v3/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"type": "Mutation",
|
||||
"abstractKey": null
|
||||
},
|
||||
"kind": "Request",
|
||||
"operation": {
|
||||
"argumentDefinitions": [
|
||||
(v1/*: any*/),
|
||||
(v0/*: any*/)
|
||||
],
|
||||
"kind": "Operation",
|
||||
"name": "ComplianceRegistryGraphDeleteMutation",
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": (v2/*: any*/),
|
||||
"concreteType": "DeleteComplianceRegistryPayload",
|
||||
"kind": "LinkedField",
|
||||
"name": "deleteComplianceRegistry",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v3/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"filters": null,
|
||||
"handle": "deleteEdge",
|
||||
"key": "",
|
||||
"kind": "ScalarHandle",
|
||||
"name": "deletedComplianceRegistryId",
|
||||
"handleArgs": [
|
||||
{
|
||||
"kind": "Variable",
|
||||
"name": "connections",
|
||||
"variableName": "connections"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "4ee4b9ffa6ea477c93a0ba80b8295a44",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "ComplianceRegistryGraphDeleteMutation",
|
||||
"operationKind": "mutation",
|
||||
"text": "mutation ComplianceRegistryGraphDeleteMutation(\n $input: DeleteComplianceRegistryInput!\n) {\n deleteComplianceRegistry(input: $input) {\n deletedComplianceRegistryId\n }\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
(node as any).hash = "c979ce19185e3d4c20c8a952b5245993";
|
||||
|
||||
export default node;
|
||||
361
apps/console/src/hooks/graph/__generated__/ComplianceRegistryGraphListQuery.graphql.ts
generated
Normal file
361
apps/console/src/hooks/graph/__generated__/ComplianceRegistryGraphListQuery.graphql.ts
generated
Normal file
@@ -0,0 +1,361 @@
|
||||
/**
|
||||
* @generated SignedSource<<8e9c859e7b87a623664e1bd16c620ef1>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @ts-nocheck
|
||||
|
||||
import { ConcreteRequest } from 'relay-runtime';
|
||||
import { FragmentRefs } from "relay-runtime";
|
||||
export type ComplianceRegistryGraphListQuery$variables = {
|
||||
organizationId: string;
|
||||
};
|
||||
export type ComplianceRegistryGraphListQuery$data = {
|
||||
readonly node: {
|
||||
readonly " $fragmentSpreads": FragmentRefs<"ComplianceRegistriesPageFragment">;
|
||||
};
|
||||
};
|
||||
export type ComplianceRegistryGraphListQuery = {
|
||||
response: ComplianceRegistryGraphListQuery$data;
|
||||
variables: ComplianceRegistryGraphListQuery$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": "__typename",
|
||||
"storageKey": null
|
||||
},
|
||||
v3 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "id",
|
||||
"storageKey": null
|
||||
},
|
||||
v4 = [
|
||||
{
|
||||
"kind": "Literal",
|
||||
"name": "first",
|
||||
"value": 10
|
||||
}
|
||||
],
|
||||
v5 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "name",
|
||||
"storageKey": null
|
||||
};
|
||||
return {
|
||||
"fragment": {
|
||||
"argumentDefinitions": (v0/*: any*/),
|
||||
"kind": "Fragment",
|
||||
"metadata": null,
|
||||
"name": "ComplianceRegistryGraphListQuery",
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": (v1/*: any*/),
|
||||
"concreteType": null,
|
||||
"kind": "LinkedField",
|
||||
"name": "node",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"kind": "InlineFragment",
|
||||
"selections": [
|
||||
{
|
||||
"args": null,
|
||||
"kind": "FragmentSpread",
|
||||
"name": "ComplianceRegistriesPageFragment"
|
||||
}
|
||||
],
|
||||
"type": "Organization",
|
||||
"abstractKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"type": "Query",
|
||||
"abstractKey": null
|
||||
},
|
||||
"kind": "Request",
|
||||
"operation": {
|
||||
"argumentDefinitions": (v0/*: any*/),
|
||||
"kind": "Operation",
|
||||
"name": "ComplianceRegistryGraphListQuery",
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": (v1/*: any*/),
|
||||
"concreteType": null,
|
||||
"kind": "LinkedField",
|
||||
"name": "node",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v2/*: any*/),
|
||||
(v3/*: any*/),
|
||||
{
|
||||
"kind": "InlineFragment",
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": (v4/*: any*/),
|
||||
"concreteType": "ComplianceRegistryConnection",
|
||||
"kind": "LinkedField",
|
||||
"name": "complianceRegistries",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "totalCount",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "ComplianceRegistryEdge",
|
||||
"kind": "LinkedField",
|
||||
"name": "edges",
|
||||
"plural": true,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "ComplianceRegistry",
|
||||
"kind": "LinkedField",
|
||||
"name": "node",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v3/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "referenceId",
|
||||
"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": "requirement",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "status",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "lastReviewDate",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "dueDate",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "actionsToBeImplemented",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "regulator",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "Audit",
|
||||
"kind": "LinkedField",
|
||||
"name": "audit",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v3/*: any*/),
|
||||
(v5/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "Framework",
|
||||
"kind": "LinkedField",
|
||||
"name": "framework",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v3/*: any*/),
|
||||
(v5/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "People",
|
||||
"kind": "LinkedField",
|
||||
"name": "owner",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v3/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "fullName",
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "createdAt",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "updatedAt",
|
||||
"storageKey": null
|
||||
},
|
||||
(v2/*: 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": "endCursor",
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"kind": "ClientExtension",
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "__id",
|
||||
"storageKey": null
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"storageKey": "complianceRegistries(first:10)"
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": (v4/*: any*/),
|
||||
"filters": null,
|
||||
"handle": "connection",
|
||||
"key": "ComplianceRegistriesPage_complianceRegistries",
|
||||
"kind": "LinkedHandle",
|
||||
"name": "complianceRegistries"
|
||||
}
|
||||
],
|
||||
"type": "Organization",
|
||||
"abstractKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "bec30edcb0f8d7c4147e827c422d524f",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "ComplianceRegistryGraphListQuery",
|
||||
"operationKind": "query",
|
||||
"text": "query ComplianceRegistryGraphListQuery(\n $organizationId: ID!\n) {\n node(id: $organizationId) {\n __typename\n ... on Organization {\n ...ComplianceRegistriesPageFragment\n }\n id\n }\n}\n\nfragment ComplianceRegistriesPageFragment on Organization {\n id\n complianceRegistries(first: 10) {\n totalCount\n edges {\n node {\n id\n referenceId\n area\n source\n requirement\n status\n lastReviewDate\n dueDate\n actionsToBeImplemented\n regulator\n audit {\n id\n name\n framework {\n id\n name\n }\n }\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 = "363434c78eb3e27ac52b6da13c7432a1";
|
||||
|
||||
export default node;
|
||||
320
apps/console/src/hooks/graph/__generated__/ComplianceRegistryGraphNodeQuery.graphql.ts
generated
Normal file
320
apps/console/src/hooks/graph/__generated__/ComplianceRegistryGraphNodeQuery.graphql.ts
generated
Normal file
@@ -0,0 +1,320 @@
|
||||
/**
|
||||
* @generated SignedSource<<14a59a4b5703ae1fb885b70ff8c8d479>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @ts-nocheck
|
||||
|
||||
import { ConcreteRequest } from 'relay-runtime';
|
||||
export type ComplianceRegistryStatus = "CLOSED" | "IN_PROGRESS" | "OPEN";
|
||||
export type ComplianceRegistryGraphNodeQuery$variables = {
|
||||
complianceRegistryId: string;
|
||||
};
|
||||
export type ComplianceRegistryGraphNodeQuery$data = {
|
||||
readonly node: {
|
||||
readonly actionsToBeImplemented?: string | null | undefined;
|
||||
readonly area?: string | null | undefined;
|
||||
readonly audit?: {
|
||||
readonly framework: {
|
||||
readonly id: string;
|
||||
readonly name: string;
|
||||
};
|
||||
readonly id: string;
|
||||
readonly name: string | null | undefined;
|
||||
};
|
||||
readonly createdAt?: any;
|
||||
readonly dueDate?: any | null | undefined;
|
||||
readonly id?: string;
|
||||
readonly lastReviewDate?: any | null | undefined;
|
||||
readonly organization?: {
|
||||
readonly id: string;
|
||||
readonly name: string;
|
||||
};
|
||||
readonly owner?: {
|
||||
readonly fullName: string;
|
||||
readonly id: string;
|
||||
};
|
||||
readonly referenceId?: string;
|
||||
readonly regulator?: string | null | undefined;
|
||||
readonly requirement?: string | null | undefined;
|
||||
readonly source?: string | null | undefined;
|
||||
readonly status?: ComplianceRegistryStatus;
|
||||
readonly updatedAt?: any;
|
||||
};
|
||||
};
|
||||
export type ComplianceRegistryGraphNodeQuery = {
|
||||
response: ComplianceRegistryGraphNodeQuery$data;
|
||||
variables: ComplianceRegistryGraphNodeQuery$variables;
|
||||
};
|
||||
|
||||
const node: ConcreteRequest = (function(){
|
||||
var v0 = [
|
||||
{
|
||||
"defaultValue": null,
|
||||
"kind": "LocalArgument",
|
||||
"name": "complianceRegistryId"
|
||||
}
|
||||
],
|
||||
v1 = [
|
||||
{
|
||||
"kind": "Variable",
|
||||
"name": "id",
|
||||
"variableName": "complianceRegistryId"
|
||||
}
|
||||
],
|
||||
v2 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "id",
|
||||
"storageKey": null
|
||||
},
|
||||
v3 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "referenceId",
|
||||
"storageKey": null
|
||||
},
|
||||
v4 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "area",
|
||||
"storageKey": null
|
||||
},
|
||||
v5 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "source",
|
||||
"storageKey": null
|
||||
},
|
||||
v6 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "requirement",
|
||||
"storageKey": null
|
||||
},
|
||||
v7 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "actionsToBeImplemented",
|
||||
"storageKey": null
|
||||
},
|
||||
v8 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "regulator",
|
||||
"storageKey": null
|
||||
},
|
||||
v9 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "lastReviewDate",
|
||||
"storageKey": null
|
||||
},
|
||||
v10 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "dueDate",
|
||||
"storageKey": null
|
||||
},
|
||||
v11 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "status",
|
||||
"storageKey": null
|
||||
},
|
||||
v12 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "name",
|
||||
"storageKey": null
|
||||
},
|
||||
v13 = [
|
||||
(v2/*: any*/),
|
||||
(v12/*: any*/)
|
||||
],
|
||||
v14 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "Audit",
|
||||
"kind": "LinkedField",
|
||||
"name": "audit",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v2/*: any*/),
|
||||
(v12/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "Framework",
|
||||
"kind": "LinkedField",
|
||||
"name": "framework",
|
||||
"plural": false,
|
||||
"selections": (v13/*: any*/),
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
},
|
||||
v15 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "People",
|
||||
"kind": "LinkedField",
|
||||
"name": "owner",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v2/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "fullName",
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
},
|
||||
v16 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "Organization",
|
||||
"kind": "LinkedField",
|
||||
"name": "organization",
|
||||
"plural": false,
|
||||
"selections": (v13/*: any*/),
|
||||
"storageKey": null
|
||||
},
|
||||
v17 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "createdAt",
|
||||
"storageKey": null
|
||||
},
|
||||
v18 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "updatedAt",
|
||||
"storageKey": null
|
||||
};
|
||||
return {
|
||||
"fragment": {
|
||||
"argumentDefinitions": (v0/*: any*/),
|
||||
"kind": "Fragment",
|
||||
"metadata": null,
|
||||
"name": "ComplianceRegistryGraphNodeQuery",
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": (v1/*: any*/),
|
||||
"concreteType": null,
|
||||
"kind": "LinkedField",
|
||||
"name": "node",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"kind": "InlineFragment",
|
||||
"selections": [
|
||||
(v2/*: any*/),
|
||||
(v3/*: any*/),
|
||||
(v4/*: any*/),
|
||||
(v5/*: any*/),
|
||||
(v6/*: any*/),
|
||||
(v7/*: any*/),
|
||||
(v8/*: any*/),
|
||||
(v9/*: any*/),
|
||||
(v10/*: any*/),
|
||||
(v11/*: any*/),
|
||||
(v14/*: any*/),
|
||||
(v15/*: any*/),
|
||||
(v16/*: any*/),
|
||||
(v17/*: any*/),
|
||||
(v18/*: any*/)
|
||||
],
|
||||
"type": "ComplianceRegistry",
|
||||
"abstractKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"type": "Query",
|
||||
"abstractKey": null
|
||||
},
|
||||
"kind": "Request",
|
||||
"operation": {
|
||||
"argumentDefinitions": (v0/*: any*/),
|
||||
"kind": "Operation",
|
||||
"name": "ComplianceRegistryGraphNodeQuery",
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": (v1/*: any*/),
|
||||
"concreteType": null,
|
||||
"kind": "LinkedField",
|
||||
"name": "node",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "__typename",
|
||||
"storageKey": null
|
||||
},
|
||||
(v2/*: any*/),
|
||||
{
|
||||
"kind": "InlineFragment",
|
||||
"selections": [
|
||||
(v3/*: any*/),
|
||||
(v4/*: any*/),
|
||||
(v5/*: any*/),
|
||||
(v6/*: any*/),
|
||||
(v7/*: any*/),
|
||||
(v8/*: any*/),
|
||||
(v9/*: any*/),
|
||||
(v10/*: any*/),
|
||||
(v11/*: any*/),
|
||||
(v14/*: any*/),
|
||||
(v15/*: any*/),
|
||||
(v16/*: any*/),
|
||||
(v17/*: any*/),
|
||||
(v18/*: any*/)
|
||||
],
|
||||
"type": "ComplianceRegistry",
|
||||
"abstractKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "bb1bf89e0916abe7f9807404aa2cf9eb",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "ComplianceRegistryGraphNodeQuery",
|
||||
"operationKind": "query",
|
||||
"text": "query ComplianceRegistryGraphNodeQuery(\n $complianceRegistryId: ID!\n) {\n node(id: $complianceRegistryId) {\n __typename\n ... on ComplianceRegistry {\n id\n referenceId\n area\n source\n requirement\n actionsToBeImplemented\n regulator\n lastReviewDate\n dueDate\n status\n audit {\n id\n name\n framework {\n id\n name\n }\n }\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 = "292fb8d0ee375d8c5e34cbf2633b7f77";
|
||||
|
||||
export default node;
|
||||
262
apps/console/src/hooks/graph/__generated__/ComplianceRegistryGraphUpdateMutation.graphql.ts
generated
Normal file
262
apps/console/src/hooks/graph/__generated__/ComplianceRegistryGraphUpdateMutation.graphql.ts
generated
Normal file
@@ -0,0 +1,262 @@
|
||||
/**
|
||||
* @generated SignedSource<<e0af427b5ec1a1056bee3859d5c06a8a>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @ts-nocheck
|
||||
|
||||
import { ConcreteRequest } from 'relay-runtime';
|
||||
export type ComplianceRegistryStatus = "CLOSED" | "IN_PROGRESS" | "OPEN";
|
||||
export type UpdateComplianceRegistryInput = {
|
||||
actionsToBeImplemented?: string | null | undefined;
|
||||
area?: string | null | undefined;
|
||||
auditId?: string | null | undefined;
|
||||
dueDate?: any | null | undefined;
|
||||
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;
|
||||
status?: ComplianceRegistryStatus | null | undefined;
|
||||
};
|
||||
export type ComplianceRegistryGraphUpdateMutation$variables = {
|
||||
input: UpdateComplianceRegistryInput;
|
||||
};
|
||||
export type ComplianceRegistryGraphUpdateMutation$data = {
|
||||
readonly updateComplianceRegistry: {
|
||||
readonly complianceRegistry: {
|
||||
readonly actionsToBeImplemented: string | null | undefined;
|
||||
readonly area: string | null | undefined;
|
||||
readonly audit: {
|
||||
readonly framework: {
|
||||
readonly id: string;
|
||||
readonly name: string;
|
||||
};
|
||||
readonly id: string;
|
||||
readonly name: string | null | undefined;
|
||||
};
|
||||
readonly dueDate: any | null | undefined;
|
||||
readonly id: string;
|
||||
readonly lastReviewDate: any | null | undefined;
|
||||
readonly owner: {
|
||||
readonly fullName: string;
|
||||
readonly id: string;
|
||||
};
|
||||
readonly referenceId: string;
|
||||
readonly regulator: string | null | undefined;
|
||||
readonly requirement: string | null | undefined;
|
||||
readonly source: string | null | undefined;
|
||||
readonly status: ComplianceRegistryStatus;
|
||||
readonly updatedAt: any;
|
||||
};
|
||||
};
|
||||
};
|
||||
export type ComplianceRegistryGraphUpdateMutation = {
|
||||
response: ComplianceRegistryGraphUpdateMutation$data;
|
||||
variables: ComplianceRegistryGraphUpdateMutation$variables;
|
||||
};
|
||||
|
||||
const node: ConcreteRequest = (function(){
|
||||
var v0 = [
|
||||
{
|
||||
"defaultValue": null,
|
||||
"kind": "LocalArgument",
|
||||
"name": "input"
|
||||
}
|
||||
],
|
||||
v1 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "id",
|
||||
"storageKey": null
|
||||
},
|
||||
v2 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "name",
|
||||
"storageKey": null
|
||||
},
|
||||
v3 = [
|
||||
{
|
||||
"alias": null,
|
||||
"args": [
|
||||
{
|
||||
"kind": "Variable",
|
||||
"name": "input",
|
||||
"variableName": "input"
|
||||
}
|
||||
],
|
||||
"concreteType": "UpdateComplianceRegistryPayload",
|
||||
"kind": "LinkedField",
|
||||
"name": "updateComplianceRegistry",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "ComplianceRegistry",
|
||||
"kind": "LinkedField",
|
||||
"name": "complianceRegistry",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v1/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "referenceId",
|
||||
"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": "requirement",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "actionsToBeImplemented",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "regulator",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "lastReviewDate",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "dueDate",
|
||||
"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": [
|
||||
(v1/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "fullName",
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "Audit",
|
||||
"kind": "LinkedField",
|
||||
"name": "audit",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v1/*: any*/),
|
||||
(v2/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "Framework",
|
||||
"kind": "LinkedField",
|
||||
"name": "framework",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v1/*: any*/),
|
||||
(v2/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "updatedAt",
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
];
|
||||
return {
|
||||
"fragment": {
|
||||
"argumentDefinitions": (v0/*: any*/),
|
||||
"kind": "Fragment",
|
||||
"metadata": null,
|
||||
"name": "ComplianceRegistryGraphUpdateMutation",
|
||||
"selections": (v3/*: any*/),
|
||||
"type": "Mutation",
|
||||
"abstractKey": null
|
||||
},
|
||||
"kind": "Request",
|
||||
"operation": {
|
||||
"argumentDefinitions": (v0/*: any*/),
|
||||
"kind": "Operation",
|
||||
"name": "ComplianceRegistryGraphUpdateMutation",
|
||||
"selections": (v3/*: any*/)
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "4a4f7e9273f36c87a7e48b5373f69bc2",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "ComplianceRegistryGraphUpdateMutation",
|
||||
"operationKind": "mutation",
|
||||
"text": "mutation ComplianceRegistryGraphUpdateMutation(\n $input: UpdateComplianceRegistryInput!\n) {\n updateComplianceRegistry(input: $input) {\n complianceRegistry {\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 audit {\n id\n name\n framework {\n id\n name\n }\n }\n updatedAt\n }\n }\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
(node as any).hash = "c4d17f11888dd8a4769b471797c25b95";
|
||||
|
||||
export default node;
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
IconBank,
|
||||
IconBook,
|
||||
IconCircleQuestionmark,
|
||||
IconCrossLargeX,
|
||||
IconFire3,
|
||||
IconGroup1,
|
||||
IconInboxEmpty,
|
||||
@@ -141,9 +142,14 @@ export function MainLayout() {
|
||||
/>
|
||||
<SidebarItem
|
||||
label={__("Nonconformity Registries")}
|
||||
icon={IconBook}
|
||||
icon={IconCrossLargeX}
|
||||
to={`${prefix}/nonconformityRegistries`}
|
||||
/>
|
||||
<SidebarItem
|
||||
label={__("Compliance Registries")}
|
||||
icon={IconBook}
|
||||
to={`${prefix}/complianceRegistries`}
|
||||
/>
|
||||
<SidebarItem
|
||||
label={__("Trust Center")}
|
||||
icon={IconShield}
|
||||
|
||||
@@ -0,0 +1,264 @@
|
||||
import {
|
||||
Button,
|
||||
IconPlusLarge,
|
||||
PageHeader,
|
||||
Card,
|
||||
Thead,
|
||||
Tbody,
|
||||
Tr,
|
||||
Th,
|
||||
Td,
|
||||
Badge,
|
||||
ActionDropdown,
|
||||
DropdownItem,
|
||||
IconTrashCan,
|
||||
Table,
|
||||
useConfirm,
|
||||
} from "@probo/ui";
|
||||
import { useTranslate } from "@probo/i18n";
|
||||
import { usePageTitle } from "@probo/hooks";
|
||||
import {
|
||||
graphql,
|
||||
usePaginationFragment,
|
||||
usePreloadedQuery,
|
||||
useMutation,
|
||||
type PreloadedQuery,
|
||||
} from "react-relay";
|
||||
import { useOrganizationId } from "/hooks/useOrganizationId";
|
||||
import { CreateComplianceRegistryDialog } from "./dialogs/CreateComplianceRegistryDialog";
|
||||
import { deleteComplianceRegistryMutation } from "../../../hooks/graph/ComplianceRegistryGraph";
|
||||
import { sprintf, promisifyMutation, getStatusVariant, getStatusLabel } from "@probo/helpers";
|
||||
import type { ComplianceRegistriesPageQuery } from "./__generated__/ComplianceRegistriesPageQuery.graphql";
|
||||
import type {
|
||||
ComplianceRegistriesPageFragment$key,
|
||||
ComplianceRegistriesPageFragment$data,
|
||||
} from "./__generated__/ComplianceRegistriesPageFragment.graphql";
|
||||
|
||||
type ComplianceRegistry = ComplianceRegistriesPageFragment$data['complianceRegistries']['edges'][number]['node'];
|
||||
|
||||
interface ComplianceRegistriesPageProps {
|
||||
queryRef: PreloadedQuery<ComplianceRegistriesPageQuery>;
|
||||
}
|
||||
|
||||
const complianceRegistriesPageFragment = graphql`
|
||||
fragment ComplianceRegistriesPageFragment on Organization
|
||||
@refetchable(queryName: "ComplianceRegistriesPageRefetchQuery")
|
||||
@argumentDefinitions(
|
||||
first: { type: "Int", defaultValue: 10 }
|
||||
after: { type: "CursorKey" }
|
||||
) {
|
||||
id
|
||||
complianceRegistries(first: $first, after: $after)
|
||||
@connection(key: "ComplianceRegistriesPage_complianceRegistries") {
|
||||
__id
|
||||
totalCount
|
||||
edges {
|
||||
node {
|
||||
id
|
||||
referenceId
|
||||
area
|
||||
source
|
||||
requirement
|
||||
status
|
||||
lastReviewDate
|
||||
dueDate
|
||||
actionsToBeImplemented
|
||||
regulator
|
||||
audit {
|
||||
id
|
||||
name
|
||||
framework {
|
||||
id
|
||||
name
|
||||
}
|
||||
}
|
||||
owner {
|
||||
id
|
||||
fullName
|
||||
}
|
||||
createdAt
|
||||
updatedAt
|
||||
}
|
||||
}
|
||||
pageInfo {
|
||||
hasNextPage
|
||||
endCursor
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export default function ComplianceRegistriesPage({ queryRef }: ComplianceRegistriesPageProps) {
|
||||
const { __ } = useTranslate();
|
||||
const organizationId = useOrganizationId();
|
||||
|
||||
usePageTitle(__("Compliance Registries"));
|
||||
|
||||
const organization = usePreloadedQuery(
|
||||
graphql`
|
||||
query ComplianceRegistriesPageQuery($organizationId: ID!) {
|
||||
node(id: $organizationId) {
|
||||
... on Organization {
|
||||
...ComplianceRegistriesPageFragment
|
||||
}
|
||||
}
|
||||
}
|
||||
`,
|
||||
queryRef
|
||||
);
|
||||
|
||||
const { data: registriesData, loadNext, hasNext } = usePaginationFragment(
|
||||
complianceRegistriesPageFragment,
|
||||
organization.node as ComplianceRegistriesPageFragment$key
|
||||
);
|
||||
|
||||
const connectionId = registriesData?.complianceRegistries?.__id || "";
|
||||
const registries: ComplianceRegistry[] = registriesData?.complianceRegistries?.edges?.map((edge) => edge.node) ?? [];
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<PageHeader
|
||||
title={__("Compliance Registries")}
|
||||
description={__(
|
||||
"Manage your organization's compliance registry entries."
|
||||
)}
|
||||
>
|
||||
<CreateComplianceRegistryDialog organizationId={organizationId} connection={connectionId}>
|
||||
<Button icon={IconPlusLarge}>{__("Add compliance registry")}</Button>
|
||||
</CreateComplianceRegistryDialog>
|
||||
</PageHeader>
|
||||
|
||||
{registries.length === 0 ? (
|
||||
<Card padded>
|
||||
<div className="text-center py-12">
|
||||
<h3 className="text-lg font-semibold mb-2">
|
||||
{__("No compliance registry entries yet")}
|
||||
</h3>
|
||||
<p className="text-txt-tertiary mb-4">
|
||||
{__("Create your first compliance registry entry to get started.")}
|
||||
</p>
|
||||
</div>
|
||||
</Card>
|
||||
) : (
|
||||
<Card>
|
||||
<Table>
|
||||
<Thead>
|
||||
<Tr>
|
||||
<Th>{__("Reference ID")}</Th>
|
||||
<Th>{__("Area")}</Th>
|
||||
<Th>{__("Source")}</Th>
|
||||
<Th>{__("Status")}</Th>
|
||||
<Th>{__("Audit")}</Th>
|
||||
<Th>{__("Owner")}</Th>
|
||||
<Th>{__("Due Date")}</Th>
|
||||
<Th>{__("Actions")}</Th>
|
||||
</Tr>
|
||||
</Thead>
|
||||
<Tbody>
|
||||
{registries.map((registry) => (
|
||||
<RegistryRow
|
||||
key={registry.id}
|
||||
registry={registry}
|
||||
connectionId={connectionId}
|
||||
/>
|
||||
))}
|
||||
</Tbody>
|
||||
</Table>
|
||||
|
||||
{hasNext && (
|
||||
<div className="p-4 border-t">
|
||||
<Button
|
||||
variant="secondary"
|
||||
onClick={() => loadNext(10)}
|
||||
disabled={!hasNext}
|
||||
>
|
||||
{__("Load more")}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</Card>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function RegistryRow({
|
||||
registry,
|
||||
connectionId,
|
||||
}: {
|
||||
registry: ComplianceRegistry;
|
||||
connectionId: string;
|
||||
}) {
|
||||
const organizationId = useOrganizationId();
|
||||
const { __ } = useTranslate();
|
||||
const [deleteRegistry] = useMutation(deleteComplianceRegistryMutation);
|
||||
const confirm = useConfirm();
|
||||
|
||||
const formatDate = (dateString: string) => {
|
||||
return new Date(dateString).toLocaleDateString();
|
||||
};
|
||||
|
||||
const handleDelete = () => {
|
||||
confirm(
|
||||
() =>
|
||||
promisifyMutation(deleteRegistry)({
|
||||
variables: {
|
||||
input: {
|
||||
complianceRegistryId: registry.id,
|
||||
},
|
||||
connections: [connectionId],
|
||||
},
|
||||
}),
|
||||
{
|
||||
message: sprintf(
|
||||
__(
|
||||
"This will permanently delete the compliance registry entry %s. This action cannot be undone."
|
||||
),
|
||||
registry.referenceId
|
||||
),
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<Tr to={`/organizations/${organizationId}/complianceRegistries/${registry.id}`}>
|
||||
<Td>
|
||||
<span className="font-mono text-sm">{registry.referenceId}</span>
|
||||
</Td>
|
||||
<Td>{registry.area || "-"}</Td>
|
||||
<Td>{registry.source || "-"}</Td>
|
||||
<Td>
|
||||
<Badge variant={getStatusVariant(registry.status || "OPEN")}>
|
||||
{getStatusLabel(registry.status || "OPEN")}
|
||||
</Badge>
|
||||
</Td>
|
||||
<Td>
|
||||
{registry.audit?.name
|
||||
? `${registry.audit.framework.name} - ${registry.audit.name}`
|
||||
: registry.audit?.framework.name || "-"
|
||||
}
|
||||
</Td>
|
||||
<Td>{registry.owner?.fullName || "-"}</Td>
|
||||
<Td>
|
||||
{registry.dueDate ? (
|
||||
<time dateTime={registry.dueDate}>
|
||||
{formatDate(registry.dueDate)}
|
||||
</time>
|
||||
) : (
|
||||
<span className="text-txt-tertiary">{__("No due date")}</span>
|
||||
)}
|
||||
</Td>
|
||||
<Td noLink width={50} className="text-end">
|
||||
<ActionDropdown>
|
||||
<DropdownItem
|
||||
icon={IconTrashCan}
|
||||
variant="danger"
|
||||
onSelect={handleDelete}
|
||||
>
|
||||
{__("Delete")}
|
||||
</DropdownItem>
|
||||
</ActionDropdown>
|
||||
</Td>
|
||||
</Tr>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,315 @@
|
||||
import {
|
||||
ConnectionHandler,
|
||||
usePreloadedQuery,
|
||||
type PreloadedQuery,
|
||||
} from "react-relay";
|
||||
import {
|
||||
complianceRegistryNodeQuery,
|
||||
useDeleteComplianceRegistry,
|
||||
useUpdateComplianceRegistry,
|
||||
ComplianceRegistriesConnectionKey,
|
||||
} from "../../../hooks/graph/ComplianceRegistryGraph";
|
||||
import {
|
||||
ActionDropdown,
|
||||
Badge,
|
||||
Breadcrumb,
|
||||
Button,
|
||||
DropdownItem,
|
||||
Field,
|
||||
IconTrashCan,
|
||||
Option,
|
||||
Input,
|
||||
Card,
|
||||
Textarea,
|
||||
useToast,
|
||||
Select,
|
||||
} from "@probo/ui";
|
||||
import { useTranslate } from "@probo/i18n";
|
||||
import { useOrganizationId } from "/hooks/useOrganizationId";
|
||||
import { PeopleSelectField } from "/components/form/PeopleSelectField";
|
||||
import { AuditSelectField } from "/components/form/AuditSelectField";
|
||||
import { useFormWithSchema } from "/hooks/useFormWithSchema";
|
||||
import { Controller } from "react-hook-form";
|
||||
import z from "zod";
|
||||
import { getStatusVariant, getStatusLabel, formatDatetime, getComplianceRegistryStatusOptions } from "@probo/helpers";
|
||||
import type { ComplianceRegistryGraphNodeQuery } from "/hooks/graph/__generated__/ComplianceRegistryGraphNodeQuery.graphql";
|
||||
|
||||
const updateRegistrySchema = z.object({
|
||||
referenceId: z.string().min(1, "Reference ID is required"),
|
||||
area: z.string().optional(),
|
||||
source: z.string().optional(),
|
||||
requirement: z.string().optional(),
|
||||
actionsToBeImplemented: z.string().optional(),
|
||||
regulator: z.string().optional(),
|
||||
lastReviewDate: z.string().optional(),
|
||||
dueDate: z.string().optional(),
|
||||
status: z.enum(["OPEN", "IN_PROGRESS", "CLOSED"]),
|
||||
ownerId: z.string().min(1, "Owner is required"),
|
||||
auditId: z.string().min(1, "Audit is required"),
|
||||
});
|
||||
|
||||
type Props = {
|
||||
queryRef: PreloadedQuery<ComplianceRegistryGraphNodeQuery>;
|
||||
};
|
||||
|
||||
export default function ComplianceRegistryDetailsPage(props: Props) {
|
||||
const data = usePreloadedQuery<ComplianceRegistryGraphNodeQuery>(complianceRegistryNodeQuery, props.queryRef);
|
||||
const registry = data.node;
|
||||
const { __ } = useTranslate();
|
||||
const { toast } = useToast();
|
||||
const organizationId = useOrganizationId();
|
||||
|
||||
if (!registry) {
|
||||
return <div>{__("Compliance registry entry not found")}</div>;
|
||||
}
|
||||
|
||||
const updateRegistry = useUpdateComplianceRegistry();
|
||||
const statusOptions = getComplianceRegistryStatusOptions(__);
|
||||
|
||||
const connectionId = ConnectionHandler.getConnectionID(
|
||||
organizationId,
|
||||
ComplianceRegistriesConnectionKey
|
||||
);
|
||||
|
||||
const deleteRegistry = useDeleteComplianceRegistry({ id: registry.id!, referenceId: registry.referenceId! }, connectionId);
|
||||
|
||||
const { register, handleSubmit, formState, control } = useFormWithSchema(
|
||||
updateRegistrySchema,
|
||||
{
|
||||
defaultValues: {
|
||||
referenceId: registry.referenceId || "",
|
||||
area: registry.area || "",
|
||||
source: registry.source || "",
|
||||
requirement: registry.requirement || "",
|
||||
actionsToBeImplemented: registry.actionsToBeImplemented || "",
|
||||
regulator: registry.regulator || "",
|
||||
lastReviewDate: registry.lastReviewDate
|
||||
? new Date(registry.lastReviewDate).toISOString().split("T")[0]
|
||||
: "",
|
||||
dueDate: registry.dueDate
|
||||
? new Date(registry.dueDate).toISOString().split("T")[0]
|
||||
: "",
|
||||
status: registry.status || "OPEN",
|
||||
ownerId: registry.owner?.id || "",
|
||||
auditId: registry.audit?.id || "",
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
const onSubmit = handleSubmit(async (formData) => {
|
||||
try {
|
||||
await updateRegistry({
|
||||
id: registry.id!,
|
||||
referenceId: formData.referenceId,
|
||||
area: formData.area || undefined,
|
||||
source: formData.source || undefined,
|
||||
requirement: formData.requirement || undefined,
|
||||
actionsToBeImplemented: formData.actionsToBeImplemented || undefined,
|
||||
regulator: formData.regulator || undefined,
|
||||
lastReviewDate: formatDatetime(formData.lastReviewDate),
|
||||
dueDate: formatDatetime(formData.dueDate),
|
||||
status: formData.status,
|
||||
ownerId: formData.ownerId,
|
||||
auditId: formData.auditId,
|
||||
});
|
||||
|
||||
toast({
|
||||
title: __("Success"),
|
||||
description: __("Compliance registry entry updated successfully"),
|
||||
variant: "success",
|
||||
});
|
||||
} catch (error) {
|
||||
toast({
|
||||
title: __("Error"),
|
||||
description: __("Failed to update compliance registry entry"),
|
||||
variant: "error",
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<div className="flex justify-between items-start">
|
||||
<div>
|
||||
<Breadcrumb
|
||||
items={[
|
||||
{ label: __("Compliance Registries"), to: "../complianceRegistries" },
|
||||
{ label: registry.referenceId! },
|
||||
]}
|
||||
/>
|
||||
<div className="flex items-center gap-3 mt-2">
|
||||
<h1 className="text-2xl font-bold">{registry.referenceId}</h1>
|
||||
<Badge variant={getStatusVariant(registry.status || "OPEN")}>
|
||||
{getStatusLabel(registry.status || "OPEN")}
|
||||
</Badge>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ActionDropdown>
|
||||
<DropdownItem icon={IconTrashCan} onClick={deleteRegistry}>
|
||||
{__("Delete")}
|
||||
</DropdownItem>
|
||||
</ActionDropdown>
|
||||
</div>
|
||||
|
||||
<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")}
|
||||
/>
|
||||
</Field>
|
||||
|
||||
<Controller
|
||||
name="auditId"
|
||||
control={control}
|
||||
render={() => (
|
||||
<AuditSelectField
|
||||
organizationId={organizationId}
|
||||
control={control}
|
||||
name="auditId"
|
||||
label={__("Audit")}
|
||||
error={formState.errors.auditId?.message}
|
||||
required
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<Field
|
||||
label={__("Area")}
|
||||
error={formState.errors.area?.message}
|
||||
>
|
||||
<Input
|
||||
{...register("area")}
|
||||
placeholder={__("Enter area")}
|
||||
/>
|
||||
</Field>
|
||||
|
||||
<Field
|
||||
label={__("Source")}
|
||||
error={formState.errors.source?.message}
|
||||
>
|
||||
<Input
|
||||
{...register("source")}
|
||||
placeholder={__("Enter source")}
|
||||
/>
|
||||
</Field>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<Field label={__("Status")}>
|
||||
<Controller
|
||||
control={control}
|
||||
name="status"
|
||||
render={({ field }) => (
|
||||
<Select
|
||||
variant="editor"
|
||||
placeholder={__("Select status")}
|
||||
onValueChange={field.onChange}
|
||||
value={field.value}
|
||||
className="w-full"
|
||||
>
|
||||
{statusOptions.map((option) => (
|
||||
<Option key={option.value} value={option.value}>
|
||||
{option.label}
|
||||
</Option>
|
||||
))}
|
||||
</Select>
|
||||
)}
|
||||
/>
|
||||
{formState.errors.status && (
|
||||
<p className="text-sm text-red-500 mt-1">{formState.errors.status.message}</p>
|
||||
)}
|
||||
</Field>
|
||||
|
||||
<Controller
|
||||
name="ownerId"
|
||||
control={control}
|
||||
render={() => (
|
||||
<PeopleSelectField
|
||||
organizationId={organizationId}
|
||||
control={control}
|
||||
name="ownerId"
|
||||
label={__("Owner")}
|
||||
error={formState.errors.ownerId?.message}
|
||||
required
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<Field
|
||||
label={__("Regulator")}
|
||||
error={formState.errors.regulator?.message}
|
||||
>
|
||||
<Input
|
||||
{...register("regulator")}
|
||||
placeholder={__("Enter regulator")}
|
||||
/>
|
||||
</Field>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<Field
|
||||
label={__("Last Review Date")}
|
||||
error={formState.errors.lastReviewDate?.message}
|
||||
>
|
||||
<Input
|
||||
{...register("lastReviewDate")}
|
||||
type="date"
|
||||
/>
|
||||
</Field>
|
||||
|
||||
<Field
|
||||
label={__("Due Date")}
|
||||
error={formState.errors.dueDate?.message}
|
||||
>
|
||||
<Input
|
||||
{...register("dueDate")}
|
||||
type="date"
|
||||
/>
|
||||
</Field>
|
||||
</div>
|
||||
|
||||
<Field
|
||||
label={__("Requirement")}
|
||||
error={formState.errors.requirement?.message}
|
||||
>
|
||||
<Textarea
|
||||
{...register("requirement")}
|
||||
placeholder={__("Enter requirement")}
|
||||
rows={4}
|
||||
/>
|
||||
</Field>
|
||||
|
||||
<Field
|
||||
label={__("Actions to be Implemented")}
|
||||
error={formState.errors.actionsToBeImplemented?.message}
|
||||
>
|
||||
<Textarea
|
||||
{...register("actionsToBeImplemented")}
|
||||
placeholder={__("Enter actions to be implemented")}
|
||||
rows={4}
|
||||
/>
|
||||
</Field>
|
||||
|
||||
<div className="flex justify-end">
|
||||
<Button
|
||||
type="submit"
|
||||
disabled={formState.isSubmitting}
|
||||
>
|
||||
{formState.isSubmitting ? __("Saving...") : __("Save Changes")}
|
||||
</Button>
|
||||
</div>
|
||||
</form>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,346 @@
|
||||
/**
|
||||
* @generated SignedSource<<388195a5e7e9e9a1a167ad7cb298c935>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @ts-nocheck
|
||||
|
||||
import { ReaderFragment } from 'relay-runtime';
|
||||
export type ComplianceRegistryStatus = "CLOSED" | "IN_PROGRESS" | "OPEN";
|
||||
import { FragmentRefs } from "relay-runtime";
|
||||
export type ComplianceRegistriesPageFragment$data = {
|
||||
readonly complianceRegistries: {
|
||||
readonly __id: string;
|
||||
readonly edges: ReadonlyArray<{
|
||||
readonly node: {
|
||||
readonly actionsToBeImplemented: string | null | undefined;
|
||||
readonly area: string | null | undefined;
|
||||
readonly audit: {
|
||||
readonly framework: {
|
||||
readonly id: string;
|
||||
readonly name: string;
|
||||
};
|
||||
readonly id: string;
|
||||
readonly name: string | null | undefined;
|
||||
};
|
||||
readonly createdAt: any;
|
||||
readonly dueDate: any | null | undefined;
|
||||
readonly id: string;
|
||||
readonly lastReviewDate: any | null | undefined;
|
||||
readonly owner: {
|
||||
readonly fullName: string;
|
||||
readonly id: string;
|
||||
};
|
||||
readonly referenceId: string;
|
||||
readonly regulator: string | null | undefined;
|
||||
readonly requirement: string | null | undefined;
|
||||
readonly source: string | null | undefined;
|
||||
readonly status: ComplianceRegistryStatus;
|
||||
readonly updatedAt: any;
|
||||
};
|
||||
}>;
|
||||
readonly pageInfo: {
|
||||
readonly endCursor: any | null | undefined;
|
||||
readonly hasNextPage: boolean;
|
||||
};
|
||||
readonly totalCount: number;
|
||||
};
|
||||
readonly id: string;
|
||||
readonly " $fragmentType": "ComplianceRegistriesPageFragment";
|
||||
};
|
||||
export type ComplianceRegistriesPageFragment$key = {
|
||||
readonly " $data"?: ComplianceRegistriesPageFragment$data;
|
||||
readonly " $fragmentSpreads": FragmentRefs<"ComplianceRegistriesPageFragment">;
|
||||
};
|
||||
|
||||
import ComplianceRegistriesPageRefetchQuery_graphql from './ComplianceRegistriesPageRefetchQuery.graphql';
|
||||
|
||||
const node: ReaderFragment = (function(){
|
||||
var v0 = [
|
||||
"complianceRegistries"
|
||||
],
|
||||
v1 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "id",
|
||||
"storageKey": null
|
||||
},
|
||||
v2 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "name",
|
||||
"storageKey": null
|
||||
};
|
||||
return {
|
||||
"argumentDefinitions": [
|
||||
{
|
||||
"defaultValue": null,
|
||||
"kind": "LocalArgument",
|
||||
"name": "after"
|
||||
},
|
||||
{
|
||||
"defaultValue": 10,
|
||||
"kind": "LocalArgument",
|
||||
"name": "first"
|
||||
}
|
||||
],
|
||||
"kind": "Fragment",
|
||||
"metadata": {
|
||||
"connection": [
|
||||
{
|
||||
"count": "first",
|
||||
"cursor": "after",
|
||||
"direction": "forward",
|
||||
"path": (v0/*: any*/)
|
||||
}
|
||||
],
|
||||
"refetch": {
|
||||
"connection": {
|
||||
"forward": {
|
||||
"count": "first",
|
||||
"cursor": "after"
|
||||
},
|
||||
"backward": null,
|
||||
"path": (v0/*: any*/)
|
||||
},
|
||||
"fragmentPathInResult": [
|
||||
"node"
|
||||
],
|
||||
"operation": ComplianceRegistriesPageRefetchQuery_graphql,
|
||||
"identifierInfo": {
|
||||
"identifierField": "id",
|
||||
"identifierQueryVariableName": "id"
|
||||
}
|
||||
}
|
||||
},
|
||||
"name": "ComplianceRegistriesPageFragment",
|
||||
"selections": [
|
||||
(v1/*: any*/),
|
||||
{
|
||||
"alias": "complianceRegistries",
|
||||
"args": null,
|
||||
"concreteType": "ComplianceRegistryConnection",
|
||||
"kind": "LinkedField",
|
||||
"name": "__ComplianceRegistriesPage_complianceRegistries_connection",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "totalCount",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "ComplianceRegistryEdge",
|
||||
"kind": "LinkedField",
|
||||
"name": "edges",
|
||||
"plural": true,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "ComplianceRegistry",
|
||||
"kind": "LinkedField",
|
||||
"name": "node",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v1/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "referenceId",
|
||||
"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": "requirement",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "status",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "lastReviewDate",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "dueDate",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "actionsToBeImplemented",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "regulator",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "Audit",
|
||||
"kind": "LinkedField",
|
||||
"name": "audit",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v1/*: any*/),
|
||||
(v2/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "Framework",
|
||||
"kind": "LinkedField",
|
||||
"name": "framework",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v1/*: any*/),
|
||||
(v2/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "People",
|
||||
"kind": "LinkedField",
|
||||
"name": "owner",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v1/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "fullName",
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"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": "__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": "endCursor",
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"kind": "ClientExtension",
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "__id",
|
||||
"storageKey": null
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"type": "Organization",
|
||||
"abstractKey": null
|
||||
};
|
||||
})();
|
||||
|
||||
(node as any).hash = "c85f1b770b00186cc074726ee8766698";
|
||||
|
||||
export default node;
|
||||
@@ -0,0 +1,361 @@
|
||||
/**
|
||||
* @generated SignedSource<<45ac04d64bae14926f41dccda7ec5a25>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @ts-nocheck
|
||||
|
||||
import { ConcreteRequest } from 'relay-runtime';
|
||||
import { FragmentRefs } from "relay-runtime";
|
||||
export type ComplianceRegistriesPageQuery$variables = {
|
||||
organizationId: string;
|
||||
};
|
||||
export type ComplianceRegistriesPageQuery$data = {
|
||||
readonly node: {
|
||||
readonly " $fragmentSpreads": FragmentRefs<"ComplianceRegistriesPageFragment">;
|
||||
};
|
||||
};
|
||||
export type ComplianceRegistriesPageQuery = {
|
||||
response: ComplianceRegistriesPageQuery$data;
|
||||
variables: ComplianceRegistriesPageQuery$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": "__typename",
|
||||
"storageKey": null
|
||||
},
|
||||
v3 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "id",
|
||||
"storageKey": null
|
||||
},
|
||||
v4 = [
|
||||
{
|
||||
"kind": "Literal",
|
||||
"name": "first",
|
||||
"value": 10
|
||||
}
|
||||
],
|
||||
v5 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "name",
|
||||
"storageKey": null
|
||||
};
|
||||
return {
|
||||
"fragment": {
|
||||
"argumentDefinitions": (v0/*: any*/),
|
||||
"kind": "Fragment",
|
||||
"metadata": null,
|
||||
"name": "ComplianceRegistriesPageQuery",
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": (v1/*: any*/),
|
||||
"concreteType": null,
|
||||
"kind": "LinkedField",
|
||||
"name": "node",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"kind": "InlineFragment",
|
||||
"selections": [
|
||||
{
|
||||
"args": null,
|
||||
"kind": "FragmentSpread",
|
||||
"name": "ComplianceRegistriesPageFragment"
|
||||
}
|
||||
],
|
||||
"type": "Organization",
|
||||
"abstractKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"type": "Query",
|
||||
"abstractKey": null
|
||||
},
|
||||
"kind": "Request",
|
||||
"operation": {
|
||||
"argumentDefinitions": (v0/*: any*/),
|
||||
"kind": "Operation",
|
||||
"name": "ComplianceRegistriesPageQuery",
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": (v1/*: any*/),
|
||||
"concreteType": null,
|
||||
"kind": "LinkedField",
|
||||
"name": "node",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v2/*: any*/),
|
||||
(v3/*: any*/),
|
||||
{
|
||||
"kind": "InlineFragment",
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": (v4/*: any*/),
|
||||
"concreteType": "ComplianceRegistryConnection",
|
||||
"kind": "LinkedField",
|
||||
"name": "complianceRegistries",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "totalCount",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "ComplianceRegistryEdge",
|
||||
"kind": "LinkedField",
|
||||
"name": "edges",
|
||||
"plural": true,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "ComplianceRegistry",
|
||||
"kind": "LinkedField",
|
||||
"name": "node",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v3/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "referenceId",
|
||||
"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": "requirement",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "status",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "lastReviewDate",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "dueDate",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "actionsToBeImplemented",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "regulator",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "Audit",
|
||||
"kind": "LinkedField",
|
||||
"name": "audit",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v3/*: any*/),
|
||||
(v5/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "Framework",
|
||||
"kind": "LinkedField",
|
||||
"name": "framework",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v3/*: any*/),
|
||||
(v5/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "People",
|
||||
"kind": "LinkedField",
|
||||
"name": "owner",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v3/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "fullName",
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "createdAt",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "updatedAt",
|
||||
"storageKey": null
|
||||
},
|
||||
(v2/*: 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": "endCursor",
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"kind": "ClientExtension",
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "__id",
|
||||
"storageKey": null
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"storageKey": "complianceRegistries(first:10)"
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": (v4/*: any*/),
|
||||
"filters": null,
|
||||
"handle": "connection",
|
||||
"key": "ComplianceRegistriesPage_complianceRegistries",
|
||||
"kind": "LinkedHandle",
|
||||
"name": "complianceRegistries"
|
||||
}
|
||||
],
|
||||
"type": "Organization",
|
||||
"abstractKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "fcc5d4d2cc4ca376314b334d7f36316f",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "ComplianceRegistriesPageQuery",
|
||||
"operationKind": "query",
|
||||
"text": "query ComplianceRegistriesPageQuery(\n $organizationId: ID!\n) {\n node(id: $organizationId) {\n __typename\n ... on Organization {\n ...ComplianceRegistriesPageFragment\n }\n id\n }\n}\n\nfragment ComplianceRegistriesPageFragment on Organization {\n id\n complianceRegistries(first: 10) {\n totalCount\n edges {\n node {\n id\n referenceId\n area\n source\n requirement\n status\n lastReviewDate\n dueDate\n actionsToBeImplemented\n regulator\n audit {\n id\n name\n framework {\n id\n name\n }\n }\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 = "3e8551eebdf52ee84fb3910ee77cfe15";
|
||||
|
||||
export default node;
|
||||
@@ -0,0 +1,371 @@
|
||||
/**
|
||||
* @generated SignedSource<<2f421894f05c26b8fbca3d5e76ebdf0d>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @ts-nocheck
|
||||
|
||||
import { ConcreteRequest } from 'relay-runtime';
|
||||
import { FragmentRefs } from "relay-runtime";
|
||||
export type ComplianceRegistriesPageRefetchQuery$variables = {
|
||||
after?: any | null | undefined;
|
||||
first?: number | null | undefined;
|
||||
id: string;
|
||||
};
|
||||
export type ComplianceRegistriesPageRefetchQuery$data = {
|
||||
readonly node: {
|
||||
readonly " $fragmentSpreads": FragmentRefs<"ComplianceRegistriesPageFragment">;
|
||||
};
|
||||
};
|
||||
export type ComplianceRegistriesPageRefetchQuery = {
|
||||
response: ComplianceRegistriesPageRefetchQuery$data;
|
||||
variables: ComplianceRegistriesPageRefetchQuery$variables;
|
||||
};
|
||||
|
||||
const node: ConcreteRequest = (function(){
|
||||
var v0 = [
|
||||
{
|
||||
"defaultValue": null,
|
||||
"kind": "LocalArgument",
|
||||
"name": "after"
|
||||
},
|
||||
{
|
||||
"defaultValue": 10,
|
||||
"kind": "LocalArgument",
|
||||
"name": "first"
|
||||
},
|
||||
{
|
||||
"defaultValue": null,
|
||||
"kind": "LocalArgument",
|
||||
"name": "id"
|
||||
}
|
||||
],
|
||||
v1 = [
|
||||
{
|
||||
"kind": "Variable",
|
||||
"name": "id",
|
||||
"variableName": "id"
|
||||
}
|
||||
],
|
||||
v2 = [
|
||||
{
|
||||
"kind": "Variable",
|
||||
"name": "after",
|
||||
"variableName": "after"
|
||||
},
|
||||
{
|
||||
"kind": "Variable",
|
||||
"name": "first",
|
||||
"variableName": "first"
|
||||
}
|
||||
],
|
||||
v3 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "__typename",
|
||||
"storageKey": null
|
||||
},
|
||||
v4 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "id",
|
||||
"storageKey": null
|
||||
},
|
||||
v5 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "name",
|
||||
"storageKey": null
|
||||
};
|
||||
return {
|
||||
"fragment": {
|
||||
"argumentDefinitions": (v0/*: any*/),
|
||||
"kind": "Fragment",
|
||||
"metadata": null,
|
||||
"name": "ComplianceRegistriesPageRefetchQuery",
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": (v1/*: any*/),
|
||||
"concreteType": null,
|
||||
"kind": "LinkedField",
|
||||
"name": "node",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"args": (v2/*: any*/),
|
||||
"kind": "FragmentSpread",
|
||||
"name": "ComplianceRegistriesPageFragment"
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"type": "Query",
|
||||
"abstractKey": null
|
||||
},
|
||||
"kind": "Request",
|
||||
"operation": {
|
||||
"argumentDefinitions": (v0/*: any*/),
|
||||
"kind": "Operation",
|
||||
"name": "ComplianceRegistriesPageRefetchQuery",
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": (v1/*: any*/),
|
||||
"concreteType": null,
|
||||
"kind": "LinkedField",
|
||||
"name": "node",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v3/*: any*/),
|
||||
(v4/*: any*/),
|
||||
{
|
||||
"kind": "InlineFragment",
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": (v2/*: any*/),
|
||||
"concreteType": "ComplianceRegistryConnection",
|
||||
"kind": "LinkedField",
|
||||
"name": "complianceRegistries",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "totalCount",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "ComplianceRegistryEdge",
|
||||
"kind": "LinkedField",
|
||||
"name": "edges",
|
||||
"plural": true,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "ComplianceRegistry",
|
||||
"kind": "LinkedField",
|
||||
"name": "node",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v4/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "referenceId",
|
||||
"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": "requirement",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "status",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "lastReviewDate",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "dueDate",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "actionsToBeImplemented",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "regulator",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "Audit",
|
||||
"kind": "LinkedField",
|
||||
"name": "audit",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v4/*: any*/),
|
||||
(v5/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "Framework",
|
||||
"kind": "LinkedField",
|
||||
"name": "framework",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v4/*: any*/),
|
||||
(v5/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "People",
|
||||
"kind": "LinkedField",
|
||||
"name": "owner",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v4/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "fullName",
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "createdAt",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "updatedAt",
|
||||
"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": "hasNextPage",
|
||||
"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": (v2/*: any*/),
|
||||
"filters": null,
|
||||
"handle": "connection",
|
||||
"key": "ComplianceRegistriesPage_complianceRegistries",
|
||||
"kind": "LinkedHandle",
|
||||
"name": "complianceRegistries"
|
||||
}
|
||||
],
|
||||
"type": "Organization",
|
||||
"abstractKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "aaec01ab09a3becc49afe167cc55acb6",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "ComplianceRegistriesPageRefetchQuery",
|
||||
"operationKind": "query",
|
||||
"text": "query ComplianceRegistriesPageRefetchQuery(\n $after: CursorKey\n $first: Int = 10\n $id: ID!\n) {\n node(id: $id) {\n __typename\n ...ComplianceRegistriesPageFragment_2HEEH6\n id\n }\n}\n\nfragment ComplianceRegistriesPageFragment_2HEEH6 on Organization {\n id\n complianceRegistries(first: $first, after: $after) {\n totalCount\n edges {\n node {\n id\n referenceId\n area\n source\n requirement\n status\n lastReviewDate\n dueDate\n actionsToBeImplemented\n regulator\n audit {\n id\n name\n framework {\n id\n name\n }\n }\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 = "c85f1b770b00186cc074726ee8766698";
|
||||
|
||||
export default node;
|
||||
@@ -0,0 +1,252 @@
|
||||
import { type ReactNode } from "react";
|
||||
import {
|
||||
Button,
|
||||
Field,
|
||||
useToast,
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogFooter,
|
||||
useDialogRef,
|
||||
Textarea,
|
||||
Breadcrumb,
|
||||
Label,
|
||||
Select,
|
||||
Option,
|
||||
Input,
|
||||
} from "@probo/ui";
|
||||
import { useTranslate } from "@probo/i18n";
|
||||
import { z } from "zod";
|
||||
import { useFormWithSchema } from "/hooks/useFormWithSchema";
|
||||
import { useCreateComplianceRegistry } from "../../../../hooks/graph/ComplianceRegistryGraph";
|
||||
import { PeopleSelectField } from "/components/form/PeopleSelectField";
|
||||
import { AuditSelectField } from "/components/form/AuditSelectField";
|
||||
import { Controller } from "react-hook-form";
|
||||
import { formatDatetime, getComplianceRegistryStatusOptions } from "@probo/helpers";
|
||||
|
||||
const schema = z.object({
|
||||
referenceId: z.string().min(1, "Reference ID is required"),
|
||||
area: z.string().optional(),
|
||||
source: z.string().optional(),
|
||||
auditId: z.string().min(1, "Audit is required"),
|
||||
requirement: z.string().optional(),
|
||||
actionsToBeImplemented: z.string().optional(),
|
||||
regulator: z.string().optional(),
|
||||
ownerId: z.string().min(1, "Owner is required"),
|
||||
lastReviewDate: z.string().optional(),
|
||||
dueDate: z.string().optional(),
|
||||
status: z.enum(["OPEN", "IN_PROGRESS", "CLOSED"]),
|
||||
});
|
||||
|
||||
type FormData = z.infer<typeof schema>;
|
||||
|
||||
interface CreateComplianceRegistryDialogProps {
|
||||
children: ReactNode;
|
||||
organizationId: string;
|
||||
connection?: string;
|
||||
}
|
||||
|
||||
export function CreateComplianceRegistryDialog({
|
||||
children,
|
||||
organizationId,
|
||||
connection,
|
||||
}: CreateComplianceRegistryDialogProps) {
|
||||
const { __ } = useTranslate();
|
||||
const { toast } = useToast();
|
||||
const dialogRef = useDialogRef();
|
||||
|
||||
const createRegistry = useCreateComplianceRegistry(connection || "");
|
||||
const statusOptions = getComplianceRegistryStatusOptions(__);
|
||||
|
||||
const { register, handleSubmit, formState, reset, control } = useFormWithSchema(schema, {
|
||||
defaultValues: {
|
||||
referenceId: "",
|
||||
area: "",
|
||||
source: "",
|
||||
auditId: "",
|
||||
requirement: "",
|
||||
actionsToBeImplemented: "",
|
||||
regulator: "",
|
||||
ownerId: "",
|
||||
lastReviewDate: "",
|
||||
dueDate: "",
|
||||
status: "OPEN" as const,
|
||||
},
|
||||
});
|
||||
|
||||
const onSubmit = handleSubmit(async (formData: FormData) => {
|
||||
try {
|
||||
await createRegistry({
|
||||
organizationId,
|
||||
referenceId: formData.referenceId,
|
||||
area: formData.area || undefined,
|
||||
source: formData.source || undefined,
|
||||
auditId: formData.auditId,
|
||||
requirement: formData.requirement || undefined,
|
||||
actionsToBeImplemented: formData.actionsToBeImplemented || undefined,
|
||||
regulator: formData.regulator || undefined,
|
||||
ownerId: formData.ownerId,
|
||||
lastReviewDate: formatDatetime(formData.lastReviewDate),
|
||||
dueDate: formatDatetime(formData.dueDate),
|
||||
status: formData.status,
|
||||
});
|
||||
|
||||
toast({
|
||||
title: __("Success"),
|
||||
description: __("Compliance registry entry created successfully"),
|
||||
variant: "success",
|
||||
});
|
||||
|
||||
reset();
|
||||
dialogRef.current?.close();
|
||||
} catch (error) {
|
||||
toast({
|
||||
title: __("Error"),
|
||||
description: __("Failed to create compliance registry entry"),
|
||||
variant: "error",
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
ref={dialogRef}
|
||||
trigger={children}
|
||||
title={<Breadcrumb items={[__("Registries"), __("Create Compliance Entry")]} />}
|
||||
className="max-w-2xl"
|
||||
>
|
||||
<form onSubmit={onSubmit}>
|
||||
<DialogContent padded className="space-y-4">
|
||||
<Field
|
||||
label={__("Reference ID")}
|
||||
{...register("referenceId")}
|
||||
placeholder="CR-001"
|
||||
error={formState.errors.referenceId?.message}
|
||||
required
|
||||
/>
|
||||
|
||||
<AuditSelectField
|
||||
organizationId={organizationId}
|
||||
control={control}
|
||||
name="auditId"
|
||||
label={__("Audit")}
|
||||
error={formState.errors.auditId?.message}
|
||||
required
|
||||
/>
|
||||
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<Field
|
||||
label={__("Area")}
|
||||
{...register("area")}
|
||||
placeholder={__("Enter area")}
|
||||
error={formState.errors.area?.message}
|
||||
/>
|
||||
|
||||
<Field
|
||||
label={__("Source")}
|
||||
{...register("source")}
|
||||
placeholder={__("Enter source")}
|
||||
error={formState.errors.source?.message}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<Field label={__("Status")}>
|
||||
<Controller
|
||||
control={control}
|
||||
name="status"
|
||||
render={({ field }) => (
|
||||
<Select
|
||||
variant="editor"
|
||||
placeholder={__("Select status")}
|
||||
onValueChange={field.onChange}
|
||||
value={field.value}
|
||||
className="w-full"
|
||||
>
|
||||
{statusOptions.map((option) => (
|
||||
<Option key={option.value} value={option.value}>
|
||||
{option.label}
|
||||
</Option>
|
||||
))}
|
||||
</Select>
|
||||
)}
|
||||
/>
|
||||
{formState.errors.status && (
|
||||
<p className="text-sm text-red-500 mt-1">{formState.errors.status.message}</p>
|
||||
)}
|
||||
</Field>
|
||||
|
||||
<PeopleSelectField
|
||||
organizationId={organizationId}
|
||||
control={control}
|
||||
name="ownerId"
|
||||
label={__("Owner")}
|
||||
error={formState.errors.ownerId?.message}
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<Field
|
||||
label={__("Regulator")}
|
||||
{...register("regulator")}
|
||||
placeholder={__("Enter regulator")}
|
||||
error={formState.errors.regulator?.message}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="lastReviewDate">{__("Last Review Date")}</Label>
|
||||
<Input
|
||||
id="lastReviewDate"
|
||||
type="date"
|
||||
{...register("lastReviewDate")}
|
||||
/>
|
||||
{formState.errors.lastReviewDate && (
|
||||
<p className="text-sm text-red-500">{formState.errors.lastReviewDate.message}</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="dueDate">{__("Due Date")}</Label>
|
||||
<Input
|
||||
id="dueDate"
|
||||
type="date"
|
||||
{...register("dueDate")}
|
||||
/>
|
||||
{formState.errors.dueDate && (
|
||||
<p className="text-sm text-red-500">{formState.errors.dueDate.message}</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="requirement">{__("Requirement")}</Label>
|
||||
<Textarea
|
||||
id="requirement"
|
||||
{...register("requirement")}
|
||||
placeholder={__("Enter requirement details...")}
|
||||
rows={3}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="actionsToBeImplemented">{__("Actions to be Implemented")}</Label>
|
||||
<Textarea
|
||||
id="actionsToBeImplemented"
|
||||
{...register("actionsToBeImplemented")}
|
||||
placeholder={__("Enter actions to be implemented...")}
|
||||
rows={3}
|
||||
/>
|
||||
</div>
|
||||
</DialogContent>
|
||||
|
||||
<DialogFooter>
|
||||
<Button type="submit" disabled={formState.isSubmitting}>
|
||||
{formState.isSubmitting ? __("Creating...") : __("Create Compliance Registry Entry")}
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</form>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
@@ -156,8 +156,6 @@ export default function NonconformityRegistryDetailsPage(props: Props) {
|
||||
<div className="max-w-4xl">
|
||||
<Card padded>
|
||||
<form onSubmit={onSubmit} className="space-y-6">
|
||||
<h3 className="text-lg font-medium">{__("Nonconformity Registry")}</h3>
|
||||
|
||||
<Field
|
||||
label={__("Reference ID")}
|
||||
required
|
||||
|
||||
@@ -30,6 +30,7 @@ import { assetRoutes } from "./routes/assetRoutes.ts";
|
||||
import { auditRoutes } from "./routes/auditRoutes.ts";
|
||||
import { trustCenterRoutes } from "./routes/trustCenterRoutes.ts";
|
||||
import { nonconformityRegistryRoutes } from "./routes/nonconformityRegistryRoutes.ts";
|
||||
import { complianceRegistryRoutes } from "./routes/complianceRegistryRoutes.ts";
|
||||
import { lazy } from "@probo/react-lazy";
|
||||
|
||||
export type AppRoute = Omit<RouteObject, "Component" | "children"> & {
|
||||
@@ -151,6 +152,7 @@ const routes = [
|
||||
...dataRoutes,
|
||||
...auditRoutes,
|
||||
...nonconformityRegistryRoutes,
|
||||
...complianceRegistryRoutes,
|
||||
...trustCenterRoutes,
|
||||
{
|
||||
path: "*",
|
||||
|
||||
29
apps/console/src/routes/complianceRegistryRoutes.ts
Normal file
29
apps/console/src/routes/complianceRegistryRoutes.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { loadQuery } from "react-relay";
|
||||
import { relayEnvironment } from "/providers/RelayProviders";
|
||||
import { PageSkeleton } from "/components/skeletons/PageSkeleton";
|
||||
import { lazy } from "@probo/react-lazy";
|
||||
import { complianceRegistriesQuery, complianceRegistryNodeQuery } from "/hooks/graph/ComplianceRegistryGraph";
|
||||
import type { AppRoute } from "/routes";
|
||||
|
||||
export const complianceRegistryRoutes = [
|
||||
{
|
||||
path: "complianceRegistries",
|
||||
fallback: PageSkeleton,
|
||||
queryLoader: ({ organizationId }: { organizationId: string }) =>
|
||||
loadQuery(relayEnvironment, complianceRegistriesQuery, { organizationId }),
|
||||
Component: lazy(
|
||||
() => import("/pages/organizations/complianceRegistries/ComplianceRegistriesPage")
|
||||
),
|
||||
},
|
||||
{
|
||||
path: "complianceRegistries/:registryId",
|
||||
fallback: PageSkeleton,
|
||||
queryLoader: (params: Record<string, string>) =>
|
||||
loadQuery(relayEnvironment, complianceRegistryNodeQuery, {
|
||||
complianceRegistryId: params.registryId
|
||||
}),
|
||||
Component: lazy(
|
||||
() => import("/pages/organizations/complianceRegistries/ComplianceRegistryDetailsPage")
|
||||
),
|
||||
},
|
||||
] satisfies AppRoute[];
|
||||
@@ -16,7 +16,7 @@ export { availableFrameworks } from "./frameworks";
|
||||
export { getDocumentTypeLabel, documentTypes } from "./documents";
|
||||
export { getAssetTypeVariant, getCriticityVariant } from "./assets";
|
||||
export { getAuditStateLabel, getAuditStateVariant, auditStates } from "./audits";
|
||||
export { getStatusVariant, getStatusLabel, getNonconformityRegistryStatusOptions, registryStatuses } from "./registryStatus";
|
||||
export { getStatusVariant, getStatusLabel, getNonconformityRegistryStatusOptions, getComplianceRegistryStatusOptions, registryStatuses } from "./registryStatus";
|
||||
export { promisifyMutation } from "./relay";
|
||||
export { fileType, fileSize } from "./file";
|
||||
export { formatDatetime } from "./date";
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
type Translator = (s: string) => string;
|
||||
|
||||
export type NonconformityRegistryStatus = "CLOSED" | "IN_PROGRESS" | "OPEN";
|
||||
export type ComplianceRegistryStatus = "CLOSED" | "IN_PROGRESS" | "OPEN";
|
||||
|
||||
export const registryStatuses = [
|
||||
"OPEN",
|
||||
@@ -8,7 +9,7 @@ export const registryStatuses = [
|
||||
"CLOSED",
|
||||
] as const;
|
||||
|
||||
export const getStatusVariant = (status: NonconformityRegistryStatus) => {
|
||||
export const getStatusVariant = (status: NonconformityRegistryStatus | ComplianceRegistryStatus) => {
|
||||
switch (status) {
|
||||
case "OPEN":
|
||||
return "danger" as const;
|
||||
@@ -21,7 +22,7 @@ export const getStatusVariant = (status: NonconformityRegistryStatus) => {
|
||||
}
|
||||
};
|
||||
|
||||
export const getStatusLabel = (status: NonconformityRegistryStatus) => {
|
||||
export const getStatusLabel = (status: NonconformityRegistryStatus | ComplianceRegistryStatus) => {
|
||||
switch (status) {
|
||||
case "OPEN":
|
||||
return "Open";
|
||||
@@ -44,3 +45,14 @@ export function getNonconformityRegistryStatusOptions(__: Translator) {
|
||||
}[status]),
|
||||
}));
|
||||
}
|
||||
|
||||
export function getComplianceRegistryStatusOptions(__: Translator) {
|
||||
return registryStatuses.map((status) => ({
|
||||
value: status,
|
||||
label: __({
|
||||
"OPEN": "Open",
|
||||
"IN_PROGRESS": "In Progress",
|
||||
"CLOSED": "Closed",
|
||||
}[status]),
|
||||
}));
|
||||
}
|
||||
|
||||
348
pkg/coredata/compliance_registry.go
Normal file
348
pkg/coredata/compliance_registry.go
Normal file
@@ -0,0 +1,348 @@
|
||||
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
|
||||
//
|
||||
// Permission to use, copy, modify, and/or distribute this software for any
|
||||
// purpose with or without fee is hereby granted, provided that the above
|
||||
// copyright notice and this permission notice appear in all copies.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
// PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"maps"
|
||||
"time"
|
||||
|
||||
"github.com/getprobo/probo/pkg/gid"
|
||||
"github.com/getprobo/probo/pkg/page"
|
||||
"github.com/jackc/pgx/v5"
|
||||
"go.gearno.de/kit/pg"
|
||||
)
|
||||
|
||||
type (
|
||||
ComplianceRegistry struct {
|
||||
ID gid.GID `db:"id"`
|
||||
OrganizationID gid.GID `db:"organization_id"`
|
||||
ReferenceID string `db:"reference_id"`
|
||||
Area *string `db:"area"`
|
||||
Source *string `db:"source"`
|
||||
AuditID gid.GID `db:"audit_id"`
|
||||
Requirement *string `db:"requirement"`
|
||||
ActionsToBeImplemented *string `db:"actions_to_be_implemented"`
|
||||
Regulator *string `db:"regulator"`
|
||||
OwnerID gid.GID `db:"owner_id"`
|
||||
LastReviewDate *time.Time `db:"last_review_date"`
|
||||
DueDate *time.Time `db:"due_date"`
|
||||
Status ComplianceRegistryStatus `db:"status"`
|
||||
CreatedAt time.Time `db:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at"`
|
||||
}
|
||||
|
||||
ComplianceRegistries []*ComplianceRegistry
|
||||
)
|
||||
|
||||
func (cr *ComplianceRegistry) CursorKey(field ComplianceRegistryOrderField) page.CursorKey {
|
||||
switch field {
|
||||
case ComplianceRegistryOrderFieldCreatedAt:
|
||||
return page.NewCursorKey(cr.ID, cr.CreatedAt)
|
||||
case ComplianceRegistryOrderFieldLastReviewDate:
|
||||
return page.NewCursorKey(cr.ID, cr.LastReviewDate)
|
||||
case ComplianceRegistryOrderFieldDueDate:
|
||||
return page.NewCursorKey(cr.ID, cr.DueDate)
|
||||
case ComplianceRegistryOrderFieldStatus:
|
||||
return page.NewCursorKey(cr.ID, cr.Status)
|
||||
case ComplianceRegistryOrderFieldReferenceId:
|
||||
return page.NewCursorKey(cr.ID, cr.ReferenceID)
|
||||
}
|
||||
|
||||
panic(fmt.Sprintf("unsupported order by: %s", field))
|
||||
}
|
||||
|
||||
func (cr *ComplianceRegistry) LoadByID(
|
||||
ctx context.Context,
|
||||
conn pg.Conn,
|
||||
scope Scoper,
|
||||
complianceRegistryID gid.GID,
|
||||
) error {
|
||||
q := `
|
||||
SELECT
|
||||
id,
|
||||
organization_id,
|
||||
reference_id,
|
||||
area,
|
||||
source,
|
||||
audit_id,
|
||||
requirement,
|
||||
actions_to_be_implemented,
|
||||
regulator,
|
||||
owner_id,
|
||||
last_review_date,
|
||||
due_date,
|
||||
status,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM
|
||||
compliance_registries
|
||||
WHERE
|
||||
%s
|
||||
AND id = @compliance_registry_id
|
||||
LIMIT 1;
|
||||
`
|
||||
|
||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{"compliance_registry_id": complianceRegistryID}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
|
||||
rows, err := conn.Query(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot query compliance registry: %w", err)
|
||||
}
|
||||
|
||||
registry, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[ComplianceRegistry])
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot collect compliance registry: %w", err)
|
||||
}
|
||||
|
||||
*cr = registry
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (crs *ComplianceRegistries) CountByOrganizationID(
|
||||
ctx context.Context,
|
||||
conn pg.Conn,
|
||||
scope Scoper,
|
||||
organizationID gid.GID,
|
||||
) (int, error) {
|
||||
q := `
|
||||
SELECT
|
||||
COUNT(id)
|
||||
FROM
|
||||
compliance_registries
|
||||
WHERE
|
||||
%s
|
||||
AND organization_id = @organization_id
|
||||
`
|
||||
|
||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{"organization_id": organizationID}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
|
||||
row := conn.QueryRow(ctx, q, args)
|
||||
|
||||
var count int
|
||||
err := row.Scan(&count)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("cannot count compliance registries: %w", err)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
func (crs *ComplianceRegistries) LoadByOrganizationID(
|
||||
ctx context.Context,
|
||||
conn pg.Conn,
|
||||
scope Scoper,
|
||||
organizationID gid.GID,
|
||||
cursor *page.Cursor[ComplianceRegistryOrderField],
|
||||
) error {
|
||||
q := `
|
||||
SELECT
|
||||
id,
|
||||
organization_id,
|
||||
reference_id,
|
||||
area,
|
||||
source,
|
||||
audit_id,
|
||||
requirement,
|
||||
actions_to_be_implemented,
|
||||
regulator,
|
||||
owner_id,
|
||||
last_review_date,
|
||||
due_date,
|
||||
status,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM
|
||||
compliance_registries
|
||||
WHERE
|
||||
%s
|
||||
AND organization_id = @organization_id
|
||||
AND %s
|
||||
`
|
||||
|
||||
q = fmt.Sprintf(q, scope.SQLFragment(), cursor.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{"organization_id": organizationID}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
maps.Copy(args, cursor.SQLArguments())
|
||||
|
||||
rows, err := conn.Query(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot query compliance registries: %w", err)
|
||||
}
|
||||
|
||||
registries, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[ComplianceRegistry])
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot collect compliance registries: %w", err)
|
||||
}
|
||||
|
||||
*crs = registries
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cr *ComplianceRegistry) Insert(
|
||||
ctx context.Context,
|
||||
conn pg.Conn,
|
||||
scope Scoper,
|
||||
) error {
|
||||
q := `
|
||||
INSERT INTO compliance_registries (
|
||||
id,
|
||||
tenant_id,
|
||||
organization_id,
|
||||
reference_id,
|
||||
area,
|
||||
source,
|
||||
audit_id,
|
||||
requirement,
|
||||
actions_to_be_implemented,
|
||||
regulator,
|
||||
owner_id,
|
||||
last_review_date,
|
||||
due_date,
|
||||
status,
|
||||
created_at,
|
||||
updated_at
|
||||
) VALUES (
|
||||
@id,
|
||||
@tenant_id,
|
||||
@organization_id,
|
||||
@reference_id,
|
||||
@area,
|
||||
@source,
|
||||
@audit_id,
|
||||
@requirement,
|
||||
@actions_to_be_implemented,
|
||||
@regulator,
|
||||
@owner_id,
|
||||
@last_review_date,
|
||||
@due_date,
|
||||
@status,
|
||||
@created_at,
|
||||
@updated_at
|
||||
)
|
||||
`
|
||||
|
||||
args := pgx.StrictNamedArgs{
|
||||
"id": cr.ID,
|
||||
"tenant_id": scope.GetTenantID(),
|
||||
"organization_id": cr.OrganizationID,
|
||||
"reference_id": cr.ReferenceID,
|
||||
"area": cr.Area,
|
||||
"source": cr.Source,
|
||||
"audit_id": cr.AuditID,
|
||||
"requirement": cr.Requirement,
|
||||
"actions_to_be_implemented": cr.ActionsToBeImplemented,
|
||||
"regulator": cr.Regulator,
|
||||
"owner_id": cr.OwnerID,
|
||||
"last_review_date": cr.LastReviewDate,
|
||||
"due_date": cr.DueDate,
|
||||
"status": cr.Status,
|
||||
"created_at": cr.CreatedAt,
|
||||
"updated_at": cr.UpdatedAt,
|
||||
}
|
||||
|
||||
_, err := conn.Exec(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot insert compliance registry: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cr *ComplianceRegistry) Update(
|
||||
ctx context.Context,
|
||||
conn pg.Conn,
|
||||
scope Scoper,
|
||||
) error {
|
||||
q := `
|
||||
UPDATE compliance_registries SET
|
||||
reference_id = @reference_id,
|
||||
area = @area,
|
||||
source = @source,
|
||||
audit_id = @audit_id,
|
||||
requirement = @requirement,
|
||||
actions_to_be_implemented = @actions_to_be_implemented,
|
||||
regulator = @regulator,
|
||||
owner_id = @owner_id,
|
||||
last_review_date = @last_review_date,
|
||||
due_date = @due_date,
|
||||
status = @status,
|
||||
updated_at = @updated_at
|
||||
WHERE
|
||||
%s
|
||||
AND id = @id
|
||||
`
|
||||
|
||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{
|
||||
"id": cr.ID,
|
||||
"reference_id": cr.ReferenceID,
|
||||
"area": cr.Area,
|
||||
"source": cr.Source,
|
||||
"audit_id": cr.AuditID,
|
||||
"requirement": cr.Requirement,
|
||||
"actions_to_be_implemented": cr.ActionsToBeImplemented,
|
||||
"regulator": cr.Regulator,
|
||||
"owner_id": cr.OwnerID,
|
||||
"last_review_date": cr.LastReviewDate,
|
||||
"due_date": cr.DueDate,
|
||||
"status": cr.Status,
|
||||
"updated_at": cr.UpdatedAt,
|
||||
}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
|
||||
_, err := conn.Exec(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot update compliance registry: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cr *ComplianceRegistry) Delete(
|
||||
ctx context.Context,
|
||||
conn pg.Conn,
|
||||
scope Scoper,
|
||||
) error {
|
||||
q := `
|
||||
DELETE FROM compliance_registries
|
||||
WHERE
|
||||
%s
|
||||
AND id = @id
|
||||
`
|
||||
|
||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{"id": cr.ID}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
|
||||
_, err := conn.Exec(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot delete compliance registry: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
55
pkg/coredata/compliance_registry_order_field.go
Normal file
55
pkg/coredata/compliance_registry_order_field.go
Normal file
@@ -0,0 +1,55 @@
|
||||
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
|
||||
//
|
||||
// Permission to use, copy, modify, and/or distribute this software for any
|
||||
// purpose with or without fee is hereby granted, provided that the above
|
||||
// copyright notice and this permission notice appear in all copies.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
// PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type ComplianceRegistryOrderField string
|
||||
|
||||
const (
|
||||
ComplianceRegistryOrderFieldCreatedAt ComplianceRegistryOrderField = "CREATED_AT"
|
||||
ComplianceRegistryOrderFieldLastReviewDate ComplianceRegistryOrderField = "LAST_REVIEW_DATE"
|
||||
ComplianceRegistryOrderFieldDueDate ComplianceRegistryOrderField = "DUE_DATE"
|
||||
ComplianceRegistryOrderFieldStatus ComplianceRegistryOrderField = "STATUS"
|
||||
ComplianceRegistryOrderFieldReferenceId ComplianceRegistryOrderField = "REFERENCE_ID"
|
||||
)
|
||||
|
||||
func (p ComplianceRegistryOrderField) Column() string {
|
||||
return string(p)
|
||||
}
|
||||
|
||||
func (p ComplianceRegistryOrderField) String() string {
|
||||
return string(p)
|
||||
}
|
||||
|
||||
func (p ComplianceRegistryOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(p.String()), nil
|
||||
}
|
||||
|
||||
func (p *ComplianceRegistryOrderField) UnmarshalText(text []byte) error {
|
||||
val := string(text)
|
||||
switch val {
|
||||
case string(ComplianceRegistryOrderFieldCreatedAt),
|
||||
string(ComplianceRegistryOrderFieldLastReviewDate),
|
||||
string(ComplianceRegistryOrderFieldDueDate),
|
||||
string(ComplianceRegistryOrderFieldStatus),
|
||||
string(ComplianceRegistryOrderFieldReferenceId):
|
||||
*p = ComplianceRegistryOrderField(val)
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("invalid ComplianceRegistryOrderField value: %q", val)
|
||||
}
|
||||
60
pkg/coredata/compliance_registry_status.go
Normal file
60
pkg/coredata/compliance_registry_status.go
Normal file
@@ -0,0 +1,60 @@
|
||||
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
|
||||
//
|
||||
// Permission to use, copy, modify, and/or distribute this software for any
|
||||
// purpose with or without fee is hereby granted, provided that the above
|
||||
// copyright notice and this permission notice appear in all copies.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
// PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type ComplianceRegistryStatus string
|
||||
|
||||
const (
|
||||
ComplianceRegistryStatusOpen ComplianceRegistryStatus = "OPEN"
|
||||
ComplianceRegistryStatusInProgress ComplianceRegistryStatus = "IN_PROGRESS"
|
||||
ComplianceRegistryStatusClosed ComplianceRegistryStatus = "CLOSED"
|
||||
)
|
||||
|
||||
func (crs ComplianceRegistryStatus) String() string {
|
||||
return string(crs)
|
||||
}
|
||||
|
||||
func (crs *ComplianceRegistryStatus) Scan(value any) error {
|
||||
var s string
|
||||
switch v := value.(type) {
|
||||
case string:
|
||||
s = v
|
||||
case []byte:
|
||||
s = string(v)
|
||||
default:
|
||||
return fmt.Errorf("unsupported type for ComplianceRegistryStatus: %T", value)
|
||||
}
|
||||
|
||||
switch s {
|
||||
case "OPEN":
|
||||
*crs = ComplianceRegistryStatusOpen
|
||||
case "IN_PROGRESS":
|
||||
*crs = ComplianceRegistryStatusInProgress
|
||||
case "CLOSED":
|
||||
*crs = ComplianceRegistryStatusClosed
|
||||
default:
|
||||
return fmt.Errorf("invalid ComplianceRegistryStatus value: %q", s)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (crs ComplianceRegistryStatus) Value() (driver.Value, error) {
|
||||
return crs.String(), nil
|
||||
}
|
||||
@@ -44,4 +44,5 @@ const (
|
||||
VendorContactEntityType
|
||||
VendorDataPrivacyAgreementEntityType
|
||||
NonconformityRegistryEntityType
|
||||
ComplianceRegistryEntityType
|
||||
)
|
||||
|
||||
42
pkg/coredata/migrations/20250818T094916Z.sql
Normal file
42
pkg/coredata/migrations/20250818T094916Z.sql
Normal file
@@ -0,0 +1,42 @@
|
||||
CREATE TYPE compliance_registries_status AS ENUM (
|
||||
'OPEN',
|
||||
'IN_PROGRESS',
|
||||
'CLOSED'
|
||||
);
|
||||
|
||||
CREATE TABLE compliance_registries (
|
||||
id TEXT PRIMARY KEY,
|
||||
tenant_id TEXT NOT NULL,
|
||||
organization_id TEXT NOT NULL,
|
||||
reference_id TEXT NOT NULL,
|
||||
area TEXT,
|
||||
source TEXT,
|
||||
audit_id TEXT NOT NULL,
|
||||
requirement TEXT,
|
||||
actions_to_be_implemented TEXT,
|
||||
regulator TEXT,
|
||||
owner_id TEXT NOT NULL,
|
||||
last_review_date DATE,
|
||||
due_date DATE,
|
||||
status compliance_registries_status NOT NULL,
|
||||
created_at TIMESTAMP WITH TIME ZONE NOT NULL,
|
||||
updated_at TIMESTAMP WITH TIME ZONE NOT NULL,
|
||||
|
||||
CONSTRAINT compliance_registries_organization_id_fkey
|
||||
FOREIGN KEY (organization_id)
|
||||
REFERENCES organizations(id)
|
||||
ON UPDATE CASCADE
|
||||
ON DELETE CASCADE,
|
||||
|
||||
CONSTRAINT compliance_registries_owner_id_fkey
|
||||
FOREIGN KEY (owner_id)
|
||||
REFERENCES peoples(id)
|
||||
ON UPDATE CASCADE
|
||||
ON DELETE RESTRICT,
|
||||
|
||||
CONSTRAINT compliance_registries_audit_id_fkey
|
||||
FOREIGN KEY (audit_id)
|
||||
REFERENCES audits(id)
|
||||
ON UPDATE CASCADE
|
||||
ON DELETE CASCADE
|
||||
);
|
||||
300
pkg/probo/compliance_registry_service.go
Normal file
300
pkg/probo/compliance_registry_service.go
Normal file
@@ -0,0 +1,300 @@
|
||||
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
|
||||
//
|
||||
// Permission to use, copy, modify, and/or distribute this software for any
|
||||
// purpose with or without fee is hereby granted, provided that the above
|
||||
// copyright notice and this permission notice appear in all copies.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
// PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
package probo
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/getprobo/probo/pkg/coredata"
|
||||
"github.com/getprobo/probo/pkg/gid"
|
||||
"github.com/getprobo/probo/pkg/page"
|
||||
"go.gearno.de/kit/pg"
|
||||
)
|
||||
|
||||
type ComplianceRegistryService struct {
|
||||
svc *TenantService
|
||||
}
|
||||
|
||||
type (
|
||||
CreateComplianceRegistryRequest struct {
|
||||
OrganizationID gid.GID
|
||||
ReferenceID string
|
||||
Area *string
|
||||
Source *string
|
||||
AuditID gid.GID
|
||||
Requirement *string
|
||||
ActionsToBeImplemented *string
|
||||
Regulator *string
|
||||
OwnerID gid.GID
|
||||
LastReviewDate *time.Time
|
||||
DueDate *time.Time
|
||||
Status *coredata.ComplianceRegistryStatus
|
||||
}
|
||||
|
||||
UpdateComplianceRegistryRequest struct {
|
||||
ID gid.GID
|
||||
ReferenceID *string
|
||||
Area **string
|
||||
Source **string
|
||||
AuditID *gid.GID
|
||||
Requirement **string
|
||||
ActionsToBeImplemented **string
|
||||
Regulator **string
|
||||
OwnerID *gid.GID
|
||||
LastReviewDate **time.Time
|
||||
DueDate **time.Time
|
||||
Status *coredata.ComplianceRegistryStatus
|
||||
}
|
||||
)
|
||||
|
||||
func (s ComplianceRegistryService) Get(
|
||||
ctx context.Context,
|
||||
complianceRegistryID gid.GID,
|
||||
) (*coredata.ComplianceRegistry, error) {
|
||||
registry := &coredata.ComplianceRegistry{}
|
||||
|
||||
err := s.svc.pg.WithConn(
|
||||
ctx,
|
||||
func(conn pg.Conn) error {
|
||||
if err := registry.LoadByID(ctx, conn, s.svc.scope, complianceRegistryID); err != nil {
|
||||
return fmt.Errorf("cannot load compliance registry: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return registry, nil
|
||||
}
|
||||
|
||||
func (s *ComplianceRegistryService) Create(
|
||||
ctx context.Context,
|
||||
req *CreateComplianceRegistryRequest,
|
||||
) (*coredata.ComplianceRegistry, error) {
|
||||
now := time.Now()
|
||||
|
||||
registry := &coredata.ComplianceRegistry{
|
||||
ID: gid.New(s.svc.scope.GetTenantID(), coredata.ComplianceRegistryEntityType),
|
||||
OrganizationID: req.OrganizationID,
|
||||
ReferenceID: req.ReferenceID,
|
||||
Area: req.Area,
|
||||
Source: req.Source,
|
||||
AuditID: req.AuditID,
|
||||
Requirement: req.Requirement,
|
||||
ActionsToBeImplemented: req.ActionsToBeImplemented,
|
||||
Regulator: req.Regulator,
|
||||
OwnerID: req.OwnerID,
|
||||
LastReviewDate: req.LastReviewDate,
|
||||
DueDate: req.DueDate,
|
||||
Status: *req.Status,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
}
|
||||
|
||||
err := s.svc.pg.WithTx(
|
||||
ctx,
|
||||
func(conn pg.Conn) error {
|
||||
organization := &coredata.Organization{}
|
||||
if err := organization.LoadByID(ctx, conn, s.svc.scope, req.OrganizationID); err != nil {
|
||||
return fmt.Errorf("cannot load organization: %w", err)
|
||||
}
|
||||
|
||||
audit := &coredata.Audit{}
|
||||
if err := audit.LoadByID(ctx, conn, s.svc.scope, req.AuditID); err != nil {
|
||||
return fmt.Errorf("cannot load audit: %w", err)
|
||||
}
|
||||
|
||||
owner := &coredata.People{}
|
||||
if err := owner.LoadByID(ctx, conn, s.svc.scope, req.OwnerID); err != nil {
|
||||
return fmt.Errorf("cannot load owner: %w", err)
|
||||
}
|
||||
|
||||
if err := registry.Insert(ctx, conn, s.svc.scope); err != nil {
|
||||
return fmt.Errorf("cannot insert compliance registry: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return registry, nil
|
||||
}
|
||||
|
||||
func (s *ComplianceRegistryService) Update(
|
||||
ctx context.Context,
|
||||
req *UpdateComplianceRegistryRequest,
|
||||
) (*coredata.ComplianceRegistry, error) {
|
||||
registry := &coredata.ComplianceRegistry{}
|
||||
|
||||
err := s.svc.pg.WithTx(
|
||||
ctx,
|
||||
func(conn pg.Conn) error {
|
||||
if err := registry.LoadByID(ctx, conn, s.svc.scope, req.ID); err != nil {
|
||||
return fmt.Errorf("cannot load compliance registry: %w", err)
|
||||
}
|
||||
|
||||
if req.ReferenceID != nil {
|
||||
registry.ReferenceID = *req.ReferenceID
|
||||
}
|
||||
|
||||
if req.Area != nil {
|
||||
registry.Area = *req.Area
|
||||
}
|
||||
|
||||
if req.Source != nil {
|
||||
registry.Source = *req.Source
|
||||
}
|
||||
|
||||
if req.AuditID != nil {
|
||||
audit := &coredata.Audit{}
|
||||
if err := audit.LoadByID(ctx, conn, s.svc.scope, *req.AuditID); err != nil {
|
||||
return fmt.Errorf("cannot load audit: %w", err)
|
||||
}
|
||||
registry.AuditID = *req.AuditID
|
||||
}
|
||||
|
||||
if req.Requirement != nil {
|
||||
registry.Requirement = *req.Requirement
|
||||
}
|
||||
|
||||
if req.ActionsToBeImplemented != nil {
|
||||
registry.ActionsToBeImplemented = *req.ActionsToBeImplemented
|
||||
}
|
||||
|
||||
if req.Regulator != nil {
|
||||
registry.Regulator = *req.Regulator
|
||||
}
|
||||
|
||||
if req.OwnerID != nil {
|
||||
owner := &coredata.People{}
|
||||
if err := owner.LoadByID(ctx, conn, s.svc.scope, *req.OwnerID); err != nil {
|
||||
return fmt.Errorf("cannot load owner: %w", err)
|
||||
}
|
||||
registry.OwnerID = *req.OwnerID
|
||||
}
|
||||
|
||||
if req.LastReviewDate != nil {
|
||||
registry.LastReviewDate = *req.LastReviewDate
|
||||
}
|
||||
|
||||
if req.DueDate != nil {
|
||||
registry.DueDate = *req.DueDate
|
||||
}
|
||||
|
||||
if req.Status != nil {
|
||||
registry.Status = *req.Status
|
||||
}
|
||||
|
||||
registry.UpdatedAt = time.Now()
|
||||
|
||||
if err := registry.Update(ctx, conn, s.svc.scope); err != nil {
|
||||
return fmt.Errorf("cannot update compliance registry: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return registry, nil
|
||||
}
|
||||
|
||||
func (s *ComplianceRegistryService) Delete(
|
||||
ctx context.Context,
|
||||
complianceRegistryID gid.GID,
|
||||
) error {
|
||||
err := s.svc.pg.WithTx(
|
||||
ctx,
|
||||
func(conn pg.Conn) error {
|
||||
registry := &coredata.ComplianceRegistry{}
|
||||
if err := registry.LoadByID(ctx, conn, s.svc.scope, complianceRegistryID); err != nil {
|
||||
return fmt.Errorf("cannot load compliance registry: %w", err)
|
||||
}
|
||||
|
||||
if err := registry.Delete(ctx, conn, s.svc.scope); err != nil {
|
||||
return fmt.Errorf("cannot delete compliance registry: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func (s ComplianceRegistryService) CountByOrganizationID(
|
||||
ctx context.Context,
|
||||
organizationID gid.GID,
|
||||
) (int, error) {
|
||||
var count int
|
||||
|
||||
err := s.svc.pg.WithConn(
|
||||
ctx,
|
||||
func(conn pg.Conn) (err error) {
|
||||
registries := coredata.ComplianceRegistries{}
|
||||
count, err = registries.CountByOrganizationID(ctx, conn, s.svc.scope, organizationID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot count compliance registries: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
func (s ComplianceRegistryService) ListForOrganizationID(
|
||||
ctx context.Context,
|
||||
organizationID gid.GID,
|
||||
cursor *page.Cursor[coredata.ComplianceRegistryOrderField],
|
||||
) (*page.Page[*coredata.ComplianceRegistry, coredata.ComplianceRegistryOrderField], error) {
|
||||
var registries coredata.ComplianceRegistries
|
||||
|
||||
err := s.svc.pg.WithConn(
|
||||
ctx,
|
||||
func(conn pg.Conn) error {
|
||||
err := registries.LoadByOrganizationID(ctx, conn, s.svc.scope, organizationID, cursor)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot load compliance registries: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return page.NewPage(registries, cursor), nil
|
||||
}
|
||||
@@ -82,6 +82,7 @@ type (
|
||||
TrustCenters *TrustCenterService
|
||||
TrustCenterAccesses *TrustCenterAccessService
|
||||
NonconformityRegistries *NonconformityRegistryService
|
||||
ComplianceRegistries *ComplianceRegistryService
|
||||
}
|
||||
)
|
||||
|
||||
@@ -175,5 +176,6 @@ func (s *Service) WithTenant(tenantID gid.TenantID) *TenantService {
|
||||
usrmgr: s.usrmgr,
|
||||
}
|
||||
tenantService.NonconformityRegistries = &NonconformityRegistryService{svc: tenantService}
|
||||
tenantService.ComplianceRegistries = &ComplianceRegistryService{svc: tenantService}
|
||||
return tenantService
|
||||
}
|
||||
|
||||
@@ -167,6 +167,22 @@ enum NonconformityRegistryStatus
|
||||
)
|
||||
}
|
||||
|
||||
enum ComplianceRegistryStatus
|
||||
@goModel(model: "github.com/getprobo/probo/pkg/coredata.ComplianceRegistryStatus") {
|
||||
OPEN
|
||||
@goEnum(
|
||||
value: "github.com/getprobo/probo/pkg/coredata.ComplianceRegistryStatusOpen"
|
||||
)
|
||||
IN_PROGRESS
|
||||
@goEnum(
|
||||
value: "github.com/getprobo/probo/pkg/coredata.ComplianceRegistryStatusInProgress"
|
||||
)
|
||||
CLOSED
|
||||
@goEnum(
|
||||
value: "github.com/getprobo/probo/pkg/coredata.ComplianceRegistryStatusClosed"
|
||||
)
|
||||
}
|
||||
|
||||
# Order Field Enums
|
||||
enum UserOrderField
|
||||
@goModel(model: "github.com/getprobo/probo/pkg/coredata.UserOrderField") {
|
||||
@@ -624,6 +640,30 @@ enum NonconformityRegistryOrderField
|
||||
)
|
||||
}
|
||||
|
||||
enum ComplianceRegistryOrderField
|
||||
@goModel(model: "github.com/getprobo/probo/pkg/coredata.ComplianceRegistryOrderField") {
|
||||
CREATED_AT
|
||||
@goEnum(
|
||||
value: "github.com/getprobo/probo/pkg/coredata.ComplianceRegistryOrderFieldCreatedAt"
|
||||
)
|
||||
REFERENCE_ID
|
||||
@goEnum(
|
||||
value: "github.com/getprobo/probo/pkg/coredata.ComplianceRegistryOrderFieldReferenceId"
|
||||
)
|
||||
LAST_REVIEW_DATE
|
||||
@goEnum(
|
||||
value: "github.com/getprobo/probo/pkg/coredata.ComplianceRegistryOrderFieldLastReviewDate"
|
||||
)
|
||||
DUE_DATE
|
||||
@goEnum(
|
||||
value: "github.com/getprobo/probo/pkg/coredata.ComplianceRegistryOrderFieldDueDate"
|
||||
)
|
||||
STATUS
|
||||
@goEnum(
|
||||
value: "github.com/getprobo/probo/pkg/coredata.ComplianceRegistryOrderFieldStatus"
|
||||
)
|
||||
}
|
||||
|
||||
enum TrustCenterAccessOrderField
|
||||
@goModel(model: "github.com/getprobo/probo/pkg/coredata.TrustCenterAccessOrderField") {
|
||||
CREATED_AT
|
||||
@@ -721,6 +761,14 @@ input NonconformityRegistryOrder
|
||||
field: NonconformityRegistryOrderField!
|
||||
}
|
||||
|
||||
input ComplianceRegistryOrder
|
||||
@goModel(
|
||||
model: "github.com/getprobo/probo/pkg/server/api/console/v1/types.ComplianceRegistryOrderBy"
|
||||
) {
|
||||
direction: OrderDirection!
|
||||
field: ComplianceRegistryOrderField!
|
||||
}
|
||||
|
||||
input TrustCenterAccessOrder
|
||||
@goModel(
|
||||
model: "github.com/getprobo/probo/pkg/server/api/console/v1/types.TrustCenterAccessOrderBy"
|
||||
@@ -944,6 +992,14 @@ type Organization implements Node {
|
||||
orderBy: NonconformityRegistryOrder
|
||||
): NonconformityRegistryConnection! @goField(forceResolver: true)
|
||||
|
||||
complianceRegistries(
|
||||
first: Int
|
||||
after: CursorKey
|
||||
last: Int
|
||||
before: CursorKey
|
||||
orderBy: ComplianceRegistryOrder
|
||||
): ComplianceRegistryConnection! @goField(forceResolver: true)
|
||||
|
||||
trustCenter: TrustCenter @goField(forceResolver: true)
|
||||
|
||||
createdAt: Datetime!
|
||||
@@ -1353,6 +1409,24 @@ type NonconformityRegistry implements Node {
|
||||
updatedAt: Datetime!
|
||||
}
|
||||
|
||||
type ComplianceRegistry implements Node {
|
||||
id: ID!
|
||||
organization: Organization! @goField(forceResolver: true)
|
||||
referenceId: String!
|
||||
area: String
|
||||
source: String
|
||||
audit: Audit! @goField(forceResolver: true)
|
||||
requirement: String
|
||||
actionsToBeImplemented: String
|
||||
regulator: String
|
||||
owner: People! @goField(forceResolver: true)
|
||||
lastReviewDate: Datetime
|
||||
dueDate: Datetime
|
||||
status: ComplianceRegistryStatus!
|
||||
createdAt: Datetime!
|
||||
updatedAt: Datetime!
|
||||
}
|
||||
|
||||
type Report implements Node {
|
||||
id: ID!
|
||||
objectKey: String!
|
||||
@@ -1650,6 +1724,20 @@ type NonconformityRegistryEdge {
|
||||
node: NonconformityRegistry!
|
||||
}
|
||||
|
||||
type ComplianceRegistryConnection
|
||||
@goModel(
|
||||
model: "github.com/getprobo/probo/pkg/server/api/console/v1/types.ComplianceRegistryConnection"
|
||||
) {
|
||||
totalCount: Int! @goField(forceResolver: true)
|
||||
edges: [ComplianceRegistryEdge!]!
|
||||
pageInfo: PageInfo!
|
||||
}
|
||||
|
||||
type ComplianceRegistryEdge {
|
||||
cursor: CursorKey!
|
||||
node: ComplianceRegistry!
|
||||
}
|
||||
|
||||
# Root Types
|
||||
type Query {
|
||||
node(id: ID!): Node!
|
||||
@@ -1880,6 +1968,17 @@ type Mutation {
|
||||
deleteNonconformityRegistry(
|
||||
input: DeleteNonconformityRegistryInput!
|
||||
): DeleteNonconformityRegistryPayload!
|
||||
|
||||
# Compliance Registry mutations
|
||||
createComplianceRegistry(
|
||||
input: CreateComplianceRegistryInput!
|
||||
): CreateComplianceRegistryPayload!
|
||||
updateComplianceRegistry(
|
||||
input: UpdateComplianceRegistryInput!
|
||||
): UpdateComplianceRegistryPayload!
|
||||
deleteComplianceRegistry(
|
||||
input: DeleteComplianceRegistryInput!
|
||||
): DeleteComplianceRegistryPayload!
|
||||
}
|
||||
|
||||
# Input Types
|
||||
@@ -2374,6 +2473,40 @@ input DeleteNonconformityRegistryInput {
|
||||
nonconformityRegistryId: ID!
|
||||
}
|
||||
|
||||
input CreateComplianceRegistryInput {
|
||||
organizationId: ID!
|
||||
referenceId: String!
|
||||
area: String
|
||||
source: String
|
||||
auditId: ID!
|
||||
requirement: String
|
||||
actionsToBeImplemented: String
|
||||
regulator: String
|
||||
ownerId: ID!
|
||||
lastReviewDate: Datetime
|
||||
dueDate: Datetime
|
||||
status: ComplianceRegistryStatus!
|
||||
}
|
||||
|
||||
input UpdateComplianceRegistryInput {
|
||||
id: ID!
|
||||
referenceId: String
|
||||
area: String
|
||||
source: String
|
||||
auditId: ID
|
||||
requirement: String
|
||||
actionsToBeImplemented: String
|
||||
regulator: String
|
||||
ownerId: ID
|
||||
lastReviewDate: Datetime
|
||||
dueDate: Datetime
|
||||
status: ComplianceRegistryStatus
|
||||
}
|
||||
|
||||
input DeleteComplianceRegistryInput {
|
||||
complianceRegistryId: ID!
|
||||
}
|
||||
|
||||
# Payload Types
|
||||
type CreateOrganizationPayload {
|
||||
organizationEdge: OrganizationEdge!
|
||||
@@ -3055,3 +3188,15 @@ type UpdateNonconformityRegistryPayload {
|
||||
type DeleteNonconformityRegistryPayload {
|
||||
deletedNonconformityRegistryId: ID!
|
||||
}
|
||||
|
||||
type CreateComplianceRegistryPayload {
|
||||
complianceRegistryEdge: ComplianceRegistryEdge!
|
||||
}
|
||||
|
||||
type UpdateComplianceRegistryPayload {
|
||||
complianceRegistry: ComplianceRegistry!
|
||||
}
|
||||
|
||||
type DeleteComplianceRegistryPayload {
|
||||
deletedComplianceRegistryId: ID!
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
77
pkg/server/api/console/v1/types/compliance_registry.go
Normal file
77
pkg/server/api/console/v1/types/compliance_registry.go
Normal file
@@ -0,0 +1,77 @@
|
||||
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
|
||||
//
|
||||
// Permission to use, copy, modify, and/or distribute this software for any
|
||||
// purpose with or without fee is hereby granted, provided that the above
|
||||
// copyright notice and this permission notice appear in all copies.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
// PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
package types
|
||||
|
||||
import (
|
||||
"github.com/getprobo/probo/pkg/coredata"
|
||||
"github.com/getprobo/probo/pkg/gid"
|
||||
"github.com/getprobo/probo/pkg/page"
|
||||
)
|
||||
|
||||
type (
|
||||
ComplianceRegistryOrderBy OrderBy[coredata.ComplianceRegistryOrderField]
|
||||
|
||||
ComplianceRegistryConnection struct {
|
||||
TotalCount int
|
||||
Edges []*ComplianceRegistryEdge
|
||||
PageInfo PageInfo
|
||||
|
||||
Resolver any
|
||||
ParentID gid.GID
|
||||
}
|
||||
)
|
||||
|
||||
func NewComplianceRegistryConnection(
|
||||
p *page.Page[*coredata.ComplianceRegistry, coredata.ComplianceRegistryOrderField],
|
||||
parentType any,
|
||||
parentID gid.GID,
|
||||
) *ComplianceRegistryConnection {
|
||||
edges := make([]*ComplianceRegistryEdge, len(p.Data))
|
||||
for i, registry := range p.Data {
|
||||
edges[i] = NewComplianceRegistryEdge(registry, p.Cursor.OrderBy.Field)
|
||||
}
|
||||
|
||||
return &ComplianceRegistryConnection{
|
||||
Edges: edges,
|
||||
PageInfo: *NewPageInfo(p),
|
||||
|
||||
Resolver: parentType,
|
||||
ParentID: parentID,
|
||||
}
|
||||
}
|
||||
|
||||
func NewComplianceRegistry(cr *coredata.ComplianceRegistry) *ComplianceRegistry {
|
||||
return &ComplianceRegistry{
|
||||
ID: cr.ID,
|
||||
ReferenceID: cr.ReferenceID,
|
||||
Area: cr.Area,
|
||||
Source: cr.Source,
|
||||
Requirement: cr.Requirement,
|
||||
ActionsToBeImplemented: cr.ActionsToBeImplemented,
|
||||
Regulator: cr.Regulator,
|
||||
LastReviewDate: cr.LastReviewDate,
|
||||
DueDate: cr.DueDate,
|
||||
Status: cr.Status,
|
||||
CreatedAt: cr.CreatedAt,
|
||||
UpdatedAt: cr.UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
func NewComplianceRegistryEdge(cr *coredata.ComplianceRegistry, orderField coredata.ComplianceRegistryOrderField) *ComplianceRegistryEdge {
|
||||
return &ComplianceRegistryEdge{
|
||||
Node: NewComplianceRegistry(cr),
|
||||
Cursor: cr.CursorKey(orderField),
|
||||
}
|
||||
}
|
||||
@@ -107,6 +107,32 @@ type CancelSignatureRequestPayload struct {
|
||||
DeletedDocumentVersionSignatureID gid.GID `json:"deletedDocumentVersionSignatureId"`
|
||||
}
|
||||
|
||||
type ComplianceRegistry struct {
|
||||
ID gid.GID `json:"id"`
|
||||
Organization *Organization `json:"organization"`
|
||||
ReferenceID string `json:"referenceId"`
|
||||
Area *string `json:"area,omitempty"`
|
||||
Source *string `json:"source,omitempty"`
|
||||
Audit *Audit `json:"audit"`
|
||||
Requirement *string `json:"requirement,omitempty"`
|
||||
ActionsToBeImplemented *string `json:"actionsToBeImplemented,omitempty"`
|
||||
Regulator *string `json:"regulator,omitempty"`
|
||||
Owner *People `json:"owner"`
|
||||
LastReviewDate *time.Time `json:"lastReviewDate,omitempty"`
|
||||
DueDate *time.Time `json:"dueDate,omitempty"`
|
||||
Status coredata.ComplianceRegistryStatus `json:"status"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
}
|
||||
|
||||
func (ComplianceRegistry) IsNode() {}
|
||||
func (this ComplianceRegistry) GetID() gid.GID { return this.ID }
|
||||
|
||||
type ComplianceRegistryEdge struct {
|
||||
Cursor page.CursorKey `json:"cursor"`
|
||||
Node *ComplianceRegistry `json:"node"`
|
||||
}
|
||||
|
||||
type ConfirmEmailInput struct {
|
||||
Token string `json:"token"`
|
||||
}
|
||||
@@ -196,6 +222,25 @@ type CreateAuditPayload struct {
|
||||
AuditEdge *AuditEdge `json:"auditEdge"`
|
||||
}
|
||||
|
||||
type CreateComplianceRegistryInput struct {
|
||||
OrganizationID gid.GID `json:"organizationId"`
|
||||
ReferenceID string `json:"referenceId"`
|
||||
Area *string `json:"area,omitempty"`
|
||||
Source *string `json:"source,omitempty"`
|
||||
AuditID gid.GID `json:"auditId"`
|
||||
Requirement *string `json:"requirement,omitempty"`
|
||||
ActionsToBeImplemented *string `json:"actionsToBeImplemented,omitempty"`
|
||||
Regulator *string `json:"regulator,omitempty"`
|
||||
OwnerID gid.GID `json:"ownerId"`
|
||||
LastReviewDate *time.Time `json:"lastReviewDate,omitempty"`
|
||||
DueDate *time.Time `json:"dueDate,omitempty"`
|
||||
Status coredata.ComplianceRegistryStatus `json:"status"`
|
||||
}
|
||||
|
||||
type CreateComplianceRegistryPayload struct {
|
||||
ComplianceRegistryEdge *ComplianceRegistryEdge `json:"complianceRegistryEdge"`
|
||||
}
|
||||
|
||||
type CreateControlAuditMappingInput struct {
|
||||
ControlID gid.GID `json:"controlId"`
|
||||
AuditID gid.GID `json:"auditId"`
|
||||
@@ -503,6 +548,14 @@ type DeleteAuditReportPayload struct {
|
||||
Audit *Audit `json:"audit"`
|
||||
}
|
||||
|
||||
type DeleteComplianceRegistryInput struct {
|
||||
ComplianceRegistryID gid.GID `json:"complianceRegistryId"`
|
||||
}
|
||||
|
||||
type DeleteComplianceRegistryPayload struct {
|
||||
DeletedComplianceRegistryID gid.GID `json:"deletedComplianceRegistryId"`
|
||||
}
|
||||
|
||||
type DeleteControlAuditMappingInput struct {
|
||||
ControlID gid.GID `json:"controlId"`
|
||||
AuditID gid.GID `json:"auditId"`
|
||||
@@ -964,6 +1017,7 @@ type Organization struct {
|
||||
Data *DatumConnection `json:"data"`
|
||||
Audits *AuditConnection `json:"audits"`
|
||||
NonconformityRegistries *NonconformityRegistryConnection `json:"nonconformityRegistries"`
|
||||
ComplianceRegistries *ComplianceRegistryConnection `json:"complianceRegistries"`
|
||||
TrustCenter *TrustCenter `json:"trustCenter,omitempty"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
@@ -1233,6 +1287,25 @@ type UpdateAuditPayload struct {
|
||||
Audit *Audit `json:"audit"`
|
||||
}
|
||||
|
||||
type UpdateComplianceRegistryInput struct {
|
||||
ID gid.GID `json:"id"`
|
||||
ReferenceID *string `json:"referenceId,omitempty"`
|
||||
Area *string `json:"area,omitempty"`
|
||||
Source *string `json:"source,omitempty"`
|
||||
AuditID *gid.GID `json:"auditId,omitempty"`
|
||||
Requirement *string `json:"requirement,omitempty"`
|
||||
ActionsToBeImplemented *string `json:"actionsToBeImplemented,omitempty"`
|
||||
Regulator *string `json:"regulator,omitempty"`
|
||||
OwnerID *gid.GID `json:"ownerId,omitempty"`
|
||||
LastReviewDate *time.Time `json:"lastReviewDate,omitempty"`
|
||||
DueDate *time.Time `json:"dueDate,omitempty"`
|
||||
Status *coredata.ComplianceRegistryStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
type UpdateComplianceRegistryPayload struct {
|
||||
ComplianceRegistry *ComplianceRegistry `json:"complianceRegistry"`
|
||||
}
|
||||
|
||||
type UpdateControlInput struct {
|
||||
ID gid.GID `json:"id"`
|
||||
SectionTitle *string `json:"sectionTitle,omitempty"`
|
||||
|
||||
@@ -220,6 +220,73 @@ func (r *auditConnectionResolver) TotalCount(ctx context.Context, obj *types.Aud
|
||||
return count, nil
|
||||
}
|
||||
|
||||
// Organization is the resolver for the organization field.
|
||||
func (r *complianceRegistryResolver) Organization(ctx context.Context, obj *types.ComplianceRegistry) (*types.Organization, error) {
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
|
||||
registry, err := prb.ComplianceRegistries.Get(ctx, obj.ID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot get compliance registry: %w", err))
|
||||
}
|
||||
|
||||
organization, err := prb.Organizations.Get(ctx, registry.OrganizationID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot get compliance registry organization: %w", err))
|
||||
}
|
||||
|
||||
return types.NewOrganization(organization), nil
|
||||
}
|
||||
|
||||
// Audit is the resolver for the audit field.
|
||||
func (r *complianceRegistryResolver) Audit(ctx context.Context, obj *types.ComplianceRegistry) (*types.Audit, error) {
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
|
||||
registry, err := prb.ComplianceRegistries.Get(ctx, obj.ID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot get compliance registry: %w", err))
|
||||
}
|
||||
|
||||
audit, err := prb.Audits.Get(ctx, registry.AuditID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot get compliance registry audit: %w", err))
|
||||
}
|
||||
|
||||
return types.NewAudit(audit), nil
|
||||
}
|
||||
|
||||
// Owner is the resolver for the owner field.
|
||||
func (r *complianceRegistryResolver) Owner(ctx context.Context, obj *types.ComplianceRegistry) (*types.People, error) {
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
|
||||
registry, err := prb.ComplianceRegistries.Get(ctx, obj.ID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot get compliance registry: %w", err))
|
||||
}
|
||||
|
||||
people, err := prb.Peoples.Get(ctx, registry.OwnerID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot get compliance registry owner: %w", err))
|
||||
}
|
||||
|
||||
return types.NewPeople(people), nil
|
||||
}
|
||||
|
||||
// TotalCount is the resolver for the totalCount field.
|
||||
func (r *complianceRegistryConnectionResolver) TotalCount(ctx context.Context, obj *types.ComplianceRegistryConnection) (int, error) {
|
||||
prb := r.ProboService(ctx, obj.ParentID.TenantID())
|
||||
|
||||
switch obj.Resolver.(type) {
|
||||
case *organizationResolver:
|
||||
count, err := prb.ComplianceRegistries.CountByOrganizationID(ctx, obj.ParentID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot count compliance registries: %w", err))
|
||||
}
|
||||
return count, nil
|
||||
}
|
||||
|
||||
panic(fmt.Errorf("unsupported resolver: %T", obj.Resolver))
|
||||
}
|
||||
|
||||
// Framework is the resolver for the framework field.
|
||||
func (r *controlResolver) Framework(ctx context.Context, obj *types.Control) (*types.Framework, error) {
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
@@ -2783,6 +2850,78 @@ func (r *mutationResolver) DeleteNonconformityRegistry(ctx context.Context, inpu
|
||||
}, nil
|
||||
}
|
||||
|
||||
// CreateComplianceRegistry is the resolver for the createComplianceRegistry field.
|
||||
func (r *mutationResolver) CreateComplianceRegistry(ctx context.Context, input types.CreateComplianceRegistryInput) (*types.CreateComplianceRegistryPayload, error) {
|
||||
prb := r.ProboService(ctx, input.OrganizationID.TenantID())
|
||||
|
||||
req := probo.CreateComplianceRegistryRequest{
|
||||
OrganizationID: input.OrganizationID,
|
||||
ReferenceID: input.ReferenceID,
|
||||
Area: input.Area,
|
||||
Source: input.Source,
|
||||
AuditID: input.AuditID,
|
||||
Requirement: input.Requirement,
|
||||
ActionsToBeImplemented: input.ActionsToBeImplemented,
|
||||
Regulator: input.Regulator,
|
||||
OwnerID: input.OwnerID,
|
||||
LastReviewDate: input.LastReviewDate,
|
||||
DueDate: input.DueDate,
|
||||
Status: &input.Status,
|
||||
}
|
||||
|
||||
registry, err := prb.ComplianceRegistries.Create(ctx, &req)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot create compliance registry: %w", err))
|
||||
}
|
||||
|
||||
return &types.CreateComplianceRegistryPayload{
|
||||
ComplianceRegistryEdge: types.NewComplianceRegistryEdge(registry, coredata.ComplianceRegistryOrderFieldCreatedAt),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// UpdateComplianceRegistry is the resolver for the updateComplianceRegistry field.
|
||||
func (r *mutationResolver) UpdateComplianceRegistry(ctx context.Context, input types.UpdateComplianceRegistryInput) (*types.UpdateComplianceRegistryPayload, error) {
|
||||
prb := r.ProboService(ctx, input.ID.TenantID())
|
||||
|
||||
req := probo.UpdateComplianceRegistryRequest{
|
||||
ID: input.ID,
|
||||
ReferenceID: input.ReferenceID,
|
||||
Area: &input.Area,
|
||||
Source: &input.Source,
|
||||
AuditID: input.AuditID,
|
||||
Requirement: &input.Requirement,
|
||||
ActionsToBeImplemented: &input.ActionsToBeImplemented,
|
||||
Regulator: &input.Regulator,
|
||||
OwnerID: input.OwnerID,
|
||||
LastReviewDate: &input.LastReviewDate,
|
||||
DueDate: &input.DueDate,
|
||||
Status: input.Status,
|
||||
}
|
||||
|
||||
registry, err := prb.ComplianceRegistries.Update(ctx, &req)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot update compliance registry: %w", err))
|
||||
}
|
||||
|
||||
return &types.UpdateComplianceRegistryPayload{
|
||||
ComplianceRegistry: types.NewComplianceRegistry(registry),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// DeleteComplianceRegistry is the resolver for the deleteComplianceRegistry field.
|
||||
func (r *mutationResolver) DeleteComplianceRegistry(ctx context.Context, input types.DeleteComplianceRegistryInput) (*types.DeleteComplianceRegistryPayload, error) {
|
||||
prb := r.ProboService(ctx, input.ComplianceRegistryID.TenantID())
|
||||
|
||||
err := prb.ComplianceRegistries.Delete(ctx, input.ComplianceRegistryID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot delete compliance registry: %w", err))
|
||||
}
|
||||
|
||||
return &types.DeleteComplianceRegistryPayload{
|
||||
DeletedComplianceRegistryID: input.ComplianceRegistryID,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Organization is the resolver for the organization field.
|
||||
func (r *nonconformityRegistryResolver) Organization(ctx context.Context, obj *types.NonconformityRegistry) (*types.Organization, error) {
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
@@ -3230,6 +3369,31 @@ func (r *organizationResolver) NonconformityRegistries(ctx context.Context, obj
|
||||
return types.NewNonconformityRegistryConnection(page, r, obj.ID), nil
|
||||
}
|
||||
|
||||
// ComplianceRegistries is the resolver for the complianceRegistries field.
|
||||
func (r *organizationResolver) ComplianceRegistries(ctx context.Context, obj *types.Organization, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.ComplianceRegistryOrderBy) (*types.ComplianceRegistryConnection, error) {
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.ComplianceRegistryOrderField]{
|
||||
Field: coredata.ComplianceRegistryOrderFieldCreatedAt,
|
||||
Direction: page.OrderDirectionDesc,
|
||||
}
|
||||
if orderBy != nil {
|
||||
pageOrderBy = page.OrderBy[coredata.ComplianceRegistryOrderField]{
|
||||
Field: orderBy.Field,
|
||||
Direction: orderBy.Direction,
|
||||
}
|
||||
}
|
||||
|
||||
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
||||
|
||||
page, err := prb.ComplianceRegistries.ListForOrganizationID(ctx, obj.ID, cursor)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot list organization compliance registries: %w", err))
|
||||
}
|
||||
|
||||
return types.NewComplianceRegistryConnection(page, r, obj.ID), nil
|
||||
}
|
||||
|
||||
// TrustCenter is the resolver for the trustCenter field.
|
||||
func (r *organizationResolver) TrustCenter(ctx context.Context, obj *types.Organization) (*types.TrustCenter, error) {
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
@@ -3379,6 +3543,12 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
panic(fmt.Errorf("cannot get nonconformity registry: %w", err))
|
||||
}
|
||||
return types.NewNonconformityRegistry(nonconformityRegistry), nil
|
||||
case coredata.ComplianceRegistryEntityType:
|
||||
complianceRegistry, err := prb.ComplianceRegistries.Get(ctx, id)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot get compliance registry: %w", err))
|
||||
}
|
||||
return types.NewComplianceRegistry(complianceRegistry), nil
|
||||
case coredata.ReportEntityType:
|
||||
report, err := prb.Reports.Get(ctx, id)
|
||||
if err != nil {
|
||||
@@ -4077,6 +4247,16 @@ func (r *Resolver) AuditConnection() schema.AuditConnectionResolver {
|
||||
return &auditConnectionResolver{r}
|
||||
}
|
||||
|
||||
// ComplianceRegistry returns schema.ComplianceRegistryResolver implementation.
|
||||
func (r *Resolver) ComplianceRegistry() schema.ComplianceRegistryResolver {
|
||||
return &complianceRegistryResolver{r}
|
||||
}
|
||||
|
||||
// ComplianceRegistryConnection returns schema.ComplianceRegistryConnectionResolver implementation.
|
||||
func (r *Resolver) ComplianceRegistryConnection() schema.ComplianceRegistryConnectionResolver {
|
||||
return &complianceRegistryConnectionResolver{r}
|
||||
}
|
||||
|
||||
// Control returns schema.ControlResolver implementation.
|
||||
func (r *Resolver) Control() schema.ControlResolver { return &controlResolver{r} }
|
||||
|
||||
@@ -4218,6 +4398,8 @@ type assetResolver struct{ *Resolver }
|
||||
type assetConnectionResolver struct{ *Resolver }
|
||||
type auditResolver struct{ *Resolver }
|
||||
type auditConnectionResolver struct{ *Resolver }
|
||||
type complianceRegistryResolver struct{ *Resolver }
|
||||
type complianceRegistryConnectionResolver struct{ *Resolver }
|
||||
type controlResolver struct{ *Resolver }
|
||||
type controlConnectionResolver struct{ *Resolver }
|
||||
type datumResolver struct{ *Resolver }
|
||||
|
||||
Reference in New Issue
Block a user