Add trust center files
Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
228
apps/console/src/components/trustCenter/TrustCenterFilesCard.tsx
Normal file
228
apps/console/src/components/trustCenter/TrustCenterFilesCard.tsx
Normal file
@@ -0,0 +1,228 @@
|
||||
import { graphql } from "relay-runtime";
|
||||
import {
|
||||
Card,
|
||||
Button,
|
||||
Tr,
|
||||
Td,
|
||||
Table,
|
||||
Thead,
|
||||
Tbody,
|
||||
Th,
|
||||
IconChevronDown,
|
||||
Field,
|
||||
Option,
|
||||
Badge,
|
||||
IconPencil,
|
||||
IconTrashCan,
|
||||
IconArrowLink,
|
||||
} from "@probo/ui";
|
||||
import { useTranslate } from "@probo/i18n";
|
||||
import type { TrustCenterFilesCardFragment$key, TrustCenterFilesCardFragment$data } from "./__generated__/TrustCenterFilesCardFragment.graphql";
|
||||
import { useFragment } from "react-relay";
|
||||
import { useMemo, useState, useCallback, useEffect } from "react";
|
||||
import { sprintf, getTrustCenterVisibilityOptions } from "@probo/helpers";
|
||||
import { formatDate } from "@probo/helpers";
|
||||
import clsx from "clsx";
|
||||
|
||||
const trustCenterFileFragment = graphql`
|
||||
fragment TrustCenterFilesCardFragment on TrustCenterFile {
|
||||
id
|
||||
name
|
||||
category
|
||||
fileUrl
|
||||
trustCenterVisibility
|
||||
createdAt
|
||||
updatedAt
|
||||
}
|
||||
`;
|
||||
|
||||
type Mutation<Params> = (p: {
|
||||
variables: {
|
||||
input: {
|
||||
id: string;
|
||||
trustCenterVisibility: "NONE" | "PRIVATE" | "PUBLIC";
|
||||
} & Params;
|
||||
};
|
||||
}) => void;
|
||||
|
||||
type Props<Params> = {
|
||||
files: TrustCenterFilesCardFragment$key[];
|
||||
params: Params;
|
||||
disabled?: boolean;
|
||||
onChangeVisibility: Mutation<Params>;
|
||||
onEdit: (file: { id: string; name: string; category: string }) => void;
|
||||
onDelete: (id: string) => void;
|
||||
variant?: "card" | "table";
|
||||
};
|
||||
|
||||
export function TrustCenterFilesCard<Params>(props: Props<Params>) {
|
||||
const { __ } = useTranslate();
|
||||
const [limit, setLimit] = useState<number | null>(4);
|
||||
const files = useMemo(() => {
|
||||
return limit ? props.files.slice(0, limit) : props.files;
|
||||
}, [props.files, limit]);
|
||||
const showMoreButton = limit !== null && props.files.length > limit;
|
||||
const variant = props.variant ?? "table";
|
||||
|
||||
const onChangeVisibility = (fileId: string, trustCenterVisibility: "NONE" | "PRIVATE" | "PUBLIC") => {
|
||||
props.onChangeVisibility({
|
||||
variables: {
|
||||
input: {
|
||||
id: fileId,
|
||||
trustCenterVisibility,
|
||||
...props.params,
|
||||
},
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const Wrapper = variant === "card" ? Card : "div";
|
||||
|
||||
return (
|
||||
<Wrapper padded className="space-y-[10px]">
|
||||
<Table className={clsx(variant === "card" && "bg-invert")}>
|
||||
<Thead>
|
||||
<Tr>
|
||||
<Th>{__("Name")}</Th>
|
||||
<Th>{__("Category")}</Th>
|
||||
<Th>{__("Upload Date")}</Th>
|
||||
<Th>{__("Visibility")}</Th>
|
||||
<Th></Th>
|
||||
</Tr>
|
||||
</Thead>
|
||||
<Tbody>
|
||||
{files.length === 0 && (
|
||||
<Tr>
|
||||
<Td colSpan={5} className="text-center text-txt-secondary">
|
||||
{__("No files available")}
|
||||
</Td>
|
||||
</Tr>
|
||||
)}
|
||||
{files.map((fileFragmentRef, index) => (
|
||||
<FileRowWrapper
|
||||
key={index}
|
||||
fileFragmentRef={fileFragmentRef}
|
||||
onChangeVisibility={onChangeVisibility}
|
||||
onEdit={props.onEdit}
|
||||
onDelete={props.onDelete}
|
||||
disabled={props.disabled}
|
||||
/>
|
||||
))}
|
||||
</Tbody>
|
||||
</Table>
|
||||
{showMoreButton && (
|
||||
<Button
|
||||
variant="tertiary"
|
||||
onClick={() => setLimit(null)}
|
||||
className="mt-3 mx-auto"
|
||||
icon={IconChevronDown}
|
||||
>
|
||||
{sprintf(__("Show %s more"), props.files.length - limit)}
|
||||
</Button>
|
||||
)}
|
||||
</Wrapper>
|
||||
);
|
||||
}
|
||||
|
||||
function FileRowWrapper(props: {
|
||||
fileFragmentRef: TrustCenterFilesCardFragment$key;
|
||||
onChangeVisibility: (fileId: string, trustCenterVisibility: "NONE" | "PRIVATE" | "PUBLIC") => void;
|
||||
onEdit: (file: { id: string; name: string; category: string }) => void;
|
||||
onDelete: (id: string) => void;
|
||||
disabled?: boolean;
|
||||
}) {
|
||||
const file = useFragment(trustCenterFileFragment, props.fileFragmentRef);
|
||||
return (
|
||||
<FileRow
|
||||
file={file}
|
||||
onChangeVisibility={props.onChangeVisibility}
|
||||
onEdit={props.onEdit}
|
||||
onDelete={props.onDelete}
|
||||
disabled={props.disabled}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function FileRow(props: {
|
||||
file: TrustCenterFilesCardFragment$data;
|
||||
onChangeVisibility: (fileId: string, trustCenterVisibility: "NONE" | "PRIVATE" | "PUBLIC") => void;
|
||||
onEdit: (file: { id: string; name: string; category: string }) => void;
|
||||
onDelete: (id: string) => void;
|
||||
disabled?: boolean;
|
||||
}) {
|
||||
const file = props.file;
|
||||
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(file.id, typedValue);
|
||||
}, [file.id, props.onChangeVisibility]);
|
||||
|
||||
useEffect(() => {
|
||||
if (optimisticValue && file.trustCenterVisibility === optimisticValue) {
|
||||
setOptimisticValue(null);
|
||||
}
|
||||
}, [file.trustCenterVisibility, optimisticValue]);
|
||||
|
||||
const currentValue = optimisticValue || file.trustCenterVisibility;
|
||||
|
||||
const visibilityOptions = getTrustCenterVisibilityOptions(__);
|
||||
|
||||
return (
|
||||
<Tr>
|
||||
<Td>
|
||||
<div className="flex gap-4 items-center">
|
||||
{file.name}
|
||||
</div>
|
||||
</Td>
|
||||
<Td>{file.category}</Td>
|
||||
<Td>{formatDate(file.createdAt)}</Td>
|
||||
<Td noLink width={130} className="pr-0">
|
||||
<Field
|
||||
type="select"
|
||||
value={currentValue}
|
||||
onValueChange={handleValueChange}
|
||||
disabled={props.disabled}
|
||||
className="w-[105px]"
|
||||
>
|
||||
{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>
|
||||
<Td noLink width={120}>
|
||||
<div className="flex gap-2">
|
||||
<Button
|
||||
variant="secondary"
|
||||
icon={IconArrowLink}
|
||||
onClick={() => window.open(file.fileUrl, '_blank', 'noopener,noreferrer')}
|
||||
title={__("Download")}
|
||||
/>
|
||||
<Button
|
||||
variant="secondary"
|
||||
icon={IconPencil}
|
||||
onClick={() => props.onEdit({ id: file.id, name: file.name, category: file.category })}
|
||||
disabled={props.disabled}
|
||||
title={__("Edit")}
|
||||
/>
|
||||
<Button
|
||||
variant="secondary"
|
||||
icon={IconTrashCan}
|
||||
onClick={() => props.onDelete(file.id)}
|
||||
disabled={props.disabled}
|
||||
title={__("Delete")}
|
||||
/>
|
||||
</div>
|
||||
</Td>
|
||||
</Tr>
|
||||
);
|
||||
}
|
||||
91
apps/console/src/components/trustCenter/__generated__/TrustCenterFilesCardFragment.graphql.ts
generated
Normal file
91
apps/console/src/components/trustCenter/__generated__/TrustCenterFilesCardFragment.graphql.ts
generated
Normal file
@@ -0,0 +1,91 @@
|
||||
/**
|
||||
* @generated SignedSource<<0defaaf1ce3544420e8fbd9c9f3af139>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @ts-nocheck
|
||||
|
||||
import { ReaderFragment } from 'relay-runtime';
|
||||
export type TrustCenterVisibility = "NONE" | "PRIVATE" | "PUBLIC";
|
||||
import { FragmentRefs } from "relay-runtime";
|
||||
export type TrustCenterFilesCardFragment$data = {
|
||||
readonly category: string;
|
||||
readonly createdAt: any;
|
||||
readonly fileUrl: string;
|
||||
readonly id: string;
|
||||
readonly name: string;
|
||||
readonly trustCenterVisibility: TrustCenterVisibility;
|
||||
readonly updatedAt: any;
|
||||
readonly " $fragmentType": "TrustCenterFilesCardFragment";
|
||||
};
|
||||
export type TrustCenterFilesCardFragment$key = {
|
||||
readonly " $data"?: TrustCenterFilesCardFragment$data;
|
||||
readonly " $fragmentSpreads": FragmentRefs<"TrustCenterFilesCardFragment">;
|
||||
};
|
||||
|
||||
const node: ReaderFragment = {
|
||||
"argumentDefinitions": [],
|
||||
"kind": "Fragment",
|
||||
"metadata": null,
|
||||
"name": "TrustCenterFilesCardFragment",
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "id",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "name",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "category",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "fileUrl",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "trustCenterVisibility",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "createdAt",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "updatedAt",
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"type": "TrustCenterFile",
|
||||
"abstractKey": null
|
||||
};
|
||||
|
||||
(node as any).hash = "33cb01782ca37fc776cd8e5dfde20f76";
|
||||
|
||||
export default node;
|
||||
@@ -47,6 +47,11 @@ export const trustCenterAccessesPaginationFragment = graphql`
|
||||
}
|
||||
}
|
||||
}
|
||||
trustCenterFile {
|
||||
id
|
||||
name
|
||||
category
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -94,16 +99,21 @@ export const createTrustCenterAccessMutation = graphql`
|
||||
title
|
||||
documentType
|
||||
}
|
||||
report {
|
||||
id
|
||||
filename
|
||||
audit {
|
||||
id
|
||||
framework {
|
||||
name
|
||||
report {
|
||||
id
|
||||
filename
|
||||
audit {
|
||||
id
|
||||
framework {
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
trustCenterFile {
|
||||
id
|
||||
name
|
||||
category
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -138,16 +148,21 @@ export const updateTrustCenterAccessMutation = graphql`
|
||||
title
|
||||
documentType
|
||||
}
|
||||
report {
|
||||
id
|
||||
filename
|
||||
audit {
|
||||
report {
|
||||
id
|
||||
framework {
|
||||
name
|
||||
filename
|
||||
audit {
|
||||
id
|
||||
framework {
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
trustCenterFile {
|
||||
id
|
||||
name
|
||||
category
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
78
apps/console/src/hooks/graph/TrustCenterFileGraph.ts
Normal file
78
apps/console/src/hooks/graph/TrustCenterFileGraph.ts
Normal file
@@ -0,0 +1,78 @@
|
||||
import { graphql } from "relay-runtime";
|
||||
import { useMutationWithToasts } from "/hooks/useMutationWithToasts";
|
||||
|
||||
export const createTrustCenterFileMutation = graphql`
|
||||
mutation TrustCenterFileGraphCreateMutation(
|
||||
$input: CreateTrustCenterFileInput!
|
||||
$connections: [ID!]!
|
||||
) {
|
||||
createTrustCenterFile(input: $input) {
|
||||
trustCenterFileEdge @prependEdge(connections: $connections) {
|
||||
node {
|
||||
id
|
||||
name
|
||||
category
|
||||
fileUrl
|
||||
trustCenterVisibility
|
||||
createdAt
|
||||
updatedAt
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export function useCreateTrustCenterFileMutation() {
|
||||
return useMutationWithToasts(
|
||||
createTrustCenterFileMutation,
|
||||
{
|
||||
successMessage: "File uploaded successfully",
|
||||
errorMessage: "Failed to upload file",
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export const updateTrustCenterFileMutation = graphql`
|
||||
mutation TrustCenterFileGraphUpdateMutation($input: UpdateTrustCenterFileInput!) {
|
||||
updateTrustCenterFile(input: $input) {
|
||||
trustCenterFile {
|
||||
id
|
||||
name
|
||||
category
|
||||
trustCenterVisibility
|
||||
updatedAt
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export function useUpdateTrustCenterFileMutation() {
|
||||
return useMutationWithToasts(
|
||||
updateTrustCenterFileMutation,
|
||||
{
|
||||
successMessage: "File updated successfully",
|
||||
errorMessage: "Failed to update file",
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export const deleteTrustCenterFileMutation = graphql`
|
||||
mutation TrustCenterFileGraphDeleteMutation(
|
||||
$input: DeleteTrustCenterFileInput!
|
||||
$connections: [ID!]!
|
||||
) {
|
||||
deleteTrustCenterFile(input: $input) {
|
||||
deletedTrustCenterFileId @deleteEdge(connections: $connections)
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export function useDeleteTrustCenterFileMutation() {
|
||||
return useMutationWithToasts(
|
||||
deleteTrustCenterFileMutation,
|
||||
{
|
||||
successMessage: "File deleted successfully",
|
||||
errorMessage: "Failed to delete file",
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -57,6 +57,15 @@ export const trustCenterQuery = graphql`
|
||||
}
|
||||
}
|
||||
}
|
||||
trustCenterFiles(first: 100) @connection(key: "TrustCenterPage_trustCenterFiles") {
|
||||
__id
|
||||
edges {
|
||||
node {
|
||||
id
|
||||
...TrustCenterFilesCardFragment
|
||||
}
|
||||
}
|
||||
}
|
||||
slackConnections(first: 100) {
|
||||
edges {
|
||||
node {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @generated SignedSource<<5c208d2afc4eb2968b59215d3e79231b>>
|
||||
* @generated SignedSource<<d527603a814e765a1a2be0900d1c59e1>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
@@ -48,6 +48,11 @@ export type TrustCenterAccessGraphCreateMutation$data = {
|
||||
readonly filename: string;
|
||||
readonly id: string;
|
||||
} | null | undefined;
|
||||
readonly trustCenterFile: {
|
||||
readonly category: string;
|
||||
readonly id: string;
|
||||
readonly name: string;
|
||||
} | null | undefined;
|
||||
readonly updatedAt: any;
|
||||
};
|
||||
}>;
|
||||
@@ -186,6 +191,26 @@ v13 = {
|
||||
"kind": "ScalarField",
|
||||
"name": "filename",
|
||||
"storageKey": null
|
||||
},
|
||||
v14 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "TrustCenterFile",
|
||||
"kind": "LinkedField",
|
||||
"name": "trustCenterFile",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v4/*: any*/),
|
||||
(v6/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "category",
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
};
|
||||
return {
|
||||
"fragment": {
|
||||
@@ -293,7 +318,8 @@ return {
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
},
|
||||
(v14/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
@@ -422,7 +448,8 @@ return {
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
},
|
||||
(v14/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
@@ -460,16 +487,16 @@ return {
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "a27b7cdf2a4cadf8cc22a95f39c3c6b0",
|
||||
"cacheID": "4422a02632b77f81f3b5048b5acbac98",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "TrustCenterAccessGraphCreateMutation",
|
||||
"operationKind": "mutation",
|
||||
"text": "mutation TrustCenterAccessGraphCreateMutation(\n $input: CreateTrustCenterAccessInput!\n) {\n createTrustCenterAccess(input: $input) {\n trustCenterAccessEdge {\n cursor\n node {\n id\n email\n name\n active\n hasAcceptedNonDisclosureAgreement\n createdAt\n documentAccesses(first: 100, orderBy: {field: CREATED_AT, direction: DESC}) {\n edges {\n node {\n id\n active\n createdAt\n updatedAt\n document {\n id\n title\n documentType\n }\n report {\n id\n filename\n audit {\n id\n framework {\n name\n id\n }\n }\n }\n }\n }\n }\n }\n }\n }\n}\n"
|
||||
"text": "mutation TrustCenterAccessGraphCreateMutation(\n $input: CreateTrustCenterAccessInput!\n) {\n createTrustCenterAccess(input: $input) {\n trustCenterAccessEdge {\n cursor\n node {\n id\n email\n name\n active\n hasAcceptedNonDisclosureAgreement\n createdAt\n documentAccesses(first: 100, orderBy: {field: CREATED_AT, direction: DESC}) {\n edges {\n node {\n id\n active\n createdAt\n updatedAt\n document {\n id\n title\n documentType\n }\n report {\n id\n filename\n audit {\n id\n framework {\n name\n id\n }\n }\n }\n trustCenterFile {\n id\n name\n category\n }\n }\n }\n }\n }\n }\n }\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
(node as any).hash = "091432e335b8fe3a97ac06d3765f172b";
|
||||
(node as any).hash = "c09c8a22a45226949a08f2262ddd0b1c";
|
||||
|
||||
export default node;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @generated SignedSource<<bf8e5a74bfd588ad123f628009b6440e>>
|
||||
* @generated SignedSource<<8c2482b7d32c42396e4645bd309e7cc2>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
@@ -350,6 +350,26 @@ return {
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "TrustCenterFile",
|
||||
"kind": "LinkedField",
|
||||
"name": "trustCenterFile",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v3/*: any*/),
|
||||
(v6/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "category",
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
@@ -403,16 +423,16 @@ return {
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "96e9906815501bb22bca79bb63a4a149",
|
||||
"cacheID": "12322ab403d03a821d2228ff68c3d191",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "TrustCenterAccessGraphPaginationQuery",
|
||||
"operationKind": "query",
|
||||
"text": "query TrustCenterAccessGraphPaginationQuery(\n $count: Int\n $cursor: CursorKey\n $id: ID!\n) {\n node(id: $id) {\n __typename\n ...TrustCenterAccessGraph_accesses\n id\n }\n}\n\nfragment TrustCenterAccessGraph_accesses on TrustCenter {\n accesses(first: $count, after: $cursor, orderBy: {field: CREATED_AT, direction: DESC}) {\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n edges {\n cursor\n node {\n id\n email\n name\n active\n hasAcceptedNonDisclosureAgreement\n createdAt\n documentAccesses(first: 100, orderBy: {field: CREATED_AT, direction: DESC}) {\n edges {\n node {\n id\n active\n createdAt\n updatedAt\n document {\n id\n title\n documentType\n }\n report {\n id\n filename\n audit {\n id\n framework {\n name\n id\n }\n }\n }\n }\n }\n }\n __typename\n }\n }\n }\n id\n}\n"
|
||||
"text": "query TrustCenterAccessGraphPaginationQuery(\n $count: Int\n $cursor: CursorKey\n $id: ID!\n) {\n node(id: $id) {\n __typename\n ...TrustCenterAccessGraph_accesses\n id\n }\n}\n\nfragment TrustCenterAccessGraph_accesses on TrustCenter {\n accesses(first: $count, after: $cursor, orderBy: {field: CREATED_AT, direction: DESC}) {\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n edges {\n cursor\n node {\n id\n email\n name\n active\n hasAcceptedNonDisclosureAgreement\n createdAt\n documentAccesses(first: 100, orderBy: {field: CREATED_AT, direction: DESC}) {\n edges {\n node {\n id\n active\n createdAt\n updatedAt\n document {\n id\n title\n documentType\n }\n report {\n id\n filename\n audit {\n id\n framework {\n name\n id\n }\n }\n }\n trustCenterFile {\n id\n name\n category\n }\n }\n }\n }\n __typename\n }\n }\n }\n id\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
(node as any).hash = "9e29aa4a382ca2d4bb9d1b014d8d81fd";
|
||||
(node as any).hash = "9c7f3e866e2593c169b1f98d0e637667";
|
||||
|
||||
export default node;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @generated SignedSource<<4fcca19ac1edb0d607a9682090e0cc3e>>
|
||||
* @generated SignedSource<<e0c9c25c78bb6c8cf63eb9437947a013>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
@@ -365,6 +365,26 @@ return {
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "TrustCenterFile",
|
||||
"kind": "LinkedField",
|
||||
"name": "trustCenterFile",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v4/*: any*/),
|
||||
(v8/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "category",
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
@@ -418,12 +438,12 @@ return {
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "4ca52668a68c0789aa73c0d680ec0abe",
|
||||
"cacheID": "37deb80fc3ff8892d2e68f7588da4e55",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "TrustCenterAccessGraphQuery",
|
||||
"operationKind": "query",
|
||||
"text": "query TrustCenterAccessGraphQuery(\n $trustCenterId: ID!\n $count: Int!\n $cursor: CursorKey\n) {\n node(id: $trustCenterId) {\n __typename\n ... on TrustCenter {\n id\n ...TrustCenterAccessGraph_accesses\n }\n id\n }\n}\n\nfragment TrustCenterAccessGraph_accesses on TrustCenter {\n accesses(first: $count, after: $cursor, orderBy: {field: CREATED_AT, direction: DESC}) {\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n edges {\n cursor\n node {\n id\n email\n name\n active\n hasAcceptedNonDisclosureAgreement\n createdAt\n documentAccesses(first: 100, orderBy: {field: CREATED_AT, direction: DESC}) {\n edges {\n node {\n id\n active\n createdAt\n updatedAt\n document {\n id\n title\n documentType\n }\n report {\n id\n filename\n audit {\n id\n framework {\n name\n id\n }\n }\n }\n }\n }\n }\n __typename\n }\n }\n }\n id\n}\n"
|
||||
"text": "query TrustCenterAccessGraphQuery(\n $trustCenterId: ID!\n $count: Int!\n $cursor: CursorKey\n) {\n node(id: $trustCenterId) {\n __typename\n ... on TrustCenter {\n id\n ...TrustCenterAccessGraph_accesses\n }\n id\n }\n}\n\nfragment TrustCenterAccessGraph_accesses on TrustCenter {\n accesses(first: $count, after: $cursor, orderBy: {field: CREATED_AT, direction: DESC}) {\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n edges {\n cursor\n node {\n id\n email\n name\n active\n hasAcceptedNonDisclosureAgreement\n createdAt\n documentAccesses(first: 100, orderBy: {field: CREATED_AT, direction: DESC}) {\n edges {\n node {\n id\n active\n createdAt\n updatedAt\n document {\n id\n title\n documentType\n }\n report {\n id\n filename\n audit {\n id\n framework {\n name\n id\n }\n }\n }\n trustCenterFile {\n id\n name\n category\n }\n }\n }\n }\n __typename\n }\n }\n }\n id\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @generated SignedSource<<395567ba680d0a9e1bad1cdef52bc2e1>>
|
||||
* @generated SignedSource<<8ecf71138aa0165738506f5e589d3181>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
@@ -16,6 +16,7 @@ export type UpdateTrustCenterAccessInput = {
|
||||
id: string;
|
||||
name?: string | null | undefined;
|
||||
reportIds?: ReadonlyArray<string> | null | undefined;
|
||||
trustCenterFileIds?: ReadonlyArray<string> | null | undefined;
|
||||
};
|
||||
export type TrustCenterAccessGraphUpdateMutation$variables = {
|
||||
input: UpdateTrustCenterAccessInput;
|
||||
@@ -46,6 +47,11 @@ export type TrustCenterAccessGraphUpdateMutation$data = {
|
||||
readonly filename: string;
|
||||
readonly id: string;
|
||||
} | null | undefined;
|
||||
readonly trustCenterFile: {
|
||||
readonly category: string;
|
||||
readonly id: string;
|
||||
readonly name: string;
|
||||
} | null | undefined;
|
||||
readonly updatedAt: any;
|
||||
};
|
||||
}>;
|
||||
@@ -174,6 +180,26 @@ v11 = {
|
||||
"kind": "ScalarField",
|
||||
"name": "filename",
|
||||
"storageKey": null
|
||||
},
|
||||
v12 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "TrustCenterFile",
|
||||
"kind": "LinkedField",
|
||||
"name": "trustCenterFile",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v2/*: any*/),
|
||||
(v4/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "category",
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
};
|
||||
return {
|
||||
"fragment": {
|
||||
@@ -270,7 +296,8 @@ return {
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
},
|
||||
(v12/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
@@ -385,7 +412,8 @@ return {
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
},
|
||||
(v12/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
@@ -404,16 +432,16 @@ return {
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "de3ddd0058b8881667e47e2bf32c8b73",
|
||||
"cacheID": "b66da9236d9f81563608b3aa5f730908",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "TrustCenterAccessGraphUpdateMutation",
|
||||
"operationKind": "mutation",
|
||||
"text": "mutation TrustCenterAccessGraphUpdateMutation(\n $input: UpdateTrustCenterAccessInput!\n) {\n updateTrustCenterAccess(input: $input) {\n trustCenterAccess {\n id\n email\n name\n active\n hasAcceptedNonDisclosureAgreement\n createdAt\n updatedAt\n documentAccesses(first: 100, orderBy: {field: CREATED_AT, direction: DESC}) {\n edges {\n node {\n id\n active\n createdAt\n updatedAt\n document {\n id\n title\n documentType\n }\n report {\n id\n filename\n audit {\n id\n framework {\n name\n id\n }\n }\n }\n }\n }\n }\n }\n }\n}\n"
|
||||
"text": "mutation TrustCenterAccessGraphUpdateMutation(\n $input: UpdateTrustCenterAccessInput!\n) {\n updateTrustCenterAccess(input: $input) {\n trustCenterAccess {\n id\n email\n name\n active\n hasAcceptedNonDisclosureAgreement\n createdAt\n updatedAt\n documentAccesses(first: 100, orderBy: {field: CREATED_AT, direction: DESC}) {\n edges {\n node {\n id\n active\n createdAt\n updatedAt\n document {\n id\n title\n documentType\n }\n report {\n id\n filename\n audit {\n id\n framework {\n name\n id\n }\n }\n }\n trustCenterFile {\n id\n name\n category\n }\n }\n }\n }\n }\n }\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
(node as any).hash = "723058aacc2e04bd2df4cf04c6df0a3c";
|
||||
(node as any).hash = "43e73cc9d80e898f1ba2a92eaf4646f5";
|
||||
|
||||
export default node;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @generated SignedSource<<ef0d644a344dbab40145e3f4128cd0ec>>
|
||||
* @generated SignedSource<<d572a906e6afd89e4a3f1dcffa5c0528>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
@@ -40,6 +40,11 @@ export type TrustCenterAccessGraph_accesses$data = {
|
||||
readonly filename: string;
|
||||
readonly id: string;
|
||||
} | null | undefined;
|
||||
readonly trustCenterFile: {
|
||||
readonly category: string;
|
||||
readonly id: string;
|
||||
readonly name: string;
|
||||
} | null | undefined;
|
||||
readonly updatedAt: any;
|
||||
};
|
||||
}>;
|
||||
@@ -348,6 +353,26 @@ return {
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "TrustCenterFile",
|
||||
"kind": "LinkedField",
|
||||
"name": "trustCenterFile",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v2/*: any*/),
|
||||
(v3/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "category",
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
@@ -393,6 +418,6 @@ return {
|
||||
};
|
||||
})();
|
||||
|
||||
(node as any).hash = "9e29aa4a382ca2d4bb9d1b014d8d81fd";
|
||||
(node as any).hash = "9c7f3e866e2593c169b1f98d0e637667";
|
||||
|
||||
export default node;
|
||||
|
||||
211
apps/console/src/hooks/graph/__generated__/TrustCenterFileGraphCreateMutation.graphql.ts
generated
Normal file
211
apps/console/src/hooks/graph/__generated__/TrustCenterFileGraphCreateMutation.graphql.ts
generated
Normal file
@@ -0,0 +1,211 @@
|
||||
/**
|
||||
* @generated SignedSource<<e70731a64db78c30ad662330d2ec2099>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @ts-nocheck
|
||||
|
||||
import { ConcreteRequest } from 'relay-runtime';
|
||||
export type TrustCenterVisibility = "NONE" | "PRIVATE" | "PUBLIC";
|
||||
export type CreateTrustCenterFileInput = {
|
||||
category: string;
|
||||
file: any;
|
||||
name: string;
|
||||
organizationId: string;
|
||||
trustCenterVisibility: TrustCenterVisibility;
|
||||
};
|
||||
export type TrustCenterFileGraphCreateMutation$variables = {
|
||||
connections: ReadonlyArray<string>;
|
||||
input: CreateTrustCenterFileInput;
|
||||
};
|
||||
export type TrustCenterFileGraphCreateMutation$data = {
|
||||
readonly createTrustCenterFile: {
|
||||
readonly trustCenterFileEdge: {
|
||||
readonly node: {
|
||||
readonly category: string;
|
||||
readonly createdAt: any;
|
||||
readonly fileUrl: string;
|
||||
readonly id: string;
|
||||
readonly name: string;
|
||||
readonly trustCenterVisibility: TrustCenterVisibility;
|
||||
readonly updatedAt: any;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
export type TrustCenterFileGraphCreateMutation = {
|
||||
response: TrustCenterFileGraphCreateMutation$data;
|
||||
variables: TrustCenterFileGraphCreateMutation$variables;
|
||||
};
|
||||
|
||||
const node: ConcreteRequest = (function(){
|
||||
var v0 = {
|
||||
"defaultValue": null,
|
||||
"kind": "LocalArgument",
|
||||
"name": "connections"
|
||||
},
|
||||
v1 = {
|
||||
"defaultValue": null,
|
||||
"kind": "LocalArgument",
|
||||
"name": "input"
|
||||
},
|
||||
v2 = [
|
||||
{
|
||||
"kind": "Variable",
|
||||
"name": "input",
|
||||
"variableName": "input"
|
||||
}
|
||||
],
|
||||
v3 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "TrustCenterFileEdge",
|
||||
"kind": "LinkedField",
|
||||
"name": "trustCenterFileEdge",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "TrustCenterFile",
|
||||
"kind": "LinkedField",
|
||||
"name": "node",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "id",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "name",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "category",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "fileUrl",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "trustCenterVisibility",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "createdAt",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "updatedAt",
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
};
|
||||
return {
|
||||
"fragment": {
|
||||
"argumentDefinitions": [
|
||||
(v0/*: any*/),
|
||||
(v1/*: any*/)
|
||||
],
|
||||
"kind": "Fragment",
|
||||
"metadata": null,
|
||||
"name": "TrustCenterFileGraphCreateMutation",
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": (v2/*: any*/),
|
||||
"concreteType": "CreateTrustCenterFilePayload",
|
||||
"kind": "LinkedField",
|
||||
"name": "createTrustCenterFile",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v3/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"type": "Mutation",
|
||||
"abstractKey": null
|
||||
},
|
||||
"kind": "Request",
|
||||
"operation": {
|
||||
"argumentDefinitions": [
|
||||
(v1/*: any*/),
|
||||
(v0/*: any*/)
|
||||
],
|
||||
"kind": "Operation",
|
||||
"name": "TrustCenterFileGraphCreateMutation",
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": (v2/*: any*/),
|
||||
"concreteType": "CreateTrustCenterFilePayload",
|
||||
"kind": "LinkedField",
|
||||
"name": "createTrustCenterFile",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v3/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"filters": null,
|
||||
"handle": "prependEdge",
|
||||
"key": "",
|
||||
"kind": "LinkedHandle",
|
||||
"name": "trustCenterFileEdge",
|
||||
"handleArgs": [
|
||||
{
|
||||
"kind": "Variable",
|
||||
"name": "connections",
|
||||
"variableName": "connections"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "57c42327b83556d36745cf8218eb01b1",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "TrustCenterFileGraphCreateMutation",
|
||||
"operationKind": "mutation",
|
||||
"text": "mutation TrustCenterFileGraphCreateMutation(\n $input: CreateTrustCenterFileInput!\n) {\n createTrustCenterFile(input: $input) {\n trustCenterFileEdge {\n node {\n id\n name\n category\n fileUrl\n trustCenterVisibility\n createdAt\n updatedAt\n }\n }\n }\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
(node as any).hash = "fa3851bf4f5e38bc26d8a063d6afab4e";
|
||||
|
||||
export default node;
|
||||
132
apps/console/src/hooks/graph/__generated__/TrustCenterFileGraphDeleteMutation.graphql.ts
generated
Normal file
132
apps/console/src/hooks/graph/__generated__/TrustCenterFileGraphDeleteMutation.graphql.ts
generated
Normal file
@@ -0,0 +1,132 @@
|
||||
/**
|
||||
* @generated SignedSource<<f788919caaf846a6a1bdc81f19841823>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @ts-nocheck
|
||||
|
||||
import { ConcreteRequest } from 'relay-runtime';
|
||||
export type DeleteTrustCenterFileInput = {
|
||||
id: string;
|
||||
};
|
||||
export type TrustCenterFileGraphDeleteMutation$variables = {
|
||||
connections: ReadonlyArray<string>;
|
||||
input: DeleteTrustCenterFileInput;
|
||||
};
|
||||
export type TrustCenterFileGraphDeleteMutation$data = {
|
||||
readonly deleteTrustCenterFile: {
|
||||
readonly deletedTrustCenterFileId: string;
|
||||
};
|
||||
};
|
||||
export type TrustCenterFileGraphDeleteMutation = {
|
||||
response: TrustCenterFileGraphDeleteMutation$data;
|
||||
variables: TrustCenterFileGraphDeleteMutation$variables;
|
||||
};
|
||||
|
||||
const node: ConcreteRequest = (function(){
|
||||
var v0 = {
|
||||
"defaultValue": null,
|
||||
"kind": "LocalArgument",
|
||||
"name": "connections"
|
||||
},
|
||||
v1 = {
|
||||
"defaultValue": null,
|
||||
"kind": "LocalArgument",
|
||||
"name": "input"
|
||||
},
|
||||
v2 = [
|
||||
{
|
||||
"kind": "Variable",
|
||||
"name": "input",
|
||||
"variableName": "input"
|
||||
}
|
||||
],
|
||||
v3 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "deletedTrustCenterFileId",
|
||||
"storageKey": null
|
||||
};
|
||||
return {
|
||||
"fragment": {
|
||||
"argumentDefinitions": [
|
||||
(v0/*: any*/),
|
||||
(v1/*: any*/)
|
||||
],
|
||||
"kind": "Fragment",
|
||||
"metadata": null,
|
||||
"name": "TrustCenterFileGraphDeleteMutation",
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": (v2/*: any*/),
|
||||
"concreteType": "DeleteTrustCenterFilePayload",
|
||||
"kind": "LinkedField",
|
||||
"name": "deleteTrustCenterFile",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v3/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"type": "Mutation",
|
||||
"abstractKey": null
|
||||
},
|
||||
"kind": "Request",
|
||||
"operation": {
|
||||
"argumentDefinitions": [
|
||||
(v1/*: any*/),
|
||||
(v0/*: any*/)
|
||||
],
|
||||
"kind": "Operation",
|
||||
"name": "TrustCenterFileGraphDeleteMutation",
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": (v2/*: any*/),
|
||||
"concreteType": "DeleteTrustCenterFilePayload",
|
||||
"kind": "LinkedField",
|
||||
"name": "deleteTrustCenterFile",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v3/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"filters": null,
|
||||
"handle": "deleteEdge",
|
||||
"key": "",
|
||||
"kind": "ScalarHandle",
|
||||
"name": "deletedTrustCenterFileId",
|
||||
"handleArgs": [
|
||||
{
|
||||
"kind": "Variable",
|
||||
"name": "connections",
|
||||
"variableName": "connections"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "ad78a064da9b58291653f8283012ffc6",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "TrustCenterFileGraphDeleteMutation",
|
||||
"operationKind": "mutation",
|
||||
"text": "mutation TrustCenterFileGraphDeleteMutation(\n $input: DeleteTrustCenterFileInput!\n) {\n deleteTrustCenterFile(input: $input) {\n deletedTrustCenterFileId\n }\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
(node as any).hash = "26c1ce69e74f3a4a39d060b38afbe3e0";
|
||||
|
||||
export default node;
|
||||
141
apps/console/src/hooks/graph/__generated__/TrustCenterFileGraphUpdateMutation.graphql.ts
generated
Normal file
141
apps/console/src/hooks/graph/__generated__/TrustCenterFileGraphUpdateMutation.graphql.ts
generated
Normal file
@@ -0,0 +1,141 @@
|
||||
/**
|
||||
* @generated SignedSource<<b78cfbea93f3bccdba56cd29900ab724>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @ts-nocheck
|
||||
|
||||
import { ConcreteRequest } from 'relay-runtime';
|
||||
export type TrustCenterVisibility = "NONE" | "PRIVATE" | "PUBLIC";
|
||||
export type UpdateTrustCenterFileInput = {
|
||||
category?: string | null | undefined;
|
||||
id: string;
|
||||
name?: string | null | undefined;
|
||||
trustCenterVisibility?: TrustCenterVisibility | null | undefined;
|
||||
};
|
||||
export type TrustCenterFileGraphUpdateMutation$variables = {
|
||||
input: UpdateTrustCenterFileInput;
|
||||
};
|
||||
export type TrustCenterFileGraphUpdateMutation$data = {
|
||||
readonly updateTrustCenterFile: {
|
||||
readonly trustCenterFile: {
|
||||
readonly category: string;
|
||||
readonly id: string;
|
||||
readonly name: string;
|
||||
readonly trustCenterVisibility: TrustCenterVisibility;
|
||||
readonly updatedAt: any;
|
||||
};
|
||||
};
|
||||
};
|
||||
export type TrustCenterFileGraphUpdateMutation = {
|
||||
response: TrustCenterFileGraphUpdateMutation$data;
|
||||
variables: TrustCenterFileGraphUpdateMutation$variables;
|
||||
};
|
||||
|
||||
const node: ConcreteRequest = (function(){
|
||||
var v0 = [
|
||||
{
|
||||
"defaultValue": null,
|
||||
"kind": "LocalArgument",
|
||||
"name": "input"
|
||||
}
|
||||
],
|
||||
v1 = [
|
||||
{
|
||||
"alias": null,
|
||||
"args": [
|
||||
{
|
||||
"kind": "Variable",
|
||||
"name": "input",
|
||||
"variableName": "input"
|
||||
}
|
||||
],
|
||||
"concreteType": "UpdateTrustCenterFilePayload",
|
||||
"kind": "LinkedField",
|
||||
"name": "updateTrustCenterFile",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "TrustCenterFile",
|
||||
"kind": "LinkedField",
|
||||
"name": "trustCenterFile",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "id",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "name",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "category",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "trustCenterVisibility",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "updatedAt",
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
];
|
||||
return {
|
||||
"fragment": {
|
||||
"argumentDefinitions": (v0/*: any*/),
|
||||
"kind": "Fragment",
|
||||
"metadata": null,
|
||||
"name": "TrustCenterFileGraphUpdateMutation",
|
||||
"selections": (v1/*: any*/),
|
||||
"type": "Mutation",
|
||||
"abstractKey": null
|
||||
},
|
||||
"kind": "Request",
|
||||
"operation": {
|
||||
"argumentDefinitions": (v0/*: any*/),
|
||||
"kind": "Operation",
|
||||
"name": "TrustCenterFileGraphUpdateMutation",
|
||||
"selections": (v1/*: any*/)
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "9ad761d91cfe34e7fa905a3f6a4d9e37",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "TrustCenterFileGraphUpdateMutation",
|
||||
"operationKind": "mutation",
|
||||
"text": "mutation TrustCenterFileGraphUpdateMutation(\n $input: UpdateTrustCenterFileInput!\n) {\n updateTrustCenterFile(input: $input) {\n trustCenterFile {\n id\n name\n category\n trustCenterVisibility\n updatedAt\n }\n }\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
(node as any).hash = "7306c3f9530a7636adc0b6a0cf28b67e";
|
||||
|
||||
export default node;
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @generated SignedSource<<6d55d37aa2ddfae16f8fc829840113d4>>
|
||||
* @generated SignedSource<<285497dfb150c3f02c055a091769f301>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
@@ -69,6 +69,15 @@ export type TrustCenterGraphQuery$data = {
|
||||
};
|
||||
readonly updatedAt: any;
|
||||
} | null | undefined;
|
||||
readonly trustCenterFiles?: {
|
||||
readonly __id: string;
|
||||
readonly edges: ReadonlyArray<{
|
||||
readonly node: {
|
||||
readonly id: string;
|
||||
readonly " $fragmentSpreads": FragmentRefs<"TrustCenterFilesCardFragment">;
|
||||
};
|
||||
}>;
|
||||
};
|
||||
readonly vendors?: {
|
||||
readonly edges: ReadonlyArray<{
|
||||
readonly node: {
|
||||
@@ -259,6 +268,57 @@ v10 = [
|
||||
(v7/*: any*/)
|
||||
],
|
||||
v11 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "__typename",
|
||||
"storageKey": null
|
||||
},
|
||||
v12 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "cursor",
|
||||
"storageKey": null
|
||||
},
|
||||
v13 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "PageInfo",
|
||||
"kind": "LinkedField",
|
||||
"name": "pageInfo",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "endCursor",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "hasNextPage",
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
},
|
||||
v14 = {
|
||||
"kind": "ClientExtension",
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "__id",
|
||||
"storageKey": null
|
||||
}
|
||||
]
|
||||
},
|
||||
v15 = {
|
||||
"alias": null,
|
||||
"args": (v10/*: any*/),
|
||||
"concreteType": "SlackConnectionConnection",
|
||||
@@ -308,12 +368,19 @@ v11 = {
|
||||
],
|
||||
"storageKey": "slackConnections(first:100)"
|
||||
},
|
||||
v12 = {
|
||||
v16 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "trustCenterVisibility",
|
||||
"storageKey": null
|
||||
},
|
||||
v17 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "category",
|
||||
"storageKey": null
|
||||
};
|
||||
return {
|
||||
"fragment": {
|
||||
@@ -454,7 +521,50 @@ return {
|
||||
],
|
||||
"storageKey": "vendors(first:100)"
|
||||
},
|
||||
(v11/*: any*/)
|
||||
{
|
||||
"alias": "trustCenterFiles",
|
||||
"args": null,
|
||||
"concreteType": "TrustCenterFileConnection",
|
||||
"kind": "LinkedField",
|
||||
"name": "__TrustCenterPage_trustCenterFiles_connection",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "TrustCenterFileEdge",
|
||||
"kind": "LinkedField",
|
||||
"name": "edges",
|
||||
"plural": true,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "TrustCenterFile",
|
||||
"kind": "LinkedField",
|
||||
"name": "node",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v2/*: any*/),
|
||||
{
|
||||
"args": null,
|
||||
"kind": "FragmentSpread",
|
||||
"name": "TrustCenterFilesCardFragment"
|
||||
},
|
||||
(v11/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
},
|
||||
(v12/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
},
|
||||
(v13/*: any*/),
|
||||
(v14/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
},
|
||||
(v15/*: any*/)
|
||||
],
|
||||
"type": "Organization",
|
||||
"abstractKey": null
|
||||
@@ -480,13 +590,7 @@ return {
|
||||
"name": "node",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "__typename",
|
||||
"storageKey": null
|
||||
},
|
||||
(v11/*: any*/),
|
||||
(v2/*: any*/),
|
||||
{
|
||||
"kind": "InlineFragment",
|
||||
@@ -534,7 +638,7 @@ return {
|
||||
"name": "documentType",
|
||||
"storageKey": null
|
||||
},
|
||||
(v12/*: any*/),
|
||||
(v16/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": [
|
||||
@@ -651,7 +755,7 @@ return {
|
||||
"name": "state",
|
||||
"storageKey": null
|
||||
},
|
||||
(v12/*: any*/),
|
||||
(v16/*: any*/),
|
||||
(v5/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
@@ -688,13 +792,7 @@ return {
|
||||
"selections": [
|
||||
(v2/*: any*/),
|
||||
(v3/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "category",
|
||||
"storageKey": null
|
||||
},
|
||||
(v17/*: any*/),
|
||||
(v8/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
@@ -713,7 +811,66 @@ return {
|
||||
],
|
||||
"storageKey": "vendors(first:100)"
|
||||
},
|
||||
(v11/*: any*/)
|
||||
{
|
||||
"alias": null,
|
||||
"args": (v10/*: any*/),
|
||||
"concreteType": "TrustCenterFileConnection",
|
||||
"kind": "LinkedField",
|
||||
"name": "trustCenterFiles",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "TrustCenterFileEdge",
|
||||
"kind": "LinkedField",
|
||||
"name": "edges",
|
||||
"plural": true,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "TrustCenterFile",
|
||||
"kind": "LinkedField",
|
||||
"name": "node",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v2/*: any*/),
|
||||
(v3/*: any*/),
|
||||
(v17/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "fileUrl",
|
||||
"storageKey": null
|
||||
},
|
||||
(v16/*: any*/),
|
||||
(v5/*: any*/),
|
||||
(v6/*: any*/),
|
||||
(v11/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
},
|
||||
(v12/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
},
|
||||
(v13/*: any*/),
|
||||
(v14/*: any*/)
|
||||
],
|
||||
"storageKey": "trustCenterFiles(first:100)"
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": (v10/*: any*/),
|
||||
"filters": null,
|
||||
"handle": "connection",
|
||||
"key": "TrustCenterPage_trustCenterFiles",
|
||||
"kind": "LinkedHandle",
|
||||
"name": "trustCenterFiles"
|
||||
},
|
||||
(v15/*: any*/)
|
||||
],
|
||||
"type": "Organization",
|
||||
"abstractKey": null
|
||||
@@ -724,16 +881,28 @@ return {
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "06cd2015e9fc2e65d35ae3153e587c58",
|
||||
"cacheID": "45a68d6b8fc3128a695529daa40eba3a",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"metadata": {
|
||||
"connection": [
|
||||
{
|
||||
"count": null,
|
||||
"cursor": null,
|
||||
"direction": "forward",
|
||||
"path": [
|
||||
"organization",
|
||||
"trustCenterFiles"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"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 customDomain {\n id\n domain\n }\n trustCenter {\n id\n active\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 slackConnections(first: 100) {\n edges {\n node {\n id\n channel\n channelId\n createdAt\n updatedAt\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"
|
||||
"text": "query TrustCenterGraphQuery(\n $organizationId: ID!\n) {\n organization: node(id: $organizationId) {\n __typename\n ... on Organization {\n id\n name\n customDomain {\n id\n domain\n }\n trustCenter {\n id\n active\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 trustCenterFiles(first: 100) {\n edges {\n node {\n id\n ...TrustCenterFilesCardFragment\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n }\n }\n slackConnections(first: 100) {\n edges {\n node {\n id\n channel\n channelId\n createdAt\n updatedAt\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 TrustCenterFilesCardFragment on TrustCenterFile {\n id\n name\n category\n fileUrl\n trustCenterVisibility\n createdAt\n updatedAt\n}\n\nfragment TrustCenterVendorsCardFragment on Vendor {\n id\n name\n category\n description\n showOnTrustCenter\n createdAt\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
(node as any).hash = "7ef9a5adc70dff604a149ea156e52edc";
|
||||
(node as any).hash = "1ee50612da47b187cb55b2e228ba5945";
|
||||
|
||||
export default node;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import {
|
||||
Badge,
|
||||
Button,
|
||||
Card,
|
||||
Checkbox,
|
||||
@@ -31,6 +32,7 @@ import {
|
||||
updateTrustCenterAccessMutation,
|
||||
deleteTrustCenterAccessMutation
|
||||
} from "/hooks/graph/TrustCenterAccessGraph";
|
||||
import type { TrustCenterAccessGraph_accesses$data } from "/hooks/graph/__generated__/TrustCenterAccessGraph_accesses.graphql";
|
||||
import { useFormWithSchema } from "/hooks/useFormWithSchema";
|
||||
import { useMutationWithToasts } from "/hooks/useMutationWithToasts";
|
||||
|
||||
@@ -76,6 +78,10 @@ export default function TrustCenterAccessTab() {
|
||||
const [selectedDocumentAccesses, setSelectedDocumentAccesses] = useState<Set<string>>(new Set());
|
||||
const [pendingEditEmail, setPendingEditEmail] = useState<string | null>(null);
|
||||
|
||||
const formattedDocumentAccesses = editingAccess?.documentAccesses
|
||||
?.map((docAccess) => getDocumentAccessInfo(docAccess, __))
|
||||
?.filter((info) => info !== null) ?? [];
|
||||
|
||||
const inviteForm = useFormWithSchema(inviteSchema, {
|
||||
defaultValues: { name: "", email: "" },
|
||||
});
|
||||
@@ -102,8 +108,48 @@ export default function TrustCenterAccessTab() {
|
||||
};
|
||||
};
|
||||
} | null;
|
||||
trustCenterFile?: {
|
||||
id: string;
|
||||
name: string;
|
||||
category: string;
|
||||
} | null;
|
||||
};
|
||||
|
||||
function getDocumentAccessInfo(
|
||||
docAccess: DocumentAccessType,
|
||||
__: (key: string) => string
|
||||
) {
|
||||
if (!!docAccess.document) {
|
||||
return {
|
||||
variant: "info" as const,
|
||||
name: docAccess.document?.title,
|
||||
type: __("Document"),
|
||||
category: docAccess.document?.documentType,
|
||||
id: docAccess.document?.id,
|
||||
};
|
||||
}
|
||||
if (!!docAccess.report) {
|
||||
return {
|
||||
variant: "success" as const,
|
||||
name: docAccess.report?.filename,
|
||||
type: __("Report"),
|
||||
category: docAccess.report?.audit?.framework?.name,
|
||||
id: docAccess.report?.id,
|
||||
};
|
||||
}
|
||||
if (!!docAccess.trustCenterFile) {
|
||||
return {
|
||||
variant: "highlight" as const,
|
||||
name: docAccess.trustCenterFile?.name,
|
||||
type: __("File"),
|
||||
category: docAccess.trustCenterFile?.category,
|
||||
id: docAccess.trustCenterFile?.id,
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
type AccessType = {
|
||||
id: string;
|
||||
email: string;
|
||||
@@ -116,18 +162,22 @@ export default function TrustCenterAccessTab() {
|
||||
|
||||
const { data: trustCenterData, loadMore, hasNext, isLoadingNext } = useTrustCenterAccesses(organization.trustCenter?.id || "");
|
||||
|
||||
const accesses: AccessType[] = trustCenterData?.node?.accesses?.edges?.map((edge: any) => ({
|
||||
type AccessEdge = NonNullable<NonNullable<TrustCenterAccessGraph_accesses$data['accesses']>['edges']>[number];
|
||||
type DocumentAccessEdge = NonNullable<NonNullable<NonNullable<AccessEdge>['node']['documentAccesses']>['edges']>[number];
|
||||
|
||||
const accesses: AccessType[] = trustCenterData?.node?.accesses?.edges?.map((edge: AccessEdge) => ({
|
||||
id: edge.node.id,
|
||||
email: edge.node.email,
|
||||
name: edge.node.name,
|
||||
active: edge.node.active,
|
||||
hasAcceptedNonDisclosureAgreement: edge.node.hasAcceptedNonDisclosureAgreement,
|
||||
createdAt: edge.node.createdAt,
|
||||
documentAccesses: edge.node.documentAccesses?.edges?.map((docEdge: any) => ({
|
||||
documentAccesses: edge.node.documentAccesses?.edges?.map((docEdge: DocumentAccessEdge) => ({
|
||||
id: docEdge.node.id,
|
||||
active: docEdge.node.active,
|
||||
document: docEdge.node.document,
|
||||
report: docEdge.node.report
|
||||
report: docEdge.node.report,
|
||||
trustCenterFile: docEdge.node.trustCenterFile
|
||||
})) ?? []
|
||||
})) ?? [];
|
||||
|
||||
@@ -173,7 +223,7 @@ export default function TrustCenterAccessTab() {
|
||||
const getActiveDocumentIds = useCallback((access: AccessType) => {
|
||||
return access.documentAccesses
|
||||
.filter(docAccess => docAccess.active)
|
||||
.map(docAccess => docAccess.document?.id || docAccess.report?.id)
|
||||
.map(docAccess => docAccess.document?.id || docAccess.report?.id || docAccess.trustCenterFile?.id)
|
||||
.filter((id): id is string => id !== undefined);
|
||||
}, []);
|
||||
|
||||
@@ -212,19 +262,21 @@ export default function TrustCenterAccessTab() {
|
||||
const handleUpdateName = editForm.handleSubmit(async (data) => {
|
||||
if (!editingAccess) return;
|
||||
|
||||
const { documentIds, reportIds } = editingAccess.documentAccesses.reduce(
|
||||
const { documentIds, reportIds, trustCenterFileIds } = editingAccess.documentAccesses.reduce(
|
||||
(acc, docAccess) => {
|
||||
const id = docAccess.document?.id || docAccess.report?.id;
|
||||
const id = docAccess.document?.id || docAccess.report?.id || docAccess.trustCenterFile?.id;
|
||||
if (id && selectedDocumentAccesses.has(id)) {
|
||||
if (docAccess.document?.id) {
|
||||
acc.documentIds.push(docAccess.document.id);
|
||||
} else if (docAccess.report?.id) {
|
||||
acc.reportIds.push(docAccess.report.id);
|
||||
} else if (docAccess.trustCenterFile?.id) {
|
||||
acc.trustCenterFileIds.push(docAccess.trustCenterFile.id);
|
||||
}
|
||||
}
|
||||
return acc;
|
||||
},
|
||||
{ documentIds: [] as string[], reportIds: [] as string[] }
|
||||
{ documentIds: [] as string[], reportIds: [] as string[], trustCenterFileIds: [] as string[] }
|
||||
);
|
||||
|
||||
await updateInvitation({
|
||||
@@ -235,6 +287,7 @@ export default function TrustCenterAccessTab() {
|
||||
active: data.active,
|
||||
documentIds,
|
||||
reportIds,
|
||||
trustCenterFileIds,
|
||||
},
|
||||
},
|
||||
onSuccess: () => {
|
||||
@@ -431,7 +484,7 @@ export default function TrustCenterAccessTab() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{editingAccess && editingAccess.documentAccesses.length > 0 && (
|
||||
{formattedDocumentAccesses.length > 0 && (
|
||||
<div>
|
||||
<h4 className="font-medium text-txt-primary mb-4">
|
||||
{__("Document Access Permissions")}
|
||||
@@ -451,39 +504,20 @@ export default function TrustCenterAccessTab() {
|
||||
</Tr>
|
||||
</Thead>
|
||||
<Tbody>
|
||||
{editingAccess.documentAccesses.map((docAccess) => {
|
||||
const getDocumentInfo = () => {
|
||||
const isDocument = !!docAccess.document;
|
||||
return {
|
||||
isDocument,
|
||||
name: docAccess.document?.title || docAccess.report?.filename || __("Unknown Item"),
|
||||
type: isDocument ? __("Document") : __("Report"),
|
||||
category: isDocument
|
||||
? docAccess.document?.documentType
|
||||
: docAccess.report?.audit?.framework?.name || __("Compliance Report"),
|
||||
id: docAccess.document?.id || docAccess.report?.id || ''
|
||||
};
|
||||
};
|
||||
|
||||
const { isDocument, name, type, category, id } = getDocumentInfo();
|
||||
{formattedDocumentAccesses.map((info) => {
|
||||
const { variant, name, type, category, id } = info;
|
||||
|
||||
return (
|
||||
<Tr key={docAccess.id}>
|
||||
<Tr key={id}>
|
||||
<Td>
|
||||
<div className="font-medium text-txt-primary">
|
||||
{name}
|
||||
</div>
|
||||
</Td>
|
||||
<Td>
|
||||
<div className="flex items-center space-x-2">
|
||||
<div className={`inline-flex items-center px-2 py-1 rounded-full text-xs font-medium ${
|
||||
isDocument
|
||||
? 'bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200'
|
||||
: 'bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200'
|
||||
}`}>
|
||||
{type}
|
||||
</div>
|
||||
</div>
|
||||
<Badge variant={variant}>
|
||||
{type}
|
||||
</Badge>
|
||||
</Td>
|
||||
<Td>
|
||||
<div className="text-txt-secondary">
|
||||
|
||||
@@ -0,0 +1,331 @@
|
||||
import {
|
||||
Button,
|
||||
Card,
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogFooter,
|
||||
Field,
|
||||
Spinner,
|
||||
useDialogRef,
|
||||
Dropzone,
|
||||
Option,
|
||||
Badge,
|
||||
} from "@probo/ui";
|
||||
import { useTranslate } from "@probo/i18n";
|
||||
import { useOutletContext } from "react-router";
|
||||
import { useState, useCallback } from "react";
|
||||
import z from "zod";
|
||||
import { getTrustCenterVisibilityOptions } from "@probo/helpers";
|
||||
import {
|
||||
useCreateTrustCenterFileMutation,
|
||||
useUpdateTrustCenterFileMutation,
|
||||
useDeleteTrustCenterFileMutation,
|
||||
} from "/hooks/graph/TrustCenterFileGraph";
|
||||
import { useFormWithSchema } from "/hooks/useFormWithSchema";
|
||||
import { TrustCenterFilesCard } from "/components/trustCenter/TrustCenterFilesCard";
|
||||
import type { TrustCenterFilesCardFragment$key } from "/components/trustCenter/__generated__/TrustCenterFilesCardFragment.graphql";
|
||||
|
||||
type ContextType = {
|
||||
organization: {
|
||||
id: string;
|
||||
trustCenterFiles?: {
|
||||
__id?: string;
|
||||
edges: Array<{
|
||||
node: TrustCenterFilesCardFragment$key;
|
||||
}>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
export default function TrustCenterFilesTab() {
|
||||
const { __ } = useTranslate();
|
||||
const { organization } = useOutletContext<ContextType>();
|
||||
|
||||
const createSchema = z.object({
|
||||
name: z.string().min(1, __("Name is required")),
|
||||
category: z.string().min(1, __("Category is required")),
|
||||
trustCenterVisibility: z.enum(["NONE", "PRIVATE", "PUBLIC"]),
|
||||
});
|
||||
|
||||
const editSchema = z.object({
|
||||
name: z.string().min(1, __("Name is required")),
|
||||
category: z.string().min(1, __("Category is required")),
|
||||
});
|
||||
|
||||
const [createFile, isCreating] = useCreateTrustCenterFileMutation();
|
||||
const [updateFile, isUpdating] = useUpdateTrustCenterFileMutation();
|
||||
const [deleteFile, isDeleting] = useDeleteTrustCenterFileMutation();
|
||||
|
||||
const createDialogRef = useDialogRef();
|
||||
const editDialogRef = useDialogRef();
|
||||
const deleteDialogRef = useDialogRef();
|
||||
|
||||
const [editingFile, setEditingFile] = useState<{ id: string; name: string; category: string } | null>(null);
|
||||
const [deletingFileId, setDeletingFileId] = useState<string | null>(null);
|
||||
const [uploadedFile, setUploadedFile] = useState<File | null>(null);
|
||||
const [isUploading, setIsUploading] = useState(false);
|
||||
|
||||
const createForm = useFormWithSchema(createSchema, {
|
||||
defaultValues: { name: "", category: "", trustCenterVisibility: "NONE" },
|
||||
});
|
||||
|
||||
const editForm = useFormWithSchema(editSchema, {
|
||||
defaultValues: { name: "", category: "" },
|
||||
});
|
||||
|
||||
const files = organization.trustCenterFiles?.edges?.map((edge) => edge.node) || [];
|
||||
|
||||
const handleFileUpload = useCallback((acceptedFiles: File[]) => {
|
||||
if (acceptedFiles.length > 0) {
|
||||
const file = acceptedFiles[0];
|
||||
|
||||
if (file.type !== "application/pdf") {
|
||||
createForm.setError("root", {
|
||||
type: "manual",
|
||||
message: __("Only PDF files are allowed"),
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
setUploadedFile(file);
|
||||
createForm.clearErrors("root");
|
||||
if (!createForm.getValues().name) {
|
||||
createForm.setValue("name", file.name.replace(/\.[^/.]+$/, ""));
|
||||
}
|
||||
}
|
||||
}, [createForm, __]);
|
||||
|
||||
const handleCreate = createForm.handleSubmit(async (data) => {
|
||||
if (!uploadedFile) {
|
||||
return;
|
||||
}
|
||||
|
||||
setIsUploading(true);
|
||||
|
||||
const connectionId = organization.trustCenterFiles?.__id;
|
||||
|
||||
try {
|
||||
await createFile({
|
||||
variables: {
|
||||
input: {
|
||||
organizationId: organization.id,
|
||||
name: data.name,
|
||||
category: data.category,
|
||||
trustCenterVisibility: data.trustCenterVisibility,
|
||||
file: null,
|
||||
},
|
||||
connections: connectionId ? [connectionId] : [],
|
||||
},
|
||||
uploadables: {
|
||||
"input.file": uploadedFile,
|
||||
},
|
||||
onSuccess: () => {
|
||||
createDialogRef.current?.close();
|
||||
createForm.reset();
|
||||
setUploadedFile(null);
|
||||
},
|
||||
});
|
||||
} finally {
|
||||
setIsUploading(false);
|
||||
}
|
||||
});
|
||||
|
||||
const handleEdit = useCallback((file: { id: string; name: string; category: string }) => {
|
||||
setEditingFile(file);
|
||||
editForm.reset({ name: file.name, category: file.category });
|
||||
editDialogRef.current?.open();
|
||||
}, [editDialogRef, editForm]);
|
||||
|
||||
const handleUpdate = editForm.handleSubmit(async (data) => {
|
||||
if (!editingFile) {
|
||||
return;
|
||||
}
|
||||
|
||||
await updateFile({
|
||||
variables: {
|
||||
input: {
|
||||
id: editingFile.id,
|
||||
name: data.name,
|
||||
category: data.category,
|
||||
},
|
||||
},
|
||||
onSuccess: () => {
|
||||
editDialogRef.current?.close();
|
||||
setEditingFile(null);
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
const handleDeleteClick = useCallback((id: string) => {
|
||||
setDeletingFileId(id);
|
||||
deleteDialogRef.current?.open();
|
||||
}, [deleteDialogRef]);
|
||||
|
||||
const handleDeleteConfirm = useCallback(async () => {
|
||||
if (!deletingFileId) {
|
||||
return;
|
||||
}
|
||||
|
||||
const connectionId = organization.trustCenterFiles?.__id;
|
||||
|
||||
await deleteFile({
|
||||
variables: {
|
||||
input: { id: deletingFileId },
|
||||
connections: connectionId ? [connectionId] : [],
|
||||
},
|
||||
onSuccess: () => {
|
||||
deleteDialogRef.current?.close();
|
||||
setDeletingFileId(null);
|
||||
},
|
||||
});
|
||||
}, [deletingFileId, deleteFile, deleteDialogRef, organization.trustCenterFiles?.__id]);
|
||||
|
||||
const handleChangeVisibility = useCallback((params: {
|
||||
variables: {
|
||||
input: {
|
||||
id: string;
|
||||
trustCenterVisibility: "NONE" | "PRIVATE" | "PUBLIC";
|
||||
};
|
||||
};
|
||||
}) => {
|
||||
updateFile(params);
|
||||
}, [updateFile]);
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<h3 className="text-base font-medium">{__("Files")}</h3>
|
||||
<p className="text-sm text-txt-tertiary">
|
||||
{__("Upload and manage files for your trust center")}
|
||||
</p>
|
||||
</div>
|
||||
<Button onClick={() => createDialogRef.current?.open()}>
|
||||
{__("Add File")}
|
||||
</Button>
|
||||
</div>
|
||||
{(isUpdating || isDeleting) && (
|
||||
<div className="flex items-center justify-center">
|
||||
<Spinner />
|
||||
</div>
|
||||
)}
|
||||
<Card padded>
|
||||
<TrustCenterFilesCard
|
||||
files={files}
|
||||
params={{}}
|
||||
disabled={isUpdating || isDeleting}
|
||||
onChangeVisibility={handleChangeVisibility}
|
||||
onEdit={handleEdit}
|
||||
onDelete={handleDeleteClick}
|
||||
variant="table"
|
||||
/>
|
||||
</Card>
|
||||
|
||||
<Dialog ref={createDialogRef} title={__("Add File")}>
|
||||
<form onSubmit={handleCreate}>
|
||||
<DialogContent padded className="space-y-4">
|
||||
<Dropzone
|
||||
description={__("Upload PDF file (max 10MB)")}
|
||||
isUploading={isUploading}
|
||||
onDrop={handleFileUpload}
|
||||
maxSize={10}
|
||||
accept={{ "application/pdf": [".pdf"] }}
|
||||
/>
|
||||
{uploadedFile && (
|
||||
<div className="text-sm text-txt-secondary">
|
||||
{__("Selected file")}: {uploadedFile.name}
|
||||
</div>
|
||||
)}
|
||||
{createForm.formState.errors.root && (
|
||||
<p className="text-sm text-txt-danger">
|
||||
{createForm.formState.errors.root.message}
|
||||
</p>
|
||||
)}
|
||||
<Field
|
||||
label={__("Name")}
|
||||
type="text"
|
||||
{...createForm.register("name")}
|
||||
error={createForm.formState.errors.name?.message}
|
||||
/>
|
||||
<Field
|
||||
label={__("Category")}
|
||||
type="text"
|
||||
{...createForm.register("category")}
|
||||
error={createForm.formState.errors.category?.message}
|
||||
/>
|
||||
<Field
|
||||
label={__("Visibility")}
|
||||
type="select"
|
||||
value={createForm.watch("trustCenterVisibility")}
|
||||
onValueChange={(value) => createForm.setValue("trustCenterVisibility", value as "NONE" | "PRIVATE" | "PUBLIC")}
|
||||
error={createForm.formState.errors.trustCenterVisibility?.message}
|
||||
>
|
||||
{getTrustCenterVisibilityOptions(__).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>
|
||||
</DialogContent>
|
||||
<DialogFooter>
|
||||
<Button
|
||||
type="submit"
|
||||
disabled={isCreating || isUploading || !uploadedFile}
|
||||
>
|
||||
{(isCreating || isUploading) && <Spinner />}
|
||||
{__("Add File")}
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</form>
|
||||
</Dialog>
|
||||
|
||||
<Dialog ref={editDialogRef} title={__("Edit File")}>
|
||||
<form onSubmit={handleUpdate}>
|
||||
<DialogContent padded className="space-y-4">
|
||||
<Field
|
||||
label={__("Name")}
|
||||
type="text"
|
||||
{...editForm.register("name")}
|
||||
error={editForm.formState.errors.name?.message}
|
||||
/>
|
||||
<Field
|
||||
label={__("Category")}
|
||||
type="text"
|
||||
{...editForm.register("category")}
|
||||
error={editForm.formState.errors.category?.message}
|
||||
/>
|
||||
</DialogContent>
|
||||
<DialogFooter>
|
||||
<Button
|
||||
type="submit"
|
||||
disabled={isUpdating}
|
||||
>
|
||||
{isUpdating && <Spinner />}
|
||||
{__("Save")}
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</form>
|
||||
</Dialog>
|
||||
|
||||
<Dialog ref={deleteDialogRef} title={__("Delete File")}>
|
||||
<DialogContent padded>
|
||||
<p>{__("Are you sure you want to delete this file? This action cannot be undone.")}</p>
|
||||
</DialogContent>
|
||||
<DialogFooter>
|
||||
<Button
|
||||
variant="danger"
|
||||
onClick={handleDeleteConfirm}
|
||||
disabled={isDeleting}
|
||||
>
|
||||
{isDeleting && <Spinner />}
|
||||
{__("Delete")}
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</Dialog>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -287,6 +287,9 @@ export default function TrustCenterPage({ queryRef }: Props) {
|
||||
<TabLink to={`/organizations/${organizationId}/trust-center/documents`}>
|
||||
{__("Documents")}
|
||||
</TabLink>
|
||||
<TabLink to={`/organizations/${organizationId}/trust-center/files`}>
|
||||
{__("Files")}
|
||||
</TabLink>
|
||||
<TabLink to={`/organizations/${organizationId}/trust-center/access`}>
|
||||
{__("Access")}
|
||||
</TabLink>
|
||||
|
||||
@@ -44,6 +44,13 @@ export const trustCenterRoutes = [
|
||||
() => import("/pages/organizations/trustCenter/TrustCenterDocumentsTab")
|
||||
),
|
||||
},
|
||||
{
|
||||
path: "files",
|
||||
fallback: LinkCardSkeleton,
|
||||
Component: lazy(
|
||||
() => import("/pages/organizations/trustCenter/TrustCenterFilesTab")
|
||||
),
|
||||
},
|
||||
{
|
||||
path: "access",
|
||||
fallback: LinkCardSkeleton,
|
||||
|
||||
Reference in New Issue
Block a user