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:
@@ -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