mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-08 09:27:50 +00:00
Add description to PKI collection
This commit is contained in:
@@ -11,6 +11,7 @@ export async function up(knex: Knex): Promise<void> {
|
|||||||
t.string("projectId").notNullable();
|
t.string("projectId").notNullable();
|
||||||
t.foreign("projectId").references("id").inTable(TableName.Project).onDelete("CASCADE");
|
t.foreign("projectId").references("id").inTable(TableName.Project).onDelete("CASCADE");
|
||||||
t.string("name").notNullable();
|
t.string("name").notNullable();
|
||||||
|
t.string("description").notNullable();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,8 @@ export const PkiCollectionsSchema = z.object({
|
|||||||
createdAt: z.date(),
|
createdAt: z.date(),
|
||||||
updatedAt: z.date(),
|
updatedAt: z.date(),
|
||||||
projectId: z.string(),
|
projectId: z.string(),
|
||||||
name: z.string()
|
name: z.string(),
|
||||||
|
description: z.string()
|
||||||
});
|
});
|
||||||
|
|
||||||
export type TPkiCollections = z.infer<typeof PkiCollectionsSchema>;
|
export type TPkiCollections = z.infer<typeof PkiCollectionsSchema>;
|
||||||
|
|||||||
@@ -1172,14 +1172,16 @@ export const ALERTS = {
|
|||||||
export const PKI_COLLECTIONS = {
|
export const PKI_COLLECTIONS = {
|
||||||
CREATE: {
|
CREATE: {
|
||||||
projectId: "The ID of the project to create the PKI collection in",
|
projectId: "The ID of the project to create the PKI collection in",
|
||||||
name: "The name of the PKI collection"
|
name: "The name of the PKI collection",
|
||||||
|
description: "A description for the PKI collection"
|
||||||
},
|
},
|
||||||
GET: {
|
GET: {
|
||||||
collectionId: "The ID of the PKI collection to get"
|
collectionId: "The ID of the PKI collection to get"
|
||||||
},
|
},
|
||||||
UPDATE: {
|
UPDATE: {
|
||||||
collectionId: "The ID of the PKI collection to update",
|
collectionId: "The ID of the PKI collection to update",
|
||||||
name: "The name of the PKI collection to update to"
|
name: "The name of the PKI collection to update to",
|
||||||
|
description: "The description for the PKI collection to update to"
|
||||||
},
|
},
|
||||||
DELETE: {
|
DELETE: {
|
||||||
collectionId: "The ID of the PKI collection to delete"
|
collectionId: "The ID of the PKI collection to delete"
|
||||||
|
|||||||
@@ -20,7 +20,8 @@ export const registerPkiCollectionRouter = async (server: FastifyZodProvider) =>
|
|||||||
description: "Create PKI collection",
|
description: "Create PKI collection",
|
||||||
body: z.object({
|
body: z.object({
|
||||||
projectId: z.string().trim().describe(PKI_COLLECTIONS.CREATE.projectId),
|
projectId: z.string().trim().describe(PKI_COLLECTIONS.CREATE.projectId),
|
||||||
name: z.string().trim().describe(PKI_COLLECTIONS.CREATE.name)
|
name: z.string().trim().describe(PKI_COLLECTIONS.CREATE.name),
|
||||||
|
description: z.string().trim().default("").describe(PKI_COLLECTIONS.CREATE.description)
|
||||||
}),
|
}),
|
||||||
response: {
|
response: {
|
||||||
200: PkiCollectionsSchema
|
200: PkiCollectionsSchema
|
||||||
@@ -104,7 +105,8 @@ export const registerPkiCollectionRouter = async (server: FastifyZodProvider) =>
|
|||||||
collectionId: z.string().trim().describe(PKI_COLLECTIONS.UPDATE.collectionId)
|
collectionId: z.string().trim().describe(PKI_COLLECTIONS.UPDATE.collectionId)
|
||||||
}),
|
}),
|
||||||
body: z.object({
|
body: z.object({
|
||||||
name: z.string().trim().optional().describe(PKI_COLLECTIONS.UPDATE.name)
|
name: z.string().trim().optional().describe(PKI_COLLECTIONS.UPDATE.name),
|
||||||
|
description: z.string().trim().optional().describe(PKI_COLLECTIONS.UPDATE.description)
|
||||||
}),
|
}),
|
||||||
response: {
|
response: {
|
||||||
200: PkiCollectionsSchema
|
200: PkiCollectionsSchema
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ export const pkiCollectionServiceFactory = ({
|
|||||||
}: TPkiCollectionServiceFactoryDep) => {
|
}: TPkiCollectionServiceFactoryDep) => {
|
||||||
const createPkiCollection = async ({
|
const createPkiCollection = async ({
|
||||||
name,
|
name,
|
||||||
|
description,
|
||||||
projectId,
|
projectId,
|
||||||
actorId,
|
actorId,
|
||||||
actorAuthMethod,
|
actorAuthMethod,
|
||||||
@@ -61,7 +62,8 @@ export const pkiCollectionServiceFactory = ({
|
|||||||
|
|
||||||
const pkiCollection = await pkiCollectionDAL.create({
|
const pkiCollection = await pkiCollectionDAL.create({
|
||||||
projectId,
|
projectId,
|
||||||
name
|
name,
|
||||||
|
description
|
||||||
});
|
});
|
||||||
|
|
||||||
return pkiCollection;
|
return pkiCollection;
|
||||||
@@ -92,6 +94,7 @@ export const pkiCollectionServiceFactory = ({
|
|||||||
const updatePkiCollection = async ({
|
const updatePkiCollection = async ({
|
||||||
collectionId,
|
collectionId,
|
||||||
name,
|
name,
|
||||||
|
description,
|
||||||
actorId,
|
actorId,
|
||||||
actorAuthMethod,
|
actorAuthMethod,
|
||||||
actor,
|
actor,
|
||||||
@@ -110,7 +113,8 @@ export const pkiCollectionServiceFactory = ({
|
|||||||
|
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Edit, ProjectPermissionSub.PkiCollections);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Edit, ProjectPermissionSub.PkiCollections);
|
||||||
pkiCollection = await pkiCollectionDAL.updateById(collectionId, {
|
pkiCollection = await pkiCollectionDAL.updateById(collectionId, {
|
||||||
name
|
name,
|
||||||
|
description
|
||||||
});
|
});
|
||||||
|
|
||||||
return pkiCollection;
|
return pkiCollection;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { TProjectPermission } from "@app/lib/types";
|
|||||||
|
|
||||||
export type TCreatePkiCollectionDTO = {
|
export type TCreatePkiCollectionDTO = {
|
||||||
name: string;
|
name: string;
|
||||||
|
description: string;
|
||||||
} & TProjectPermission;
|
} & TProjectPermission;
|
||||||
|
|
||||||
export type TGetPkiCollectionByIdDTO = {
|
export type TGetPkiCollectionByIdDTO = {
|
||||||
@@ -11,6 +12,7 @@ export type TGetPkiCollectionByIdDTO = {
|
|||||||
export type TUpdatePkiCollectionDTO = {
|
export type TUpdatePkiCollectionDTO = {
|
||||||
collectionId: string;
|
collectionId: string;
|
||||||
name?: string;
|
name?: string;
|
||||||
|
description?: string;
|
||||||
} & Omit<TProjectPermission, "projectId">;
|
} & Omit<TProjectPermission, "projectId">;
|
||||||
|
|
||||||
export type TDeletePkiCollectionDTO = {
|
export type TDeletePkiCollectionDTO = {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
export type TPkiCollection = {
|
export type TPkiCollection = {
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
|
description: string;
|
||||||
projectId: string;
|
projectId: string;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
@@ -9,12 +10,14 @@ export type TPkiCollection = {
|
|||||||
export type TCreatePkiCollectionDTO = {
|
export type TCreatePkiCollectionDTO = {
|
||||||
projectId: string;
|
projectId: string;
|
||||||
name: string;
|
name: string;
|
||||||
|
description: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type TUpdatePkiCollectionTO = {
|
export type TUpdatePkiCollectionTO = {
|
||||||
collectionId: string;
|
collectionId: string;
|
||||||
projectId: string;
|
projectId: string;
|
||||||
name?: string;
|
name?: string;
|
||||||
|
description?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type TDeletePkiCollectionDTO = {
|
export type TDeletePkiCollectionDTO = {
|
||||||
|
|||||||
+2
@@ -1,5 +1,6 @@
|
|||||||
import { motion } from "framer-motion";
|
import { motion } from "framer-motion";
|
||||||
|
|
||||||
|
import { PkiCollectionSection } from "../PkiAlertsTab/components";
|
||||||
import { CertificatesSection } from "./components";
|
import { CertificatesSection } from "./components";
|
||||||
|
|
||||||
export const CertificatesTab = () => {
|
export const CertificatesTab = () => {
|
||||||
@@ -11,6 +12,7 @@ export const CertificatesTab = () => {
|
|||||||
animate={{ opacity: 1, translateX: 0 }}
|
animate={{ opacity: 1, translateX: 0 }}
|
||||||
exit={{ opacity: 0, translateX: 30 }}
|
exit={{ opacity: 0, translateX: 30 }}
|
||||||
>
|
>
|
||||||
|
<PkiCollectionSection />
|
||||||
<CertificatesSection />
|
<CertificatesSection />
|
||||||
</motion.div>
|
</motion.div>
|
||||||
);
|
);
|
||||||
|
|||||||
+22
-4
@@ -15,7 +15,8 @@ import {
|
|||||||
import { UsePopUpState } from "@app/hooks/usePopUp";
|
import { UsePopUpState } from "@app/hooks/usePopUp";
|
||||||
|
|
||||||
const schema = z.object({
|
const schema = z.object({
|
||||||
name: z.string().trim().min(1)
|
name: z.string().trim().min(1),
|
||||||
|
description: z.string()
|
||||||
});
|
});
|
||||||
|
|
||||||
export type FormData = z.infer<typeof schema>;
|
export type FormData = z.infer<typeof schema>;
|
||||||
@@ -49,16 +50,18 @@ export const PkiCollectionModal = ({ popUp, handlePopUpToggle }: Props) => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (pkiCollection) {
|
if (pkiCollection) {
|
||||||
reset({
|
reset({
|
||||||
name: pkiCollection.name
|
name: pkiCollection.name,
|
||||||
|
description: pkiCollection.description
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
reset({
|
reset({
|
||||||
name: ""
|
name: "",
|
||||||
|
description: ""
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [pkiCollection]);
|
}, [pkiCollection]);
|
||||||
|
|
||||||
const onFormSubmit = async ({ name }: FormData) => {
|
const onFormSubmit = async ({ name, description }: FormData) => {
|
||||||
try {
|
try {
|
||||||
if (!projectId) return;
|
if (!projectId) return;
|
||||||
|
|
||||||
@@ -67,12 +70,14 @@ export const PkiCollectionModal = ({ popUp, handlePopUpToggle }: Props) => {
|
|||||||
await updatePkiCollection({
|
await updatePkiCollection({
|
||||||
collectionId: pkiCollection.id,
|
collectionId: pkiCollection.id,
|
||||||
name,
|
name,
|
||||||
|
description,
|
||||||
projectId
|
projectId
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// create
|
// create
|
||||||
const { id: createdId } = await createPkiCollection({
|
const { id: createdId } = await createPkiCollection({
|
||||||
name,
|
name,
|
||||||
|
description,
|
||||||
projectId
|
projectId
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -121,6 +126,19 @@ export const PkiCollectionModal = ({ popUp, handlePopUpToggle }: Props) => {
|
|||||||
</FormControl>
|
</FormControl>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
<Controller
|
||||||
|
control={control}
|
||||||
|
defaultValue=""
|
||||||
|
name="description"
|
||||||
|
render={({ field, fieldState: { error } }) => (
|
||||||
|
<FormControl label="Description" isError={Boolean(error)} errorText={error?.message}>
|
||||||
|
<Input
|
||||||
|
{...field}
|
||||||
|
placeholder="A collection to house certificates for ACME device"
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
<div className="flex items-center">
|
<div className="flex items-center">
|
||||||
<Button
|
<Button
|
||||||
className="mr-4"
|
className="mr-4"
|
||||||
|
|||||||
+1
-1
@@ -48,7 +48,7 @@ export const PkiCollectionSection = () => {
|
|||||||
return (
|
return (
|
||||||
<div className="mb-6 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
|
<div className="mb-6 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
|
||||||
<div className="mb-4 flex justify-between">
|
<div className="mb-4 flex justify-between">
|
||||||
<p className="text-xl font-semibold text-mineshaft-100">Certificate Collection</p>
|
<p className="text-xl font-semibold text-mineshaft-100">Certificate Collections</p>
|
||||||
<ProjectPermissionCan
|
<ProjectPermissionCan
|
||||||
I={ProjectPermissionActions.Create}
|
I={ProjectPermissionActions.Create}
|
||||||
a={ProjectPermissionSub.PkiCollections}
|
a={ProjectPermissionSub.PkiCollections}
|
||||||
|
|||||||
+3
-1
@@ -46,11 +46,12 @@ export const PkiCollectionTable = ({ handlePopUpOpen }: Props) => {
|
|||||||
<THead>
|
<THead>
|
||||||
<Tr>
|
<Tr>
|
||||||
<Th>Name</Th>
|
<Th>Name</Th>
|
||||||
|
<Th>Description</Th>
|
||||||
<Th className="w-5" />
|
<Th className="w-5" />
|
||||||
</Tr>
|
</Tr>
|
||||||
</THead>
|
</THead>
|
||||||
<TBody>
|
<TBody>
|
||||||
{isLoading && <TableSkeleton columns={2} innerKey="pki-collections" />}
|
{isLoading && <TableSkeleton columns={3} innerKey="pki-collections" />}
|
||||||
{!isLoading &&
|
{!isLoading &&
|
||||||
data?.collections.map((pkiCollection) => {
|
data?.collections.map((pkiCollection) => {
|
||||||
return (
|
return (
|
||||||
@@ -62,6 +63,7 @@ export const PkiCollectionTable = ({ handlePopUpOpen }: Props) => {
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
<Td>{pkiCollection.name}</Td>
|
<Td>{pkiCollection.name}</Td>
|
||||||
|
<Td>{pkiCollection.description}</Td>
|
||||||
<Td>
|
<Td>
|
||||||
<DropdownMenu>
|
<DropdownMenu>
|
||||||
<DropdownMenuTrigger asChild className="rounded-lg">
|
<DropdownMenuTrigger asChild className="rounded-lg">
|
||||||
|
|||||||
+5
-1
@@ -71,10 +71,14 @@ export const PkiCollectionDetailsSection = ({ collectionId, handlePopUpOpen }: P
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div className="mb-4">
|
||||||
<p className="text-sm font-semibold text-mineshaft-300">Name</p>
|
<p className="text-sm font-semibold text-mineshaft-300">Name</p>
|
||||||
<p className="text-sm text-mineshaft-300">{pkiCollection.name}</p>
|
<p className="text-sm text-mineshaft-300">{pkiCollection.name}</p>
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
<p className="text-sm font-semibold text-mineshaft-300">Description</p>
|
||||||
|
<p className="text-sm text-mineshaft-300">{pkiCollection.description}</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
Reference in New Issue
Block a user