From a857375cc10050338a40dde056beee91b9301e02 Mon Sep 17 00:00:00 2001 From: = Date: Wed, 11 Dec 2024 21:19:37 +0530 Subject: [PATCH] feat: fixed migration issues and resolved all routes in frontend --- ...0241205160300_project-split-to-products.ts | 68 +++---- .../src/server/routes/v1/project-router.ts | 2 +- backend/src/services/org/org-service.ts | 2 +- backend/src/services/project/project-dal.ts | 10 +- .../src/services/project/project-service.ts | 8 +- backend/src/services/project/project-types.ts | 2 +- .../src/components/dashboard/AddTagsMenu.tsx | 4 +- .../integrations/NoEnvironmentsBanner.tsx | 4 +- .../v2/projects/NewProjectModal.tsx | 2 +- .../WorkspaceContext/WorkspaceContext.tsx | 4 +- frontend/src/helpers/workspace.ts | 12 ++ frontend/src/hooks/api/workspace/queries.tsx | 6 +- frontend/src/layouts/AppLayout/AppLayout.tsx | 167 +----------------- .../ProjectSelect/ProjectSelect.tsx | 3 +- .../ProjectSidebarItems.tsx | 158 +++++++++++++++++ .../components/ProjectSidebarItems/index.tsx | 1 + .../[id]/allowlist/index.tsx | 0 .../[id]/ca/[caId]/index.tsx | 0 .../[id]/certificates/index.tsx | 0 .../[id]/identities/[identityId]/index.tsx | 0 .../[id]/members/[membershipId]/index.tsx | 0 .../[id]/members/index.tsx | 0 .../pki-collections/[collectionId]/index.tsx | 0 .../[id]/roles/[roleSlug]/index.tsx | 0 .../[id]/settings/index.tsx | 0 .../src/pages/cmek/[id]/allowlist/index.tsx | 21 +++ .../[id]/identities/[identityId]/index.tsx | 20 +++ .../{project => cmek}/[id]/kms/index.tsx | 0 .../[id]/members/[membershipId]/index.tsx | 20 +++ .../src/pages/cmek/[id]/members/index.tsx | 21 +++ .../cmek/[id]/roles/[roleSlug]/index.tsx | 20 +++ .../src/pages/cmek/[id]/settings/index.tsx | 22 +++ .../pages/org/[id]/cert-manager/overview.tsx | 1 + frontend/src/pages/org/[id]/cmek/overview.tsx | 1 + .../src/pages/org/[id]/overview/index.tsx | 5 +- .../org/[id]/secret-manager/overview.tsx | 8 +- .../secret-manager/[id]/allowlist/index.tsx | 21 +++ .../[id]/approval/index.tsx | 0 .../[id]/identities/[identityId]/index.tsx | 20 +++ .../[id]/members/[membershipId]/index.tsx | 20 +++ .../secret-manager/[id]/members/index.tsx | 21 +++ .../[id]/roles/[roleSlug]/index.tsx | 20 +++ .../[id]/secret-rotation/index.tsx | 0 .../[id]/secrets/[env].tsx | 0 .../[id]/secrets/overview.tsx | 0 .../secret-manager/[id]/settings/index.tsx | 22 +++ frontend/src/pages/signup/index.tsx | 5 +- frontend/src/pages/signupinvite.tsx | 3 +- frontend/src/views/Login/Login.utils.tsx | 3 +- .../IdentityProjectRow.tsx | 4 +- .../views/Org/components/CreateOrgModal.tsx | 5 +- .../OrgAdminProjects/OrgAdminProjects.tsx | 11 +- frontend/src/views/Project/CaPage/CaPage.tsx | 5 +- .../components/CaTab/components/CaTable.tsx | 3 +- .../components/PkiCollectionModal.tsx | 3 +- .../components/PkiCollectionTable.tsx | 3 +- .../IdentityDetailPage.tsx | 4 +- .../MemberDetailsPage/MemberDetailPage.tsx | 4 +- .../components/IdentityTab/IdentityTab.tsx | 4 +- .../MembersTab/components/MembersTable.tsx | 4 +- .../ProjectRoleList/ProjectRoleList.tsx | 4 +- .../PkiCollectionPage/PkiCollectionPage.tsx | 5 +- .../src/views/Project/RolePage/RolePage.tsx | 4 +- .../Project/RolePage/components/RoleModal.tsx | 2 +- .../views/SecretMainPage/SecretMainPage.tsx | 3 +- .../SecretOverviewPage/SecretOverviewPage.tsx | 6 +- .../DeleteProjectSection.tsx | 5 +- .../BackupPDFStep/BackupPDFStep.tsx | 3 +- .../admin/DashboardPage/DashboardPage.tsx | 3 +- 69 files changed, 547 insertions(+), 265 deletions(-) create mode 100644 frontend/src/helpers/workspace.ts create mode 100644 frontend/src/layouts/AppLayout/components/ProjectSidebarItems/ProjectSidebarItems.tsx create mode 100644 frontend/src/layouts/AppLayout/components/ProjectSidebarItems/index.tsx rename frontend/src/pages/{project => cert-manager}/[id]/allowlist/index.tsx (100%) rename frontend/src/pages/{project => cert-manager}/[id]/ca/[caId]/index.tsx (100%) rename frontend/src/pages/{project => cert-manager}/[id]/certificates/index.tsx (100%) rename frontend/src/pages/{project => cert-manager}/[id]/identities/[identityId]/index.tsx (100%) rename frontend/src/pages/{project => cert-manager}/[id]/members/[membershipId]/index.tsx (100%) rename frontend/src/pages/{project => cert-manager}/[id]/members/index.tsx (100%) rename frontend/src/pages/{project => cert-manager}/[id]/pki-collections/[collectionId]/index.tsx (100%) rename frontend/src/pages/{project => cert-manager}/[id]/roles/[roleSlug]/index.tsx (100%) rename frontend/src/pages/{project => cert-manager}/[id]/settings/index.tsx (100%) create mode 100644 frontend/src/pages/cmek/[id]/allowlist/index.tsx create mode 100644 frontend/src/pages/cmek/[id]/identities/[identityId]/index.tsx rename frontend/src/pages/{project => cmek}/[id]/kms/index.tsx (100%) create mode 100644 frontend/src/pages/cmek/[id]/members/[membershipId]/index.tsx create mode 100644 frontend/src/pages/cmek/[id]/members/index.tsx create mode 100644 frontend/src/pages/cmek/[id]/roles/[roleSlug]/index.tsx create mode 100644 frontend/src/pages/cmek/[id]/settings/index.tsx create mode 100644 frontend/src/pages/secret-manager/[id]/allowlist/index.tsx rename frontend/src/pages/{project => secret-manager}/[id]/approval/index.tsx (100%) create mode 100644 frontend/src/pages/secret-manager/[id]/identities/[identityId]/index.tsx create mode 100644 frontend/src/pages/secret-manager/[id]/members/[membershipId]/index.tsx create mode 100644 frontend/src/pages/secret-manager/[id]/members/index.tsx create mode 100644 frontend/src/pages/secret-manager/[id]/roles/[roleSlug]/index.tsx rename frontend/src/pages/{project => secret-manager}/[id]/secret-rotation/index.tsx (100%) rename frontend/src/pages/{project => secret-manager}/[id]/secrets/[env].tsx (100%) rename frontend/src/pages/{project => secret-manager}/[id]/secrets/overview.tsx (100%) create mode 100644 frontend/src/pages/secret-manager/[id]/settings/index.tsx diff --git a/backend/src/db/migrations/20241205160300_project-split-to-products.ts b/backend/src/db/migrations/20241205160300_project-split-to-products.ts index bf572edfc..6ebac71e5 100644 --- a/backend/src/db/migrations/20241205160300_project-split-to-products.ts +++ b/backend/src/db/migrations/20241205160300_project-split-to-products.ts @@ -1,11 +1,12 @@ +import slugify from "@sindresorhus/slugify"; import { Knex } from "knex"; import { v4 as uuidV4 } from "uuid"; -import slugify from "@sindresorhus/slugify"; -import { ProjectType, TableName } from "../schemas"; import { alphaNumericNanoId } from "@app/lib/nanoid"; -/* eslint-disable no-await-in-loop,no-param-reassign,@typescript-eslint/ban-ts-comment */ +import { ProjectType, TableName } from "../schemas"; + +/* eslint-disable no-await-in-loop,@typescript-eslint/ban-ts-comment */ const newProject = async (knex: Knex, projectId: string, projectType: ProjectType) => { const newProjectId = uuidV4(); const project = await knex(TableName.Project).where("id", projectId).first(); @@ -24,10 +25,12 @@ const newProject = async (knex: Knex, projectId: string, projectType: ProjectTyp projectCustomRoles.map((el) => { const id = uuidV4(); customRoleMapping[el.id] = id; - el.id = id; - el.projectId = newProjectId; - el.permissions = el.permissions ? JSON.stringify(el.permissions) : el.permissions; - return el; + return { + ...el, + id, + projectId: newProjectId, + permissions: el.permissions ? JSON.stringify(el.permissions) : el.permissions + }; }) ); } @@ -38,9 +41,7 @@ const newProject = async (knex: Knex, projectId: string, projectType: ProjectTyp groupMemberships.map((el) => { const id = uuidV4(); groupMembershipMapping[el.id] = id; - el.id = id; - el.projectId = newProjectId; - return el; + return { ...el, id, projectId: newProjectId }; }) ); } @@ -53,10 +54,9 @@ const newProject = async (knex: Knex, projectId: string, projectType: ProjectTyp await knex(TableName.GroupProjectMembershipRole).insert( groupMembershipRoles.map((el) => { const id = uuidV4(); - el.id = id; - el.projectMembershipId = groupMembershipMapping[el.id]; - el.customRoleId = el.customRoleId ? customRoleMapping[el.customRoleId] : el.customRoleId; - return el; + const projectMembershipId = groupMembershipMapping[el.id]; + const customRoleId = el.customRoleId ? customRoleMapping[el.customRoleId] : el.customRoleId; + return { ...el, id, projectMembershipId, customRoleId }; }) ); } @@ -68,9 +68,7 @@ const newProject = async (knex: Knex, projectId: string, projectType: ProjectTyp identities.map((el) => { const id = uuidV4(); identityProjectMembershipMapping[el.id] = id; - el.id = id; - el.projectId = newProjectId; - return el; + return { ...el, id, projectId: newProjectId }; }) ); } @@ -83,10 +81,9 @@ const newProject = async (knex: Knex, projectId: string, projectType: ProjectTyp await knex(TableName.IdentityProjectMembershipRole).insert( identitiesRoles.map((el) => { const id = uuidV4(); - el.id = id; - el.projectMembershipId = identityProjectMembershipMapping[el.projectMembershipId]; - el.customRoleId = el.customRoleId ? customRoleMapping[el.customRoleId] : el.customRoleId; - return el; + const projectMembershipId = identityProjectMembershipMapping[el.projectMembershipId]; + const customRoleId = el.customRoleId ? customRoleMapping[el.customRoleId] : el.customRoleId; + return { ...el, id, projectMembershipId, customRoleId }; }) ); } @@ -98,9 +95,7 @@ const newProject = async (knex: Knex, projectId: string, projectType: ProjectTyp projectUserMembers.map((el) => { const id = uuidV4(); projectMembershipMapping[el.id] = id; - el.id = id; - el.projectId = newProjectId; - return el; + return { ...el, id, projectId: newProjectId }; }) ); } @@ -112,10 +107,9 @@ const newProject = async (knex: Knex, projectId: string, projectType: ProjectTyp await knex(TableName.ProjectUserMembershipRole).insert( membershipRoles.map((el) => { const id = uuidV4(); - el.id = id; - el.projectMembershipId = projectMembershipMapping[el.projectMembershipId]; - el.customRoleId = el.customRoleId ? customRoleMapping[el.customRoleId] : el.customRoleId; - return el; + const projectMembershipId = projectMembershipMapping[el.projectMembershipId]; + const customRoleId = el.customRoleId ? customRoleMapping[el.customRoleId] : el.customRoleId; + return { ...el, id, projectMembershipId, customRoleId }; }) ); } @@ -125,10 +119,8 @@ const newProject = async (knex: Knex, projectId: string, projectType: ProjectTyp await knex(TableName.KmsKey).insert( kmsKeys.map((el) => { const id = uuidV4(); - el.id = id; - el.projectId = newProjectId; - el.slug = slugify(alphaNumericNanoId(8).toLowerCase()); - return el; + const slug = slugify(alphaNumericNanoId(8).toLowerCase()); + return { ...el, id, slug, projectId: newProjectId }; }) ); } @@ -143,9 +135,7 @@ const newProject = async (knex: Knex, projectId: string, projectType: ProjectTyp await knex(TableName.ProjectKeys).insert( projectKeys.map((el) => { const id = uuidV4(); - el.id = id; - el.projectId = newProjectId; - return el; + return { ...el, id, projectId: newProjectId }; }) ); } @@ -154,16 +144,14 @@ const newProject = async (knex: Knex, projectId: string, projectType: ProjectTyp if (serviceTokens.length) { await knex(TableName.ServiceToken).insert( serviceTokens.map((el) => { - el.id = uuidV4(); - el.projectId = projectId; - el.scopes = el.scopes ? JSON.stringify(el.scopes) : el.scopes; - return el; + const id = uuidV4(); + const scopes = el.scopes ? JSON.stringify(el.scopes) : el.scopes; + return { ...el, id, scopes, projectId: newProjectId }; }) ); } return newProjectId; }; -/* eslint-enable */ const BATCH_SIZE = 500; export async function up(knex: Knex): Promise { diff --git a/backend/src/server/routes/v1/project-router.ts b/backend/src/server/routes/v1/project-router.ts index f348a7cf4..5944777ae 100644 --- a/backend/src/server/routes/v1/project-router.ts +++ b/backend/src/server/routes/v1/project-router.ts @@ -137,7 +137,7 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => { .enum(["true", "false"]) .default("false") .transform((value) => value === "true"), - type: z.nativeEnum(ProjectType).optional() + type: z.enum([ProjectType.SecretManager, ProjectType.Cmek, ProjectType.CertificateManager, "all"]).optional() }), response: { 200: z.object({ diff --git a/backend/src/services/org/org-service.ts b/backend/src/services/org/org-service.ts index 9a48f583a..33931bf26 100644 --- a/backend/src/services/org/org-service.ts +++ b/backend/src/services/org/org-service.ts @@ -197,7 +197,7 @@ export const orgServiceFactory = ({ const findAllWorkspaces = async ({ actor, actorId, orgId, type }: TFindAllWorkspacesDTO) => { if (actor === ActorType.USER) { - const workspaces = await projectDAL.findAllProjects(actorId, orgId, type); + const workspaces = await projectDAL.findAllProjects(actorId, orgId, type || "all"); return workspaces; } diff --git a/backend/src/services/project/project-dal.ts b/backend/src/services/project/project-dal.ts index 2f1877799..c13258a39 100644 --- a/backend/src/services/project/project-dal.ts +++ b/backend/src/services/project/project-dal.ts @@ -19,7 +19,7 @@ export type TProjectDALFactory = ReturnType; export const projectDALFactory = (db: TDbClient) => { const projectOrm = ormify(db, TableName.Project); - const findAllProjects = async (userId: string, orgId: string, projectType?: ProjectType | null) => { + const findAllProjects = async (userId: string, orgId: string, projectType: ProjectType | "all") => { try { const workspaces = await db .replicaNode()(TableName.ProjectMembership) @@ -27,7 +27,7 @@ export const projectDALFactory = (db: TDbClient) => { .join(TableName.Project, `${TableName.ProjectMembership}.projectId`, `${TableName.Project}.id`) .where(`${TableName.Project}.orgId`, orgId) .andWhere((qb) => { - if (projectType) { + if (projectType !== "all") { void qb.where(`${TableName.Project}.type`, projectType); } }) @@ -130,7 +130,11 @@ export const projectDALFactory = (db: TDbClient) => { .replicaNode()(TableName.IdentityProjectMembership) .where({ identityId }) .join(TableName.Project, `${TableName.IdentityProjectMembership}.projectId`, `${TableName.Project}.id`) - .where(`${TableName.Project}.type`, projectType) + .andWhere((qb) => { + if (projectType) { + void qb.where(`${TableName.Project}.type`, projectType); + } + }) .leftJoin(TableName.Environment, `${TableName.Environment}.projectId`, `${TableName.Project}.id`) .select( selectAllTableCols(TableName.Project), diff --git a/backend/src/services/project/project-service.ts b/backend/src/services/project/project-service.ts index 2c1dabc5c..47cc48b1d 100644 --- a/backend/src/services/project/project-service.ts +++ b/backend/src/services/project/project-service.ts @@ -431,7 +431,13 @@ export const projectServiceFactory = ({ return deletedProject; }; - const getProjects = async ({ actorId, includeRoles, actorAuthMethod, actorOrgId, type }: TListProjectsDTO) => { + const getProjects = async ({ + actorId, + includeRoles, + actorAuthMethod, + actorOrgId, + type = ProjectType.SecretManager + }: TListProjectsDTO) => { const workspaces = await projectDAL.findAllProjects(actorId, actorOrgId, type); if (includeRoles) { diff --git a/backend/src/services/project/project-types.ts b/backend/src/services/project/project-types.ts index 39a3f2520..29261da4f 100644 --- a/backend/src/services/project/project-types.ts +++ b/backend/src/services/project/project-types.ts @@ -85,7 +85,7 @@ export type TDeleteProjectDTO = { export type TListProjectsDTO = { includeRoles: boolean; - type?: ProjectType | null; + type?: ProjectType | "all"; } & Omit; export type TUpgradeProjectDTO = { diff --git a/frontend/src/components/dashboard/AddTagsMenu.tsx b/frontend/src/components/dashboard/AddTagsMenu.tsx index 3a54f77ab..d2e295c14 100644 --- a/frontend/src/components/dashboard/AddTagsMenu.tsx +++ b/frontend/src/components/dashboard/AddTagsMenu.tsx @@ -5,6 +5,8 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { Menu, Transition } from "@headlessui/react"; import { Tag } from "public/data/frequentInterfaces"; +import { ProjectType } from "@app/hooks/api/workspace/types"; + /** * This is the menu that is used to add more tags to a secret * @param {object} obj @@ -75,7 +77,7 @@ const AddTagsMenu = ({ diff --git a/frontend/src/components/v2/projects/NewProjectModal.tsx b/frontend/src/components/v2/projects/NewProjectModal.tsx index 7510f5d23..a081ef4f0 100644 --- a/frontend/src/components/v2/projects/NewProjectModal.tsx +++ b/frontend/src/components/v2/projects/NewProjectModal.tsx @@ -148,7 +148,7 @@ const NewProjectForm = ({ onOpenChange, projectType }: NewProjectFormProps) => { createNotification({ text: "Project created", type: "success" }); reset(); onOpenChange(false); - router.push(`/project/${newProjectId}/${projectType}/overview`); + router.push(`/${projectType}/${newProjectId}/${projectType}/overview`); } catch (err) { console.error(err); createNotification({ text: "Failed to create project", type: "error" }); diff --git a/frontend/src/context/WorkspaceContext/WorkspaceContext.tsx b/frontend/src/context/WorkspaceContext/WorkspaceContext.tsx index 38d86ce97..8a4a599b4 100644 --- a/frontend/src/context/WorkspaceContext/WorkspaceContext.tsx +++ b/frontend/src/context/WorkspaceContext/WorkspaceContext.tsx @@ -3,7 +3,7 @@ import { useRouter } from "next/router"; import { createNotification } from "@app/components/notifications"; import { useGetUserWorkspaces } from "@app/hooks/api"; -import { Workspace } from "@app/hooks/api/workspace/types"; +import { ProjectType, Workspace } from "@app/hooks/api/workspace/types"; type TWorkspaceContext = { workspaces: Workspace[]; @@ -35,7 +35,7 @@ export const WorkspaceProvider = ({ children }: Props): JSX.Element => { const shouldTriggerNoProjectAccess = !value.isLoading && !value.currentWorkspace && - router.pathname.startsWith("/project") && + Object.values(ProjectType).some((el) => router.pathname.startsWith(`/${el}`)) && workspaceId; // handle redirects for project-specific routes diff --git a/frontend/src/helpers/workspace.ts b/frontend/src/helpers/workspace.ts new file mode 100644 index 000000000..1bdd1f8f9 --- /dev/null +++ b/frontend/src/helpers/workspace.ts @@ -0,0 +1,12 @@ +import { Workspace } from "@app/hooks/api/types"; +import { ProjectType } from "@app/hooks/api/workspace/types"; + +export const getWorkspaceHomePage = (workspace: Workspace) => { + if (workspace.type === ProjectType.SecretManager) { + return `/${workspace.type}/${workspace.id}/secrets/overview`; + } + if (workspace.type === ProjectType.CertificateManager) { + return `/${workspace.type}/${workspace.id}/certificates`; + } + return `/${workspace.type}/${workspace.id}/kms`; +}; diff --git a/frontend/src/hooks/api/workspace/queries.tsx b/frontend/src/hooks/api/workspace/queries.tsx index 96d4e3c9d..9fdce5b67 100644 --- a/frontend/src/hooks/api/workspace/queries.tsx +++ b/frontend/src/hooks/api/workspace/queries.tsx @@ -103,7 +103,7 @@ export const useGetUpgradeProjectStatus = ({ }); }; -const fetchUserWorkspaces = async (includeRoles?: boolean, type?: ProjectType) => { +const fetchUserWorkspaces = async (includeRoles?: boolean, type?: ProjectType | "all") => { const { data } = await apiRequest.get<{ workspaces: Workspace[] }>("/api/v1/workspace", { params: { includeRoles, @@ -143,10 +143,10 @@ export const useGetWorkspaceById = ( export const useGetUserWorkspaces = ({ includeRoles, - type + type = "all" }: { includeRoles?: boolean; - type?: ProjectType; + type?: ProjectType | "all"; } = {}) => useQuery(workspaceKeys.getAllUserWorkspace(type || ""), () => fetchUserWorkspaces(includeRoles, type) diff --git a/frontend/src/layouts/AppLayout/AppLayout.tsx b/frontend/src/layouts/AppLayout/AppLayout.tsx index ece5dd8e2..0cbe2362d 100644 --- a/frontend/src/layouts/AppLayout/AppLayout.tsx +++ b/frontend/src/layouts/AppLayout/AppLayout.tsx @@ -5,7 +5,7 @@ /* eslint-disable no-var */ /* eslint-disable func-names */ -import { useEffect, useMemo, useState } from "react"; +import { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; import Link from "next/link"; import { useRouter } from "next/router"; @@ -38,13 +38,7 @@ import { } from "@app/components/v2"; import { useOrganization, useSubscription, useUser, useWorkspace } from "@app/context"; import { usePopUp, useToggle } from "@app/hooks"; -import { - useGetAccessRequestsCount, - useGetOrgTrialUrl, - useGetSecretApprovalRequestCount, - useLogoutUser, - useSelectOrganization -} from "@app/hooks/api"; +import { useGetOrgTrialUrl, useLogoutUser, useSelectOrganization } from "@app/hooks/api"; import { MfaMethod } from "@app/hooks/api/auth/types"; import { AuthMethod } from "@app/hooks/api/users/types"; import { InsecureConnectionBanner } from "@app/layouts/AppLayout/components/InsecureConnectionBanner"; @@ -53,6 +47,7 @@ import { navigateUserToOrg } from "@app/views/Login/Login.utils"; import { Mfa } from "@app/views/Login/Mfa"; import { CreateOrgModal } from "@app/views/Org/components"; +import { ProjectSidebarItem } from "./components/ProjectSidebarItems"; import { WishForm } from "./components/WishForm/WishForm"; interface LayoutProps { @@ -87,7 +82,7 @@ export const AppLayout = ({ children }: LayoutProps) => { const { mutateAsync } = useGetOrgTrialUrl(); - const { workspaces, currentWorkspace } = useWorkspace(); + const { currentWorkspace } = useWorkspace(); const { orgs, currentOrg } = useOrganization(); const [shouldShowMfa, toggleShowMfa] = useToggle(false); @@ -96,15 +91,6 @@ export const AppLayout = ({ children }: LayoutProps) => { const { user } = useUser(); const { subscription } = useSubscription(); - const workspaceId = currentWorkspace?.id || ""; - const projectSlug = currentWorkspace?.slug || ""; - - const { data: secretApprovalReqCount } = useGetSecretApprovalRequestCount({ workspaceId }); - const { data: accessApprovalRequestCount } = useGetAccessRequestsCount({ projectSlug }); - - const pendingRequestsCount = useMemo(() => { - return (secretApprovalReqCount?.open || 0) + (accessApprovalRequestCount?.pendingCount || 0); - }, [secretApprovalReqCount, accessApprovalRequestCount]); const infisicalPlatformVersion = process.env.NEXT_PUBLIC_INFISICAL_PLATFORM_VERSION; @@ -152,41 +138,6 @@ export const AppLayout = ({ children }: LayoutProps) => { if (tempLocalStorage("orgData.id") === "" && orgs?.[0]?.id) { localStorage.setItem("orgData.id", orgs?.[0]?.id); } - - if ( - currentOrg && - ((workspaces?.length === 0 && router.asPath.includes("project")) || - router.asPath.includes("/project/undefined") || - (!orgs?.map((org) => org.id)?.includes(router.query.id as string) && - !router.asPath.includes("project") && - !router.asPath.includes("personal") && - !router.asPath.includes("secret-scanning") && - !router.asPath.includes("integration"))) - ) { - router.push(`/org/${currentOrg?.id}/secret-manager/overview`); - } - // else if (!router.asPath.includes("org") && !router.asPath.includes("project") && !router.asPath.includes("integrations") && !router.asPath.includes("personal-settings")) { - - // const pathSegments = router.asPath.split("/").filter((segment) => segment.length > 0); - - // let intendedWorkspaceId; - // if (pathSegments.length >= 2 && pathSegments[0] === "dashboard") { - // [, intendedWorkspaceId] = pathSegments; - // } else if (pathSegments.length >= 3 && pathSegments[0] === "settings") { - // [, , intendedWorkspaceId] = pathSegments; - // } else { - // const lastPathSegments = router.asPath.split("/").pop(); - // if (lastPathSegments !== undefined) { - // [intendedWorkspaceId] = lastPathSegments.split("?"); - // } - // } - - // if (!intendedWorkspaceId) return; - - // if (!["callback", "create", "authorize"].includes(intendedWorkspaceId)) { - // localStorage.setItem("projectData.id", intendedWorkspaceId); - // } - // } }; putUserInOrg(); }, [router.query.id]); @@ -214,8 +165,7 @@ export const AppLayout = ({ children }: LayoutProps) => {
{!router.asPath.includes("personal") && (
- {(router.asPath.includes("project") || - router.asPath.includes("integrations")) && ( + {(currentWorkspace || router.asPath.includes("integrations")) && (
@@ -387,111 +337,8 @@ export const AppLayout = ({ children }: LayoutProps) => { ))}
- {(router.asPath.includes("project") || router.asPath.includes("integrations")) && - currentWorkspace ? ( - - - - - {t("nav.menu.secrets")} - - - - - - - Internal PKI - - - - - - - Key Management - - - - - - - Access Control - - - - - - - {t("nav.menu.integrations")} - - - - - - - Secret Rotation - - - - - - - Approvals - {Boolean( - secretApprovalReqCount?.open || - accessApprovalRequestCount?.pendingCount - ) && ( - - {pendingRequestsCount} - - )} - - - - - - - {t("nav.menu.project-settings")} - - - - - ) : ( + + {router.pathname.startsWith("/org") && ( diff --git a/frontend/src/layouts/AppLayout/components/ProjectSelect/ProjectSelect.tsx b/frontend/src/layouts/AppLayout/components/ProjectSelect/ProjectSelect.tsx index e69ada548..f327517ec 100644 --- a/frontend/src/layouts/AppLayout/components/ProjectSelect/ProjectSelect.tsx +++ b/frontend/src/layouts/AppLayout/components/ProjectSelect/ProjectSelect.tsx @@ -16,6 +16,7 @@ import { useSubscription, useWorkspace } from "@app/context"; +import { getWorkspaceHomePage } from "@app/helpers/workspace"; import { usePopUp } from "@app/hooks"; import { useUpdateUserProjectFavorites } from "@app/hooks/api/users/mutation"; import { useGetUserProjectFavorites } from "@app/hooks/api/users/queries"; @@ -190,7 +191,7 @@ export const ProjectSelect = () => { // todo(akhi): this is not using react query because react query in overview is throwing error when envs are not exact same count // to reproduce change this back to router.push and switch between two projects with different env count // look into this on dashboard revamp - window.location.assign(`/project/${project.id}/secrets/overview`); + window.location.assign(getWorkspaceHomePage(project)); }} options={options} components={{ diff --git a/frontend/src/layouts/AppLayout/components/ProjectSidebarItems/ProjectSidebarItems.tsx b/frontend/src/layouts/AppLayout/components/ProjectSidebarItems/ProjectSidebarItems.tsx new file mode 100644 index 000000000..4d33921a1 --- /dev/null +++ b/frontend/src/layouts/AppLayout/components/ProjectSidebarItems/ProjectSidebarItems.tsx @@ -0,0 +1,158 @@ +import { useTranslation } from "react-i18next"; +import Link from "next/link"; +import { useRouter } from "next/router"; + +import { Menu, MenuItem } from "@app/components/v2"; +import { useWorkspace } from "@app/context"; +import { useGetAccessRequestsCount, useGetSecretApprovalRequestCount } from "@app/hooks/api"; +import { ProjectType } from "@app/hooks/api/workspace/types"; + +export const ProjectSidebarItem = () => { + const { currentWorkspace } = useWorkspace(); + const router = useRouter(); + const { t } = useTranslation(); + + const workspaceId = currentWorkspace?.id || ""; + const projectSlug = currentWorkspace?.slug || ""; + + const { data: secretApprovalReqCount } = useGetSecretApprovalRequestCount({ workspaceId }); + const { data: accessApprovalRequestCount } = useGetAccessRequestsCount({ projectSlug }); + + const pendingRequestsCount = + (secretApprovalReqCount?.open || 0) + (accessApprovalRequestCount?.pendingCount || 0); + + if ( + !currentWorkspace || + router.asPath.startsWith("personal") || + router.asPath.startsWith("integrations") + ) { + return
; + } + + const isSecretManager = currentWorkspace?.type === ProjectType.SecretManager; + const isCertManager = currentWorkspace?.type === ProjectType.CertificateManager; + const isCmek = currentWorkspace?.type === ProjectType.Cmek; + + return ( + + {isSecretManager && ( + + + + {t("nav.menu.secrets")} + + + + )} + {isCertManager && ( + + + + Internal PKI + + + + )} + {isCmek && ( + + + + Key Management + + + + )} + + + + Access Control + + + + {isSecretManager && ( + + + + {t("nav.menu.integrations")} + + + + )} + {isSecretManager && ( + + + + Secret Rotation + + + + )} + {isSecretManager && ( + + + + Approvals + {Boolean( + secretApprovalReqCount?.open || accessApprovalRequestCount?.pendingCount + ) && ( + + {pendingRequestsCount} + + )} + + + + )} + + + + {t("nav.menu.project-settings")} + + + + + ); +}; diff --git a/frontend/src/layouts/AppLayout/components/ProjectSidebarItems/index.tsx b/frontend/src/layouts/AppLayout/components/ProjectSidebarItems/index.tsx new file mode 100644 index 000000000..70b5840b3 --- /dev/null +++ b/frontend/src/layouts/AppLayout/components/ProjectSidebarItems/index.tsx @@ -0,0 +1 @@ +export { ProjectSidebarItem } from "./ProjectSidebarItems"; diff --git a/frontend/src/pages/project/[id]/allowlist/index.tsx b/frontend/src/pages/cert-manager/[id]/allowlist/index.tsx similarity index 100% rename from frontend/src/pages/project/[id]/allowlist/index.tsx rename to frontend/src/pages/cert-manager/[id]/allowlist/index.tsx diff --git a/frontend/src/pages/project/[id]/ca/[caId]/index.tsx b/frontend/src/pages/cert-manager/[id]/ca/[caId]/index.tsx similarity index 100% rename from frontend/src/pages/project/[id]/ca/[caId]/index.tsx rename to frontend/src/pages/cert-manager/[id]/ca/[caId]/index.tsx diff --git a/frontend/src/pages/project/[id]/certificates/index.tsx b/frontend/src/pages/cert-manager/[id]/certificates/index.tsx similarity index 100% rename from frontend/src/pages/project/[id]/certificates/index.tsx rename to frontend/src/pages/cert-manager/[id]/certificates/index.tsx diff --git a/frontend/src/pages/project/[id]/identities/[identityId]/index.tsx b/frontend/src/pages/cert-manager/[id]/identities/[identityId]/index.tsx similarity index 100% rename from frontend/src/pages/project/[id]/identities/[identityId]/index.tsx rename to frontend/src/pages/cert-manager/[id]/identities/[identityId]/index.tsx diff --git a/frontend/src/pages/project/[id]/members/[membershipId]/index.tsx b/frontend/src/pages/cert-manager/[id]/members/[membershipId]/index.tsx similarity index 100% rename from frontend/src/pages/project/[id]/members/[membershipId]/index.tsx rename to frontend/src/pages/cert-manager/[id]/members/[membershipId]/index.tsx diff --git a/frontend/src/pages/project/[id]/members/index.tsx b/frontend/src/pages/cert-manager/[id]/members/index.tsx similarity index 100% rename from frontend/src/pages/project/[id]/members/index.tsx rename to frontend/src/pages/cert-manager/[id]/members/index.tsx diff --git a/frontend/src/pages/project/[id]/pki-collections/[collectionId]/index.tsx b/frontend/src/pages/cert-manager/[id]/pki-collections/[collectionId]/index.tsx similarity index 100% rename from frontend/src/pages/project/[id]/pki-collections/[collectionId]/index.tsx rename to frontend/src/pages/cert-manager/[id]/pki-collections/[collectionId]/index.tsx diff --git a/frontend/src/pages/project/[id]/roles/[roleSlug]/index.tsx b/frontend/src/pages/cert-manager/[id]/roles/[roleSlug]/index.tsx similarity index 100% rename from frontend/src/pages/project/[id]/roles/[roleSlug]/index.tsx rename to frontend/src/pages/cert-manager/[id]/roles/[roleSlug]/index.tsx diff --git a/frontend/src/pages/project/[id]/settings/index.tsx b/frontend/src/pages/cert-manager/[id]/settings/index.tsx similarity index 100% rename from frontend/src/pages/project/[id]/settings/index.tsx rename to frontend/src/pages/cert-manager/[id]/settings/index.tsx diff --git a/frontend/src/pages/cmek/[id]/allowlist/index.tsx b/frontend/src/pages/cmek/[id]/allowlist/index.tsx new file mode 100644 index 000000000..73c25d802 --- /dev/null +++ b/frontend/src/pages/cmek/[id]/allowlist/index.tsx @@ -0,0 +1,21 @@ +import { useTranslation } from "react-i18next"; +import Head from "next/head"; + +import { IPAllowlistPage } from "@app/views/Project/IPAllowListPage"; + +const ProjectAllowlist = () => { + const { t } = useTranslation(); + return ( + <> + + {t("common.head-title", { title: t("settings.project.title") })} + + + + + ); +}; + +export default ProjectAllowlist; + +ProjectAllowlist.requireAuth = true; diff --git a/frontend/src/pages/cmek/[id]/identities/[identityId]/index.tsx b/frontend/src/pages/cmek/[id]/identities/[identityId]/index.tsx new file mode 100644 index 000000000..ae8b2716a --- /dev/null +++ b/frontend/src/pages/cmek/[id]/identities/[identityId]/index.tsx @@ -0,0 +1,20 @@ +import { useTranslation } from "react-i18next"; +import Head from "next/head"; + +import { IdentityDetailsPage } from "@app/views/Project/IdentityDetailsPage"; + +export default function ProjectIdentityDetailsPage() { + const { t } = useTranslation(); + + return ( + <> + + {t("common.head-title", { title: t("settings.members.title") })} + + + + + ); +} + +ProjectIdentityDetailsPage.requireAuth = true; diff --git a/frontend/src/pages/project/[id]/kms/index.tsx b/frontend/src/pages/cmek/[id]/kms/index.tsx similarity index 100% rename from frontend/src/pages/project/[id]/kms/index.tsx rename to frontend/src/pages/cmek/[id]/kms/index.tsx diff --git a/frontend/src/pages/cmek/[id]/members/[membershipId]/index.tsx b/frontend/src/pages/cmek/[id]/members/[membershipId]/index.tsx new file mode 100644 index 000000000..033aa2b15 --- /dev/null +++ b/frontend/src/pages/cmek/[id]/members/[membershipId]/index.tsx @@ -0,0 +1,20 @@ +import { useTranslation } from "react-i18next"; +import Head from "next/head"; + +import { MemberDetailsPage } from "@app/views/Project/MemberDetailsPage"; + +export default function Page() { + const { t } = useTranslation(); + + return ( + <> + + {t("common.head-title", { title: t("settings.members.title") })} + + + + + ); +} + +Page.requireAuth = true; diff --git a/frontend/src/pages/cmek/[id]/members/index.tsx b/frontend/src/pages/cmek/[id]/members/index.tsx new file mode 100644 index 000000000..4bcbb833e --- /dev/null +++ b/frontend/src/pages/cmek/[id]/members/index.tsx @@ -0,0 +1,21 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ +import { useTranslation } from "react-i18next"; +import Head from "next/head"; + +import { MembersPage } from "@app/views/Project/MembersPage"; + +export default function WorkspaceMemberSettings() { + const { t } = useTranslation(); + + return ( + <> + + {t("common.head-title", { title: t("settings.members.title") })} + + + + + ); +} + +WorkspaceMemberSettings.requireAuth = true; diff --git a/frontend/src/pages/cmek/[id]/roles/[roleSlug]/index.tsx b/frontend/src/pages/cmek/[id]/roles/[roleSlug]/index.tsx new file mode 100644 index 000000000..17c854cee --- /dev/null +++ b/frontend/src/pages/cmek/[id]/roles/[roleSlug]/index.tsx @@ -0,0 +1,20 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ +import { useTranslation } from "react-i18next"; +import Head from "next/head"; + +import { RolePage } from "@app/views/Project/RolePage"; + +export default function Role() { + const { t } = useTranslation(); + return ( + <> + + {t("common.head-title", { title: "Project Settings" })} + + + + + ); +} + +Role.requireAuth = true; diff --git a/frontend/src/pages/cmek/[id]/settings/index.tsx b/frontend/src/pages/cmek/[id]/settings/index.tsx new file mode 100644 index 000000000..331ba8cc5 --- /dev/null +++ b/frontend/src/pages/cmek/[id]/settings/index.tsx @@ -0,0 +1,22 @@ +import { useTranslation } from "react-i18next"; +import Head from "next/head"; + +import { ProjectSettingsPage } from "@app/views/Settings/ProjectSettingsPage"; + +const ProjectSettings = () => { + const { t } = useTranslation(); + + return ( + <> + + {t("common.head-title", { title: t("settings.project.title") })} + + + + + ); +}; + +export default ProjectSettings; + +ProjectSettings.requireAuth = true; diff --git a/frontend/src/pages/org/[id]/cert-manager/overview.tsx b/frontend/src/pages/org/[id]/cert-manager/overview.tsx index 4b50a3c6e..07f00833e 100644 --- a/frontend/src/pages/org/[id]/cert-manager/overview.tsx +++ b/frontend/src/pages/org/[id]/cert-manager/overview.tsx @@ -1,4 +1,5 @@ import { ProjectType } from "@app/hooks/api/workspace/types"; + import { ProductOverview } from "../secret-manager/overview"; const CertManagerOverviewPage = () => ; diff --git a/frontend/src/pages/org/[id]/cmek/overview.tsx b/frontend/src/pages/org/[id]/cmek/overview.tsx index b1c3b96ec..e6c8066e3 100644 --- a/frontend/src/pages/org/[id]/cmek/overview.tsx +++ b/frontend/src/pages/org/[id]/cmek/overview.tsx @@ -1,4 +1,5 @@ import { ProjectType } from "@app/hooks/api/workspace/types"; + import { ProductOverview } from "../secret-manager/overview"; const CmekManagerOverviewPage = () => ; diff --git a/frontend/src/pages/org/[id]/overview/index.tsx b/frontend/src/pages/org/[id]/overview/index.tsx index 25a2bbcf0..6cdf79247 100644 --- a/frontend/src/pages/org/[id]/overview/index.tsx +++ b/frontend/src/pages/org/[id]/overview/index.tsx @@ -1,6 +1,7 @@ -import { useOrganization } from "@app/context"; -import { useRouter } from "next/router"; import { useEffect } from "react"; +import { useRouter } from "next/router"; + +import { useOrganization } from "@app/context"; // #TODO: Update all the workspaceIds const OrganizationPage = () => { diff --git a/frontend/src/pages/org/[id]/secret-manager/overview.tsx b/frontend/src/pages/org/[id]/secret-manager/overview.tsx index 54f6b7e55..0e5c2cec8 100644 --- a/frontend/src/pages/org/[id]/secret-manager/overview.tsx +++ b/frontend/src/pages/org/[id]/secret-manager/overview.tsx @@ -51,6 +51,7 @@ import { useSubscription, useUser } from "@app/context"; +import { getWorkspaceHomePage } from "@app/helpers/workspace"; import { usePagination, useResetPageHelper } from "@app/hooks"; import { useGetUserWorkspaces, useRegisterUserAction } from "@app/hooks/api"; import { OrderByDirection } from "@app/hooks/api/generic/types"; @@ -59,8 +60,8 @@ import { useFetchServerStatus } from "@app/hooks/api/serverDetails"; import { Workspace } from "@app/hooks/api/types"; import { useUpdateUserProjectFavorites } from "@app/hooks/api/users/mutation"; import { useGetUserProjectFavorites } from "@app/hooks/api/users/queries"; -import { usePopUp } from "@app/hooks/usePopUp"; import { ProjectType } from "@app/hooks/api/workspace/types"; +import { usePopUp } from "@app/hooks/usePopUp"; const features = [ { @@ -603,7 +604,7 @@ export const ProductOverview = ({ type }: Props) => { // eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events
{ - router.push(`/project/${workspace.id}/secrets/overview`); + router.push(getWorkspaceHomePage(workspace)); localStorage.setItem("projectData.id", workspace.id); }} key={workspace.id} @@ -667,7 +668,7 @@ export const ProductOverview = ({ type }: Props) => { // eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events
{ - router.push(`/project/${workspace.id}/secrets/overview`); + router.push(getWorkspaceHomePage(workspace)); localStorage.setItem("projectData.id", workspace.id); }} key={workspace.id} @@ -1047,7 +1048,6 @@ export const ProductOverview = ({ type }: Props) => { onOpenChange={(isOpen) => handlePopUpToggle("upgradePlan", isOpen)} text="You have exceeded the number of projects allowed on the free plan." /> - {/* */}
); }; diff --git a/frontend/src/pages/secret-manager/[id]/allowlist/index.tsx b/frontend/src/pages/secret-manager/[id]/allowlist/index.tsx new file mode 100644 index 000000000..73c25d802 --- /dev/null +++ b/frontend/src/pages/secret-manager/[id]/allowlist/index.tsx @@ -0,0 +1,21 @@ +import { useTranslation } from "react-i18next"; +import Head from "next/head"; + +import { IPAllowlistPage } from "@app/views/Project/IPAllowListPage"; + +const ProjectAllowlist = () => { + const { t } = useTranslation(); + return ( + <> + + {t("common.head-title", { title: t("settings.project.title") })} + + + + + ); +}; + +export default ProjectAllowlist; + +ProjectAllowlist.requireAuth = true; diff --git a/frontend/src/pages/project/[id]/approval/index.tsx b/frontend/src/pages/secret-manager/[id]/approval/index.tsx similarity index 100% rename from frontend/src/pages/project/[id]/approval/index.tsx rename to frontend/src/pages/secret-manager/[id]/approval/index.tsx diff --git a/frontend/src/pages/secret-manager/[id]/identities/[identityId]/index.tsx b/frontend/src/pages/secret-manager/[id]/identities/[identityId]/index.tsx new file mode 100644 index 000000000..ae8b2716a --- /dev/null +++ b/frontend/src/pages/secret-manager/[id]/identities/[identityId]/index.tsx @@ -0,0 +1,20 @@ +import { useTranslation } from "react-i18next"; +import Head from "next/head"; + +import { IdentityDetailsPage } from "@app/views/Project/IdentityDetailsPage"; + +export default function ProjectIdentityDetailsPage() { + const { t } = useTranslation(); + + return ( + <> + + {t("common.head-title", { title: t("settings.members.title") })} + + + + + ); +} + +ProjectIdentityDetailsPage.requireAuth = true; diff --git a/frontend/src/pages/secret-manager/[id]/members/[membershipId]/index.tsx b/frontend/src/pages/secret-manager/[id]/members/[membershipId]/index.tsx new file mode 100644 index 000000000..033aa2b15 --- /dev/null +++ b/frontend/src/pages/secret-manager/[id]/members/[membershipId]/index.tsx @@ -0,0 +1,20 @@ +import { useTranslation } from "react-i18next"; +import Head from "next/head"; + +import { MemberDetailsPage } from "@app/views/Project/MemberDetailsPage"; + +export default function Page() { + const { t } = useTranslation(); + + return ( + <> + + {t("common.head-title", { title: t("settings.members.title") })} + + + + + ); +} + +Page.requireAuth = true; diff --git a/frontend/src/pages/secret-manager/[id]/members/index.tsx b/frontend/src/pages/secret-manager/[id]/members/index.tsx new file mode 100644 index 000000000..4bcbb833e --- /dev/null +++ b/frontend/src/pages/secret-manager/[id]/members/index.tsx @@ -0,0 +1,21 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ +import { useTranslation } from "react-i18next"; +import Head from "next/head"; + +import { MembersPage } from "@app/views/Project/MembersPage"; + +export default function WorkspaceMemberSettings() { + const { t } = useTranslation(); + + return ( + <> + + {t("common.head-title", { title: t("settings.members.title") })} + + + + + ); +} + +WorkspaceMemberSettings.requireAuth = true; diff --git a/frontend/src/pages/secret-manager/[id]/roles/[roleSlug]/index.tsx b/frontend/src/pages/secret-manager/[id]/roles/[roleSlug]/index.tsx new file mode 100644 index 000000000..17c854cee --- /dev/null +++ b/frontend/src/pages/secret-manager/[id]/roles/[roleSlug]/index.tsx @@ -0,0 +1,20 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ +import { useTranslation } from "react-i18next"; +import Head from "next/head"; + +import { RolePage } from "@app/views/Project/RolePage"; + +export default function Role() { + const { t } = useTranslation(); + return ( + <> + + {t("common.head-title", { title: "Project Settings" })} + + + + + ); +} + +Role.requireAuth = true; diff --git a/frontend/src/pages/project/[id]/secret-rotation/index.tsx b/frontend/src/pages/secret-manager/[id]/secret-rotation/index.tsx similarity index 100% rename from frontend/src/pages/project/[id]/secret-rotation/index.tsx rename to frontend/src/pages/secret-manager/[id]/secret-rotation/index.tsx diff --git a/frontend/src/pages/project/[id]/secrets/[env].tsx b/frontend/src/pages/secret-manager/[id]/secrets/[env].tsx similarity index 100% rename from frontend/src/pages/project/[id]/secrets/[env].tsx rename to frontend/src/pages/secret-manager/[id]/secrets/[env].tsx diff --git a/frontend/src/pages/project/[id]/secrets/overview.tsx b/frontend/src/pages/secret-manager/[id]/secrets/overview.tsx similarity index 100% rename from frontend/src/pages/project/[id]/secrets/overview.tsx rename to frontend/src/pages/secret-manager/[id]/secrets/overview.tsx diff --git a/frontend/src/pages/secret-manager/[id]/settings/index.tsx b/frontend/src/pages/secret-manager/[id]/settings/index.tsx new file mode 100644 index 000000000..331ba8cc5 --- /dev/null +++ b/frontend/src/pages/secret-manager/[id]/settings/index.tsx @@ -0,0 +1,22 @@ +import { useTranslation } from "react-i18next"; +import Head from "next/head"; + +import { ProjectSettingsPage } from "@app/views/Settings/ProjectSettingsPage"; + +const ProjectSettings = () => { + const { t } = useTranslation(); + + return ( + <> + + {t("common.head-title", { title: t("settings.project.title") })} + + + + + ); +}; + +export default ProjectSettings; + +ProjectSettings.requireAuth = true; diff --git a/frontend/src/pages/signup/index.tsx b/frontend/src/pages/signup/index.tsx index 0719111d6..fa26437f4 100644 --- a/frontend/src/pages/signup/index.tsx +++ b/frontend/src/pages/signup/index.tsx @@ -16,6 +16,7 @@ import { useServerConfig } from "@app/context"; import { useVerifySignupEmailVerificationCode } from "@app/hooks/api"; import { fetchOrganizations } from "@app/hooks/api/organization/queries"; import { useFetchServerStatus } from "@app/hooks/api/serverDetails"; +import { ProjectType } from "@app/hooks/api/workspace/types"; /** * @returns the signup page @@ -47,7 +48,7 @@ export default function SignUp() { const tryAuth = async () => { try { const userOrgs = await fetchOrganizations(); - router.push(`/org/${userOrgs[0].id}/overview`); + router.push(`/org/${userOrgs[0].id}/${ProjectType.SecretManager}/overview`); } catch (error) { console.log("Error - Not logged in yet"); } @@ -90,7 +91,7 @@ export default function SignUp() { if (!serverDetails?.emailConfigured && step === 5) { const userOrgs = await fetchOrganizations(); - router.push(`/org/${userOrgs[0].id}/overview`); + router.push(`/org/${userOrgs[0].id}/${ProjectType.SecretManager}/overview`); } })(); }, [step]); diff --git a/frontend/src/pages/signupinvite.tsx b/frontend/src/pages/signupinvite.tsx index e64f4d7c0..8a0d712e3 100644 --- a/frontend/src/pages/signupinvite.tsx +++ b/frontend/src/pages/signupinvite.tsx @@ -31,6 +31,7 @@ import { } from "@app/hooks/api/auth/queries"; import { MfaMethod } from "@app/hooks/api/auth/types"; import { fetchOrganizations } from "@app/hooks/api/organization/queries"; +import { ProjectType } from "@app/hooks/api/workspace/types"; import { navigateUserToOrg } from "@app/views/Login/Login.utils"; import { Mfa } from "@app/views/Login/Mfa"; @@ -386,7 +387,7 @@ export default function SignupInvite() { setBackupKeyError, setBackupKeyIssued }); - router.push(`/org/${organizationId}/overview`); + router.push(`/org/${organizationId}/${ProjectType.SecretManager}/overview`); }} size="lg" /> diff --git a/frontend/src/views/Login/Login.utils.tsx b/frontend/src/views/Login/Login.utils.tsx index b0cd3d031..71089532a 100644 --- a/frontend/src/views/Login/Login.utils.tsx +++ b/frontend/src/views/Login/Login.utils.tsx @@ -3,6 +3,7 @@ import { NextRouter, useRouter } from "next/router"; import { useServerConfig } from "@app/context"; import { fetchOrganizations } from "@app/hooks/api/organization/queries"; import { userKeys } from "@app/hooks/api/users"; +import { ProjectType } from "@app/hooks/api/workspace/types"; import { queryClient } from "@app/reactQuery"; export const navigateUserToOrg = async (router: NextRouter, organizationId?: string) => { @@ -20,7 +21,7 @@ export const navigateUserToOrg = async (router: NextRouter, organizationId?: str // user is part of at least 1 non-auth enforced org const userOrg = nonAuthEnforcedOrgs[0] && nonAuthEnforcedOrgs[0].id; localStorage.setItem("orgData.id", userOrg); - router.push(`/org/${userOrg}/overview`); + router.push(`/org/${userOrg}/${ProjectType.SecretManager}/overview`); } else { // user is not part of any non-auth enforced orgs localStorage.removeItem("orgData.id"); diff --git a/frontend/src/views/Org/IdentityPage/components/IdentityProjectsSection/IdentityProjectRow.tsx b/frontend/src/views/Org/IdentityPage/components/IdentityProjectsSection/IdentityProjectRow.tsx index 4cbd1362d..9d3ef00b5 100644 --- a/frontend/src/views/Org/IdentityPage/components/IdentityProjectsSection/IdentityProjectRow.tsx +++ b/frontend/src/views/Org/IdentityPage/components/IdentityProjectsSection/IdentityProjectRow.tsx @@ -33,7 +33,7 @@ export const IdentityProjectRow = ({ membership: { id, createdAt, identity, project, roles }, handlePopUpOpen }: Props) => { - const { workspaces } = useWorkspace(); + const { workspaces,currentWorkspace } = useWorkspace(); const router = useRouter(); const isAccessible = useMemo(() => { @@ -52,7 +52,7 @@ export const IdentityProjectRow = ({ key={`identity-project-membership-${id}`} onClick={() => { if (isAccessible) { - router.push(`/project/${project.id}/members?selectedTab=${TabSections.Identities}`); + router.push(`/${currentWorkspace?.type}/${project.id}/members?selectedTab=${TabSections.Identities}`); return; } diff --git a/frontend/src/views/Org/components/CreateOrgModal.tsx b/frontend/src/views/Org/components/CreateOrgModal.tsx index a5eb4f9e1..d1baf2c9c 100644 --- a/frontend/src/views/Org/components/CreateOrgModal.tsx +++ b/frontend/src/views/Org/components/CreateOrgModal.tsx @@ -7,6 +7,7 @@ import z from "zod"; import { createNotification } from "@app/components/notifications"; import { Button, FormControl, Input, Modal, ModalContent } from "@app/components/v2"; import { useCreateOrg, useSelectOrganization } from "@app/hooks/api"; +import { ProjectType } from "@app/hooks/api/workspace/types"; const schema = z .object({ @@ -57,8 +58,8 @@ export const CreateOrgModal: FC = ({ isOpen, onClose }) => type: "success" }); - if (router.isReady) router.push(`/org/${organization.id}/overview`); - else window.location.href = `/org/${organization.id}/overview`; + if (router.isReady) router.push(`/org/${organization.id}/${ProjectType.SecretManager}/overview`); + else window.location.href = `/org/${organization.id}/${ProjectType.SecretManager}/overview`; localStorage.setItem("orgData.id", organization.id); diff --git a/frontend/src/views/OrgAdminPage/components/OrgAdminProjects/OrgAdminProjects.tsx b/frontend/src/views/OrgAdminPage/components/OrgAdminProjects/OrgAdminProjects.tsx index 1731e6dd5..64838dff4 100644 --- a/frontend/src/views/OrgAdminPage/components/OrgAdminProjects/OrgAdminProjects.tsx +++ b/frontend/src/views/OrgAdminPage/components/OrgAdminProjects/OrgAdminProjects.tsx @@ -52,16 +52,13 @@ export const OrgAdminProjects = withPermission( const projectCount = data?.count || 0; const isEmpty = !isProjectsLoading && projects.length === 0; - const handleAccessProject = async (projectId: string) => { + const handleAccessProject = async (type:string,projectId: string) => { try { await orgAdminAccessProject.mutateAsync({ projectId }); await router.push({ - pathname: "/project/[projectId]/secrets/overview", - query: { - projectId - } + pathname: `/${type}/${projectId}/secrets/overview`, }); } catch { createNotification({ @@ -103,7 +100,7 @@ export const OrgAdminProjects = withPermission( {isProjectsLoading && } {!isProjectsLoading && - projects?.map(({ name, slug, createdAt, id }) => ( + projects?.map(({ name, slug, createdAt,type, id }) => ( {name} {slug} @@ -124,7 +121,7 @@ export const OrgAdminProjects = withPermission( onClick={(e) => { e.stopPropagation(); e.preventDefault(); - handleAccessProject(id); + handleAccessProject(type,id); }} icon={} disabled={ diff --git a/frontend/src/views/Project/CaPage/CaPage.tsx b/frontend/src/views/Project/CaPage/CaPage.tsx index 4afb537f0..9b769bac9 100644 --- a/frontend/src/views/Project/CaPage/CaPage.tsx +++ b/frontend/src/views/Project/CaPage/CaPage.tsx @@ -18,6 +18,7 @@ import { import { ProjectPermissionActions, ProjectPermissionSub, useWorkspace } from "@app/context"; import { withProjectPermission } from "@app/hoc"; import { useDeleteCa, useGetCaById } from "@app/hooks/api"; +import { ProjectType } from "@app/hooks/api/workspace/types"; import { usePopUp } from "@app/hooks/usePopUp"; import { CaModal } from "@app/views/Project/CertificatesPage/components/CaTab/components/CaModal"; @@ -60,7 +61,7 @@ export const CaPage = withProjectPermission( }); handlePopUpClose("deleteCa"); - router.push(`/project/${projectId}/certificates`); + router.push(`/${ProjectType.CertificateManager}/${projectId}/certificates`); } catch (err) { console.error(err); createNotification({ @@ -78,7 +79,7 @@ export const CaPage = withProjectPermission( variant="link" type="submit" leftIcon={} - onClick={() => router.push(`/project/${projectId}/certificates`)} + onClick={() => router.push(`/${ProjectType.CertificateManager}/${projectId}/certificates`)} className="mb-4" > Certificate Authorities diff --git a/frontend/src/views/Project/CertificatesPage/components/CaTab/components/CaTable.tsx b/frontend/src/views/Project/CertificatesPage/components/CaTab/components/CaTable.tsx index 35c034f34..ec535e44b 100644 --- a/frontend/src/views/Project/CertificatesPage/components/CaTab/components/CaTable.tsx +++ b/frontend/src/views/Project/CertificatesPage/components/CaTab/components/CaTable.tsx @@ -34,6 +34,7 @@ import { caTypeToNameMap, getCaStatusBadgeVariant } from "@app/hooks/api/ca/constants"; +import { ProjectType } from "@app/hooks/api/workspace/types"; import { UsePopUpState } from "@app/hooks/usePopUp"; type Props = { @@ -80,7 +81,7 @@ export const CaTable = ({ handlePopUpOpen }: Props) => { router.push(`/project/${currentWorkspace?.id}/ca/${ca.id}`)} + onClick={() => router.push(`/${ProjectType.CertificateManager}/${currentWorkspace?.id}/ca/${ca.id}`)} > {ca.friendlyName} diff --git a/frontend/src/views/Project/CertificatesPage/components/PkiAlertsTab/components/PkiCollectionModal.tsx b/frontend/src/views/Project/CertificatesPage/components/PkiAlertsTab/components/PkiCollectionModal.tsx index 78a2bdded..95d6aa8b8 100644 --- a/frontend/src/views/Project/CertificatesPage/components/PkiAlertsTab/components/PkiCollectionModal.tsx +++ b/frontend/src/views/Project/CertificatesPage/components/PkiAlertsTab/components/PkiCollectionModal.tsx @@ -12,6 +12,7 @@ import { useGetPkiCollectionById, useUpdatePkiCollection } from "@app/hooks/api"; +import { ProjectType } from "@app/hooks/api/workspace/types"; import { UsePopUpState } from "@app/hooks/usePopUp"; const schema = z.object({ @@ -81,7 +82,7 @@ export const PkiCollectionModal = ({ popUp, handlePopUpToggle }: Props) => { projectId }); - router.push(`/project/${projectId}/pki-collections/${createdId}`); + router.push(`/${ProjectType.CertificateManager}/${projectId}/pki-collections/${createdId}`); } handlePopUpToggle("pkiCollection", false); diff --git a/frontend/src/views/Project/CertificatesPage/components/PkiAlertsTab/components/PkiCollectionTable.tsx b/frontend/src/views/Project/CertificatesPage/components/PkiAlertsTab/components/PkiCollectionTable.tsx index a27662449..cd5b64925 100644 --- a/frontend/src/views/Project/CertificatesPage/components/PkiAlertsTab/components/PkiCollectionTable.tsx +++ b/frontend/src/views/Project/CertificatesPage/components/PkiAlertsTab/components/PkiCollectionTable.tsx @@ -21,6 +21,7 @@ import { } from "@app/components/v2"; import { ProjectPermissionActions, ProjectPermissionSub, useWorkspace } from "@app/context"; import { useListWorkspacePkiCollections } from "@app/hooks/api"; +import { ProjectType } from "@app/hooks/api/workspace/types"; import { UsePopUpState } from "@app/hooks/usePopUp"; type Props = { @@ -59,7 +60,7 @@ export const PkiCollectionTable = ({ handlePopUpOpen }: Props) => { className="h-10 cursor-pointer transition-colors duration-100 hover:bg-mineshaft-700" key={`pki-collection-${pkiCollection.id}`} onClick={() => - router.push(`/project/${projectId}/pki-collections/${pkiCollection.id}`) + router.push(`/${ProjectType.CertificateManager}/${projectId}/pki-collections/${pkiCollection.id}`) } > {pkiCollection.name} diff --git a/frontend/src/views/Project/IdentityDetailsPage/IdentityDetailPage.tsx b/frontend/src/views/Project/IdentityDetailsPage/IdentityDetailPage.tsx index d16bd64ae..238c24f42 100644 --- a/frontend/src/views/Project/IdentityDetailsPage/IdentityDetailPage.tsx +++ b/frontend/src/views/Project/IdentityDetailsPage/IdentityDetailPage.tsx @@ -48,7 +48,7 @@ export const IdentityDetailsPage = withProjectPermission( type: "success" }); handlePopUpClose("deleteIdentity"); - router.push(`/project/${workspaceId}/members?selectedTab=identities`); + router.push(`/${currentWorkspace?.type}/${workspaceId}/members?selectedTab=identities`); } catch (err) { console.error(err); const error = err as any; @@ -77,7 +77,7 @@ export const IdentityDetailsPage = withProjectPermission( type="submit" leftIcon={} onClick={() => { - router.push(`/project/${workspaceId}/members?selectedTab=identities`); + router.push(`/${currentWorkspace?.type}/${workspaceId}/members?selectedTab=identities`); }} className="mb-4" > diff --git a/frontend/src/views/Project/MemberDetailsPage/MemberDetailPage.tsx b/frontend/src/views/Project/MemberDetailsPage/MemberDetailPage.tsx index 8948e91fe..6c08b7da8 100644 --- a/frontend/src/views/Project/MemberDetailsPage/MemberDetailPage.tsx +++ b/frontend/src/views/Project/MemberDetailsPage/MemberDetailPage.tsx @@ -58,7 +58,7 @@ export const MemberDetailsPage = withProjectPermission( text: "Successfully removed user from project", type: "success" }); - router.push(`/project/${currentWorkspace?.id}/members`); + router.push(`/${currentWorkspace.type}/${currentWorkspace?.id}/members`); } catch (error) { console.error(error); createNotification({ @@ -85,7 +85,7 @@ export const MemberDetailsPage = withProjectPermission( type="submit" leftIcon={} onClick={() => { - router.push(`/project/${workspaceId}/members`); + router.push(`/${currentWorkspace?.type}/${workspaceId}/members`); }} className="mb-4" > diff --git a/frontend/src/views/Project/MembersPage/components/IdentityTab/IdentityTab.tsx b/frontend/src/views/Project/MembersPage/components/IdentityTab/IdentityTab.tsx index 362c15656..42ae5cfae 100644 --- a/frontend/src/views/Project/MembersPage/components/IdentityTab/IdentityTab.tsx +++ b/frontend/src/views/Project/MembersPage/components/IdentityTab/IdentityTab.tsx @@ -244,10 +244,10 @@ export const IdentityTab = withProjectPermission( tabIndex={0} onKeyDown={(evt) => { if (evt.key === "Enter") { - router.push(`/project/${workspaceId}/identities/${id}`); + router.push(`/${currentWorkspace?.type}/${workspaceId}/identities/${id}`); } }} - onClick={() => router.push(`/project/${workspaceId}/identities/${id}`)} + onClick={() => router.push(`/${currentWorkspace?.type}/${workspaceId}/identities/${id}`)} > {name} diff --git a/frontend/src/views/Project/MembersPage/components/MembersTab/components/MembersTable.tsx b/frontend/src/views/Project/MembersPage/components/MembersTab/components/MembersTable.tsx index 17d1d523b..984ae28fd 100644 --- a/frontend/src/views/Project/MembersPage/components/MembersTab/components/MembersTable.tsx +++ b/frontend/src/views/Project/MembersPage/components/MembersTab/components/MembersTable.tsx @@ -212,10 +212,10 @@ export const MembersTable = ({ handlePopUpOpen }: Props) => { tabIndex={0} onKeyDown={(evt) => { if (evt.key === "Enter") { - router.push(`/project/${workspaceId}/members/${membershipId}`); + router.push(`/${currentWorkspace?.type}/${workspaceId}/members/${membershipId}`); } }} - onClick={() => router.push(`/project/${workspaceId}/members/${membershipId}`)} + onClick={() => router.push(`/${currentWorkspace?.type}/${workspaceId}/members/${membershipId}`)} > {name} {email} diff --git a/frontend/src/views/Project/MembersPage/components/ProjectRoleListTab/components/ProjectRoleList/ProjectRoleList.tsx b/frontend/src/views/Project/MembersPage/components/ProjectRoleListTab/components/ProjectRoleList/ProjectRoleList.tsx index 3394cd619..1d4314b21 100644 --- a/frontend/src/views/Project/MembersPage/components/ProjectRoleListTab/components/ProjectRoleList/ProjectRoleList.tsx +++ b/frontend/src/views/Project/MembersPage/components/ProjectRoleListTab/components/ProjectRoleList/ProjectRoleList.tsx @@ -92,7 +92,7 @@ export const ProjectRoleList = () => { router.push(`/project/${projectId}/roles/${slug}`)} + onClick={() => router.push(`/${currentWorkspace?.type}/${projectId}/roles/${slug}`)} > {name} {slug} @@ -115,7 +115,7 @@ export const ProjectRoleList = () => { )} onClick={(e) => { e.stopPropagation(); - router.push(`/project/${projectId}/roles/${slug}`); + router.push(`/${currentWorkspace?.type}/${projectId}/roles/${slug}`); }} disabled={!isAllowed} > diff --git a/frontend/src/views/Project/PkiCollectionPage/PkiCollectionPage.tsx b/frontend/src/views/Project/PkiCollectionPage/PkiCollectionPage.tsx index 6964279d0..3e455f339 100644 --- a/frontend/src/views/Project/PkiCollectionPage/PkiCollectionPage.tsx +++ b/frontend/src/views/Project/PkiCollectionPage/PkiCollectionPage.tsx @@ -19,6 +19,7 @@ import { ProjectPermissionActions, ProjectPermissionSub, useWorkspace } from "@a import { withProjectPermission } from "@app/hoc"; import { useDeletePkiCollection, useGetPkiCollectionById } from "@app/hooks/api"; import { PkiItemType } from "@app/hooks/api/pkiCollections/constants"; +import { ProjectType } from "@app/hooks/api/workspace/types"; import { usePopUp } from "@app/hooks/usePopUp"; import { PkiCollectionModal } from "../CertificatesPage/components/PkiAlertsTab/components/PkiCollectionModal"; @@ -53,7 +54,7 @@ export const PkiCollectionPage = withProjectPermission( type: "success" }); handlePopUpClose("deletePkiCollection"); - router.push(`/project/${projectId}/certificates`); + router.push(`/${ProjectType.CertificateManager}/${projectId}/certificates`); } catch (err) { console.error(err); } @@ -68,7 +69,7 @@ export const PkiCollectionPage = withProjectPermission( type="submit" leftIcon={} onClick={() => { - router.push(`/project/${projectId}/certificates`); + router.push(`/${ProjectType.CertificateManager}/${projectId}/certificates`); }} className="mb-4" > diff --git a/frontend/src/views/Project/RolePage/RolePage.tsx b/frontend/src/views/Project/RolePage/RolePage.tsx index a3b6e2041..6d867822b 100644 --- a/frontend/src/views/Project/RolePage/RolePage.tsx +++ b/frontend/src/views/Project/RolePage/RolePage.tsx @@ -53,7 +53,7 @@ export const RolePage = withProjectPermission( type: "success" }); handlePopUpClose("deleteRole"); - router.push(`/project/${projectId}/members?selectedTab=${TabSections.Roles}`); + router.push(`/${currentWorkspace?.type}/${projectId}/members?selectedTab=${TabSections.Roles}`); } catch (err) { console.error(err); const error = err as any; @@ -77,7 +77,7 @@ export const RolePage = withProjectPermission( type="submit" leftIcon={} onClick={() => - router.push(`/project/${projectId}/members?selectedTab=${TabSections.Roles}`) + router.push(`/${currentWorkspace?.type}/${projectId}/members?selectedTab=${TabSections.Roles}`) } className="mb-4" > diff --git a/frontend/src/views/Project/RolePage/components/RoleModal.tsx b/frontend/src/views/Project/RolePage/components/RoleModal.tsx index cf8cab03b..d65910f36 100644 --- a/frontend/src/views/Project/RolePage/components/RoleModal.tsx +++ b/frontend/src/views/Project/RolePage/components/RoleModal.tsx @@ -99,7 +99,7 @@ export const RoleModal = ({ popUp, handlePopUpToggle }: Props) => { permissions: [] }); - router.push(`/project/${currentWorkspace?.id}/roles/${newRole.slug}`); + router.push(`/${currentWorkspace?.type}/${currentWorkspace?.id}/roles/${newRole.slug}`); handlePopUpToggle("role", false); } diff --git a/frontend/src/views/SecretMainPage/SecretMainPage.tsx b/frontend/src/views/SecretMainPage/SecretMainPage.tsx index 85d25a56f..3ad900ecb 100644 --- a/frontend/src/views/SecretMainPage/SecretMainPage.tsx +++ b/frontend/src/views/SecretMainPage/SecretMainPage.tsx @@ -35,6 +35,7 @@ import { import { useGetProjectSecretsDetails } from "@app/hooks/api/dashboard"; import { DashboardSecretsOrderBy } from "@app/hooks/api/dashboard/types"; import { OrderByDirection } from "@app/hooks/api/generic/types"; +import { ProjectType } from "@app/hooks/api/workspace/types"; import { DynamicSecretListView } from "@app/views/SecretMainPage/components/DynamicSecretListView"; import { FolderListView } from "@app/views/SecretMainPage/components/FolderListView"; import { SecretImportListView } from "@app/views/SecretMainPage/components/SecretImportListView"; @@ -142,7 +143,7 @@ const SecretMainPageContent = () => { !currentWorkspace?.environments.find((env) => env.slug === environment) && router.isReady ) { - router.push(`/project/${workspaceId}/secrets/overview`); + router.push(`/${ProjectType.SecretManager}/${workspaceId}/secrets/overview`); createNotification({ text: "No environment found with given slug", type: "error" diff --git a/frontend/src/views/SecretOverviewPage/SecretOverviewPage.tsx b/frontend/src/views/SecretOverviewPage/SecretOverviewPage.tsx index 6bd803f64..1162485cf 100644 --- a/frontend/src/views/SecretOverviewPage/SecretOverviewPage.tsx +++ b/frontend/src/views/SecretOverviewPage/SecretOverviewPage.tsx @@ -68,7 +68,7 @@ import { OrderByDirection } from "@app/hooks/api/generic/types"; import { useUpdateFolderBatch } from "@app/hooks/api/secretFolders/queries"; import { TUpdateFolderBatchDTO } from "@app/hooks/api/secretFolders/types"; import { SecretType, SecretV3RawSanitized, TSecretFolder } from "@app/hooks/api/types"; -import { ProjectVersion } from "@app/hooks/api/workspace/types"; +import { ProjectType, ProjectVersion } from "@app/hooks/api/workspace/types"; import { useDynamicSecretOverview, useFolderOverview, useSecretOverview } from "@app/hooks/utils"; import { SecretOverviewDynamicSecretRow } from "@app/views/SecretOverviewPage/components/SecretOverviewDynamicSecretRow"; import { @@ -170,7 +170,7 @@ export const SecretOverviewPage = () => { useEffect(() => { if (!isWorkspaceLoading && !workspaceId && router.isReady) { - router.push(`/org/${currentOrg?.id}/overview`); + router.push(`/org/${currentOrg?.id}/${ProjectType.SecretManager}/overview`); } }, [isWorkspaceLoading, workspaceId, router.isReady]); @@ -508,7 +508,7 @@ export const SecretOverviewPage = () => { const envIndex = visibleEnvs.findIndex((el) => slug === el.slug); if (envIndex !== -1) { router.push({ - pathname: "/project/[id]/secrets/[env]", + pathname: `/${ProjectType.SecretManager}/[id]/secrets/[env]`, query }); } diff --git a/frontend/src/views/Settings/ProjectSettingsPage/components/DeleteProjectSection/DeleteProjectSection.tsx b/frontend/src/views/Settings/ProjectSettingsPage/components/DeleteProjectSection/DeleteProjectSection.tsx index 2f4cb3091..72dbe2992 100644 --- a/frontend/src/views/Settings/ProjectSettingsPage/components/DeleteProjectSection/DeleteProjectSection.tsx +++ b/frontend/src/views/Settings/ProjectSettingsPage/components/DeleteProjectSection/DeleteProjectSection.tsx @@ -14,6 +14,7 @@ import { } from "@app/context"; import { useToggle } from "@app/hooks"; import { useDeleteWorkspace, useGetWorkspaceUsers, useLeaveProject } from "@app/hooks/api"; +import { ProjectType } from "@app/hooks/api/workspace/types"; import { usePopUp } from "@app/hooks/usePopUp"; export const DeleteProjectSection = () => { @@ -63,7 +64,7 @@ export const DeleteProjectSection = () => { type: "success" }); - router.push(`/org/${orgId}/overview`); + router.push(`/org/${orgId}/${ProjectType.SecretManager}/overview`); handlePopUpClose("deleteWorkspace"); } catch (err) { console.error(err); @@ -120,7 +121,7 @@ export const DeleteProjectSection = () => { workspaceId: currentWorkspace.id }); - router.push(`/org/${currentOrg.id}/overview`); + router.push(`/org/${currentOrg.id}/${ProjectType.SecretManager}/overview`); } catch (err) { console.error(err); createNotification({ diff --git a/frontend/src/views/Signup/components/BackupPDFStep/BackupPDFStep.tsx b/frontend/src/views/Signup/components/BackupPDFStep/BackupPDFStep.tsx index b43018d47..1216e9d62 100644 --- a/frontend/src/views/Signup/components/BackupPDFStep/BackupPDFStep.tsx +++ b/frontend/src/views/Signup/components/BackupPDFStep/BackupPDFStep.tsx @@ -5,6 +5,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import issueBackupKey from "@app/components/utilities/cryptography/issueBackupKey"; import { Button } from "@app/components/v2"; +import { ProjectType } from "@app/hooks/api/workspace/types"; interface DownloadBackupPDFStepProps { email: string; @@ -49,7 +50,7 @@ export const BackupPDFStep = ({ email, password, name }: DownloadBackupPDFStepPr setBackupKeyIssued: () => {} }); - router.push(`/org/${localStorage.getItem("orgData.id")}/overview`); + router.push(`/org/${localStorage.getItem("orgData.id")}/${ProjectType.SecretManager}/overview`); }} size="sm" isFullWidth diff --git a/frontend/src/views/admin/DashboardPage/DashboardPage.tsx b/frontend/src/views/admin/DashboardPage/DashboardPage.tsx index ac87596ae..1f89ed357 100644 --- a/frontend/src/views/admin/DashboardPage/DashboardPage.tsx +++ b/frontend/src/views/admin/DashboardPage/DashboardPage.tsx @@ -27,6 +27,7 @@ import { useGetServerRootKmsEncryptionDetails, useUpdateServerConfig } from "@app/hooks/api"; +import { ProjectType } from "@app/hooks/api/workspace/types"; import { AuthPanel } from "./AuthPanel"; import { EncryptionPanel } from "./EncryptionPanel"; @@ -98,7 +99,7 @@ export const AdminDashboardPage = () => { if (isNotAllowed && !isUserLoading) { if (orgs?.length) { localStorage.setItem("orgData.id", orgs?.[0]?.id); - router.push(`/org/${orgs?.[0]?.id}/overview`); + router.push(`/org/${orgs?.[0]?.id}/${ProjectType.SecretManager}/overview`); } } }, [isNotAllowed, isUserLoading]);