From ec1ce3dc06ef5876bc0ac8635ca1d467c0031eaa Mon Sep 17 00:00:00 2001 From: Tuan Dang Date: Thu, 5 Dec 2024 23:16:31 -0800 Subject: [PATCH] Fix type issues --- frontend/src/context/OrgPermissionContext/index.tsx | 5 +---- frontend/src/context/OrgPermissionContext/types.ts | 2 +- frontend/src/context/index.tsx | 1 - .../RolePage/components/OrgRoleModifySection.utils.ts | 9 +-------- .../RolePermissionsSection/RolePermissionRow.tsx | 7 ------- .../components/SshCertificateTemplatesSection.tsx | 4 ++-- .../components/SshCertificateTemplatesTable.tsx | 10 +++++----- .../Org/SshPage/components/SshCertificatesTable.tsx | 5 ++++- 8 files changed, 14 insertions(+), 29 deletions(-) diff --git a/frontend/src/context/OrgPermissionContext/index.tsx b/frontend/src/context/OrgPermissionContext/index.tsx index 10d7703b8..730fe55b1 100644 --- a/frontend/src/context/OrgPermissionContext/index.tsx +++ b/frontend/src/context/OrgPermissionContext/index.tsx @@ -1,6 +1,3 @@ export { OrgPermissionProvider, useOrgPermission } from "./OrgPermissionContext"; export type { TOrgPermission } from "./types"; -export { - OrgPermissionActions, - OrgPermissionSshCertificateTemplateActions, - OrgPermissionSubjects} from "./types"; +export { OrgPermissionActions, OrgPermissionSubjects } from "./types"; diff --git a/frontend/src/context/OrgPermissionContext/types.ts b/frontend/src/context/OrgPermissionContext/types.ts index c0bdd8029..ae2c95736 100644 --- a/frontend/src/context/OrgPermissionContext/types.ts +++ b/frontend/src/context/OrgPermissionContext/types.ts @@ -53,6 +53,6 @@ export type OrgPermissionSet = | [OrgPermissionActions, OrgPermissionSubjects.ProjectTemplates] | [OrgPermissionActions, OrgPermissionSubjects.SshCertificateAuthorities] | [OrgPermissionActions, OrgPermissionSubjects.SshCertificates] - | [OrgPermissionSshCertificateTemplateActions, OrgPermissionSubjects.SshCertificateTemplates]; + | [OrgPermissionActions, OrgPermissionSubjects.SshCertificateTemplates]; export type TOrgPermission = MongoAbility; diff --git a/frontend/src/context/index.tsx b/frontend/src/context/index.tsx index 83e771111..91dae5d2d 100644 --- a/frontend/src/context/index.tsx +++ b/frontend/src/context/index.tsx @@ -4,7 +4,6 @@ export type { TOrgPermission } from "./OrgPermissionContext"; export { OrgPermissionActions, OrgPermissionProvider, - OrgPermissionSshCertificateTemplateActions, OrgPermissionSubjects, useOrgPermission } from "./OrgPermissionContext"; diff --git a/frontend/src/views/Org/RolePage/components/OrgRoleModifySection.utils.ts b/frontend/src/views/Org/RolePage/components/OrgRoleModifySection.utils.ts index b155e21cb..b9da49ca7 100644 --- a/frontend/src/views/Org/RolePage/components/OrgRoleModifySection.utils.ts +++ b/frontend/src/views/Org/RolePage/components/OrgRoleModifySection.utils.ts @@ -13,13 +13,6 @@ const generalPermissionSchema = z }) .optional(); -const sshCertificateSchema = z - .object({ - read: z.boolean().optional(), - create: z.boolean().optional() - }) - .optional(); - const adminConsolePermissionSchmea = z .object({ "access-all-projects": z.boolean().optional() @@ -58,7 +51,7 @@ export const formSchema = z.object({ [OrgPermissionSubjects.Kms]: generalPermissionSchema, [OrgPermissionSubjects.ProjectTemplates]: generalPermissionSchema, [OrgPermissionSubjects.SshCertificateAuthorities]: generalPermissionSchema, - [OrgPermissionSubjects.SshCertificates]: sshCertificateSchema, + [OrgPermissionSubjects.SshCertificates]: generalPermissionSchema, [OrgPermissionSubjects.SshCertificateTemplates]: generalPermissionSchema }) .optional() diff --git a/frontend/src/views/Org/RolePage/components/RolePermissionsSection/RolePermissionRow.tsx b/frontend/src/views/Org/RolePage/components/RolePermissionsSection/RolePermissionRow.tsx index 4a5699ec6..3a50dc976 100644 --- a/frontend/src/views/Org/RolePage/components/RolePermissionsSection/RolePermissionRow.tsx +++ b/frontend/src/views/Org/RolePage/components/RolePermissionsSection/RolePermissionRow.tsx @@ -51,11 +51,6 @@ const PROJECT_TEMPLATES_PERMISSIONS = [ { action: "delete", label: "Remove" } ] as const; -const SSH_CERTIFICATES_PERMISSIONS = [ - { action: "read", label: "View" }, - { action: "create", label: "Create" } -] as const; - const getPermissionList = (option: string) => { switch (option) { case "secret-scanning": @@ -68,8 +63,6 @@ const getPermissionList = (option: string) => { return MEMBERS_PERMISSIONS; case OrgPermissionSubjects.ProjectTemplates: return PROJECT_TEMPLATES_PERMISSIONS; - case OrgPermissionSubjects.SshCertificates: - return SSH_CERTIFICATES_PERMISSIONS; default: return PERMISSIONS; } diff --git a/frontend/src/views/Org/SshCaPage/components/SshCertificateTemplatesSection.tsx b/frontend/src/views/Org/SshCaPage/components/SshCertificateTemplatesSection.tsx index 75db07ff6..9a66f6622 100644 --- a/frontend/src/views/Org/SshCaPage/components/SshCertificateTemplatesSection.tsx +++ b/frontend/src/views/Org/SshCaPage/components/SshCertificateTemplatesSection.tsx @@ -4,7 +4,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { createNotification } from "@app/components/notifications"; import { OrgPermissionCan } from "@app/components/permissions"; import { DeleteActionModal, IconButton } from "@app/components/v2"; -import { OrgPermissionSshCertificateTemplateActions, OrgPermissionSubjects } from "@app/context"; +import { OrgPermissionActions, OrgPermissionSubjects } from "@app/context"; import { usePopUp } from "@app/hooks"; import { useDeleteSshCertTemplate } from "@app/hooks/api"; @@ -52,7 +52,7 @@ export const SshCertificateTemplatesSection = ({ caId }: Props) => {

Certificate Templates

{(isAllowed) => ( diff --git a/frontend/src/views/Org/SshCaPage/components/SshCertificateTemplatesTable.tsx b/frontend/src/views/Org/SshCaPage/components/SshCertificateTemplatesTable.tsx index 62cf1a8b4..8104a6442 100644 --- a/frontend/src/views/Org/SshCaPage/components/SshCertificateTemplatesTable.tsx +++ b/frontend/src/views/Org/SshCaPage/components/SshCertificateTemplatesTable.tsx @@ -1,4 +1,4 @@ -import { faCertificate,faEllipsis, faFileAlt, faTrash } from "@fortawesome/free-solid-svg-icons"; +import { faCertificate, faEllipsis, faFileAlt, faTrash } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { twMerge } from "tailwind-merge"; @@ -19,7 +19,7 @@ import { Tooltip, Tr } from "@app/components/v2"; -import { OrgPermissionSshCertificateTemplateActions, OrgPermissionSubjects } from "@app/context"; +import { OrgPermissionActions, OrgPermissionSubjects } from "@app/context"; import { useGetSshCaCertTemplates } from "@app/hooks/api"; import { UsePopUpState } from "@app/hooks/usePopUp"; @@ -69,7 +69,7 @@ export const SshCertificateTemplatesTable = ({ handlePopUpOpen, sshCaId }: Props {(isAllowed) => ( diff --git a/frontend/src/views/Org/SshPage/components/SshCertificatesTable.tsx b/frontend/src/views/Org/SshPage/components/SshCertificatesTable.tsx index 4ef0e78ab..c696919bb 100644 --- a/frontend/src/views/Org/SshPage/components/SshCertificatesTable.tsx +++ b/frontend/src/views/Org/SshPage/components/SshCertificatesTable.tsx @@ -11,7 +11,8 @@ import { Td, Th, THead, - Tr} from "@app/components/v2"; + Tr +} from "@app/components/v2"; import { useOrganization } from "@app/context"; import { useListOrgSshCertificates } from "@app/hooks/api"; import { sshCertTypeToNameMap } from "@app/hooks/api/ssh-ca/constants"; @@ -29,6 +30,8 @@ export const SshCertificatesTable = () => { limit: perPage }); + console.log("SSH Certificates Table data: ", data); + return (