Fix compliance page to only show published document versions
The compliance page was leaking draft document content and titles. Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @generated SignedSource<<e02fc31002f54ed30be7e53370069aaa>>
|
||||
* @generated SignedSource<<2a0f1332c57638e29eeee8e4113858d3>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
@@ -17,6 +17,7 @@ export type CompliancePageDocumentListFragment$data = {
|
||||
readonly documents: {
|
||||
readonly edges: ReadonlyArray<{
|
||||
readonly node: {
|
||||
readonly currentPublishedVersion: number | null | undefined;
|
||||
readonly id: string;
|
||||
readonly " $fragmentSpreads": FragmentRefs<"CompliancePageDocumentListItem_documentFragment">;
|
||||
};
|
||||
@@ -92,6 +93,13 @@ const node: ReaderFragment = {
|
||||
"name": "id",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "currentPublishedVersion",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"args": null,
|
||||
"kind": "FragmentSpread",
|
||||
@@ -111,6 +119,6 @@ const node: ReaderFragment = {
|
||||
"abstractKey": null
|
||||
};
|
||||
|
||||
(node as any).hash = "a8d512034c171dc461a42e6ae6e76f12";
|
||||
(node as any).hash = "48e4f01fb5d80ae0856433598608d4cf";
|
||||
|
||||
export default node;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @generated SignedSource<<112e917e3fb881859a56b794f07ce7e7>>
|
||||
* @generated SignedSource<<85da952604018b5f879924bf3f8d5a27>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
@@ -9,22 +9,19 @@
|
||||
// @ts-nocheck
|
||||
|
||||
import { ReaderFragment } from 'relay-runtime';
|
||||
export type DocumentStatus = "DRAFT" | "PUBLISHED";
|
||||
export type DocumentType = "ISMS" | "OTHER" | "POLICY" | "PROCEDURE";
|
||||
export type TrustCenterVisibility = "NONE" | "PRIVATE" | "PUBLIC";
|
||||
import { FragmentRefs } from "relay-runtime";
|
||||
export type CompliancePageDocumentListItem_documentFragment$data = {
|
||||
readonly documentType: DocumentType;
|
||||
readonly id: string;
|
||||
readonly lastVersion: {
|
||||
readonly latestPublishedVersion: {
|
||||
readonly edges: ReadonlyArray<{
|
||||
readonly node: {
|
||||
readonly id: string;
|
||||
readonly status: DocumentStatus;
|
||||
readonly title: string;
|
||||
};
|
||||
}>;
|
||||
};
|
||||
readonly title: string;
|
||||
readonly trustCenterVisibility: TrustCenterVisibility;
|
||||
readonly " $fragmentType": "CompliancePageDocumentListItem_documentFragment";
|
||||
};
|
||||
@@ -33,21 +30,19 @@ export type CompliancePageDocumentListItem_documentFragment$key = {
|
||||
readonly " $fragmentSpreads": FragmentRefs<"CompliancePageDocumentListItem_documentFragment">;
|
||||
};
|
||||
|
||||
const node: ReaderFragment = (function(){
|
||||
var v0 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "id",
|
||||
"storageKey": null
|
||||
};
|
||||
return {
|
||||
const node: ReaderFragment = {
|
||||
"argumentDefinitions": [],
|
||||
"kind": "Fragment",
|
||||
"metadata": null,
|
||||
"name": "CompliancePageDocumentListItem_documentFragment",
|
||||
"selections": [
|
||||
(v0/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "id",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
@@ -55,13 +50,6 @@ return {
|
||||
"name": "documentType",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "title",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
@@ -70,8 +58,15 @@ return {
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": "lastVersion",
|
||||
"alias": "latestPublishedVersion",
|
||||
"args": [
|
||||
{
|
||||
"kind": "Literal",
|
||||
"name": "filter",
|
||||
"value": {
|
||||
"status": "PUBLISHED"
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "Literal",
|
||||
"name": "first",
|
||||
@@ -107,12 +102,11 @@ return {
|
||||
"name": "node",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v0/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "status",
|
||||
"name": "title",
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
@@ -122,14 +116,13 @@ return {
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": "versions(first:1,orderBy:{\"direction\":\"DESC\",\"field\":\"CREATED_AT\"})"
|
||||
"storageKey": "versions(filter:{\"status\":\"PUBLISHED\"},first:1,orderBy:{\"direction\":\"DESC\",\"field\":\"CREATED_AT\"})"
|
||||
}
|
||||
],
|
||||
"type": "Document",
|
||||
"abstractKey": null
|
||||
};
|
||||
})();
|
||||
|
||||
(node as any).hash = "ab2b10ffbd76c59d1a3facab0f794402";
|
||||
(node as any).hash = "4c6d4e935f4a54b6d2ef486f60aab5f6";
|
||||
|
||||
export default node;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @generated SignedSource<<0948c131a30705ee3921f60bbd40c3cb>>
|
||||
* @generated SignedSource<<976e80f8eb6650a229d5af8f1f58b5f5>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
@@ -127,13 +127,6 @@ return {
|
||||
"name": "documentType",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "title",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
@@ -142,8 +135,15 @@ return {
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": "lastVersion",
|
||||
"alias": "latestPublishedVersion",
|
||||
"args": [
|
||||
{
|
||||
"kind": "Literal",
|
||||
"name": "filter",
|
||||
"value": {
|
||||
"status": "PUBLISHED"
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "Literal",
|
||||
"name": "first",
|
||||
@@ -179,14 +179,14 @@ return {
|
||||
"name": "node",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v2/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "status",
|
||||
"name": "title",
|
||||
"storageKey": null
|
||||
}
|
||||
},
|
||||
(v2/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
@@ -194,7 +194,7 @@ return {
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": "versions(first:1,orderBy:{\"direction\":\"DESC\",\"field\":\"CREATED_AT\"})"
|
||||
"storageKey": "versions(filter:{\"status\":\"PUBLISHED\"},first:1,orderBy:{\"direction\":\"DESC\",\"field\":\"CREATED_AT\"})"
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
@@ -205,12 +205,12 @@ return {
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "f72f0dd5039dbfeaa609b7914308c0fe",
|
||||
"cacheID": "8bb0348deb10b7f0fe65b953bccf8cb3",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "CompliancePageDocumentListItem_updateVisibilityMutation",
|
||||
"operationKind": "mutation",
|
||||
"text": "mutation CompliancePageDocumentListItem_updateVisibilityMutation(\n $input: UpdateDocumentInput!\n) {\n updateDocument(input: $input) {\n document {\n ...CompliancePageDocumentListItem_documentFragment\n id\n }\n }\n}\n\nfragment CompliancePageDocumentListItem_documentFragment on Document {\n id\n documentType\n title\n trustCenterVisibility\n lastVersion: versions(first: 1, orderBy: {field: CREATED_AT, direction: DESC}) {\n edges {\n node {\n id\n status\n }\n }\n }\n}\n"
|
||||
"text": "mutation CompliancePageDocumentListItem_updateVisibilityMutation(\n $input: UpdateDocumentInput!\n) {\n updateDocument(input: $input) {\n document {\n ...CompliancePageDocumentListItem_documentFragment\n id\n }\n }\n}\n\nfragment CompliancePageDocumentListItem_documentFragment on Document {\n id\n documentType\n trustCenterVisibility\n latestPublishedVersion: versions(first: 1, orderBy: {field: CREATED_AT, direction: DESC}, filter: {status: PUBLISHED}) {\n edges {\n node {\n title\n id\n }\n }\n }\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @generated SignedSource<<ccda9818c715d1b77b33d0114c235cb4>>
|
||||
* @generated SignedSource<<56c0070ef19b8dff73eeb111e11fff52>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
@@ -156,14 +156,14 @@ return {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "documentType",
|
||||
"name": "currentPublishedVersion",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "title",
|
||||
"name": "documentType",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
@@ -174,8 +174,15 @@ return {
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": "lastVersion",
|
||||
"alias": "latestPublishedVersion",
|
||||
"args": [
|
||||
{
|
||||
"kind": "Literal",
|
||||
"name": "filter",
|
||||
"value": {
|
||||
"status": "PUBLISHED"
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "Literal",
|
||||
"name": "first",
|
||||
@@ -211,14 +218,14 @@ return {
|
||||
"name": "node",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v2/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "status",
|
||||
"name": "title",
|
||||
"storageKey": null
|
||||
}
|
||||
},
|
||||
(v2/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
@@ -226,7 +233,7 @@ return {
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": "versions(first:1,orderBy:{\"direction\":\"DESC\",\"field\":\"CREATED_AT\"})"
|
||||
"storageKey": "versions(filter:{\"status\":\"PUBLISHED\"},first:1,orderBy:{\"direction\":\"DESC\",\"field\":\"CREATED_AT\"})"
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
@@ -248,12 +255,12 @@ return {
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "a094d511faa776c9e8d68f53933b3937",
|
||||
"cacheID": "44c832e5fec9c0e84a0cbd844063d0fe",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "CompliancePageDocumentsPageQuery",
|
||||
"operationKind": "query",
|
||||
"text": "query CompliancePageDocumentsPageQuery(\n $organizationId: ID!\n) {\n organization: node(id: $organizationId) {\n __typename\n ...CompliancePageDocumentListFragment\n id\n }\n}\n\nfragment CompliancePageDocumentListFragment on Organization {\n compliancePage: trustCenter {\n ...CompliancePageDocumentListItem_compliancePageFragment\n id\n }\n documents(first: 100) {\n edges {\n node {\n id\n ...CompliancePageDocumentListItem_documentFragment\n }\n }\n }\n}\n\nfragment CompliancePageDocumentListItem_compliancePageFragment on TrustCenter {\n canUpdate: permission(action: \"core:trust-center:update\")\n}\n\nfragment CompliancePageDocumentListItem_documentFragment on Document {\n id\n documentType\n title\n trustCenterVisibility\n lastVersion: versions(first: 1, orderBy: {field: CREATED_AT, direction: DESC}) {\n edges {\n node {\n id\n status\n }\n }\n }\n}\n"
|
||||
"text": "query CompliancePageDocumentsPageQuery(\n $organizationId: ID!\n) {\n organization: node(id: $organizationId) {\n __typename\n ...CompliancePageDocumentListFragment\n id\n }\n}\n\nfragment CompliancePageDocumentListFragment on Organization {\n compliancePage: trustCenter {\n ...CompliancePageDocumentListItem_compliancePageFragment\n id\n }\n documents(first: 100) {\n edges {\n node {\n id\n currentPublishedVersion\n ...CompliancePageDocumentListItem_documentFragment\n }\n }\n }\n}\n\nfragment CompliancePageDocumentListItem_compliancePageFragment on TrustCenter {\n canUpdate: permission(action: \"core:trust-center:update\")\n}\n\nfragment CompliancePageDocumentListItem_documentFragment on Document {\n id\n documentType\n trustCenterVisibility\n latestPublishedVersion: versions(first: 1, orderBy: {field: CREATED_AT, direction: DESC}, filter: {status: PUBLISHED}) {\n edges {\n node {\n title\n id\n }\n }\n }\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
@@ -16,6 +16,7 @@ const fragment = graphql`
|
||||
edges {
|
||||
node {
|
||||
id
|
||||
currentPublishedVersion
|
||||
...CompliancePageDocumentListItem_documentFragment
|
||||
}
|
||||
}
|
||||
@@ -29,6 +30,7 @@ export function CompliancePageDocumentList(props: { fragmentRef: CompliancePageD
|
||||
const { __ } = useTranslate();
|
||||
|
||||
const { compliancePage, documents } = useFragment<CompliancePageDocumentListFragment$key>(fragment, fragmentRef);
|
||||
const publishedDocuments = documents.edges.filter(({ node }) => node.currentPublishedVersion != null);
|
||||
|
||||
return (
|
||||
<div className="space-y-[10px]">
|
||||
@@ -37,19 +39,18 @@ export function CompliancePageDocumentList(props: { fragmentRef: CompliancePageD
|
||||
<Tr>
|
||||
<Th>{__("Name")}</Th>
|
||||
<Th>{__("Type")}</Th>
|
||||
<Th>{__("State")}</Th>
|
||||
<Th>{__("Visibility")}</Th>
|
||||
</Tr>
|
||||
</Thead>
|
||||
<Tbody>
|
||||
{documents.edges.length === 0 && (
|
||||
{publishedDocuments.length === 0 && (
|
||||
<Tr>
|
||||
<Td colSpan={5} className="text-center text-txt-secondary">
|
||||
<Td colSpan={3} className="text-center text-txt-secondary">
|
||||
{__("No documents available")}
|
||||
</Td>
|
||||
</Tr>
|
||||
)}
|
||||
{documents.edges.map(({ node: document }) => (
|
||||
{publishedDocuments.map(({ node: document }) => (
|
||||
<CompliancePageDocumentListItem
|
||||
key={document.id}
|
||||
compliancePageFragmentRef={compliancePage}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { getTrustCenterVisibilityOptions } from "@probo/helpers";
|
||||
import { useTranslate } from "@probo/i18n";
|
||||
import { Badge, DocumentTypeBadge, DocumentVersionBadge, Field, Option, Td, Tr } from "@probo/ui";
|
||||
import { Badge, DocumentTypeBadge, Field, Option, Td, Tr } from "@probo/ui";
|
||||
import { useCallback } from "react";
|
||||
import { useFragment } from "react-relay";
|
||||
import { graphql } from "relay-runtime";
|
||||
@@ -20,13 +20,15 @@ const documentFragment = graphql`
|
||||
fragment CompliancePageDocumentListItem_documentFragment on Document {
|
||||
id
|
||||
documentType
|
||||
title
|
||||
trustCenterVisibility
|
||||
lastVersion: versions(first: 1, orderBy: { field: CREATED_AT, direction: DESC }) {
|
||||
latestPublishedVersion: versions(
|
||||
first: 1
|
||||
orderBy: { field: CREATED_AT, direction: DESC }
|
||||
filter: { status: PUBLISHED }
|
||||
) {
|
||||
edges {
|
||||
node {
|
||||
id
|
||||
status
|
||||
title
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -86,19 +88,16 @@ export function CompliancePageDocumentListItem(props: {
|
||||
[document.id, updateDocumentVisibility],
|
||||
);
|
||||
|
||||
const versionTitle = document.latestPublishedVersion.edges[0]?.node.title;
|
||||
|
||||
return (
|
||||
<Tr to={`/organizations/${organizationId}/documents/${document.id}`}>
|
||||
<Td>
|
||||
<div className="flex gap-4 items-center">{document.title}</div>
|
||||
<div className="flex gap-4 items-center">{versionTitle}</div>
|
||||
</Td>
|
||||
<Td>
|
||||
<DocumentTypeBadge type={document.documentType} />
|
||||
</Td>
|
||||
<Td>
|
||||
<DocumentVersionBadge
|
||||
state={document.lastVersion.edges[0].node.status}
|
||||
/>
|
||||
</Td>
|
||||
<Td noLink width={130} className="pr-0">
|
||||
<Field
|
||||
type="select"
|
||||
|
||||
Reference in New Issue
Block a user