Use alias slugs for navigation in trust center
Document, file, and audit rows now navigate to /documents/<alias> when an alias is set, falling back to the resource ID otherwise. The document page query accepts a string ID to support both forms. Signed-off-by: Bryan Frimin <bryan@probo.com>
This commit is contained in:
@@ -57,6 +57,7 @@ const auditRowFragment = graphql`
|
|||||||
name
|
name
|
||||||
reportFile {
|
reportFile {
|
||||||
id
|
id
|
||||||
|
alias
|
||||||
isUserAuthorized
|
isUserAuthorized
|
||||||
access {
|
access {
|
||||||
id
|
id
|
||||||
@@ -84,6 +85,7 @@ export function AuditRow(props: { audit: AuditRowFragment$key }) {
|
|||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const audit = useFragment(auditRowFragment, props.audit);
|
const audit = useFragment(auditRowFragment, props.audit);
|
||||||
|
const reportPath = audit.reportFile?.alias ?? audit.reportFile?.id;
|
||||||
const hasRequested = audit.reportFile?.access?.status === "REQUESTED";
|
const hasRequested = audit.reportFile?.access?.status === "REQUESTED";
|
||||||
|
|
||||||
const [requestAccess, isRequestingAccess]
|
const [requestAccess, isRequestingAccess]
|
||||||
@@ -146,7 +148,7 @@ export function AuditRow(props: { audit: AuditRowFragment$key }) {
|
|||||||
className="w-full md:w-max"
|
className="w-full md:w-max"
|
||||||
variant="secondary"
|
variant="secondary"
|
||||||
icon={IconArrowLink}
|
icon={IconArrowLink}
|
||||||
to={`/documents/${audit.reportFile.id}`}
|
to={reportPath ? `/documents/${reportPath}` : undefined}
|
||||||
>
|
>
|
||||||
{__("View")}
|
{__("View")}
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ const requestAccessMutation = graphql`
|
|||||||
const documentRowFragment = graphql`
|
const documentRowFragment = graphql`
|
||||||
fragment DocumentRowFragment on Document {
|
fragment DocumentRowFragment on Document {
|
||||||
id
|
id
|
||||||
|
alias
|
||||||
title
|
title
|
||||||
isUserAuthorized
|
isUserAuthorized
|
||||||
access {
|
access {
|
||||||
@@ -66,6 +67,7 @@ export function DocumentRow(props: { document: DocumentRowFragment$key }) {
|
|||||||
const [searchParams] = useSearchParams();
|
const [searchParams] = useSearchParams();
|
||||||
|
|
||||||
const document = useFragment(documentRowFragment, props.document);
|
const document = useFragment(documentRowFragment, props.document);
|
||||||
|
const documentPath = document.alias ?? document.id;
|
||||||
const hasRequested = document.access?.status === "REQUESTED";
|
const hasRequested = document.access?.status === "REQUESTED";
|
||||||
|
|
||||||
const [requestAccess, isRequestingAccess]
|
const [requestAccess, isRequestingAccess]
|
||||||
@@ -127,7 +129,7 @@ export function DocumentRow(props: { document: DocumentRowFragment$key }) {
|
|||||||
className="w-full md:w-max"
|
className="w-full md:w-max"
|
||||||
variant="secondary"
|
variant="secondary"
|
||||||
icon={IconArrowLink}
|
icon={IconArrowLink}
|
||||||
onClick={() => void navigate(`/documents/${document.id}`)}
|
onClick={() => void navigate(`/documents/${documentPath}`)}
|
||||||
>
|
>
|
||||||
{__("View")}
|
{__("View")}
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ const requestAccessMutation = graphql`
|
|||||||
const trustCenterFileRowFragment = graphql`
|
const trustCenterFileRowFragment = graphql`
|
||||||
fragment TrustCenterFileRowFragment on TrustCenterFile {
|
fragment TrustCenterFileRowFragment on TrustCenterFile {
|
||||||
id
|
id
|
||||||
|
alias
|
||||||
name
|
name
|
||||||
isUserAuthorized
|
isUserAuthorized
|
||||||
access {
|
access {
|
||||||
@@ -68,6 +69,7 @@ export function TrustCenterFileRow(props: {
|
|||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const file = useFragment(trustCenterFileRowFragment, props.file);
|
const file = useFragment(trustCenterFileRowFragment, props.file);
|
||||||
|
const filePath = file.alias ?? file.id;
|
||||||
const hasRequested = file.access?.status === "REQUESTED";
|
const hasRequested = file.access?.status === "REQUESTED";
|
||||||
|
|
||||||
const [requestAccess, isRequestingAccess]
|
const [requestAccess, isRequestingAccess]
|
||||||
@@ -131,7 +133,7 @@ export function TrustCenterFileRow(props: {
|
|||||||
className="w-full md:w-max"
|
className="w-full md:w-max"
|
||||||
variant="secondary"
|
variant="secondary"
|
||||||
icon={IconArrowLink}
|
icon={IconArrowLink}
|
||||||
onClick={() => void navigate(`/documents/${file.id}`)}
|
onClick={() => void navigate(`/documents/${filePath}`)}
|
||||||
>
|
>
|
||||||
{__("View")}
|
{__("View")}
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ import type { DocumentPageRequestReportAccessMutation } from "./__generated__/Do
|
|||||||
import type { DocumentPageRequestTrustCenterFileAccessMutation } from "./__generated__/DocumentPageRequestTrustCenterFileAccessMutation.graphql";
|
import type { DocumentPageRequestTrustCenterFileAccessMutation } from "./__generated__/DocumentPageRequestTrustCenterFileAccessMutation.graphql";
|
||||||
|
|
||||||
export const documentPageQuery = graphql`
|
export const documentPageQuery = graphql`
|
||||||
query DocumentPageQuery($id: ID!) {
|
query DocumentPageQuery($id: String!) {
|
||||||
currentTrustCenter {
|
currentTrustCenter {
|
||||||
logo {
|
logo {
|
||||||
downloadUrl
|
downloadUrl
|
||||||
|
|||||||
Reference in New Issue
Block a user