feat: removed last bit of workspace in frontend. Fatality!

This commit is contained in:
=
2025-09-16 00:08:41 +05:30
parent 37a80fa1ac
commit ac80242749
356 changed files with 1788 additions and 1890 deletions
+7 -7
View File
@@ -4,12 +4,12 @@ import { Link, Outlet } from "@tanstack/react-router";
import { motion } from "framer-motion";
import { Lottie, Menu, MenuGroup, MenuItem } from "@app/components/v2";
import { useProjectPermission, useWorkspace } from "@app/context";
import { useProjectPermission, useProject } from "@app/context";
import { AssumePrivilegeModeBanner } from "../ProjectLayout/components/AssumePrivilegeModeBanner";
export const KmsLayout = () => {
const { currentWorkspace } = useWorkspace();
const { currentProject } = useProject();
const { assumedPrivilegeDetails } = useProjectPermission();
return (
@@ -34,7 +34,7 @@ export const KmsLayout = () => {
<Link
to="/projects/kms/$projectId/overview"
params={{
projectId: currentWorkspace.id
projectId: currentProject.id
}}
>
{({ isActive }) => (
@@ -51,7 +51,7 @@ export const KmsLayout = () => {
<Link
to="/projects/kms/$projectId/kmip"
params={{
projectId: currentWorkspace.id
projectId: currentProject.id
}}
>
{({ isActive }) => (
@@ -70,7 +70,7 @@ export const KmsLayout = () => {
<Link
to="/projects/kms/$projectId/access-management"
params={{
projectId: currentWorkspace.id
projectId: currentProject.id
}}
>
{({ isActive }) => (
@@ -87,7 +87,7 @@ export const KmsLayout = () => {
<Link
to="/projects/kms/$projectId/audit-logs"
params={{
projectId: currentWorkspace.id
projectId: currentProject.id
}}
>
{({ isActive }) => (
@@ -104,7 +104,7 @@ export const KmsLayout = () => {
<Link
to="/projects/kms/$projectId/settings"
params={{
projectId: currentWorkspace.id
projectId: currentProject.id
}}
>
{({ isActive }) => (
@@ -40,7 +40,7 @@ import { envConfig } from "@app/config/env";
import { useOrganization, useSubscription, useUser } from "@app/context";
import { isInfisicalCloud } from "@app/helpers/platform";
import { useToggle } from "@app/hooks";
import { useGetOrganizations, useLogoutUser, workspaceKeys } from "@app/hooks/api";
import { useGetOrganizations, useLogoutUser, projectKeys } from "@app/hooks/api";
import { authKeys, selectOrganization } from "@app/hooks/api/auth/queries";
import { MfaMethod } from "@app/hooks/api/auth/types";
import { getAuthToken } from "@app/hooks/api/reactQuery";
@@ -135,7 +135,7 @@ export const Navbar = () => {
const handleOrgChange = async (orgId: string) => {
queryClient.removeQueries({ queryKey: authKeys.getAuthToken });
queryClient.removeQueries({ queryKey: workspaceKeys.getAllUserWorkspace() });
queryClient.removeQueries({ queryKey: projectKeys.getAllUserProjects() });
const { token, isMfaEnabled, mfaMethod } = await selectOrganization({
organizationId: orgId
@@ -16,12 +16,12 @@ import { Link, Outlet } from "@tanstack/react-router";
import { motion } from "framer-motion";
import { Lottie, Menu, MenuGroup, MenuItem } from "@app/components/v2";
import { useProjectPermission, useWorkspace } from "@app/context";
import { useProjectPermission, useProject } from "@app/context";
import { AssumePrivilegeModeBanner } from "../ProjectLayout/components/AssumePrivilegeModeBanner";
export const PkiManagerLayout = () => {
const { currentWorkspace } = useWorkspace();
const { currentProject } = useProject();
const { assumedPrivilegeDetails } = useProjectPermission();
const { t } = useTranslation();
@@ -48,7 +48,7 @@ export const PkiManagerLayout = () => {
<Link
to="/projects/cert-management/$projectId/subscribers"
params={{
projectId: currentWorkspace.id
projectId: currentProject.id
}}
>
{({ isActive }) => (
@@ -65,7 +65,7 @@ export const PkiManagerLayout = () => {
<Link
to="/projects/cert-management/$projectId/certificate-templates"
params={{
projectId: currentWorkspace.id
projectId: currentProject.id
}}
>
{({ isActive }) => (
@@ -82,7 +82,7 @@ export const PkiManagerLayout = () => {
<Link
to="/projects/cert-management/$projectId/certificates"
params={{
projectId: currentWorkspace.id
projectId: currentProject.id
}}
>
{({ isActive }) => (
@@ -99,7 +99,7 @@ export const PkiManagerLayout = () => {
<Link
to="/projects/cert-management/$projectId/certificate-authorities"
params={{
projectId: currentWorkspace.id
projectId: currentProject.id
}}
>
{({ isActive }) => (
@@ -116,7 +116,7 @@ export const PkiManagerLayout = () => {
<Link
to="/projects/cert-management/$projectId/alerting"
params={{
projectId: currentWorkspace.id
projectId: currentProject.id
}}
>
{({ isActive }) => (
@@ -135,7 +135,7 @@ export const PkiManagerLayout = () => {
<Link
to="/projects/cert-management/$projectId/access-management"
params={{
projectId: currentWorkspace.id
projectId: currentProject.id
}}
>
{({ isActive }) => (
@@ -152,7 +152,7 @@ export const PkiManagerLayout = () => {
<Link
to="/projects/cert-management/$projectId/audit-logs"
params={{
projectId: currentWorkspace.id
projectId: currentProject.id
}}
>
{({ isActive }) => (
@@ -169,7 +169,7 @@ export const PkiManagerLayout = () => {
<Link
to="/projects/cert-management/$projectId/settings"
params={{
projectId: currentWorkspace.id
projectId: currentProject.id
}}
>
{({ isActive }) => (
@@ -2,13 +2,13 @@ import { faInfoCircle } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { Button } from "@app/components/v2";
import { useProjectPermission, useWorkspace } from "@app/context";
import { useProjectPermission, useProject } from "@app/context";
import { getProjectHomePage } from "@app/helpers/project";
import { useRemoveAssumeProjectPrivilege } from "@app/hooks/api";
import { ActorType } from "@app/hooks/api/auditLogs/enums";
export const AssumePrivilegeModeBanner = () => {
const { currentWorkspace } = useWorkspace();
const { currentProject } = useProject();
const exitAssumePrivilegeMode = useRemoveAssumeProjectPrivilege();
const { assumedPrivilegeDetails } = useProjectPermission();
@@ -32,15 +32,12 @@ export const AssumePrivilegeModeBanner = () => {
onClick={() => {
exitAssumePrivilegeMode.mutate(
{
projectId: currentWorkspace.id
projectId: currentProject.id
},
{
onSuccess: () => {
const url = getProjectHomePage(
currentWorkspace.type,
currentWorkspace.environments
);
window.location.href = url.replace("$projectId", currentWorkspace.id);
const url = getProjectHomePage(currentProject.type, currentProject.environments);
window.location.href = url.replace("$projectId", currentProject.id);
}
}
);
@@ -29,20 +29,20 @@ import {
OrgPermissionSubjects,
useOrganization,
useSubscription,
useWorkspace
useProject
} from "@app/context";
import { getProjectHomePage } from "@app/helpers/project";
import { usePopUp } from "@app/hooks";
import { useGetUserWorkspaces } from "@app/hooks/api";
import { useGetUserProjects } from "@app/hooks/api";
import { useUpdateUserProjectFavorites } from "@app/hooks/api/users/mutation";
import { useGetUserProjectFavorites } from "@app/hooks/api/users/queries";
import { Project } from "@app/hooks/api/workspace/types";
import { Project } from "@app/hooks/api/projects/types";
export const ProjectSelect = () => {
const [searchProject, setSearchProject] = useState("");
const { currentWorkspace } = useWorkspace();
const { currentProject: currentWorkspace } = useProject();
const { currentOrg } = useOrganization();
const { data: workspaces = [] } = useGetUserWorkspaces();
const { data: projects = [] } = useGetUserProjects();
const { data: projectFavorites } = useGetUserProjectFavorites(currentOrg.id);
const { subscription } = useSubscription();
@@ -86,8 +86,8 @@ export const ProjectSelect = () => {
"upgradePlan"
] as const);
const projects = useMemo(() => {
const projectOptions = workspaces
const projectsSortedByFav = useMemo(() => {
const projectOptions = projects
.map((w): Project & { isFavorite: boolean } => ({
...w,
isFavorite: Boolean(projectFavorites?.includes(w.id))
@@ -95,7 +95,7 @@ export const ProjectSelect = () => {
.sort((a, b) => Number(b.isFavorite) - Number(a.isFavorite));
return projectOptions;
}, [workspaces, projectFavorites, currentWorkspace]);
}, [projects, projectFavorites, currentWorkspace]);
return (
<div className="-mr-2 flex w-full items-center gap-1">
@@ -147,7 +147,7 @@ export const ProjectSelect = () => {
/>
</div>
<div className="thin-scrollbar max-h-80 overflow-auto">
{projects
{projectsSortedByFav
?.filter((el) => el.name?.toLowerCase().includes(searchProject.toLowerCase()))
?.map((workspace) => {
return (
@@ -15,7 +15,7 @@ import { Link, Outlet, useLocation } from "@tanstack/react-router";
import { motion } from "framer-motion";
import { Badge, Lottie, Menu, MenuGroup, MenuItem } from "@app/components/v2";
import { useProjectPermission, useWorkspace } from "@app/context";
import { useProjectPermission, useProject } from "@app/context";
import {
useGetAccessRequestsCount,
useGetSecretApprovalRequestCount,
@@ -25,16 +25,15 @@ import {
import { AssumePrivilegeModeBanner } from "../ProjectLayout/components/AssumePrivilegeModeBanner";
export const SecretManagerLayout = () => {
const { currentWorkspace } = useWorkspace();
const { currentProject, projectId } = useProject();
const { assumedPrivilegeDetails } = useProjectPermission();
const { t } = useTranslation();
const workspaceId = currentWorkspace?.id || "";
const projectSlug = currentWorkspace?.slug || "";
const projectSlug = currentProject?.slug || "";
const location = useLocation();
const { data: secretApprovalReqCount } = useGetSecretApprovalRequestCount({
workspaceId
projectId
});
const { data: accessApprovalRequestCount } = useGetAccessRequestsCount({
projectSlug
@@ -42,7 +41,7 @@ export const SecretManagerLayout = () => {
// we only show the secret rotations v1 tab if they have existing rotations
const { data: secretRotations } = useGetSecretRotations({
workspaceId,
workspaceId: projectId,
options: {
refetchOnMount: false
}
@@ -74,9 +73,9 @@ export const SecretManagerLayout = () => {
<Link
to="/projects/secret-management/$projectId/overview"
params={{
projectId: currentWorkspace.id,
...(currentWorkspace.environments.length
? { envSlug: currentWorkspace.environments[0]?.slug }
projectId: currentProject.id,
...(currentProject.environments.length
? { envSlug: currentProject.environments[0]?.slug }
: {})
}}
>
@@ -85,7 +84,7 @@ export const SecretManagerLayout = () => {
isSelected={
isActive ||
location.pathname.startsWith(
`/projects/secret-management/${currentWorkspace.id}/overview`
`/projects/secret-management/${currentProject.id}/overview`
)
}
>
@@ -101,7 +100,7 @@ export const SecretManagerLayout = () => {
<Link
to="/projects/secret-management/$projectId/integrations"
params={{
projectId: currentWorkspace.id
projectId: currentProject.id
}}
>
{({ isActive }) => (
@@ -119,7 +118,7 @@ export const SecretManagerLayout = () => {
<Link
to="/projects/secret-management/$projectId/secret-rotation"
params={{
projectId: currentWorkspace.id
projectId: currentProject.id
}}
>
{({ isActive }) => (
@@ -137,7 +136,7 @@ export const SecretManagerLayout = () => {
<Link
to="/projects/secret-management/$projectId/approval"
params={{
projectId: currentWorkspace.id
projectId: currentProject.id
}}
>
{({ isActive }) => (
@@ -164,7 +163,7 @@ export const SecretManagerLayout = () => {
<Link
to="/projects/secret-management/$projectId/access-management"
params={{
projectId: currentWorkspace.id
projectId: currentProject.id
}}
>
{({ isActive }) => (
@@ -181,7 +180,7 @@ export const SecretManagerLayout = () => {
<Link
to="/projects/secret-management/$projectId/audit-logs"
params={{
projectId: currentWorkspace.id
projectId: currentProject.id
}}
>
{({ isActive }) => (
@@ -198,7 +197,7 @@ export const SecretManagerLayout = () => {
<Link
to="/projects/secret-management/$projectId/settings"
params={{
projectId: currentWorkspace.id
projectId: currentProject.id
}}
>
{({ isActive }) => (
@@ -15,7 +15,7 @@ import {
ProjectPermissionSub,
useProjectPermission,
useSubscription,
useWorkspace
useProject
} from "@app/context";
import { ProjectPermissionSecretScanningFindingActions } from "@app/context/ProjectPermissionContext/types";
import { useGetSecretScanningUnresolvedFindingCount } from "@app/hooks/api/secretScanningV2";
@@ -23,14 +23,14 @@ import { useGetSecretScanningUnresolvedFindingCount } from "@app/hooks/api/secre
import { AssumePrivilegeModeBanner } from "../ProjectLayout/components/AssumePrivilegeModeBanner";
export const SecretScanningLayout = () => {
const { currentWorkspace } = useWorkspace();
const { currentProject } = useProject();
const { assumedPrivilegeDetails } = useProjectPermission();
const { permission } = useProjectPermission();
const { subscription } = useSubscription();
const { data: unresolvedFindings } = useGetSecretScanningUnresolvedFindingCount(
currentWorkspace.id,
currentProject.id,
{
enabled:
subscription.secretScanning &&
@@ -64,7 +64,7 @@ export const SecretScanningLayout = () => {
<Link
to="/projects/secret-scanning/$projectId/data-sources"
params={{
projectId: currentWorkspace.id
projectId: currentProject.id
}}
>
{({ isActive }) => (
@@ -81,7 +81,7 @@ export const SecretScanningLayout = () => {
<Link
to="/projects/secret-scanning/$projectId/findings"
params={{
projectId: currentWorkspace.id
projectId: currentProject.id
}}
>
{({ isActive }) => (
@@ -105,7 +105,7 @@ export const SecretScanningLayout = () => {
<Link
to="/projects/secret-scanning/$projectId/access-management"
params={{
projectId: currentWorkspace.id
projectId: currentProject.id
}}
>
{({ isActive }) => (
@@ -122,7 +122,7 @@ export const SecretScanningLayout = () => {
<Link
to="/projects/secret-scanning/$projectId/audit-logs"
params={{
projectId: currentWorkspace.id
projectId: currentProject.id
}}
>
{({ isActive }) => (
@@ -139,7 +139,7 @@ export const SecretScanningLayout = () => {
<Link
to="/projects/secret-scanning/$projectId/settings"
params={{
projectId: currentWorkspace.id
projectId: currentProject.id
}}
>
{({ isActive }) => (
+7 -7
View File
@@ -16,13 +16,13 @@ import {
ProjectPermissionActions,
ProjectPermissionSub,
useProjectPermission,
useWorkspace
useProject
} from "@app/context";
import { AssumePrivilegeModeBanner } from "../ProjectLayout/components/AssumePrivilegeModeBanner";
export const SshLayout = () => {
const { currentWorkspace } = useWorkspace();
const { currentProject } = useProject();
const { assumedPrivilegeDetails } = useProjectPermission();
return (
@@ -47,7 +47,7 @@ export const SshLayout = () => {
<Link
to="/projects/ssh/$projectId/overview"
params={{
projectId: currentWorkspace.id
projectId: currentProject.id
}}
>
{({ isActive }) => (
@@ -70,7 +70,7 @@ export const SshLayout = () => {
<Link
to="/projects/ssh/$projectId/cas"
params={{
projectId: currentWorkspace.id
projectId: currentProject.id
}}
>
{({ isActive }) => (
@@ -93,7 +93,7 @@ export const SshLayout = () => {
<Link
to="/projects/ssh/$projectId/access-management"
params={{
projectId: currentWorkspace.id
projectId: currentProject.id
}}
>
{({ isActive }) => (
@@ -110,7 +110,7 @@ export const SshLayout = () => {
<Link
to="/projects/ssh/$projectId/audit-logs"
params={{
projectId: currentWorkspace.id
projectId: currentProject.id
}}
>
{({ isActive }) => (
@@ -127,7 +127,7 @@ export const SshLayout = () => {
<Link
to="/projects/ssh/$projectId/settings"
params={{
projectId: currentWorkspace.id
projectId: currentProject.id
}}
>
{({ isActive }) => (