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