Add public trust center documents
Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
@@ -9,14 +9,14 @@ import {
|
||||
Tbody,
|
||||
Th,
|
||||
IconChevronDown,
|
||||
IconCheckmark1,
|
||||
IconCrossLargeX,
|
||||
Badge,
|
||||
Field,
|
||||
Option,
|
||||
} from "@probo/ui";
|
||||
import { useTranslate } from "@probo/i18n";
|
||||
import { useFragment } from "react-relay";
|
||||
import { useMemo, useState } from "react";
|
||||
import { sprintf, getAuditStateVariant, getAuditStateLabel, formatDate } from "@probo/helpers";
|
||||
import { useMemo, useState, useCallback, useEffect } from "react";
|
||||
import { sprintf, getAuditStateVariant, getAuditStateLabel, formatDate, getTrustCenterVisibilityOptions } from "@probo/helpers";
|
||||
import { useOrganizationId } from "/hooks/useOrganizationId";
|
||||
import clsx from "clsx";
|
||||
import type { TrustCenterAuditsCardFragment$key } from "./__generated__/TrustCenterAuditsCardFragment.graphql";
|
||||
@@ -31,7 +31,7 @@ const trustCenterAuditFragment = graphql`
|
||||
validFrom
|
||||
validUntil
|
||||
state
|
||||
showOnTrustCenter
|
||||
trustCenterVisibility
|
||||
createdAt
|
||||
}
|
||||
`;
|
||||
@@ -40,7 +40,7 @@ type Mutation<Params> = (p: {
|
||||
variables: {
|
||||
input: {
|
||||
id: string;
|
||||
showOnTrustCenter: boolean;
|
||||
trustCenterVisibility: "NONE" | "PRIVATE" | "PUBLIC";
|
||||
} & Params;
|
||||
};
|
||||
}) => void;
|
||||
@@ -49,7 +49,7 @@ type Props<Params> = {
|
||||
audits: TrustCenterAuditsCardFragment$key[];
|
||||
params: Params;
|
||||
disabled?: boolean;
|
||||
onToggleVisibility: Mutation<Params>;
|
||||
onChangeVisibility: Mutation<Params>;
|
||||
variant?: "card" | "table";
|
||||
};
|
||||
|
||||
@@ -62,12 +62,12 @@ export function TrustCenterAuditsCard<Params>(props: Props<Params>) {
|
||||
const showMoreButton = limit !== null && props.audits.length > limit;
|
||||
const variant = props.variant ?? "table";
|
||||
|
||||
const onToggleVisibility = (auditId: string, showOnTrustCenter: boolean) => {
|
||||
props.onToggleVisibility({
|
||||
const onChangeVisibility = (auditId: string, trustCenterVisibility: "NONE" | "PRIVATE" | "PUBLIC") => {
|
||||
props.onChangeVisibility({
|
||||
variables: {
|
||||
input: {
|
||||
id: auditId,
|
||||
showOnTrustCenter,
|
||||
trustCenterVisibility,
|
||||
...props.params,
|
||||
},
|
||||
},
|
||||
@@ -86,7 +86,6 @@ export function TrustCenterAuditsCard<Params>(props: Props<Params>) {
|
||||
<Th>{__("Valid Until")}</Th>
|
||||
<Th>{__("State")}</Th>
|
||||
<Th>{__("Visibility")}</Th>
|
||||
<Th></Th>
|
||||
</Tr>
|
||||
</Thead>
|
||||
<Tbody>
|
||||
@@ -101,7 +100,7 @@ export function TrustCenterAuditsCard<Params>(props: Props<Params>) {
|
||||
<AuditRow
|
||||
key={index}
|
||||
audit={audit}
|
||||
onToggleVisibility={onToggleVisibility}
|
||||
onChangeVisibility={onChangeVisibility}
|
||||
disabled={props.disabled}
|
||||
/>
|
||||
))}
|
||||
@@ -123,12 +122,30 @@ export function TrustCenterAuditsCard<Params>(props: Props<Params>) {
|
||||
|
||||
function AuditRow(props: {
|
||||
audit: TrustCenterAuditsCardFragment$key;
|
||||
onToggleVisibility: (auditId: string, showOnTrustCenter: boolean) => void;
|
||||
onChangeVisibility: (auditId: string, trustCenterVisibility: "NONE" | "PRIVATE" | "PUBLIC") => void;
|
||||
disabled?: boolean;
|
||||
}) {
|
||||
const audit = useFragment(trustCenterAuditFragment, props.audit);
|
||||
const organizationId = useOrganizationId();
|
||||
const { __ } = useTranslate();
|
||||
const [optimisticValue, setOptimisticValue] = useState<string | null>(null);
|
||||
|
||||
const handleValueChange = useCallback((value: string | {}) => {
|
||||
const stringValue = typeof value === 'string' ? value : '';
|
||||
const typedValue = stringValue as "NONE" | "PRIVATE" | "PUBLIC";
|
||||
setOptimisticValue(typedValue);
|
||||
props.onChangeVisibility(audit.id, typedValue);
|
||||
}, [audit.id, props.onChangeVisibility]);
|
||||
|
||||
useEffect(() => {
|
||||
if (optimisticValue && audit.trustCenterVisibility === optimisticValue) {
|
||||
setOptimisticValue(null);
|
||||
}
|
||||
}, [audit.trustCenterVisibility, optimisticValue]);
|
||||
|
||||
const currentValue = optimisticValue || audit.trustCenterVisibility;
|
||||
|
||||
const visibilityOptions = getTrustCenterVisibilityOptions(__);
|
||||
|
||||
const validUntilFormatted = audit.validUntil
|
||||
? formatDate(audit.validUntil)
|
||||
@@ -148,30 +165,24 @@ function AuditRow(props: {
|
||||
{getAuditStateLabel(__, audit.state)}
|
||||
</Badge>
|
||||
</Td>
|
||||
<Td>
|
||||
<div className="flex items-center gap-2">
|
||||
{audit.showOnTrustCenter ? (
|
||||
<>
|
||||
<IconCheckmark1 className="w-4 h-4 text-txt-primary" />
|
||||
<span className="text-txt-primary">{__("Visible")}</span>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<IconCrossLargeX className="w-4 h-4 text-txt-tertiary" />
|
||||
<span className="text-txt-tertiary">{__("Hidden")}</span>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</Td>
|
||||
<Td noLink width={100} className="text-end">
|
||||
<Button
|
||||
variant="secondary"
|
||||
onClick={() => props.onToggleVisibility(audit.id, !audit.showOnTrustCenter)}
|
||||
icon={audit.showOnTrustCenter ? IconCrossLargeX : IconCheckmark1}
|
||||
<Td noLink width={130} className="pr-0">
|
||||
<Field
|
||||
type="select"
|
||||
value={currentValue}
|
||||
onValueChange={handleValueChange}
|
||||
disabled={props.disabled}
|
||||
className="w-[105px]"
|
||||
>
|
||||
{audit.showOnTrustCenter ? __("Hide") : __("Show")}
|
||||
</Button>
|
||||
{visibilityOptions.map((option) => (
|
||||
<Option key={option.value} value={option.value}>
|
||||
<div className="flex items-center justify-between w-full">
|
||||
<Badge variant={option.variant}>
|
||||
{option.label}
|
||||
</Badge>
|
||||
</div>
|
||||
</Option>
|
||||
))}
|
||||
</Field>
|
||||
</Td>
|
||||
</Tr>
|
||||
);
|
||||
|
||||
@@ -1,99 +0,0 @@
|
||||
import { useTranslate } from "@probo/i18n";
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogFooter,
|
||||
Button,
|
||||
useDialogRef,
|
||||
} from "@probo/ui";
|
||||
import { type ReactNode } from "react";
|
||||
import { useFragment, graphql } from "react-relay";
|
||||
import type { TrustCenterDocumentsCardFragment$key } from "./__generated__/TrustCenterDocumentsCardFragment.graphql";
|
||||
|
||||
const trustCenterDocumentDialogFragment = graphql`
|
||||
fragment TrustCenterDocumentDialogFragment on Document {
|
||||
id
|
||||
title
|
||||
showOnTrustCenter
|
||||
}
|
||||
`;
|
||||
|
||||
type Props = {
|
||||
children: ReactNode;
|
||||
documents: (TrustCenterDocumentsCardFragment$key & { id: string })[];
|
||||
onToggleVisibility: (documentId: string, showOnTrustCenter: boolean) => void;
|
||||
disabled?: boolean;
|
||||
};
|
||||
|
||||
export default function TrustCenterDocumentDialog({
|
||||
children,
|
||||
documents,
|
||||
onToggleVisibility,
|
||||
disabled,
|
||||
}: Props) {
|
||||
const { __ } = useTranslate();
|
||||
const dialogRef = useDialogRef();
|
||||
|
||||
return (
|
||||
<>
|
||||
<span onClick={() => !disabled && dialogRef.current?.open()}>
|
||||
{children}
|
||||
</span>
|
||||
<Dialog ref={dialogRef}>
|
||||
<DialogContent>
|
||||
<div className="text-lg font-semibold mb-4">
|
||||
{__("Manage Document Visibility on Trust Center")}
|
||||
</div>
|
||||
<div className="py-4">
|
||||
<p className="text-txt-secondary mb-4">
|
||||
{__("Control which documents are visible on your public trust center.")}
|
||||
</p>
|
||||
<div className="space-y-2 max-h-96 overflow-y-auto">
|
||||
{documents.map((documentKey) => (
|
||||
<DocumentDialogRow
|
||||
key={documentKey.id}
|
||||
document={documentKey}
|
||||
onToggleVisibility={onToggleVisibility}
|
||||
disabled={disabled}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<DialogFooter>
|
||||
<Button onClick={() => dialogRef.current?.close()}>
|
||||
{__("Close")}
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function DocumentDialogRow({
|
||||
document: documentKey,
|
||||
onToggleVisibility,
|
||||
disabled,
|
||||
}: {
|
||||
document: TrustCenterDocumentsCardFragment$key & { id: string };
|
||||
onToggleVisibility: (documentId: string, showOnTrustCenter: boolean) => void;
|
||||
disabled?: boolean;
|
||||
}) {
|
||||
const document = useFragment(trustCenterDocumentDialogFragment, documentKey);
|
||||
const { __ } = useTranslate();
|
||||
|
||||
return (
|
||||
<div className="flex items-center justify-between p-3 border border-border-solid rounded">
|
||||
<div className="flex-1">
|
||||
<div className="font-medium">{document.title}</div>
|
||||
</div>
|
||||
<Button
|
||||
variant="secondary"
|
||||
onClick={() => onToggleVisibility(document.id, !document.showOnTrustCenter)}
|
||||
disabled={disabled}
|
||||
>
|
||||
{document.showOnTrustCenter ? __("Hide") : __("Show")}
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -9,16 +9,17 @@ import {
|
||||
Tbody,
|
||||
Th,
|
||||
IconChevronDown,
|
||||
IconCheckmark1,
|
||||
IconCrossLargeX,
|
||||
DocumentVersionBadge,
|
||||
DocumentTypeBadge,
|
||||
Field,
|
||||
Option,
|
||||
Badge,
|
||||
} from "@probo/ui";
|
||||
import { useTranslate } from "@probo/i18n";
|
||||
import type { TrustCenterDocumentsCardFragment$key } from "./__generated__/TrustCenterDocumentsCardFragment.graphql";
|
||||
import { useFragment } from "react-relay";
|
||||
import { useMemo, useState } from "react";
|
||||
import { sprintf } from "@probo/helpers";
|
||||
import { useMemo, useState, useCallback, useEffect } from "react";
|
||||
import { sprintf, getTrustCenterVisibilityOptions } from "@probo/helpers";
|
||||
import { useOrganizationId } from "/hooks/useOrganizationId";
|
||||
import clsx from "clsx";
|
||||
|
||||
@@ -28,7 +29,7 @@ const trustCenterDocumentFragment = graphql`
|
||||
title
|
||||
createdAt
|
||||
documentType
|
||||
showOnTrustCenter
|
||||
trustCenterVisibility
|
||||
versions(first: 1) {
|
||||
edges {
|
||||
node {
|
||||
@@ -44,7 +45,7 @@ type Mutation<Params> = (p: {
|
||||
variables: {
|
||||
input: {
|
||||
id: string;
|
||||
showOnTrustCenter: boolean;
|
||||
trustCenterVisibility: "NONE" | "PRIVATE" | "PUBLIC";
|
||||
} & Params;
|
||||
};
|
||||
}) => void;
|
||||
@@ -53,7 +54,7 @@ type Props<Params> = {
|
||||
documents: TrustCenterDocumentsCardFragment$key[];
|
||||
params: Params;
|
||||
disabled?: boolean;
|
||||
onToggleVisibility: Mutation<Params>;
|
||||
onChangeVisibility: Mutation<Params>;
|
||||
variant?: "card" | "table";
|
||||
};
|
||||
|
||||
@@ -66,12 +67,12 @@ export function TrustCenterDocumentsCard<Params>(props: Props<Params>) {
|
||||
const showMoreButton = limit !== null && props.documents.length > limit;
|
||||
const variant = props.variant ?? "table";
|
||||
|
||||
const onToggleVisibility = (documentId: string, showOnTrustCenter: boolean) => {
|
||||
props.onToggleVisibility({
|
||||
const onChangeVisibility = (documentId: string, trustCenterVisibility: "NONE" | "PRIVATE" | "PUBLIC") => {
|
||||
props.onChangeVisibility({
|
||||
variables: {
|
||||
input: {
|
||||
id: documentId,
|
||||
showOnTrustCenter,
|
||||
trustCenterVisibility,
|
||||
...props.params,
|
||||
},
|
||||
},
|
||||
@@ -89,7 +90,6 @@ export function TrustCenterDocumentsCard<Params>(props: Props<Params>) {
|
||||
<Th>{__("Type")}</Th>
|
||||
<Th>{__("State")}</Th>
|
||||
<Th>{__("Visibility")}</Th>
|
||||
<Th></Th>
|
||||
</Tr>
|
||||
</Thead>
|
||||
<Tbody>
|
||||
@@ -104,7 +104,7 @@ export function TrustCenterDocumentsCard<Params>(props: Props<Params>) {
|
||||
<DocumentRow
|
||||
key={index}
|
||||
document={document}
|
||||
onToggleVisibility={onToggleVisibility}
|
||||
onChangeVisibility={onChangeVisibility}
|
||||
disabled={props.disabled}
|
||||
/>
|
||||
))}
|
||||
@@ -127,12 +127,30 @@ export function TrustCenterDocumentsCard<Params>(props: Props<Params>) {
|
||||
|
||||
function DocumentRow(props: {
|
||||
document: TrustCenterDocumentsCardFragment$key;
|
||||
onToggleVisibility: (documentId: string, showOnTrustCenter: boolean) => void;
|
||||
onChangeVisibility: (documentId: string, trustCenterVisibility: "NONE" | "PRIVATE" | "PUBLIC") => void;
|
||||
disabled?: boolean;
|
||||
}) {
|
||||
const document = useFragment(trustCenterDocumentFragment, props.document);
|
||||
const organizationId = useOrganizationId();
|
||||
const { __ } = useTranslate();
|
||||
const [optimisticValue, setOptimisticValue] = useState<string | null>(null);
|
||||
|
||||
const handleValueChange = useCallback((value: string | {}) => {
|
||||
const stringValue = typeof value === 'string' ? value : '';
|
||||
const typedValue = stringValue as "NONE" | "PRIVATE" | "PUBLIC";
|
||||
setOptimisticValue(typedValue);
|
||||
props.onChangeVisibility(document.id, typedValue);
|
||||
}, [document.id, props.onChangeVisibility]);
|
||||
|
||||
useEffect(() => {
|
||||
if (optimisticValue && document.trustCenterVisibility === optimisticValue) {
|
||||
setOptimisticValue(null);
|
||||
}
|
||||
}, [document.trustCenterVisibility, optimisticValue]);
|
||||
|
||||
const currentValue = optimisticValue || document.trustCenterVisibility;
|
||||
|
||||
const visibilityOptions = getTrustCenterVisibilityOptions(__);
|
||||
|
||||
return (
|
||||
<Tr to={`/organizations/${organizationId}/documents/${document.id}`}>
|
||||
@@ -147,30 +165,24 @@ function DocumentRow(props: {
|
||||
<Td>
|
||||
<DocumentVersionBadge state={document.versions?.edges?.[0]?.node?.status} />
|
||||
</Td>
|
||||
<Td>
|
||||
<div className="flex items-center gap-2">
|
||||
{document.showOnTrustCenter ? (
|
||||
<>
|
||||
<IconCheckmark1 className="w-4 h-4 text-txt-primary" />
|
||||
<span className="text-txt-primary">{__("Visible")}</span>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<IconCrossLargeX className="w-4 h-4 text-txt-tertiary" />
|
||||
<span className="text-txt-tertiary">{__("Hidden")}</span>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</Td>
|
||||
<Td noLink width={100} className="text-end">
|
||||
<Button
|
||||
variant="secondary"
|
||||
onClick={() => props.onToggleVisibility(document.id, !document.showOnTrustCenter)}
|
||||
icon={document.showOnTrustCenter ? IconCrossLargeX : IconCheckmark1}
|
||||
<Td noLink width={130} className="pr-0">
|
||||
<Field
|
||||
type="select"
|
||||
value={currentValue}
|
||||
onValueChange={handleValueChange}
|
||||
disabled={props.disabled}
|
||||
className="w-[105px]"
|
||||
>
|
||||
{document.showOnTrustCenter ? __("Hide") : __("Show")}
|
||||
</Button>
|
||||
{visibilityOptions.map((option) => (
|
||||
<Option key={option.value} value={option.value}>
|
||||
<div className="flex items-center justify-between w-full">
|
||||
<Badge variant={option.variant}>
|
||||
{option.label}
|
||||
</Badge>
|
||||
</div>
|
||||
</Option>
|
||||
))}
|
||||
</Field>
|
||||
</Td>
|
||||
</Tr>
|
||||
);
|
||||
|
||||
@@ -137,19 +137,9 @@ function VendorRow(props: {
|
||||
</Badge>
|
||||
</Td>
|
||||
<Td>
|
||||
<div className="flex items-center gap-2">
|
||||
{vendor.showOnTrustCenter ? (
|
||||
<>
|
||||
<IconCheckmark1 className="w-4 h-4 text-txt-primary" />
|
||||
<span className="text-txt-primary">{__("Visible")}</span>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<IconCrossLargeX className="w-4 h-4 text-txt-tertiary" />
|
||||
<span className="text-txt-tertiary">{__("Hidden")}</span>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
<Badge variant={vendor.showOnTrustCenter ? "success" : "danger"}>
|
||||
{vendor.showOnTrustCenter ? __("Visible") : __("None")}
|
||||
</Badge>
|
||||
</Td>
|
||||
<Td noLink width={100} className="text-end">
|
||||
<Button
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @generated SignedSource<<b29f60aeb151f0b4ded9ebb02829b67f>>
|
||||
* @generated SignedSource<<155c0b8eda88507e66eb65e060ded192>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
import { ReaderFragment } from 'relay-runtime';
|
||||
export type AuditState = "COMPLETED" | "IN_PROGRESS" | "NOT_STARTED" | "OUTDATED" | "REJECTED";
|
||||
export type TrustCenterVisibility = "NONE" | "PRIVATE" | "PUBLIC";
|
||||
import { FragmentRefs } from "relay-runtime";
|
||||
export type TrustCenterAuditsCardFragment$data = {
|
||||
readonly createdAt: any;
|
||||
@@ -18,8 +19,8 @@ export type TrustCenterAuditsCardFragment$data = {
|
||||
};
|
||||
readonly id: string;
|
||||
readonly name: string | null | undefined;
|
||||
readonly showOnTrustCenter: boolean;
|
||||
readonly state: AuditState;
|
||||
readonly trustCenterVisibility: TrustCenterVisibility;
|
||||
readonly validFrom: any | null | undefined;
|
||||
readonly validUntil: any | null | undefined;
|
||||
readonly " $fragmentType": "TrustCenterAuditsCardFragment";
|
||||
@@ -88,7 +89,7 @@ return {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "showOnTrustCenter",
|
||||
"name": "trustCenterVisibility",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
@@ -104,6 +105,6 @@ return {
|
||||
};
|
||||
})();
|
||||
|
||||
(node as any).hash = "1c5db1ae603a40619342702f790adfeb";
|
||||
(node as any).hash = "c0f615fcad79ad39f60b48daacabdbbd";
|
||||
|
||||
export default node;
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
/**
|
||||
* @generated SignedSource<<3ff483dcc660e6b45d676db7fc05a30e>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @ts-nocheck
|
||||
|
||||
import { ReaderFragment } from 'relay-runtime';
|
||||
import { FragmentRefs } from "relay-runtime";
|
||||
export type TrustCenterDocumentDialogFragment$data = {
|
||||
readonly id: string;
|
||||
readonly showOnTrustCenter: boolean;
|
||||
readonly title: string;
|
||||
readonly " $fragmentType": "TrustCenterDocumentDialogFragment";
|
||||
};
|
||||
export type TrustCenterDocumentDialogFragment$key = {
|
||||
readonly " $data"?: TrustCenterDocumentDialogFragment$data;
|
||||
readonly " $fragmentSpreads": FragmentRefs<"TrustCenterDocumentDialogFragment">;
|
||||
};
|
||||
|
||||
const node: ReaderFragment = {
|
||||
"argumentDefinitions": [],
|
||||
"kind": "Fragment",
|
||||
"metadata": null,
|
||||
"name": "TrustCenterDocumentDialogFragment",
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "id",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "title",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "showOnTrustCenter",
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"type": "Document",
|
||||
"abstractKey": null
|
||||
};
|
||||
|
||||
(node as any).hash = "d886df25fdf197161a91bbc693c9fac8";
|
||||
|
||||
export default node;
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @generated SignedSource<<711a0b67f3e93814ae3297a2578373c6>>
|
||||
* @generated SignedSource<<869852416d522b3851e516a543454edb>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
@@ -11,13 +11,14 @@
|
||||
import { ReaderFragment } from 'relay-runtime';
|
||||
export type DocumentStatus = "DRAFT" | "PUBLISHED";
|
||||
export type DocumentType = "ISMS" | "OTHER" | "POLICY";
|
||||
export type TrustCenterVisibility = "NONE" | "PRIVATE" | "PUBLIC";
|
||||
import { FragmentRefs } from "relay-runtime";
|
||||
export type TrustCenterDocumentsCardFragment$data = {
|
||||
readonly createdAt: any;
|
||||
readonly documentType: DocumentType;
|
||||
readonly id: string;
|
||||
readonly showOnTrustCenter: boolean;
|
||||
readonly title: string;
|
||||
readonly trustCenterVisibility: TrustCenterVisibility;
|
||||
readonly versions: {
|
||||
readonly edges: ReadonlyArray<{
|
||||
readonly node: {
|
||||
@@ -73,7 +74,7 @@ return {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "showOnTrustCenter",
|
||||
"name": "trustCenterVisibility",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
@@ -129,6 +130,6 @@ return {
|
||||
};
|
||||
})();
|
||||
|
||||
(node as any).hash = "88d5e5e3a2d9f4b730428efcea644f25";
|
||||
(node as any).hash = "a90715444be8a289eae6615ce44e244d";
|
||||
|
||||
export default node;
|
||||
|
||||
@@ -8,7 +8,7 @@ export const trustCenterAuditUpdateMutation = graphql`
|
||||
updateAudit(input: $input) {
|
||||
audit {
|
||||
id
|
||||
showOnTrustCenter
|
||||
trustCenterVisibility
|
||||
...TrustCenterAuditsCardFragment
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ export const updateDocumentVisibilityMutation = graphql`
|
||||
updateDocument(input: $input) {
|
||||
document {
|
||||
id
|
||||
showOnTrustCenter
|
||||
trustCenterVisibility
|
||||
...TrustCenterDocumentsCardFragment
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @generated SignedSource<<a3c134dcea5981e6a45b623ec2905962>>
|
||||
* @generated SignedSource<<b6236fab1ef470add01b9d9cc7527caa>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
@@ -10,11 +10,13 @@
|
||||
|
||||
import { ConcreteRequest } from 'relay-runtime';
|
||||
export type AuditState = "COMPLETED" | "IN_PROGRESS" | "NOT_STARTED" | "OUTDATED" | "REJECTED";
|
||||
export type TrustCenterVisibility = "NONE" | "PRIVATE" | "PUBLIC";
|
||||
export type CreateAuditInput = {
|
||||
frameworkId: string;
|
||||
name?: string | null | undefined;
|
||||
organizationId: string;
|
||||
state?: AuditState | null | undefined;
|
||||
trustCenterVisibility?: TrustCenterVisibility | null | undefined;
|
||||
validFrom?: any | null | undefined;
|
||||
validUntil?: any | null | undefined;
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @generated SignedSource<<4255866a0c7fe3c9c3416fe2603b5f63>>
|
||||
* @generated SignedSource<<014a8f33bc7d6674a2a93e8b3dde8edf>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
@@ -10,11 +10,12 @@
|
||||
|
||||
import { ConcreteRequest } from 'relay-runtime';
|
||||
export type AuditState = "COMPLETED" | "IN_PROGRESS" | "NOT_STARTED" | "OUTDATED" | "REJECTED";
|
||||
export type TrustCenterVisibility = "NONE" | "PRIVATE" | "PUBLIC";
|
||||
export type UpdateAuditInput = {
|
||||
id: string;
|
||||
name?: string | null | undefined;
|
||||
showOnTrustCenter?: boolean | null | undefined;
|
||||
state?: AuditState | null | undefined;
|
||||
trustCenterVisibility?: TrustCenterVisibility | null | undefined;
|
||||
validFrom?: any | null | undefined;
|
||||
validUntil?: any | null | undefined;
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @generated SignedSource<<5773d0630d11596682d41b4df95716c3>>
|
||||
* @generated SignedSource<<0d25ae690e5016a27d889ed1c4a1667f>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
@@ -11,11 +11,12 @@
|
||||
import { ConcreteRequest } from 'relay-runtime';
|
||||
import { FragmentRefs } from "relay-runtime";
|
||||
export type AuditState = "COMPLETED" | "IN_PROGRESS" | "NOT_STARTED" | "OUTDATED" | "REJECTED";
|
||||
export type TrustCenterVisibility = "NONE" | "PRIVATE" | "PUBLIC";
|
||||
export type UpdateAuditInput = {
|
||||
id: string;
|
||||
name?: string | null | undefined;
|
||||
showOnTrustCenter?: boolean | null | undefined;
|
||||
state?: AuditState | null | undefined;
|
||||
trustCenterVisibility?: TrustCenterVisibility | null | undefined;
|
||||
validFrom?: any | null | undefined;
|
||||
validUntil?: any | null | undefined;
|
||||
};
|
||||
@@ -26,7 +27,7 @@ export type TrustCenterAuditGraphUpdateMutation$data = {
|
||||
readonly updateAudit: {
|
||||
readonly audit: {
|
||||
readonly id: string;
|
||||
readonly showOnTrustCenter: boolean;
|
||||
readonly trustCenterVisibility: TrustCenterVisibility;
|
||||
readonly " $fragmentSpreads": FragmentRefs<"TrustCenterAuditsCardFragment">;
|
||||
};
|
||||
};
|
||||
@@ -62,7 +63,7 @@ v3 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "showOnTrustCenter",
|
||||
"name": "trustCenterVisibility",
|
||||
"storageKey": null
|
||||
},
|
||||
v4 = {
|
||||
@@ -187,16 +188,16 @@ return {
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "d27b79a065314a22dbcbd8216de1268b",
|
||||
"cacheID": "70742901eeb45d5e00e4e61d83b2f828",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "TrustCenterAuditGraphUpdateMutation",
|
||||
"operationKind": "mutation",
|
||||
"text": "mutation TrustCenterAuditGraphUpdateMutation(\n $input: UpdateAuditInput!\n) {\n updateAudit(input: $input) {\n audit {\n id\n showOnTrustCenter\n ...TrustCenterAuditsCardFragment\n }\n }\n}\n\nfragment TrustCenterAuditsCardFragment on Audit {\n id\n name\n framework {\n name\n id\n }\n validFrom\n validUntil\n state\n showOnTrustCenter\n createdAt\n}\n"
|
||||
"text": "mutation TrustCenterAuditGraphUpdateMutation(\n $input: UpdateAuditInput!\n) {\n updateAudit(input: $input) {\n audit {\n id\n trustCenterVisibility\n ...TrustCenterAuditsCardFragment\n }\n }\n}\n\nfragment TrustCenterAuditsCardFragment on Audit {\n id\n name\n framework {\n name\n id\n }\n validFrom\n validUntil\n state\n trustCenterVisibility\n createdAt\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
(node as any).hash = "1e92374989ecf8f439d069eb003e4e4e";
|
||||
(node as any).hash = "c958ccce67f79bb75593e9fcb31ee9d8";
|
||||
|
||||
export default node;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @generated SignedSource<<6676a9b480eeef26f00ff97963b39b86>>
|
||||
* @generated SignedSource<<1135bf3b786a26466e2763cbeecb7b5b>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
@@ -204,7 +204,7 @@ return {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "showOnTrustCenter",
|
||||
"name": "trustCenterVisibility",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
@@ -273,12 +273,12 @@ return {
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "f8e5f4d7adcf1e794bc046ef21317f89",
|
||||
"cacheID": "1df18b182ace4562ffa876b7e8073a22",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "TrustCenterDocumentGraphQuery",
|
||||
"operationKind": "query",
|
||||
"text": "query TrustCenterDocumentGraphQuery(\n $organizationId: ID!\n) {\n organization: node(id: $organizationId) {\n __typename\n ... on Organization {\n id\n documents(first: 100) {\n edges {\n node {\n id\n ...TrustCenterDocumentsCardFragment\n }\n }\n }\n }\n id\n }\n}\n\nfragment TrustCenterDocumentsCardFragment on Document {\n id\n title\n createdAt\n documentType\n showOnTrustCenter\n versions(first: 1) {\n edges {\n node {\n id\n status\n }\n }\n }\n}\n"
|
||||
"text": "query TrustCenterDocumentGraphQuery(\n $organizationId: ID!\n) {\n organization: node(id: $organizationId) {\n __typename\n ... on Organization {\n id\n documents(first: 100) {\n edges {\n node {\n id\n ...TrustCenterDocumentsCardFragment\n }\n }\n }\n }\n id\n }\n}\n\nfragment TrustCenterDocumentsCardFragment on Document {\n id\n title\n createdAt\n documentType\n trustCenterVisibility\n versions(first: 1) {\n edges {\n node {\n id\n status\n }\n }\n }\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @generated SignedSource<<46d46472ea11f58c00df8b8827afab98>>
|
||||
* @generated SignedSource<<64b79a80214710d6c3e4676cd63136e4>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
@@ -11,13 +11,14 @@
|
||||
import { ConcreteRequest } from 'relay-runtime';
|
||||
import { FragmentRefs } from "relay-runtime";
|
||||
export type DocumentType = "ISMS" | "OTHER" | "POLICY";
|
||||
export type TrustCenterVisibility = "NONE" | "PRIVATE" | "PUBLIC";
|
||||
export type UpdateDocumentInput = {
|
||||
content?: string | null | undefined;
|
||||
documentType?: DocumentType | null | undefined;
|
||||
id: string;
|
||||
ownerId?: string | null | undefined;
|
||||
showOnTrustCenter?: boolean | null | undefined;
|
||||
title?: string | null | undefined;
|
||||
trustCenterVisibility?: TrustCenterVisibility | null | undefined;
|
||||
};
|
||||
export type TrustCenterDocumentGraphUpdateMutation$variables = {
|
||||
input: UpdateDocumentInput;
|
||||
@@ -26,7 +27,7 @@ export type TrustCenterDocumentGraphUpdateMutation$data = {
|
||||
readonly updateDocument: {
|
||||
readonly document: {
|
||||
readonly id: string;
|
||||
readonly showOnTrustCenter: boolean;
|
||||
readonly trustCenterVisibility: TrustCenterVisibility;
|
||||
readonly " $fragmentSpreads": FragmentRefs<"TrustCenterDocumentsCardFragment">;
|
||||
};
|
||||
};
|
||||
@@ -62,7 +63,7 @@ v3 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "showOnTrustCenter",
|
||||
"name": "trustCenterVisibility",
|
||||
"storageKey": null
|
||||
};
|
||||
return {
|
||||
@@ -206,16 +207,16 @@ return {
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "b112314d6ef35feebf49bd2f8c636b33",
|
||||
"cacheID": "04cb2a4e83386dfffce8c12eae320cfe",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "TrustCenterDocumentGraphUpdateMutation",
|
||||
"operationKind": "mutation",
|
||||
"text": "mutation TrustCenterDocumentGraphUpdateMutation(\n $input: UpdateDocumentInput!\n) {\n updateDocument(input: $input) {\n document {\n id\n showOnTrustCenter\n ...TrustCenterDocumentsCardFragment\n }\n }\n}\n\nfragment TrustCenterDocumentsCardFragment on Document {\n id\n title\n createdAt\n documentType\n showOnTrustCenter\n versions(first: 1) {\n edges {\n node {\n id\n status\n }\n }\n }\n}\n"
|
||||
"text": "mutation TrustCenterDocumentGraphUpdateMutation(\n $input: UpdateDocumentInput!\n) {\n updateDocument(input: $input) {\n document {\n id\n trustCenterVisibility\n ...TrustCenterDocumentsCardFragment\n }\n }\n}\n\nfragment TrustCenterDocumentsCardFragment on Document {\n id\n title\n createdAt\n documentType\n trustCenterVisibility\n versions(first: 1) {\n edges {\n node {\n id\n status\n }\n }\n }\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
(node as any).hash = "46f72a664d3edb0e5665b1ecea69e31a";
|
||||
(node as any).hash = "293896dbfec4de53d0fe30a2462f833b";
|
||||
|
||||
export default node;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @generated SignedSource<<241faf24f6f9e1ca0e5f8171e40e5cd3>>
|
||||
* @generated SignedSource<<da6b3823d7bc60f99482bce2b08b9668>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
@@ -236,7 +236,7 @@ v10 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "showOnTrustCenter",
|
||||
"name": "trustCenterVisibility",
|
||||
"storageKey": null
|
||||
};
|
||||
return {
|
||||
@@ -617,7 +617,13 @@ return {
|
||||
"storageKey": null
|
||||
},
|
||||
(v7/*: any*/),
|
||||
(v10/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "showOnTrustCenter",
|
||||
"storageKey": null
|
||||
},
|
||||
(v4/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
@@ -638,12 +644,12 @@ return {
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "d08519f604d27066ddaabb667d234552",
|
||||
"cacheID": "3aed31b283ab7aa8e5ae0549474b449f",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "TrustCenterGraphQuery",
|
||||
"operationKind": "query",
|
||||
"text": "query TrustCenterGraphQuery(\n $organizationId: ID!\n) {\n organization: node(id: $organizationId) {\n __typename\n ... on Organization {\n id\n name\n trustCenter {\n id\n active\n slug\n ndaFileName\n ndaFileUrl\n createdAt\n updatedAt\n references(first: 100, orderBy: {field: CREATED_AT, direction: DESC}) {\n edges {\n node {\n id\n name\n description\n websiteUrl\n logoUrl\n createdAt\n updatedAt\n }\n }\n }\n }\n documents(first: 100) {\n edges {\n node {\n id\n ...TrustCenterDocumentsCardFragment\n }\n }\n }\n audits(first: 100) {\n edges {\n node {\n id\n ...TrustCenterAuditsCardFragment\n }\n }\n }\n vendors(first: 100) {\n edges {\n node {\n id\n ...TrustCenterVendorsCardFragment\n }\n }\n }\n }\n id\n }\n}\n\nfragment TrustCenterAuditsCardFragment on Audit {\n id\n name\n framework {\n name\n id\n }\n validFrom\n validUntil\n state\n showOnTrustCenter\n createdAt\n}\n\nfragment TrustCenterDocumentsCardFragment on Document {\n id\n title\n createdAt\n documentType\n showOnTrustCenter\n versions(first: 1) {\n edges {\n node {\n id\n status\n }\n }\n }\n}\n\nfragment TrustCenterVendorsCardFragment on Vendor {\n id\n name\n category\n description\n showOnTrustCenter\n createdAt\n}\n"
|
||||
"text": "query TrustCenterGraphQuery(\n $organizationId: ID!\n) {\n organization: node(id: $organizationId) {\n __typename\n ... on Organization {\n id\n name\n trustCenter {\n id\n active\n slug\n ndaFileName\n ndaFileUrl\n createdAt\n updatedAt\n references(first: 100, orderBy: {field: CREATED_AT, direction: DESC}) {\n edges {\n node {\n id\n name\n description\n websiteUrl\n logoUrl\n createdAt\n updatedAt\n }\n }\n }\n }\n documents(first: 100) {\n edges {\n node {\n id\n ...TrustCenterDocumentsCardFragment\n }\n }\n }\n audits(first: 100) {\n edges {\n node {\n id\n ...TrustCenterAuditsCardFragment\n }\n }\n }\n vendors(first: 100) {\n edges {\n node {\n id\n ...TrustCenterVendorsCardFragment\n }\n }\n }\n }\n id\n }\n}\n\nfragment TrustCenterAuditsCardFragment on Audit {\n id\n name\n framework {\n name\n id\n }\n validFrom\n validUntil\n state\n trustCenterVisibility\n createdAt\n}\n\nfragment TrustCenterDocumentsCardFragment on Document {\n id\n title\n createdAt\n documentType\n trustCenterVisibility\n versions(first: 1) {\n edges {\n node {\n id\n status\n }\n }\n }\n}\n\nfragment TrustCenterVendorsCardFragment on Vendor {\n id\n name\n category\n description\n showOnTrustCenter\n createdAt\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @generated SignedSource<<aa94f8d2cc4c6a5c29de3029d5e6d2ca>>
|
||||
* @generated SignedSource<<efe95ef5290fa021d00c7f32922ae801>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
@@ -10,13 +10,14 @@
|
||||
|
||||
import { ConcreteRequest } from 'relay-runtime';
|
||||
export type DocumentType = "ISMS" | "OTHER" | "POLICY";
|
||||
export type TrustCenterVisibility = "NONE" | "PRIVATE" | "PUBLIC";
|
||||
export type UpdateDocumentInput = {
|
||||
content?: string | null | undefined;
|
||||
documentType?: DocumentType | null | undefined;
|
||||
id: string;
|
||||
ownerId?: string | null | undefined;
|
||||
showOnTrustCenter?: boolean | null | undefined;
|
||||
title?: string | null | undefined;
|
||||
trustCenterVisibility?: TrustCenterVisibility | null | undefined;
|
||||
};
|
||||
export type DocumentDetailPageUpdateMutation$variables = {
|
||||
input: UpdateDocumentInput;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @generated SignedSource<<ce2f4f138b340f04b4e413ecbfff2ea1>>
|
||||
* @generated SignedSource<<7f9d3e67d06cbf2aaf21c61be65bc7ee>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
@@ -11,12 +11,14 @@
|
||||
import { ConcreteRequest } from 'relay-runtime';
|
||||
import { FragmentRefs } from "relay-runtime";
|
||||
export type DocumentType = "ISMS" | "OTHER" | "POLICY";
|
||||
export type TrustCenterVisibility = "NONE" | "PRIVATE" | "PUBLIC";
|
||||
export type CreateDocumentInput = {
|
||||
content: string;
|
||||
documentType: DocumentType;
|
||||
organizationId: string;
|
||||
ownerId: string;
|
||||
title: string;
|
||||
trustCenterVisibility?: TrustCenterVisibility | null | undefined;
|
||||
};
|
||||
export type CreateDocumentDialogMutation$variables = {
|
||||
connections: ReadonlyArray<string>;
|
||||
|
||||
@@ -30,7 +30,7 @@ export default function TrustCenterAuditsTab() {
|
||||
audits={audits}
|
||||
params={{}}
|
||||
disabled={isUpdatingAudits}
|
||||
onToggleVisibility={updateAuditVisibility}
|
||||
onChangeVisibility={updateAuditVisibility}
|
||||
variant="table"
|
||||
/>
|
||||
</Card>
|
||||
|
||||
@@ -30,7 +30,7 @@ export default function TrustCenterDocumentsTab() {
|
||||
documents={documents}
|
||||
params={{}}
|
||||
disabled={isUpdatingDocuments}
|
||||
onToggleVisibility={updateDocumentVisibility}
|
||||
onChangeVisibility={updateDocumentVisibility}
|
||||
variant="table"
|
||||
/>
|
||||
</Card>
|
||||
|
||||
@@ -43,6 +43,13 @@ export {
|
||||
getObligationStatusLabel,
|
||||
getObligationStatusOptions,
|
||||
} from "./obligationStatus";
|
||||
export {
|
||||
getTrustCenterVisibilityVariant,
|
||||
getTrustCenterVisibilityLabel,
|
||||
getTrustCenterVisibilityOptions,
|
||||
trustCenterVisibilities,
|
||||
type TrustCenterVisibility,
|
||||
} from "./trustCenterVisibility";
|
||||
export { promisifyMutation } from "./relay";
|
||||
export { fileType, fileSize } from "./file";
|
||||
export { formatDatetime, formatDate } from "./date";
|
||||
|
||||
47
packages/helpers/src/trustCenterVisibility.ts
Normal file
47
packages/helpers/src/trustCenterVisibility.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
type Translator = (s: string) => string;
|
||||
|
||||
export type TrustCenterVisibility = "NONE" | "PRIVATE" | "PUBLIC";
|
||||
|
||||
export const trustCenterVisibilities = [
|
||||
"NONE",
|
||||
"PRIVATE",
|
||||
"PUBLIC",
|
||||
] as const;
|
||||
|
||||
export const getTrustCenterVisibilityVariant = (visibility: TrustCenterVisibility) => {
|
||||
switch (visibility) {
|
||||
case "NONE":
|
||||
return "danger" as const;
|
||||
case "PRIVATE":
|
||||
return "warning" as const;
|
||||
case "PUBLIC":
|
||||
return "success" as const;
|
||||
default:
|
||||
return "neutral" as const;
|
||||
}
|
||||
};
|
||||
|
||||
export const getTrustCenterVisibilityLabel = (visibility: TrustCenterVisibility) => {
|
||||
switch (visibility) {
|
||||
case "NONE":
|
||||
return "None";
|
||||
case "PRIVATE":
|
||||
return "Private";
|
||||
case "PUBLIC":
|
||||
return "Public";
|
||||
default:
|
||||
return visibility;
|
||||
}
|
||||
};
|
||||
|
||||
export function getTrustCenterVisibilityOptions(__: Translator) {
|
||||
return trustCenterVisibilities.map((visibility) => ({
|
||||
value: visibility,
|
||||
label: __({
|
||||
"NONE": "None",
|
||||
"PRIVATE": "Private",
|
||||
"PUBLIC": "Public",
|
||||
}[visibility]),
|
||||
variant: getTrustCenterVisibilityVariant(visibility),
|
||||
}));
|
||||
}
|
||||
@@ -28,17 +28,17 @@ import (
|
||||
|
||||
type (
|
||||
Audit struct {
|
||||
ID gid.GID `db:"id"`
|
||||
Name *string `db:"name"`
|
||||
OrganizationID gid.GID `db:"organization_id"`
|
||||
FrameworkID gid.GID `db:"framework_id"`
|
||||
ReportID *gid.GID `db:"report_id"`
|
||||
ValidFrom *time.Time `db:"valid_from"`
|
||||
ValidUntil *time.Time `db:"valid_until"`
|
||||
State AuditState `db:"state"`
|
||||
ShowOnTrustCenter bool `db:"show_on_trust_center"`
|
||||
CreatedAt time.Time `db:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at"`
|
||||
ID gid.GID `db:"id"`
|
||||
Name *string `db:"name"`
|
||||
OrganizationID gid.GID `db:"organization_id"`
|
||||
FrameworkID gid.GID `db:"framework_id"`
|
||||
ReportID *gid.GID `db:"report_id"`
|
||||
ValidFrom *time.Time `db:"valid_from"`
|
||||
ValidUntil *time.Time `db:"valid_until"`
|
||||
State AuditState `db:"state"`
|
||||
TrustCenterVisibility TrustCenterVisibility `db:"trust_center_visibility"`
|
||||
CreatedAt time.Time `db:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at"`
|
||||
}
|
||||
|
||||
Audits []*Audit
|
||||
@@ -75,7 +75,7 @@ SELECT
|
||||
valid_from,
|
||||
valid_until,
|
||||
state,
|
||||
show_on_trust_center,
|
||||
trust_center_visibility,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM
|
||||
@@ -156,7 +156,7 @@ SELECT
|
||||
valid_from,
|
||||
valid_until,
|
||||
state,
|
||||
show_on_trust_center,
|
||||
trust_center_visibility,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM
|
||||
@@ -207,7 +207,7 @@ SELECT
|
||||
valid_from,
|
||||
valid_until,
|
||||
state,
|
||||
show_on_trust_center,
|
||||
trust_center_visibility,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM
|
||||
@@ -256,7 +256,7 @@ INSERT INTO audits (
|
||||
valid_from,
|
||||
valid_until,
|
||||
state,
|
||||
show_on_trust_center,
|
||||
trust_center_visibility,
|
||||
created_at,
|
||||
updated_at
|
||||
) VALUES (
|
||||
@@ -269,25 +269,25 @@ INSERT INTO audits (
|
||||
@valid_from,
|
||||
@valid_until,
|
||||
@state,
|
||||
@show_on_trust_center,
|
||||
@trust_center_visibility,
|
||||
@created_at,
|
||||
@updated_at
|
||||
)
|
||||
`
|
||||
|
||||
args := pgx.StrictNamedArgs{
|
||||
"id": a.ID,
|
||||
"name": a.Name,
|
||||
"tenant_id": scope.GetTenantID(),
|
||||
"organization_id": a.OrganizationID,
|
||||
"framework_id": a.FrameworkID,
|
||||
"report_id": a.ReportID,
|
||||
"valid_from": a.ValidFrom,
|
||||
"valid_until": a.ValidUntil,
|
||||
"state": a.State,
|
||||
"show_on_trust_center": a.ShowOnTrustCenter,
|
||||
"created_at": a.CreatedAt,
|
||||
"updated_at": a.UpdatedAt,
|
||||
"id": a.ID,
|
||||
"name": a.Name,
|
||||
"tenant_id": scope.GetTenantID(),
|
||||
"organization_id": a.OrganizationID,
|
||||
"framework_id": a.FrameworkID,
|
||||
"report_id": a.ReportID,
|
||||
"valid_from": a.ValidFrom,
|
||||
"valid_until": a.ValidUntil,
|
||||
"state": a.State,
|
||||
"trust_center_visibility": a.TrustCenterVisibility,
|
||||
"created_at": a.CreatedAt,
|
||||
"updated_at": a.UpdatedAt,
|
||||
}
|
||||
|
||||
_, err := conn.Exec(ctx, q, args)
|
||||
@@ -311,7 +311,7 @@ SET
|
||||
valid_from = @valid_from,
|
||||
valid_until = @valid_until,
|
||||
state = @state,
|
||||
show_on_trust_center = @show_on_trust_center,
|
||||
trust_center_visibility = @trust_center_visibility,
|
||||
updated_at = @updated_at
|
||||
WHERE
|
||||
%s
|
||||
@@ -321,14 +321,14 @@ WHERE
|
||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{
|
||||
"id": a.ID,
|
||||
"name": a.Name,
|
||||
"report_id": a.ReportID,
|
||||
"valid_from": a.ValidFrom,
|
||||
"valid_until": a.ValidUntil,
|
||||
"state": a.State,
|
||||
"show_on_trust_center": a.ShowOnTrustCenter,
|
||||
"updated_at": a.UpdatedAt,
|
||||
"id": a.ID,
|
||||
"name": a.Name,
|
||||
"report_id": a.ReportID,
|
||||
"valid_from": a.ValidFrom,
|
||||
"valid_until": a.ValidUntil,
|
||||
"state": a.State,
|
||||
"trust_center_visibility": a.TrustCenterVisibility,
|
||||
"updated_at": a.UpdatedAt,
|
||||
}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
|
||||
@@ -423,7 +423,7 @@ WITH audits_by_control AS (
|
||||
a.valid_from,
|
||||
a.valid_until,
|
||||
a.state,
|
||||
a.show_on_trust_center,
|
||||
a.trust_center_visibility,
|
||||
a.created_at,
|
||||
a.updated_at
|
||||
FROM
|
||||
@@ -442,7 +442,7 @@ SELECT
|
||||
valid_from,
|
||||
valid_until,
|
||||
state,
|
||||
show_on_trust_center,
|
||||
trust_center_visibility,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM
|
||||
@@ -487,7 +487,7 @@ SELECT
|
||||
valid_from,
|
||||
valid_until,
|
||||
state,
|
||||
show_on_trust_center,
|
||||
trust_center_visibility,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM
|
||||
|
||||
@@ -20,7 +20,7 @@ import (
|
||||
|
||||
type (
|
||||
AuditFilter struct {
|
||||
showOnTrustCenter *bool
|
||||
trustCenterVisibilities []TrustCenterVisibility
|
||||
}
|
||||
)
|
||||
|
||||
@@ -29,25 +29,31 @@ func NewAuditFilter() *AuditFilter {
|
||||
}
|
||||
|
||||
func NewAuditTrustCenterFilter() *AuditFilter {
|
||||
showOnTrustCenter := true
|
||||
return &AuditFilter{
|
||||
showOnTrustCenter: &showOnTrustCenter,
|
||||
trustCenterVisibilities: []TrustCenterVisibility{
|
||||
TrustCenterVisibilityPrivate,
|
||||
TrustCenterVisibilityPublic,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (f *AuditFilter) SQLArguments() pgx.NamedArgs {
|
||||
args := pgx.NamedArgs{}
|
||||
|
||||
if f.showOnTrustCenter != nil {
|
||||
args["show_on_trust_center"] = *f.showOnTrustCenter
|
||||
if f.trustCenterVisibilities != nil {
|
||||
visibilities := make([]string, len(f.trustCenterVisibilities))
|
||||
for i, v := range f.trustCenterVisibilities {
|
||||
visibilities[i] = v.String()
|
||||
}
|
||||
args["trust_center_visibilities"] = visibilities
|
||||
}
|
||||
|
||||
return args
|
||||
}
|
||||
|
||||
func (f *AuditFilter) SQLFragment() string {
|
||||
if f.showOnTrustCenter != nil {
|
||||
return "show_on_trust_center = @show_on_trust_center"
|
||||
if f.trustCenterVisibilities != nil {
|
||||
return "trust_center_visibility = ANY(@trust_center_visibilities::trust_center_visibility[])"
|
||||
}
|
||||
|
||||
return "TRUE"
|
||||
|
||||
@@ -28,15 +28,15 @@ import (
|
||||
|
||||
type (
|
||||
Document struct {
|
||||
ID gid.GID `db:"id"`
|
||||
OrganizationID gid.GID `db:"organization_id"`
|
||||
OwnerID gid.GID `db:"owner_id"`
|
||||
Title string `db:"title"`
|
||||
DocumentType DocumentType `db:"document_type"`
|
||||
CurrentPublishedVersion *int `db:"current_published_version"`
|
||||
ShowOnTrustCenter bool `db:"show_on_trust_center"`
|
||||
CreatedAt time.Time `db:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at"`
|
||||
ID gid.GID `db:"id"`
|
||||
OrganizationID gid.GID `db:"organization_id"`
|
||||
OwnerID gid.GID `db:"owner_id"`
|
||||
Title string `db:"title"`
|
||||
DocumentType DocumentType `db:"document_type"`
|
||||
CurrentPublishedVersion *int `db:"current_published_version"`
|
||||
TrustCenterVisibility TrustCenterVisibility `db:"trust_center_visibility"`
|
||||
CreatedAt time.Time `db:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at"`
|
||||
}
|
||||
|
||||
Documents []*Document
|
||||
@@ -69,7 +69,7 @@ SELECT
|
||||
title,
|
||||
document_type,
|
||||
current_published_version,
|
||||
show_on_trust_center,
|
||||
trust_center_visibility,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM
|
||||
@@ -151,7 +151,7 @@ SELECT
|
||||
title,
|
||||
document_type,
|
||||
current_published_version,
|
||||
show_on_trust_center,
|
||||
trust_center_visibility,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM
|
||||
@@ -201,7 +201,7 @@ SELECT
|
||||
title,
|
||||
document_type,
|
||||
current_published_version,
|
||||
show_on_trust_center,
|
||||
trust_center_visibility,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM
|
||||
@@ -250,7 +250,7 @@ INSERT INTO
|
||||
title,
|
||||
document_type,
|
||||
current_published_version,
|
||||
show_on_trust_center,
|
||||
trust_center_visibility,
|
||||
created_at,
|
||||
updated_at
|
||||
)
|
||||
@@ -262,7 +262,7 @@ VALUES (
|
||||
@title,
|
||||
@document_type,
|
||||
@current_published_version,
|
||||
@show_on_trust_center,
|
||||
@trust_center_visibility,
|
||||
@created_at,
|
||||
@updated_at
|
||||
);
|
||||
@@ -276,7 +276,7 @@ VALUES (
|
||||
"title": p.Title,
|
||||
"document_type": p.DocumentType,
|
||||
"current_published_version": p.CurrentPublishedVersion,
|
||||
"show_on_trust_center": p.ShowOnTrustCenter,
|
||||
"trust_center_visibility": p.TrustCenterVisibility,
|
||||
"created_at": p.CreatedAt,
|
||||
"updated_at": p.UpdatedAt,
|
||||
}
|
||||
@@ -334,7 +334,7 @@ SET
|
||||
current_published_version = @current_published_version,
|
||||
owner_id = @owner_id,
|
||||
document_type = @document_type,
|
||||
show_on_trust_center = @show_on_trust_center,
|
||||
trust_center_visibility = @trust_center_visibility,
|
||||
updated_at = @updated_at
|
||||
WHERE
|
||||
%s
|
||||
@@ -350,7 +350,7 @@ WHERE
|
||||
"current_published_version": p.CurrentPublishedVersion,
|
||||
"owner_id": p.OwnerID,
|
||||
"document_type": p.DocumentType,
|
||||
"show_on_trust_center": p.ShowOnTrustCenter,
|
||||
"trust_center_visibility": p.TrustCenterVisibility,
|
||||
}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
|
||||
@@ -375,7 +375,7 @@ WITH plcs AS (
|
||||
p.id,
|
||||
p.tenant_id,
|
||||
p.search_vector,
|
||||
p.show_on_trust_center,
|
||||
p.trust_center_visibility,
|
||||
p.deleted_at
|
||||
FROM
|
||||
documents p
|
||||
@@ -428,7 +428,7 @@ WITH plcs AS (
|
||||
p.title,
|
||||
p.document_type,
|
||||
p.current_published_version,
|
||||
p.show_on_trust_center,
|
||||
p.trust_center_visibility,
|
||||
p.created_at,
|
||||
p.updated_at,
|
||||
p.deleted_at
|
||||
@@ -446,7 +446,7 @@ SELECT
|
||||
title,
|
||||
document_type,
|
||||
current_published_version,
|
||||
show_on_trust_center,
|
||||
trust_center_visibility,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM
|
||||
@@ -492,7 +492,7 @@ WITH plcs AS (
|
||||
p.id,
|
||||
p.tenant_id,
|
||||
p.search_vector,
|
||||
p.show_on_trust_center,
|
||||
p.trust_center_visibility,
|
||||
p.deleted_at
|
||||
FROM
|
||||
documents p
|
||||
@@ -544,7 +544,7 @@ WITH plcs AS (
|
||||
p.title,
|
||||
p.document_type,
|
||||
p.current_published_version,
|
||||
p.show_on_trust_center,
|
||||
p.trust_center_visibility,
|
||||
p.created_at,
|
||||
p.updated_at,
|
||||
p.search_vector,
|
||||
@@ -563,7 +563,7 @@ SELECT
|
||||
title,
|
||||
document_type,
|
||||
current_published_version,
|
||||
show_on_trust_center,
|
||||
trust_center_visibility,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM
|
||||
|
||||
@@ -20,8 +20,8 @@ import (
|
||||
|
||||
type (
|
||||
DocumentFilter struct {
|
||||
query *string
|
||||
showOnTrustCenter *bool
|
||||
query *string
|
||||
trustCenterVisibilities []TrustCenterVisibility
|
||||
}
|
||||
)
|
||||
|
||||
@@ -32,16 +32,25 @@ func NewDocumentFilter(query *string) *DocumentFilter {
|
||||
}
|
||||
|
||||
func NewDocumentTrustCenterFilter() *DocumentFilter {
|
||||
showOnTrustCenter := true
|
||||
return &DocumentFilter{
|
||||
showOnTrustCenter: &showOnTrustCenter,
|
||||
trustCenterVisibilities: []TrustCenterVisibility{
|
||||
TrustCenterVisibilityPrivate,
|
||||
TrustCenterVisibilityPublic,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (f *DocumentFilter) SQLArguments() pgx.StrictNamedArgs {
|
||||
var visibilities []string
|
||||
if f.trustCenterVisibilities != nil {
|
||||
visibilities = make([]string, len(f.trustCenterVisibilities))
|
||||
for i, v := range f.trustCenterVisibilities {
|
||||
visibilities[i] = v.String()
|
||||
}
|
||||
}
|
||||
return pgx.StrictNamedArgs{
|
||||
"query": f.query,
|
||||
"show_on_trust_center": f.showOnTrustCenter,
|
||||
"query": f.query,
|
||||
"trust_center_visibilities": visibilities,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,8 +67,8 @@ func (f *DocumentFilter) SQLFragment() string {
|
||||
END
|
||||
AND
|
||||
CASE
|
||||
WHEN @show_on_trust_center::boolean IS NOT NULL THEN
|
||||
show_on_trust_center = @show_on_trust_center::boolean
|
||||
WHEN @trust_center_visibilities::trust_center_visibility[] IS NOT NULL THEN
|
||||
trust_center_visibility = ANY(@trust_center_visibilities::trust_center_visibility[])
|
||||
ELSE TRUE
|
||||
END
|
||||
)`
|
||||
|
||||
25
pkg/coredata/migrations/20251002T131830Z.sql
Normal file
25
pkg/coredata/migrations/20251002T131830Z.sql
Normal file
@@ -0,0 +1,25 @@
|
||||
CREATE TYPE trust_center_visibility AS ENUM (
|
||||
'NONE',
|
||||
'PRIVATE',
|
||||
'PUBLIC'
|
||||
);
|
||||
|
||||
ALTER TABLE documents ADD COLUMN trust_center_visibility trust_center_visibility NOT NULL DEFAULT 'NONE';
|
||||
|
||||
UPDATE documents SET trust_center_visibility = CASE
|
||||
WHEN show_on_trust_center = true THEN 'PRIVATE'::trust_center_visibility
|
||||
ELSE 'NONE'::trust_center_visibility
|
||||
END;
|
||||
|
||||
ALTER TABLE documents ALTER COLUMN trust_center_visibility DROP DEFAULT;
|
||||
ALTER TABLE documents DROP COLUMN show_on_trust_center;
|
||||
|
||||
ALTER TABLE audits ADD COLUMN trust_center_visibility trust_center_visibility NOT NULL DEFAULT 'NONE';
|
||||
|
||||
UPDATE audits SET trust_center_visibility = CASE
|
||||
WHEN show_on_trust_center = true THEN 'PRIVATE'::trust_center_visibility
|
||||
ELSE 'NONE'::trust_center_visibility
|
||||
END;
|
||||
|
||||
ALTER TABLE audits ALTER COLUMN trust_center_visibility DROP DEFAULT;
|
||||
ALTER TABLE audits DROP COLUMN show_on_trust_center;
|
||||
60
pkg/coredata/trust_center_visibility.go
Normal file
60
pkg/coredata/trust_center_visibility.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 TrustCenterVisibility string
|
||||
|
||||
const (
|
||||
TrustCenterVisibilityNone TrustCenterVisibility = "NONE"
|
||||
TrustCenterVisibilityPrivate TrustCenterVisibility = "PRIVATE"
|
||||
TrustCenterVisibilityPublic TrustCenterVisibility = "PUBLIC"
|
||||
)
|
||||
|
||||
func (tcv TrustCenterVisibility) String() string {
|
||||
return string(tcv)
|
||||
}
|
||||
|
||||
func (tcv *TrustCenterVisibility) 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 TrustCenterVisibility: %T", value)
|
||||
}
|
||||
|
||||
switch s {
|
||||
case "NONE":
|
||||
*tcv = TrustCenterVisibilityNone
|
||||
case "PRIVATE":
|
||||
*tcv = TrustCenterVisibilityPrivate
|
||||
case "PUBLIC":
|
||||
*tcv = TrustCenterVisibilityPublic
|
||||
default:
|
||||
return fmt.Errorf("invalid TrustCenterVisibility value: %q", s)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (tcv TrustCenterVisibility) Value() (driver.Value, error) {
|
||||
return tcv.String(), nil
|
||||
}
|
||||
@@ -34,21 +34,22 @@ type AuditService struct {
|
||||
|
||||
type (
|
||||
CreateAuditRequest struct {
|
||||
OrganizationID gid.GID
|
||||
FrameworkID gid.GID
|
||||
Name *string
|
||||
ValidFrom *time.Time
|
||||
ValidUntil *time.Time
|
||||
State *coredata.AuditState
|
||||
OrganizationID gid.GID
|
||||
FrameworkID gid.GID
|
||||
Name *string
|
||||
ValidFrom *time.Time
|
||||
ValidUntil *time.Time
|
||||
State *coredata.AuditState
|
||||
TrustCenterVisibility *coredata.TrustCenterVisibility
|
||||
}
|
||||
|
||||
UpdateAuditRequest struct {
|
||||
ID gid.GID
|
||||
Name **string
|
||||
ValidFrom *time.Time
|
||||
ValidUntil *time.Time
|
||||
State *coredata.AuditState
|
||||
ShowOnTrustCenter *bool
|
||||
ID gid.GID
|
||||
Name **string
|
||||
ValidFrom *time.Time
|
||||
ValidUntil *time.Time
|
||||
State *coredata.AuditState
|
||||
TrustCenterVisibility *coredata.TrustCenterVisibility
|
||||
}
|
||||
|
||||
UpdateAuditStateRequest struct {
|
||||
@@ -113,22 +114,26 @@ func (s *AuditService) Create(
|
||||
now := time.Now()
|
||||
|
||||
audit := &coredata.Audit{
|
||||
ID: gid.New(s.svc.scope.GetTenantID(), coredata.AuditEntityType),
|
||||
Name: req.Name,
|
||||
OrganizationID: req.OrganizationID,
|
||||
FrameworkID: req.FrameworkID,
|
||||
ValidFrom: req.ValidFrom,
|
||||
ValidUntil: req.ValidUntil,
|
||||
State: coredata.AuditStateNotStarted,
|
||||
ShowOnTrustCenter: false,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
ID: gid.New(s.svc.scope.GetTenantID(), coredata.AuditEntityType),
|
||||
Name: req.Name,
|
||||
OrganizationID: req.OrganizationID,
|
||||
FrameworkID: req.FrameworkID,
|
||||
ValidFrom: req.ValidFrom,
|
||||
ValidUntil: req.ValidUntil,
|
||||
State: coredata.AuditStateNotStarted,
|
||||
TrustCenterVisibility: coredata.TrustCenterVisibilityNone,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
}
|
||||
|
||||
if req.State != nil {
|
||||
audit.State = *req.State
|
||||
}
|
||||
|
||||
if req.TrustCenterVisibility != nil {
|
||||
audit.TrustCenterVisibility = *req.TrustCenterVisibility
|
||||
}
|
||||
|
||||
err := s.svc.pg.WithTx(
|
||||
ctx,
|
||||
func(conn pg.Conn) error {
|
||||
@@ -182,8 +187,8 @@ func (s *AuditService) Update(
|
||||
if req.State != nil {
|
||||
audit.State = *req.State
|
||||
}
|
||||
if req.ShowOnTrustCenter != nil {
|
||||
audit.ShowOnTrustCenter = *req.ShowOnTrustCenter
|
||||
if req.TrustCenterVisibility != nil {
|
||||
audit.TrustCenterVisibility = *req.TrustCenterVisibility
|
||||
}
|
||||
|
||||
audit.UpdatedAt = time.Now()
|
||||
|
||||
@@ -40,11 +40,12 @@ type (
|
||||
}
|
||||
|
||||
CreateDocumentRequest struct {
|
||||
OrganizationID gid.GID
|
||||
Title string
|
||||
Content string
|
||||
OwnerID gid.GID
|
||||
DocumentType coredata.DocumentType
|
||||
OrganizationID gid.GID
|
||||
Title string
|
||||
Content string
|
||||
OwnerID gid.GID
|
||||
DocumentType coredata.DocumentType
|
||||
TrustCenterVisibility *coredata.TrustCenterVisibility
|
||||
}
|
||||
|
||||
UpdateDocumentVersionRequest struct {
|
||||
@@ -310,12 +311,16 @@ func (s *DocumentService) Create(
|
||||
people := &coredata.People{}
|
||||
|
||||
document := &coredata.Document{
|
||||
ID: documentID,
|
||||
Title: req.Title,
|
||||
DocumentType: req.DocumentType,
|
||||
ShowOnTrustCenter: false,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
ID: documentID,
|
||||
Title: req.Title,
|
||||
DocumentType: req.DocumentType,
|
||||
TrustCenterVisibility: coredata.TrustCenterVisibilityNone,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
}
|
||||
|
||||
if req.TrustCenterVisibility != nil {
|
||||
document.TrustCenterVisibility = *req.TrustCenterVisibility
|
||||
}
|
||||
|
||||
documentVersion := &coredata.DocumentVersion{
|
||||
@@ -1096,7 +1101,7 @@ func (s *DocumentService) Update(
|
||||
newOwnerID *gid.GID,
|
||||
documentType *coredata.DocumentType,
|
||||
title *string,
|
||||
showOnTrustCenter *bool,
|
||||
trustCenterVisibility *coredata.TrustCenterVisibility,
|
||||
) (*coredata.Document, error) {
|
||||
document := &coredata.Document{}
|
||||
people := &coredata.People{}
|
||||
@@ -1124,8 +1129,8 @@ func (s *DocumentService) Update(
|
||||
document.Title = *title
|
||||
}
|
||||
|
||||
if showOnTrustCenter != nil {
|
||||
document.ShowOnTrustCenter = *showOnTrustCenter
|
||||
if trustCenterVisibility != nil {
|
||||
document.TrustCenterVisibility = *trustCenterVisibility
|
||||
}
|
||||
|
||||
document.UpdatedAt = now
|
||||
|
||||
@@ -152,6 +152,22 @@ enum AuditState
|
||||
)
|
||||
}
|
||||
|
||||
enum TrustCenterVisibility
|
||||
@goModel(model: "github.com/getprobo/probo/pkg/coredata.TrustCenterVisibility") {
|
||||
NONE
|
||||
@goEnum(
|
||||
value: "github.com/getprobo/probo/pkg/coredata.TrustCenterVisibilityNone"
|
||||
)
|
||||
PRIVATE
|
||||
@goEnum(
|
||||
value: "github.com/getprobo/probo/pkg/coredata.TrustCenterVisibilityPrivate"
|
||||
)
|
||||
PUBLIC
|
||||
@goEnum(
|
||||
value: "github.com/getprobo/probo/pkg/coredata.TrustCenterVisibilityPublic"
|
||||
)
|
||||
}
|
||||
|
||||
enum NonconformityStatus
|
||||
@goModel(model: "github.com/getprobo/probo/pkg/coredata.NonconformityStatus") {
|
||||
OPEN
|
||||
@@ -1950,7 +1966,7 @@ type Document implements Node {
|
||||
description: String!
|
||||
documentType: DocumentType!
|
||||
currentPublishedVersion: Int
|
||||
showOnTrustCenter: Boolean!
|
||||
trustCenterVisibility: TrustCenterVisibility!
|
||||
owner: People! @goField(forceResolver: true)
|
||||
organization: Organization! @goField(forceResolver: true)
|
||||
|
||||
@@ -2054,7 +2070,7 @@ type Audit implements Node {
|
||||
filter: ControlFilter
|
||||
): ControlConnection! @goField(forceResolver: true)
|
||||
|
||||
showOnTrustCenter: Boolean!
|
||||
trustCenterVisibility: TrustCenterVisibility!
|
||||
createdAt: Datetime!
|
||||
updatedAt: Datetime!
|
||||
}
|
||||
@@ -3345,6 +3361,7 @@ input CreateDocumentInput {
|
||||
content: String!
|
||||
ownerId: ID!
|
||||
documentType: DocumentType!
|
||||
trustCenterVisibility: TrustCenterVisibility
|
||||
}
|
||||
|
||||
input UpdateDocumentInput {
|
||||
@@ -3353,7 +3370,7 @@ input UpdateDocumentInput {
|
||||
content: String
|
||||
ownerId: ID
|
||||
documentType: DocumentType
|
||||
showOnTrustCenter: Boolean
|
||||
trustCenterVisibility: TrustCenterVisibility
|
||||
}
|
||||
|
||||
input ExportDocumentVersionPDFInput {
|
||||
@@ -3413,6 +3430,7 @@ input CreateAuditInput {
|
||||
validFrom: Datetime
|
||||
validUntil: Datetime
|
||||
state: AuditState
|
||||
trustCenterVisibility: TrustCenterVisibility
|
||||
}
|
||||
|
||||
input UpdateAuditInput {
|
||||
@@ -3421,7 +3439,7 @@ input UpdateAuditInput {
|
||||
validFrom: Datetime
|
||||
validUntil: Datetime
|
||||
state: AuditState
|
||||
showOnTrustCenter: Boolean
|
||||
trustCenterVisibility: TrustCenterVisibility
|
||||
}
|
||||
|
||||
input DeleteAuditInput {
|
||||
|
||||
@@ -139,19 +139,19 @@ type ComplexityRoot struct {
|
||||
}
|
||||
|
||||
Audit struct {
|
||||
Controls func(childComplexity int, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.ControlOrderBy, filter *types.ControlFilter) int
|
||||
CreatedAt func(childComplexity int) int
|
||||
Framework func(childComplexity int) int
|
||||
ID func(childComplexity int) int
|
||||
Name func(childComplexity int) int
|
||||
Organization func(childComplexity int) int
|
||||
Report func(childComplexity int) int
|
||||
ReportURL func(childComplexity int) int
|
||||
ShowOnTrustCenter func(childComplexity int) int
|
||||
State func(childComplexity int) int
|
||||
UpdatedAt func(childComplexity int) int
|
||||
ValidFrom func(childComplexity int) int
|
||||
ValidUntil func(childComplexity int) int
|
||||
Controls func(childComplexity int, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.ControlOrderBy, filter *types.ControlFilter) int
|
||||
CreatedAt func(childComplexity int) int
|
||||
Framework func(childComplexity int) int
|
||||
ID func(childComplexity int) int
|
||||
Name func(childComplexity int) int
|
||||
Organization func(childComplexity int) int
|
||||
Report func(childComplexity int) int
|
||||
ReportURL func(childComplexity int) int
|
||||
State func(childComplexity int) int
|
||||
TrustCenterVisibility func(childComplexity int) int
|
||||
UpdatedAt func(childComplexity int) int
|
||||
ValidFrom func(childComplexity int) int
|
||||
ValidUntil func(childComplexity int) int
|
||||
}
|
||||
|
||||
AuditConnection struct {
|
||||
@@ -573,8 +573,8 @@ type ComplexityRoot struct {
|
||||
ID func(childComplexity int) int
|
||||
Organization func(childComplexity int) int
|
||||
Owner func(childComplexity int) int
|
||||
ShowOnTrustCenter func(childComplexity int) int
|
||||
Title func(childComplexity int) int
|
||||
TrustCenterVisibility func(childComplexity int) int
|
||||
UpdatedAt func(childComplexity int) int
|
||||
Versions func(childComplexity int, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.DocumentVersionOrderBy, filter *types.DocumentVersionFilter) int
|
||||
}
|
||||
@@ -2132,13 +2132,6 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin
|
||||
|
||||
return e.complexity.Audit.ReportURL(childComplexity), true
|
||||
|
||||
case "Audit.showOnTrustCenter":
|
||||
if e.complexity.Audit.ShowOnTrustCenter == nil {
|
||||
break
|
||||
}
|
||||
|
||||
return e.complexity.Audit.ShowOnTrustCenter(childComplexity), true
|
||||
|
||||
case "Audit.state":
|
||||
if e.complexity.Audit.State == nil {
|
||||
break
|
||||
@@ -2146,6 +2139,13 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin
|
||||
|
||||
return e.complexity.Audit.State(childComplexity), true
|
||||
|
||||
case "Audit.trustCenterVisibility":
|
||||
if e.complexity.Audit.TrustCenterVisibility == nil {
|
||||
break
|
||||
}
|
||||
|
||||
return e.complexity.Audit.TrustCenterVisibility(childComplexity), true
|
||||
|
||||
case "Audit.updatedAt":
|
||||
if e.complexity.Audit.UpdatedAt == nil {
|
||||
break
|
||||
@@ -3317,13 +3317,6 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin
|
||||
|
||||
return e.complexity.Document.Owner(childComplexity), true
|
||||
|
||||
case "Document.showOnTrustCenter":
|
||||
if e.complexity.Document.ShowOnTrustCenter == nil {
|
||||
break
|
||||
}
|
||||
|
||||
return e.complexity.Document.ShowOnTrustCenter(childComplexity), true
|
||||
|
||||
case "Document.title":
|
||||
if e.complexity.Document.Title == nil {
|
||||
break
|
||||
@@ -3331,6 +3324,13 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin
|
||||
|
||||
return e.complexity.Document.Title(childComplexity), true
|
||||
|
||||
case "Document.trustCenterVisibility":
|
||||
if e.complexity.Document.TrustCenterVisibility == nil {
|
||||
break
|
||||
}
|
||||
|
||||
return e.complexity.Document.TrustCenterVisibility(childComplexity), true
|
||||
|
||||
case "Document.updatedAt":
|
||||
if e.complexity.Document.UpdatedAt == nil {
|
||||
break
|
||||
@@ -8705,6 +8705,22 @@ enum AuditState
|
||||
)
|
||||
}
|
||||
|
||||
enum TrustCenterVisibility
|
||||
@goModel(model: "github.com/getprobo/probo/pkg/coredata.TrustCenterVisibility") {
|
||||
NONE
|
||||
@goEnum(
|
||||
value: "github.com/getprobo/probo/pkg/coredata.TrustCenterVisibilityNone"
|
||||
)
|
||||
PRIVATE
|
||||
@goEnum(
|
||||
value: "github.com/getprobo/probo/pkg/coredata.TrustCenterVisibilityPrivate"
|
||||
)
|
||||
PUBLIC
|
||||
@goEnum(
|
||||
value: "github.com/getprobo/probo/pkg/coredata.TrustCenterVisibilityPublic"
|
||||
)
|
||||
}
|
||||
|
||||
enum NonconformityStatus
|
||||
@goModel(model: "github.com/getprobo/probo/pkg/coredata.NonconformityStatus") {
|
||||
OPEN
|
||||
@@ -10503,7 +10519,7 @@ type Document implements Node {
|
||||
description: String!
|
||||
documentType: DocumentType!
|
||||
currentPublishedVersion: Int
|
||||
showOnTrustCenter: Boolean!
|
||||
trustCenterVisibility: TrustCenterVisibility!
|
||||
owner: People! @goField(forceResolver: true)
|
||||
organization: Organization! @goField(forceResolver: true)
|
||||
|
||||
@@ -10607,7 +10623,7 @@ type Audit implements Node {
|
||||
filter: ControlFilter
|
||||
): ControlConnection! @goField(forceResolver: true)
|
||||
|
||||
showOnTrustCenter: Boolean!
|
||||
trustCenterVisibility: TrustCenterVisibility!
|
||||
createdAt: Datetime!
|
||||
updatedAt: Datetime!
|
||||
}
|
||||
@@ -11898,6 +11914,7 @@ input CreateDocumentInput {
|
||||
content: String!
|
||||
ownerId: ID!
|
||||
documentType: DocumentType!
|
||||
trustCenterVisibility: TrustCenterVisibility
|
||||
}
|
||||
|
||||
input UpdateDocumentInput {
|
||||
@@ -11906,7 +11923,7 @@ input UpdateDocumentInput {
|
||||
content: String
|
||||
ownerId: ID
|
||||
documentType: DocumentType
|
||||
showOnTrustCenter: Boolean
|
||||
trustCenterVisibility: TrustCenterVisibility
|
||||
}
|
||||
|
||||
input ExportDocumentVersionPDFInput {
|
||||
@@ -11966,6 +11983,7 @@ input CreateAuditInput {
|
||||
validFrom: Datetime
|
||||
validUntil: Datetime
|
||||
state: AuditState
|
||||
trustCenterVisibility: TrustCenterVisibility
|
||||
}
|
||||
|
||||
input UpdateAuditInput {
|
||||
@@ -11974,7 +11992,7 @@ input UpdateAuditInput {
|
||||
validFrom: Datetime
|
||||
validUntil: Datetime
|
||||
state: AuditState
|
||||
showOnTrustCenter: Boolean
|
||||
trustCenterVisibility: TrustCenterVisibility
|
||||
}
|
||||
|
||||
input DeleteAuditInput {
|
||||
@@ -22353,8 +22371,8 @@ func (ec *executionContext) fieldContext_Audit_controls(ctx context.Context, fie
|
||||
return fc, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) _Audit_showOnTrustCenter(ctx context.Context, field graphql.CollectedField, obj *types.Audit) (ret graphql.Marshaler) {
|
||||
fc, err := ec.fieldContext_Audit_showOnTrustCenter(ctx, field)
|
||||
func (ec *executionContext) _Audit_trustCenterVisibility(ctx context.Context, field graphql.CollectedField, obj *types.Audit) (ret graphql.Marshaler) {
|
||||
fc, err := ec.fieldContext_Audit_trustCenterVisibility(ctx, field)
|
||||
if err != nil {
|
||||
return graphql.Null
|
||||
}
|
||||
@@ -22367,7 +22385,7 @@ func (ec *executionContext) _Audit_showOnTrustCenter(ctx context.Context, field
|
||||
}()
|
||||
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) {
|
||||
ctx = rctx // use context from middleware stack in children
|
||||
return obj.ShowOnTrustCenter, nil
|
||||
return obj.TrustCenterVisibility, nil
|
||||
})
|
||||
if err != nil {
|
||||
ec.Error(ctx, err)
|
||||
@@ -22379,19 +22397,19 @@ func (ec *executionContext) _Audit_showOnTrustCenter(ctx context.Context, field
|
||||
}
|
||||
return graphql.Null
|
||||
}
|
||||
res := resTmp.(bool)
|
||||
res := resTmp.(coredata.TrustCenterVisibility)
|
||||
fc.Result = res
|
||||
return ec.marshalNBoolean2bool(ctx, field.Selections, res)
|
||||
return ec.marshalNTrustCenterVisibility2githubᚗcomᚋgetproboᚋproboᚋpkgᚋcoredataᚐTrustCenterVisibility(ctx, field.Selections, res)
|
||||
}
|
||||
|
||||
func (ec *executionContext) fieldContext_Audit_showOnTrustCenter(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
||||
func (ec *executionContext) fieldContext_Audit_trustCenterVisibility(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
||||
fc = &graphql.FieldContext{
|
||||
Object: "Audit",
|
||||
Field: field,
|
||||
IsMethod: false,
|
||||
IsResolver: false,
|
||||
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
|
||||
return nil, errors.New("field of type Boolean does not have child fields")
|
||||
return nil, errors.New("field of type TrustCenterVisibility does not have child fields")
|
||||
},
|
||||
}
|
||||
return fc, nil
|
||||
@@ -22736,8 +22754,8 @@ func (ec *executionContext) fieldContext_AuditEdge_node(_ context.Context, field
|
||||
return ec.fieldContext_Audit_state(ctx, field)
|
||||
case "controls":
|
||||
return ec.fieldContext_Audit_controls(ctx, field)
|
||||
case "showOnTrustCenter":
|
||||
return ec.fieldContext_Audit_showOnTrustCenter(ctx, field)
|
||||
case "trustCenterVisibility":
|
||||
return ec.fieldContext_Audit_trustCenterVisibility(ctx, field)
|
||||
case "createdAt":
|
||||
return ec.fieldContext_Audit_createdAt(ctx, field)
|
||||
case "updatedAt":
|
||||
@@ -28170,8 +28188,8 @@ func (ec *executionContext) fieldContext_DeleteAuditReportPayload_audit(_ contex
|
||||
return ec.fieldContext_Audit_state(ctx, field)
|
||||
case "controls":
|
||||
return ec.fieldContext_Audit_controls(ctx, field)
|
||||
case "showOnTrustCenter":
|
||||
return ec.fieldContext_Audit_showOnTrustCenter(ctx, field)
|
||||
case "trustCenterVisibility":
|
||||
return ec.fieldContext_Audit_trustCenterVisibility(ctx, field)
|
||||
case "createdAt":
|
||||
return ec.fieldContext_Audit_createdAt(ctx, field)
|
||||
case "updatedAt":
|
||||
@@ -30138,8 +30156,8 @@ func (ec *executionContext) fieldContext_Document_currentPublishedVersion(_ cont
|
||||
return fc, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) _Document_showOnTrustCenter(ctx context.Context, field graphql.CollectedField, obj *types.Document) (ret graphql.Marshaler) {
|
||||
fc, err := ec.fieldContext_Document_showOnTrustCenter(ctx, field)
|
||||
func (ec *executionContext) _Document_trustCenterVisibility(ctx context.Context, field graphql.CollectedField, obj *types.Document) (ret graphql.Marshaler) {
|
||||
fc, err := ec.fieldContext_Document_trustCenterVisibility(ctx, field)
|
||||
if err != nil {
|
||||
return graphql.Null
|
||||
}
|
||||
@@ -30152,7 +30170,7 @@ func (ec *executionContext) _Document_showOnTrustCenter(ctx context.Context, fie
|
||||
}()
|
||||
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) {
|
||||
ctx = rctx // use context from middleware stack in children
|
||||
return obj.ShowOnTrustCenter, nil
|
||||
return obj.TrustCenterVisibility, nil
|
||||
})
|
||||
if err != nil {
|
||||
ec.Error(ctx, err)
|
||||
@@ -30164,19 +30182,19 @@ func (ec *executionContext) _Document_showOnTrustCenter(ctx context.Context, fie
|
||||
}
|
||||
return graphql.Null
|
||||
}
|
||||
res := resTmp.(bool)
|
||||
res := resTmp.(coredata.TrustCenterVisibility)
|
||||
fc.Result = res
|
||||
return ec.marshalNBoolean2bool(ctx, field.Selections, res)
|
||||
return ec.marshalNTrustCenterVisibility2githubᚗcomᚋgetproboᚋproboᚋpkgᚋcoredataᚐTrustCenterVisibility(ctx, field.Selections, res)
|
||||
}
|
||||
|
||||
func (ec *executionContext) fieldContext_Document_showOnTrustCenter(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
||||
func (ec *executionContext) fieldContext_Document_trustCenterVisibility(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
||||
fc = &graphql.FieldContext{
|
||||
Object: "Document",
|
||||
Field: field,
|
||||
IsMethod: false,
|
||||
IsResolver: false,
|
||||
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
|
||||
return nil, errors.New("field of type Boolean does not have child fields")
|
||||
return nil, errors.New("field of type TrustCenterVisibility does not have child fields")
|
||||
},
|
||||
}
|
||||
return fc, nil
|
||||
@@ -30803,8 +30821,8 @@ func (ec *executionContext) fieldContext_DocumentEdge_node(_ context.Context, fi
|
||||
return ec.fieldContext_Document_documentType(ctx, field)
|
||||
case "currentPublishedVersion":
|
||||
return ec.fieldContext_Document_currentPublishedVersion(ctx, field)
|
||||
case "showOnTrustCenter":
|
||||
return ec.fieldContext_Document_showOnTrustCenter(ctx, field)
|
||||
case "trustCenterVisibility":
|
||||
return ec.fieldContext_Document_trustCenterVisibility(ctx, field)
|
||||
case "owner":
|
||||
return ec.fieldContext_Document_owner(ctx, field)
|
||||
case "organization":
|
||||
@@ -30917,8 +30935,8 @@ func (ec *executionContext) fieldContext_DocumentVersion_document(_ context.Cont
|
||||
return ec.fieldContext_Document_documentType(ctx, field)
|
||||
case "currentPublishedVersion":
|
||||
return ec.fieldContext_Document_currentPublishedVersion(ctx, field)
|
||||
case "showOnTrustCenter":
|
||||
return ec.fieldContext_Document_showOnTrustCenter(ctx, field)
|
||||
case "trustCenterVisibility":
|
||||
return ec.fieldContext_Document_trustCenterVisibility(ctx, field)
|
||||
case "owner":
|
||||
return ec.fieldContext_Document_owner(ctx, field)
|
||||
case "organization":
|
||||
@@ -42270,8 +42288,8 @@ func (ec *executionContext) fieldContext_Nonconformity_audit(_ context.Context,
|
||||
return ec.fieldContext_Audit_state(ctx, field)
|
||||
case "controls":
|
||||
return ec.fieldContext_Audit_controls(ctx, field)
|
||||
case "showOnTrustCenter":
|
||||
return ec.fieldContext_Audit_showOnTrustCenter(ctx, field)
|
||||
case "trustCenterVisibility":
|
||||
return ec.fieldContext_Audit_trustCenterVisibility(ctx, field)
|
||||
case "createdAt":
|
||||
return ec.fieldContext_Audit_createdAt(ctx, field)
|
||||
case "updatedAt":
|
||||
@@ -47969,8 +47987,8 @@ func (ec *executionContext) fieldContext_PublishDocumentVersionPayload_document(
|
||||
return ec.fieldContext_Document_documentType(ctx, field)
|
||||
case "currentPublishedVersion":
|
||||
return ec.fieldContext_Document_currentPublishedVersion(ctx, field)
|
||||
case "showOnTrustCenter":
|
||||
return ec.fieldContext_Document_showOnTrustCenter(ctx, field)
|
||||
case "trustCenterVisibility":
|
||||
return ec.fieldContext_Document_trustCenterVisibility(ctx, field)
|
||||
case "owner":
|
||||
return ec.fieldContext_Document_owner(ctx, field)
|
||||
case "organization":
|
||||
@@ -48677,8 +48695,8 @@ func (ec *executionContext) fieldContext_Report_audit(_ context.Context, field g
|
||||
return ec.fieldContext_Audit_state(ctx, field)
|
||||
case "controls":
|
||||
return ec.fieldContext_Audit_controls(ctx, field)
|
||||
case "showOnTrustCenter":
|
||||
return ec.fieldContext_Audit_showOnTrustCenter(ctx, field)
|
||||
case "trustCenterVisibility":
|
||||
return ec.fieldContext_Audit_trustCenterVisibility(ctx, field)
|
||||
case "createdAt":
|
||||
return ec.fieldContext_Audit_createdAt(ctx, field)
|
||||
case "updatedAt":
|
||||
@@ -53308,8 +53326,8 @@ func (ec *executionContext) fieldContext_TrustCenterDocumentAccess_document(_ co
|
||||
return ec.fieldContext_Document_documentType(ctx, field)
|
||||
case "currentPublishedVersion":
|
||||
return ec.fieldContext_Document_currentPublishedVersion(ctx, field)
|
||||
case "showOnTrustCenter":
|
||||
return ec.fieldContext_Document_showOnTrustCenter(ctx, field)
|
||||
case "trustCenterVisibility":
|
||||
return ec.fieldContext_Document_trustCenterVisibility(ctx, field)
|
||||
case "owner":
|
||||
return ec.fieldContext_Document_owner(ctx, field)
|
||||
case "organization":
|
||||
@@ -54511,8 +54529,8 @@ func (ec *executionContext) fieldContext_UpdateAuditPayload_audit(_ context.Cont
|
||||
return ec.fieldContext_Audit_state(ctx, field)
|
||||
case "controls":
|
||||
return ec.fieldContext_Audit_controls(ctx, field)
|
||||
case "showOnTrustCenter":
|
||||
return ec.fieldContext_Audit_showOnTrustCenter(ctx, field)
|
||||
case "trustCenterVisibility":
|
||||
return ec.fieldContext_Audit_trustCenterVisibility(ctx, field)
|
||||
case "createdAt":
|
||||
return ec.fieldContext_Audit_createdAt(ctx, field)
|
||||
case "updatedAt":
|
||||
@@ -54781,8 +54799,8 @@ func (ec *executionContext) fieldContext_UpdateDocumentPayload_document(_ contex
|
||||
return ec.fieldContext_Document_documentType(ctx, field)
|
||||
case "currentPublishedVersion":
|
||||
return ec.fieldContext_Document_currentPublishedVersion(ctx, field)
|
||||
case "showOnTrustCenter":
|
||||
return ec.fieldContext_Document_showOnTrustCenter(ctx, field)
|
||||
case "trustCenterVisibility":
|
||||
return ec.fieldContext_Document_trustCenterVisibility(ctx, field)
|
||||
case "owner":
|
||||
return ec.fieldContext_Document_owner(ctx, field)
|
||||
case "organization":
|
||||
@@ -56169,8 +56187,8 @@ func (ec *executionContext) fieldContext_UploadAuditReportPayload_audit(_ contex
|
||||
return ec.fieldContext_Audit_state(ctx, field)
|
||||
case "controls":
|
||||
return ec.fieldContext_Audit_controls(ctx, field)
|
||||
case "showOnTrustCenter":
|
||||
return ec.fieldContext_Audit_showOnTrustCenter(ctx, field)
|
||||
case "trustCenterVisibility":
|
||||
return ec.fieldContext_Audit_trustCenterVisibility(ctx, field)
|
||||
case "createdAt":
|
||||
return ec.fieldContext_Audit_createdAt(ctx, field)
|
||||
case "updatedAt":
|
||||
@@ -64908,7 +64926,7 @@ func (ec *executionContext) unmarshalInputCreateAuditInput(ctx context.Context,
|
||||
asMap[k] = v
|
||||
}
|
||||
|
||||
fieldsInOrder := [...]string{"organizationId", "frameworkId", "name", "validFrom", "validUntil", "state"}
|
||||
fieldsInOrder := [...]string{"organizationId", "frameworkId", "name", "validFrom", "validUntil", "state", "trustCenterVisibility"}
|
||||
for _, k := range fieldsInOrder {
|
||||
v, ok := asMap[k]
|
||||
if !ok {
|
||||
@@ -64957,6 +64975,13 @@ func (ec *executionContext) unmarshalInputCreateAuditInput(ctx context.Context,
|
||||
return it, err
|
||||
}
|
||||
it.State = data
|
||||
case "trustCenterVisibility":
|
||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("trustCenterVisibility"))
|
||||
data, err := ec.unmarshalOTrustCenterVisibility2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋcoredataᚐTrustCenterVisibility(ctx, v)
|
||||
if err != nil {
|
||||
return it, err
|
||||
}
|
||||
it.TrustCenterVisibility = data
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65299,7 +65324,7 @@ func (ec *executionContext) unmarshalInputCreateDocumentInput(ctx context.Contex
|
||||
asMap[k] = v
|
||||
}
|
||||
|
||||
fieldsInOrder := [...]string{"organizationId", "title", "content", "ownerId", "documentType"}
|
||||
fieldsInOrder := [...]string{"organizationId", "title", "content", "ownerId", "documentType", "trustCenterVisibility"}
|
||||
for _, k := range fieldsInOrder {
|
||||
v, ok := asMap[k]
|
||||
if !ok {
|
||||
@@ -65341,6 +65366,13 @@ func (ec *executionContext) unmarshalInputCreateDocumentInput(ctx context.Contex
|
||||
return it, err
|
||||
}
|
||||
it.DocumentType = data
|
||||
case "trustCenterVisibility":
|
||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("trustCenterVisibility"))
|
||||
data, err := ec.unmarshalOTrustCenterVisibility2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋcoredataᚐTrustCenterVisibility(ctx, v)
|
||||
if err != nil {
|
||||
return it, err
|
||||
}
|
||||
it.TrustCenterVisibility = data
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69154,7 +69186,7 @@ func (ec *executionContext) unmarshalInputUpdateAuditInput(ctx context.Context,
|
||||
asMap[k] = v
|
||||
}
|
||||
|
||||
fieldsInOrder := [...]string{"id", "name", "validFrom", "validUntil", "state", "showOnTrustCenter"}
|
||||
fieldsInOrder := [...]string{"id", "name", "validFrom", "validUntil", "state", "trustCenterVisibility"}
|
||||
for _, k := range fieldsInOrder {
|
||||
v, ok := asMap[k]
|
||||
if !ok {
|
||||
@@ -69196,13 +69228,13 @@ func (ec *executionContext) unmarshalInputUpdateAuditInput(ctx context.Context,
|
||||
return it, err
|
||||
}
|
||||
it.State = data
|
||||
case "showOnTrustCenter":
|
||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("showOnTrustCenter"))
|
||||
data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v)
|
||||
case "trustCenterVisibility":
|
||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("trustCenterVisibility"))
|
||||
data, err := ec.unmarshalOTrustCenterVisibility2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋcoredataᚐTrustCenterVisibility(ctx, v)
|
||||
if err != nil {
|
||||
return it, err
|
||||
}
|
||||
it.ShowOnTrustCenter = data
|
||||
it.TrustCenterVisibility = data
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69409,7 +69441,7 @@ func (ec *executionContext) unmarshalInputUpdateDocumentInput(ctx context.Contex
|
||||
asMap[k] = v
|
||||
}
|
||||
|
||||
fieldsInOrder := [...]string{"id", "title", "content", "ownerId", "documentType", "showOnTrustCenter"}
|
||||
fieldsInOrder := [...]string{"id", "title", "content", "ownerId", "documentType", "trustCenterVisibility"}
|
||||
for _, k := range fieldsInOrder {
|
||||
v, ok := asMap[k]
|
||||
if !ok {
|
||||
@@ -69451,13 +69483,13 @@ func (ec *executionContext) unmarshalInputUpdateDocumentInput(ctx context.Contex
|
||||
return it, err
|
||||
}
|
||||
it.DocumentType = data
|
||||
case "showOnTrustCenter":
|
||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("showOnTrustCenter"))
|
||||
data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v)
|
||||
case "trustCenterVisibility":
|
||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("trustCenterVisibility"))
|
||||
data, err := ec.unmarshalOTrustCenterVisibility2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋcoredataᚐTrustCenterVisibility(ctx, v)
|
||||
if err != nil {
|
||||
return it, err
|
||||
}
|
||||
it.ShowOnTrustCenter = data
|
||||
it.TrustCenterVisibility = data
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72132,8 +72164,8 @@ func (ec *executionContext) _Audit(ctx context.Context, sel ast.SelectionSet, ob
|
||||
}
|
||||
|
||||
out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) })
|
||||
case "showOnTrustCenter":
|
||||
out.Values[i] = ec._Audit_showOnTrustCenter(ctx, field, obj)
|
||||
case "trustCenterVisibility":
|
||||
out.Values[i] = ec._Audit_trustCenterVisibility(ctx, field, obj)
|
||||
if out.Values[i] == graphql.Null {
|
||||
atomic.AddUint32(&out.Invalids, 1)
|
||||
}
|
||||
@@ -76300,8 +76332,8 @@ func (ec *executionContext) _Document(ctx context.Context, sel ast.SelectionSet,
|
||||
}
|
||||
case "currentPublishedVersion":
|
||||
out.Values[i] = ec._Document_currentPublishedVersion(ctx, field, obj)
|
||||
case "showOnTrustCenter":
|
||||
out.Values[i] = ec._Document_showOnTrustCenter(ctx, field, obj)
|
||||
case "trustCenterVisibility":
|
||||
out.Values[i] = ec._Document_trustCenterVisibility(ctx, field, obj)
|
||||
if out.Values[i] == graphql.Null {
|
||||
atomic.AddUint32(&out.Invalids, 1)
|
||||
}
|
||||
@@ -93295,6 +93327,36 @@ var (
|
||||
}
|
||||
)
|
||||
|
||||
func (ec *executionContext) unmarshalNTrustCenterVisibility2githubᚗcomᚋgetproboᚋproboᚋpkgᚋcoredataᚐTrustCenterVisibility(ctx context.Context, v any) (coredata.TrustCenterVisibility, error) {
|
||||
tmp, err := graphql.UnmarshalString(v)
|
||||
res := unmarshalNTrustCenterVisibility2githubᚗcomᚋgetproboᚋproboᚋpkgᚋcoredataᚐTrustCenterVisibility[tmp]
|
||||
return res, graphql.ErrorOnPath(ctx, err)
|
||||
}
|
||||
|
||||
func (ec *executionContext) marshalNTrustCenterVisibility2githubᚗcomᚋgetproboᚋproboᚋpkgᚋcoredataᚐTrustCenterVisibility(ctx context.Context, sel ast.SelectionSet, v coredata.TrustCenterVisibility) graphql.Marshaler {
|
||||
_ = sel
|
||||
res := graphql.MarshalString(marshalNTrustCenterVisibility2githubᚗcomᚋgetproboᚋproboᚋpkgᚋcoredataᚐTrustCenterVisibility[v])
|
||||
if res == graphql.Null {
|
||||
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
|
||||
ec.Errorf(ctx, "the requested element is null which the schema does not allow")
|
||||
}
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
var (
|
||||
unmarshalNTrustCenterVisibility2githubᚗcomᚋgetproboᚋproboᚋpkgᚋcoredataᚐTrustCenterVisibility = map[string]coredata.TrustCenterVisibility{
|
||||
"NONE": coredata.TrustCenterVisibilityNone,
|
||||
"PRIVATE": coredata.TrustCenterVisibilityPrivate,
|
||||
"PUBLIC": coredata.TrustCenterVisibilityPublic,
|
||||
}
|
||||
marshalNTrustCenterVisibility2githubᚗcomᚋgetproboᚋproboᚋpkgᚋcoredataᚐTrustCenterVisibility = map[coredata.TrustCenterVisibility]string{
|
||||
coredata.TrustCenterVisibilityNone: "NONE",
|
||||
coredata.TrustCenterVisibilityPrivate: "PRIVATE",
|
||||
coredata.TrustCenterVisibilityPublic: "PUBLIC",
|
||||
}
|
||||
)
|
||||
|
||||
func (ec *executionContext) unmarshalNUnassignTaskInput2githubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐUnassignTaskInput(ctx context.Context, v any) (types.UnassignTaskInput, error) {
|
||||
res, err := ec.unmarshalInputUnassignTaskInput(ctx, v)
|
||||
return res, graphql.ErrorOnPath(ctx, err)
|
||||
@@ -96681,6 +96743,38 @@ func (ec *executionContext) unmarshalOTrustCenterReferenceOrder2ᚖgithubᚗcom
|
||||
return &res, graphql.ErrorOnPath(ctx, err)
|
||||
}
|
||||
|
||||
func (ec *executionContext) unmarshalOTrustCenterVisibility2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋcoredataᚐTrustCenterVisibility(ctx context.Context, v any) (*coredata.TrustCenterVisibility, error) {
|
||||
if v == nil {
|
||||
return nil, nil
|
||||
}
|
||||
tmp, err := graphql.UnmarshalString(v)
|
||||
res := unmarshalOTrustCenterVisibility2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋcoredataᚐTrustCenterVisibility[tmp]
|
||||
return &res, graphql.ErrorOnPath(ctx, err)
|
||||
}
|
||||
|
||||
func (ec *executionContext) marshalOTrustCenterVisibility2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋcoredataᚐTrustCenterVisibility(ctx context.Context, sel ast.SelectionSet, v *coredata.TrustCenterVisibility) graphql.Marshaler {
|
||||
if v == nil {
|
||||
return graphql.Null
|
||||
}
|
||||
_ = sel
|
||||
_ = ctx
|
||||
res := graphql.MarshalString(marshalOTrustCenterVisibility2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋcoredataᚐTrustCenterVisibility[*v])
|
||||
return res
|
||||
}
|
||||
|
||||
var (
|
||||
unmarshalOTrustCenterVisibility2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋcoredataᚐTrustCenterVisibility = map[string]coredata.TrustCenterVisibility{
|
||||
"NONE": coredata.TrustCenterVisibilityNone,
|
||||
"PRIVATE": coredata.TrustCenterVisibilityPrivate,
|
||||
"PUBLIC": coredata.TrustCenterVisibilityPublic,
|
||||
}
|
||||
marshalOTrustCenterVisibility2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋcoredataᚐTrustCenterVisibility = map[coredata.TrustCenterVisibility]string{
|
||||
coredata.TrustCenterVisibilityNone: "NONE",
|
||||
coredata.TrustCenterVisibilityPrivate: "PRIVATE",
|
||||
coredata.TrustCenterVisibilityPublic: "PUBLIC",
|
||||
}
|
||||
)
|
||||
|
||||
func (ec *executionContext) unmarshalOUpload2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚐUpload(ctx context.Context, v any) (*graphql.Upload, error) {
|
||||
if v == nil {
|
||||
return nil, nil
|
||||
|
||||
@@ -54,14 +54,14 @@ func NewAuditConnection(
|
||||
|
||||
func NewAudit(a *coredata.Audit) *Audit {
|
||||
return &Audit{
|
||||
ID: a.ID,
|
||||
ValidFrom: a.ValidFrom,
|
||||
ValidUntil: a.ValidUntil,
|
||||
State: a.State,
|
||||
Name: a.Name,
|
||||
ShowOnTrustCenter: a.ShowOnTrustCenter,
|
||||
CreatedAt: a.CreatedAt,
|
||||
UpdatedAt: a.UpdatedAt,
|
||||
ID: a.ID,
|
||||
ValidFrom: a.ValidFrom,
|
||||
ValidUntil: a.ValidUntil,
|
||||
State: a.State,
|
||||
Name: a.Name,
|
||||
TrustCenterVisibility: a.TrustCenterVisibility,
|
||||
CreatedAt: a.CreatedAt,
|
||||
UpdatedAt: a.UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ func NewDocument(document *coredata.Document) *Document {
|
||||
Title: document.Title,
|
||||
DocumentType: document.DocumentType,
|
||||
CurrentPublishedVersion: document.CurrentPublishedVersion,
|
||||
ShowOnTrustCenter: document.ShowOnTrustCenter,
|
||||
TrustCenterVisibility: document.TrustCenterVisibility,
|
||||
CreatedAt: document.CreatedAt,
|
||||
UpdatedAt: document.UpdatedAt,
|
||||
}
|
||||
|
||||
@@ -62,19 +62,19 @@ type AssignTaskPayload struct {
|
||||
}
|
||||
|
||||
type Audit struct {
|
||||
ID gid.GID `json:"id"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
Organization *Organization `json:"organization"`
|
||||
Framework *Framework `json:"framework"`
|
||||
ValidFrom *time.Time `json:"validFrom,omitempty"`
|
||||
ValidUntil *time.Time `json:"validUntil,omitempty"`
|
||||
Report *Report `json:"report,omitempty"`
|
||||
ReportURL *string `json:"reportUrl,omitempty"`
|
||||
State coredata.AuditState `json:"state"`
|
||||
Controls *ControlConnection `json:"controls"`
|
||||
ShowOnTrustCenter bool `json:"showOnTrustCenter"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
ID gid.GID `json:"id"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
Organization *Organization `json:"organization"`
|
||||
Framework *Framework `json:"framework"`
|
||||
ValidFrom *time.Time `json:"validFrom,omitempty"`
|
||||
ValidUntil *time.Time `json:"validUntil,omitempty"`
|
||||
Report *Report `json:"report,omitempty"`
|
||||
ReportURL *string `json:"reportUrl,omitempty"`
|
||||
State coredata.AuditState `json:"state"`
|
||||
Controls *ControlConnection `json:"controls"`
|
||||
TrustCenterVisibility coredata.TrustCenterVisibility `json:"trustCenterVisibility"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
}
|
||||
|
||||
func (Audit) IsNode() {}
|
||||
@@ -237,12 +237,13 @@ type CreateAssetPayload struct {
|
||||
}
|
||||
|
||||
type CreateAuditInput struct {
|
||||
OrganizationID gid.GID `json:"organizationId"`
|
||||
FrameworkID gid.GID `json:"frameworkId"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
ValidFrom *time.Time `json:"validFrom,omitempty"`
|
||||
ValidUntil *time.Time `json:"validUntil,omitempty"`
|
||||
State *coredata.AuditState `json:"state,omitempty"`
|
||||
OrganizationID gid.GID `json:"organizationId"`
|
||||
FrameworkID gid.GID `json:"frameworkId"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
ValidFrom *time.Time `json:"validFrom,omitempty"`
|
||||
ValidUntil *time.Time `json:"validUntil,omitempty"`
|
||||
State *coredata.AuditState `json:"state,omitempty"`
|
||||
TrustCenterVisibility *coredata.TrustCenterVisibility `json:"trustCenterVisibility,omitempty"`
|
||||
}
|
||||
|
||||
type CreateAuditPayload struct {
|
||||
@@ -330,11 +331,12 @@ type CreateDatumPayload struct {
|
||||
}
|
||||
|
||||
type CreateDocumentInput struct {
|
||||
OrganizationID gid.GID `json:"organizationId"`
|
||||
Title string `json:"title"`
|
||||
Content string `json:"content"`
|
||||
OwnerID gid.GID `json:"ownerId"`
|
||||
DocumentType coredata.DocumentType `json:"documentType"`
|
||||
OrganizationID gid.GID `json:"organizationId"`
|
||||
Title string `json:"title"`
|
||||
Content string `json:"content"`
|
||||
OwnerID gid.GID `json:"ownerId"`
|
||||
DocumentType coredata.DocumentType `json:"documentType"`
|
||||
TrustCenterVisibility *coredata.TrustCenterVisibility `json:"trustCenterVisibility,omitempty"`
|
||||
}
|
||||
|
||||
type CreateDocumentPayload struct {
|
||||
@@ -943,18 +945,18 @@ type DeleteVendorServicePayload struct {
|
||||
}
|
||||
|
||||
type Document struct {
|
||||
ID gid.GID `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Description string `json:"description"`
|
||||
DocumentType coredata.DocumentType `json:"documentType"`
|
||||
CurrentPublishedVersion *int `json:"currentPublishedVersion,omitempty"`
|
||||
ShowOnTrustCenter bool `json:"showOnTrustCenter"`
|
||||
Owner *People `json:"owner"`
|
||||
Organization *Organization `json:"organization"`
|
||||
Versions *DocumentVersionConnection `json:"versions"`
|
||||
Controls *ControlConnection `json:"controls"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
ID gid.GID `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Description string `json:"description"`
|
||||
DocumentType coredata.DocumentType `json:"documentType"`
|
||||
CurrentPublishedVersion *int `json:"currentPublishedVersion,omitempty"`
|
||||
TrustCenterVisibility coredata.TrustCenterVisibility `json:"trustCenterVisibility"`
|
||||
Owner *People `json:"owner"`
|
||||
Organization *Organization `json:"organization"`
|
||||
Versions *DocumentVersionConnection `json:"versions"`
|
||||
Controls *ControlConnection `json:"controls"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
}
|
||||
|
||||
func (Document) IsNode() {}
|
||||
@@ -1615,12 +1617,12 @@ type UpdateAssetPayload struct {
|
||||
}
|
||||
|
||||
type UpdateAuditInput struct {
|
||||
ID gid.GID `json:"id"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
ValidFrom *time.Time `json:"validFrom,omitempty"`
|
||||
ValidUntil *time.Time `json:"validUntil,omitempty"`
|
||||
State *coredata.AuditState `json:"state,omitempty"`
|
||||
ShowOnTrustCenter *bool `json:"showOnTrustCenter,omitempty"`
|
||||
ID gid.GID `json:"id"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
ValidFrom *time.Time `json:"validFrom,omitempty"`
|
||||
ValidUntil *time.Time `json:"validUntil,omitempty"`
|
||||
State *coredata.AuditState `json:"state,omitempty"`
|
||||
TrustCenterVisibility *coredata.TrustCenterVisibility `json:"trustCenterVisibility,omitempty"`
|
||||
}
|
||||
|
||||
type UpdateAuditPayload struct {
|
||||
@@ -1668,12 +1670,12 @@ type UpdateDatumPayload struct {
|
||||
}
|
||||
|
||||
type UpdateDocumentInput struct {
|
||||
ID gid.GID `json:"id"`
|
||||
Title *string `json:"title,omitempty"`
|
||||
Content *string `json:"content,omitempty"`
|
||||
OwnerID *gid.GID `json:"ownerId,omitempty"`
|
||||
DocumentType *coredata.DocumentType `json:"documentType,omitempty"`
|
||||
ShowOnTrustCenter *bool `json:"showOnTrustCenter,omitempty"`
|
||||
ID gid.GID `json:"id"`
|
||||
Title *string `json:"title,omitempty"`
|
||||
Content *string `json:"content,omitempty"`
|
||||
OwnerID *gid.GID `json:"ownerId,omitempty"`
|
||||
DocumentType *coredata.DocumentType `json:"documentType,omitempty"`
|
||||
TrustCenterVisibility *coredata.TrustCenterVisibility `json:"trustCenterVisibility,omitempty"`
|
||||
}
|
||||
|
||||
type UpdateDocumentPayload struct {
|
||||
|
||||
@@ -2500,11 +2500,12 @@ func (r *mutationResolver) CreateDocument(ctx context.Context, input types.Creat
|
||||
document, documentVersion, err := prb.Documents.Create(
|
||||
ctx,
|
||||
probo.CreateDocumentRequest{
|
||||
OrganizationID: input.OrganizationID,
|
||||
DocumentType: input.DocumentType,
|
||||
Title: input.Title,
|
||||
OwnerID: input.OwnerID,
|
||||
Content: input.Content,
|
||||
OrganizationID: input.OrganizationID,
|
||||
DocumentType: input.DocumentType,
|
||||
Title: input.Title,
|
||||
OwnerID: input.OwnerID,
|
||||
Content: input.Content,
|
||||
TrustCenterVisibility: input.TrustCenterVisibility,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
@@ -2527,7 +2528,7 @@ func (r *mutationResolver) UpdateDocument(ctx context.Context, input types.Updat
|
||||
input.OwnerID,
|
||||
input.DocumentType,
|
||||
input.Title,
|
||||
input.ShowOnTrustCenter,
|
||||
input.TrustCenterVisibility,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
@@ -2963,12 +2964,13 @@ func (r *mutationResolver) CreateAudit(ctx context.Context, input types.CreateAu
|
||||
prb := r.ProboService(ctx, input.OrganizationID.TenantID())
|
||||
|
||||
req := probo.CreateAuditRequest{
|
||||
OrganizationID: input.OrganizationID,
|
||||
FrameworkID: input.FrameworkID,
|
||||
Name: input.Name,
|
||||
ValidFrom: input.ValidFrom,
|
||||
ValidUntil: input.ValidUntil,
|
||||
State: input.State,
|
||||
OrganizationID: input.OrganizationID,
|
||||
FrameworkID: input.FrameworkID,
|
||||
Name: input.Name,
|
||||
ValidFrom: input.ValidFrom,
|
||||
ValidUntil: input.ValidUntil,
|
||||
State: input.State,
|
||||
TrustCenterVisibility: input.TrustCenterVisibility,
|
||||
}
|
||||
|
||||
audit, err := prb.Audits.Create(ctx, &req)
|
||||
@@ -2986,12 +2988,12 @@ func (r *mutationResolver) UpdateAudit(ctx context.Context, input types.UpdateAu
|
||||
prb := r.ProboService(ctx, input.ID.TenantID())
|
||||
|
||||
req := probo.UpdateAuditRequest{
|
||||
ID: input.ID,
|
||||
Name: &input.Name,
|
||||
ValidFrom: input.ValidFrom,
|
||||
ValidUntil: input.ValidUntil,
|
||||
State: input.State,
|
||||
ShowOnTrustCenter: input.ShowOnTrustCenter,
|
||||
ID: input.ID,
|
||||
Name: &input.Name,
|
||||
ValidFrom: input.ValidFrom,
|
||||
ValidUntil: input.ValidUntil,
|
||||
State: input.State,
|
||||
TrustCenterVisibility: input.TrustCenterVisibility,
|
||||
}
|
||||
|
||||
audit, err := prb.Audits.Update(ctx, &req)
|
||||
|
||||
@@ -59,6 +59,17 @@ func (r *auditResolver) Report(ctx context.Context, obj *types.Audit) (*types.Re
|
||||
|
||||
// IsUserAuthorized is the resolver for the isUserAuthorized field.
|
||||
func (r *documentResolver) IsUserAuthorized(ctx context.Context, obj *types.Document) (bool, error) {
|
||||
publicTrustService := r.PublicTrustService(ctx, obj.ID.TenantID())
|
||||
|
||||
document, err := publicTrustService.Documents.Get(ctx, obj.ID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot load document: %w", err))
|
||||
}
|
||||
|
||||
if document.TrustCenterVisibility == coredata.TrustCenterVisibilityPublic {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
privateTrustService, err := r.PrivateTrustService(ctx, obj.ID.TenantID())
|
||||
if err != nil {
|
||||
return false, nil
|
||||
@@ -153,9 +164,27 @@ func (r *mutationResolver) RequestAllAccesses(ctx context.Context, input types.R
|
||||
|
||||
// ExportDocumentPDF is the resolver for the exportDocumentPDF field.
|
||||
func (r *mutationResolver) ExportDocumentPDF(ctx context.Context, input types.ExportDocumentPDFInput) (*types.ExportDocumentPDFPayload, error) {
|
||||
publicTrustService := r.PublicTrustService(ctx, input.DocumentID.TenantID())
|
||||
|
||||
document, err := publicTrustService.Documents.Get(ctx, input.DocumentID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot load document: %w", err))
|
||||
}
|
||||
|
||||
if document.TrustCenterVisibility == coredata.TrustCenterVisibilityPublic {
|
||||
pdf, err := publicTrustService.Documents.ExportPDFWithoutWatermark(ctx, input.DocumentID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot export document PDF: %w", err))
|
||||
}
|
||||
|
||||
return &types.ExportDocumentPDFPayload{
|
||||
Data: fmt.Sprintf("data:application/pdf;base64,%s", base64.StdEncoding.EncodeToString(pdf)),
|
||||
}, nil
|
||||
}
|
||||
|
||||
privateTrustService, err := r.PrivateTrustService(ctx, input.DocumentID.TenantID())
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot export document PDF: %w", err)
|
||||
panic(fmt.Errorf("cannot export document PDF: %w", err))
|
||||
}
|
||||
|
||||
tokenData := TokenAccessFromContext(ctx)
|
||||
@@ -214,6 +243,24 @@ func (r *mutationResolver) ExportDocumentPDF(ctx context.Context, input types.Ex
|
||||
|
||||
// ExportReportPDF is the resolver for the exportReportPDF field.
|
||||
func (r *mutationResolver) ExportReportPDF(ctx context.Context, input types.ExportReportPDFInput) (*types.ExportReportPDFPayload, error) {
|
||||
publicTrustService := r.PublicTrustService(ctx, input.ReportID.TenantID())
|
||||
|
||||
audit, err := publicTrustService.Audits.GetByReportID(ctx, input.ReportID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot load audit: %w", err))
|
||||
}
|
||||
|
||||
if audit.TrustCenterVisibility == coredata.TrustCenterVisibilityPublic {
|
||||
pdf, err := publicTrustService.Reports.ExportPDFWithoutWatermark(ctx, input.ReportID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot export report PDF: %w", err))
|
||||
}
|
||||
|
||||
return &types.ExportReportPDFPayload{
|
||||
Data: fmt.Sprintf("data:application/pdf;base64,%s", base64.StdEncoding.EncodeToString(pdf)),
|
||||
}, nil
|
||||
}
|
||||
|
||||
privateTrustService, err := r.PrivateTrustService(ctx, input.ReportID.TenantID())
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot export report PDF: %w", err)
|
||||
@@ -296,6 +343,15 @@ func (r *mutationResolver) AcceptNonDisclosureAgreement(ctx context.Context, inp
|
||||
func (r *mutationResolver) RequestDocumentAccess(ctx context.Context, input types.RequestDocumentAccessInput) (*types.RequestAccessesPayload, error) {
|
||||
publicTrustService := r.PublicTrustService(ctx, input.TrustCenterID.TenantID())
|
||||
|
||||
document, err := publicTrustService.Documents.Get(ctx, input.DocumentID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot load document: %w", err))
|
||||
}
|
||||
|
||||
if document.TrustCenterVisibility == coredata.TrustCenterVisibilityPublic {
|
||||
return nil, fmt.Errorf("document is publicly available and does not require access request")
|
||||
}
|
||||
|
||||
userData := r.UserFromContext(ctx)
|
||||
if userData != nil {
|
||||
return nil, fmt.Errorf("sessions users cannot request trust center access")
|
||||
@@ -340,6 +396,15 @@ func (r *mutationResolver) RequestDocumentAccess(ctx context.Context, input type
|
||||
func (r *mutationResolver) RequestReportAccess(ctx context.Context, input types.RequestReportAccessInput) (*types.RequestAccessesPayload, error) {
|
||||
publicTrustService := r.PublicTrustService(ctx, input.TrustCenterID.TenantID())
|
||||
|
||||
audit, err := publicTrustService.Audits.GetByReportID(ctx, input.ReportID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot load audit: %w", err))
|
||||
}
|
||||
|
||||
if audit.TrustCenterVisibility == coredata.TrustCenterVisibilityPublic {
|
||||
return nil, fmt.Errorf("report is publicly available and does not require access request")
|
||||
}
|
||||
|
||||
userData := r.UserFromContext(ctx)
|
||||
if userData != nil {
|
||||
return nil, fmt.Errorf("session users cannot request trust center access")
|
||||
@@ -484,6 +549,17 @@ func (r *queryResolver) TrustCenterBySlug(ctx context.Context, slug string) (*ty
|
||||
|
||||
// IsUserAuthorized is the resolver for the isUserAuthorized field.
|
||||
func (r *reportResolver) IsUserAuthorized(ctx context.Context, obj *types.Report) (bool, error) {
|
||||
publicTrustService := r.PublicTrustService(ctx, obj.ID.TenantID())
|
||||
|
||||
audit, err := publicTrustService.Audits.GetByReportID(ctx, obj.ID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot load document: %w", err))
|
||||
}
|
||||
|
||||
if audit.TrustCenterVisibility == coredata.TrustCenterVisibilityPublic {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
privateTrustService, err := r.PrivateTrustService(ctx, obj.ID.TenantID())
|
||||
if err != nil {
|
||||
return false, nil
|
||||
|
||||
@@ -53,6 +53,31 @@ func (s AuditService) Get(
|
||||
return audit, nil
|
||||
}
|
||||
|
||||
func (s AuditService) GetByReportID(
|
||||
ctx context.Context,
|
||||
reportID gid.GID,
|
||||
) (*coredata.Audit, error) {
|
||||
audit := &coredata.Audit{}
|
||||
|
||||
err := s.svc.pg.WithConn(
|
||||
ctx,
|
||||
func(conn pg.Conn) error {
|
||||
err := audit.LoadByReportID(ctx, conn, s.svc.scope, reportID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot load audit: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return audit, nil
|
||||
}
|
||||
|
||||
func (s AuditService) ListForOrganizationId(
|
||||
ctx context.Context,
|
||||
organizationID gid.GID,
|
||||
|
||||
@@ -88,6 +88,55 @@ func (s *DocumentService) ExportPDF(
|
||||
ctx context.Context,
|
||||
documentID gid.GID,
|
||||
email string,
|
||||
) ([]byte, error) {
|
||||
pdfData, err := s.exportPDFData(ctx, documentID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot export document PDF: %w", err)
|
||||
}
|
||||
|
||||
watermarkedPDF, err := watermarkpdf.AddConfidentialWithTimestamp(pdfData, email)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot add watermark to PDF: %w", err)
|
||||
}
|
||||
|
||||
return watermarkedPDF, nil
|
||||
}
|
||||
|
||||
func (s *DocumentService) ExportPDFWithoutWatermark(
|
||||
ctx context.Context,
|
||||
documentID gid.GID,
|
||||
) ([]byte, error) {
|
||||
return s.exportPDFData(ctx, documentID)
|
||||
}
|
||||
|
||||
func (s DocumentService) Get(
|
||||
ctx context.Context,
|
||||
documentID gid.GID,
|
||||
) (*coredata.Document, error) {
|
||||
document := &coredata.Document{}
|
||||
|
||||
err := s.svc.pg.WithConn(
|
||||
ctx,
|
||||
func(conn pg.Conn) error {
|
||||
err := document.LoadByID(ctx, conn, s.svc.scope, documentID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot load document: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return document, nil
|
||||
}
|
||||
|
||||
func (s *DocumentService) exportPDFData(
|
||||
ctx context.Context,
|
||||
documentID gid.GID,
|
||||
) ([]byte, error) {
|
||||
document := &coredata.Document{}
|
||||
version := &coredata.DocumentVersion{}
|
||||
@@ -100,7 +149,7 @@ func (s *DocumentService) ExportPDF(
|
||||
return fmt.Errorf("cannot load document: %w", err)
|
||||
}
|
||||
|
||||
if !document.ShowOnTrustCenter {
|
||||
if document.TrustCenterVisibility == coredata.TrustCenterVisibilityNone {
|
||||
return fmt.Errorf("document not visible on trust center")
|
||||
}
|
||||
|
||||
@@ -163,35 +212,5 @@ func (s *DocumentService) ExportPDF(
|
||||
return nil, fmt.Errorf("cannot read PDF data: %w", err)
|
||||
}
|
||||
|
||||
watermarkedPDF, err := watermarkpdf.AddConfidentialWithTimestamp(pdfData, email)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot add watermark to PDF: %w", err)
|
||||
}
|
||||
|
||||
return watermarkedPDF, nil
|
||||
}
|
||||
|
||||
func (s DocumentService) Get(
|
||||
ctx context.Context,
|
||||
documentID gid.GID,
|
||||
) (*coredata.Document, error) {
|
||||
document := &coredata.Document{}
|
||||
|
||||
err := s.svc.pg.WithConn(
|
||||
ctx,
|
||||
func(conn pg.Conn) error {
|
||||
err := document.LoadByID(ctx, conn, s.svc.scope, documentID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot load document: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return document, nil
|
||||
return pdfData, nil
|
||||
}
|
||||
|
||||
@@ -89,6 +89,30 @@ func (s ReportService) ExportPDF(
|
||||
ctx context.Context,
|
||||
reportID gid.GID,
|
||||
email string,
|
||||
) ([]byte, error) {
|
||||
pdfData, err := s.exportPDFData(ctx, reportID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot export report PDF: %w", err)
|
||||
}
|
||||
|
||||
watermarkedPDF, err := watermarkpdf.AddConfidentialWithTimestamp(pdfData, email)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot add watermark to PDF: %w", err)
|
||||
}
|
||||
|
||||
return watermarkedPDF, nil
|
||||
}
|
||||
|
||||
func (s ReportService) ExportPDFWithoutWatermark(
|
||||
ctx context.Context,
|
||||
reportID gid.GID,
|
||||
) ([]byte, error) {
|
||||
return s.exportPDFData(ctx, reportID)
|
||||
}
|
||||
|
||||
func (s ReportService) exportPDFData(
|
||||
ctx context.Context,
|
||||
reportID gid.GID,
|
||||
) ([]byte, error) {
|
||||
report, err := s.Get(ctx, reportID)
|
||||
if err != nil {
|
||||
@@ -109,10 +133,5 @@ func (s ReportService) ExportPDF(
|
||||
return nil, fmt.Errorf("cannot read PDF data: %w", err)
|
||||
}
|
||||
|
||||
watermarkedPDF, err := watermarkpdf.AddConfidentialWithTimestamp(pdfData, email)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot add watermark to PDF: %w", err)
|
||||
}
|
||||
|
||||
return watermarkedPDF, nil
|
||||
return pdfData, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user