review fixes: docs + frontend

This commit is contained in:
x032205
2025-05-05 15:07:57 -04:00
parent b6e6a3c6be
commit f6e802c017
3 changed files with 19 additions and 11 deletions

View File

@@ -1,5 +1,5 @@
---
title: "List"
title: "Get Certificate Bundle"
openapi: "GET /api/v2/workspace/{slug}/bundle"
---

View File

@@ -1,4 +1,4 @@
---
title: "List"
title: "Get Certificate Private Key"
openapi: "GET /api/v2/workspace/{slug}/private-key"
---

View File

@@ -1,14 +1,14 @@
import { Modal, ModalContent } from "@app/components/v2";
import { useGetCertBody } from "@app/hooks/api";
import { UsePopUpState } from "@app/hooks/usePopUp";
import { CertificateContent } from "./CertificateContent";
import {
ProjectPermissionCertificateActions,
ProjectPermissionSub,
useProjectPermission
} from "@app/context";
import { useGetCertBody } from "@app/hooks/api";
import { useGetCertBundle } from "@app/hooks/api/certificates/queries";
import { UsePopUpState } from "@app/hooks/usePopUp";
import { CertificateContent } from "./CertificateContent";
type Props = {
popUp: UsePopUpState<["certificateCert"]>;
@@ -26,9 +26,18 @@ export const CertificateCertModal = ({ popUp, handlePopUpToggle }: Props) => {
ProjectPermissionSub.Certificates
);
const { data } = canReadPrivateKey
? useGetCertBundle(serialNumber)
: useGetCertBody(serialNumber);
// useGetCertBundle fails unless user has the correct permissions
const { data: bundleData } = useGetCertBundle(serialNumber);
const { data: bodyData } = useGetCertBody(serialNumber);
const data:
| {
certificate: string;
certificateChain: string;
serialNumber: string;
privateKey?: string;
}
| undefined = canReadPrivateKey ? bundleData : bodyData;
return (
<Modal
@@ -43,8 +52,7 @@ export const CertificateCertModal = ({ popUp, handlePopUpToggle }: Props) => {
serialNumber={data.serialNumber}
certificate={data.certificate}
certificateChain={data.certificateChain}
// A hacky fix for typescript error
privateKey={(data as { privateKey?: string }).privateKey}
privateKey={data.privateKey}
/>
) : (
<div />