misc: addressed PR feedback regarding audit logs and endpoint structure

This commit is contained in:
Sheen Capadngan
2024-08-19 16:15:43 +08:00
parent abdcb95a8f
commit 00039ba0e4
12 changed files with 145 additions and 96 deletions
@@ -683,6 +683,12 @@ interface CreateCertificateTemplate {
type: EventType.CREATE_CERTIFICATE_TEMPLATE;
metadata: {
certificateTemplateId: string;
caId: string;
pkiCollectionId?: string;
name: string;
commonName: string;
subjectAlternativeName: string;
ttl: string;
};
}
@@ -697,6 +703,12 @@ interface UpdateCertificateTemplate {
type: EventType.UPDATE_CERTIFICATE_TEMPLATE;
metadata: {
certificateTemplateId: string;
caId: string;
pkiCollectionId?: string;
name: string;
commonName: string;
subjectAlternativeName: string;
ttl: string;
};
}
@@ -15,9 +15,7 @@ export const useCreateCertTemplate = () => {
const queryClient = useQueryClient();
return useMutation<TCertificateTemplate, {}, TCreateCertificateTemplateDTO>({
mutationFn: async (data) => {
const {
data: { certificateTemplate }
} = await apiRequest.post<{ certificateTemplate: TCertificateTemplate }>(
const { data: certificateTemplate } = await apiRequest.post<TCertificateTemplate>(
"/api/v1/pki/certificate-templates",
data
);
@@ -33,9 +31,7 @@ export const useUpdateCertTemplate = () => {
const queryClient = useQueryClient();
return useMutation<TCertificateTemplate, {}, TUpdateCertificateTemplateDTO>({
mutationFn: async (data) => {
const {
data: { certificateTemplate }
} = await apiRequest.patch<{ certificateTemplate: TCertificateTemplate }>(
const { data: certificateTemplate } = await apiRequest.patch<TCertificateTemplate>(
`/api/v1/pki/certificate-templates/${data.id}`,
data
);
@@ -12,9 +12,7 @@ export const useGetCertTemplate = (id: string) => {
return useQuery({
queryKey: certTemplateKeys.getCertTemplateById(id),
queryFn: async () => {
const {
data: { certificateTemplate }
} = await apiRequest.get<{ certificateTemplate: TCertificateTemplate }>(
const { data: certificateTemplate } = await apiRequest.get<TCertificateTemplate>(
`/api/v1/pki/certificate-templates/${id}`
);
return certificateTemplate;
@@ -1,13 +1,8 @@
export type TCertificateTemplateListEntry = {
id: string;
name: string;
caName: string;
caId: string;
};
export type TCertificateTemplate = {
id: string;
caId: string;
caName: string;
projectId: string;
pkiCollectionId?: string;
name: string;
commonName: string;
+2 -2
View File
@@ -5,7 +5,7 @@ import { apiRequest } from "@app/config/request";
import { CaStatus } from "../ca/enums";
import { TCertificateAuthority } from "../ca/types";
import { TCertificate } from "../certificates/types";
import { TCertificateTemplateListEntry } from "../certificateTemplates/types";
import { TCertificateTemplate } from "../certificateTemplates/types";
import { TGroupMembership } from "../groups/types";
import { identitiesKeys } from "../identities/queries";
import { IdentityMembership } from "../identities/types";
@@ -649,7 +649,7 @@ export const useListWorkspaceCertificateTemplates = ({ workspaceId }: { workspac
queryFn: async () => {
const {
data: { certificateTemplates }
} = await apiRequest.get<{ certificateTemplates: TCertificateTemplateListEntry[] }>(
} = await apiRequest.get<{ certificateTemplates: TCertificateTemplate[] }>(
`/api/v2/workspace/${workspaceId}/certificate-templates`
);
@@ -408,6 +408,19 @@ export const LogsTableRow = ({ auditLog }: Props) => {
);
case EventType.CREATE_CERTIFICATE_TEMPLATE:
case EventType.UPDATE_CERTIFICATE_TEMPLATE:
return (
<Td>
<p>{`Certificate Template ID: ${event.metadata.certificateTemplateId}`}</p>
<p>{`Certificate Authority ID: ${event.metadata.caId}`}</p>
<p>{`Name: ${event.metadata.name}`}</p>
<p>{`Common Name: ${event.metadata.commonName}`}</p>
<p>{`Subject Alternative Name: ${event.metadata.subjectAlternativeName}`}</p>
<p>{`TTL: ${event.metadata.ttl}`}</p>
{event.metadata.pkiCollectionId && (
<p>{`Collection ID: ${event.metadata.pkiCollectionId}`}</p>
)}
</Td>
);
case EventType.GET_CERTIFICATE_TEMPLATE:
case EventType.DELETE_CERTIFICATE_TEMPLATE:
return (