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
@@ -16,7 +16,7 @@ import {
DropdownMenuTrigger,
PageHeader
} from "@app/components/v2";
import { ProjectPermissionActions, ProjectPermissionSub, useWorkspace } from "@app/context";
import { ProjectPermissionActions, ProjectPermissionSub, useProject } from "@app/context";
import { getProjectBaseURL } from "@app/helpers/project";
import { useDeleteProjectRole, useGetProjectRoleBySlug } from "@app/hooks/api";
import { ProjectMembershipRole } from "@app/hooks/api/roles/types";
@@ -33,8 +33,8 @@ const Page = () => {
strict: false,
select: (el) => el.roleSlug as string
});
const { currentWorkspace } = useWorkspace();
const projectId = currentWorkspace?.id || "";
const { currentProject } = useProject();
const projectId = currentProject?.id || "";
const { data } = useGetProjectRoleBySlug(projectId, roleSlug as string);
@@ -48,7 +48,7 @@ const Page = () => {
const onDeleteRoleSubmit = async () => {
try {
if (!currentWorkspace?.slug || !data?.id) return;
if (!currentProject?.slug || !data?.id) return;
await deleteProjectRole({
projectId,
@@ -61,7 +61,7 @@ const Page = () => {
});
handlePopUpClose("deleteRole");
navigate({
to: `${getProjectBaseURL(currentWorkspace.type)}/access-management` as const,
to: `${getProjectBaseURL(currentProject.type)}/access-management` as const,
params: {
projectId
},
@@ -9,7 +9,7 @@ import {
IconButton
} from "@app/components/v2";
import { usePopUp } from "@app/hooks";
import { ProjectType } from "@app/hooks/api/workspace/types";
import { ProjectType } from "@app/hooks/api/projects/types";
import { PolicySelectionModal } from "@app/pages/project/RoleDetailsBySlugPage/components/PolicySelectionModal";
import { PolicyTemplateModal } from "@app/pages/project/RoleDetailsBySlugPage/components/PolicyTemplateModal";
@@ -5,7 +5,7 @@ import { z } from "zod";
import { createNotification } from "@app/components/notifications";
import { Button, FormControl, Input, Modal, ModalContent, Spinner } from "@app/components/v2";
import { ProjectPermissionSub, useWorkspace } from "@app/context";
import { ProjectPermissionSub, useProject } from "@app/context";
import { ProjectPermissionSecretActions } from "@app/context/ProjectPermissionContext/types";
import { getProjectBaseURL } from "@app/helpers/project";
import { useCreateProjectRole, useGetProjectRoleBySlug } from "@app/hooks/api";
@@ -45,7 +45,7 @@ const Content = ({ role, onClose }: ContentProps) => {
resolver: zodResolver(schema)
});
const { currentWorkspace } = useWorkspace();
const { currentProject } = useProject();
const createRole = useCreateProjectRole();
const navigate = useNavigate();
@@ -70,7 +70,7 @@ const Content = ({ role, onClose }: ContentProps) => {
});
const newRole = await createRole.mutateAsync({
projectId: currentWorkspace.id,
projectId: currentProject.id,
permissions: sanitizedPermission,
...form
});
@@ -81,10 +81,10 @@ const Content = ({ role, onClose }: ContentProps) => {
});
navigate({
to: `${getProjectBaseURL(currentWorkspace.type)}/roles/$roleSlug` as const,
to: `${getProjectBaseURL(currentProject.type)}/roles/$roleSlug` as const,
params: {
roleSlug: newRole.slug,
projectId: currentWorkspace.id
projectId: currentProject.id
}
});
@@ -142,9 +142,9 @@ const Content = ({ role, onClose }: ContentProps) => {
};
export const DuplicateProjectRoleModal = ({ isOpen, onOpenChange, roleSlug }: Props) => {
const { currentWorkspace } = useWorkspace();
const { currentProject } = useProject();
const { data: role, isPending } = useGetProjectRoleBySlug(currentWorkspace.id, roleSlug ?? "");
const { data: role, isPending } = useGetProjectRoleBySlug(currentProject.id, roleSlug ?? "");
if (!roleSlug) return null;
@@ -19,7 +19,7 @@ import {
Tr
} from "@app/components/v2";
import { ProjectPermissionSub } from "@app/context";
import { ProjectType } from "@app/hooks/api/workspace/types";
import { ProjectType } from "@app/hooks/api/projects/types";
import {
EXCLUDED_PERMISSION_SUBS,
@@ -13,7 +13,7 @@ import {
ModalContent
} from "@app/components/v2";
import { ProjectPermissionSub } from "@app/context";
import { ProjectType } from "@app/hooks/api/workspace/types";
import { ProjectType } from "@app/hooks/api/projects/types";
import {
PROJECT_PERMISSION_OBJECT,
@@ -33,7 +33,7 @@ import {
TPermissionConditionOperators
} from "@app/context/ProjectPermissionContext/types";
import { TProjectPermission } from "@app/hooks/api/roles/types";
import { ProjectType } from "@app/hooks/api/workspace/types";
import { ProjectType } from "@app/hooks/api/projects/types";
const GeneralPolicyActionSchema = z.object({
read: z.boolean().optional(),
@@ -6,7 +6,7 @@ import { z } from "zod";
import { createNotification } from "@app/components/notifications";
import { Button, FormControl, Input, Modal, ModalContent } from "@app/components/v2";
import { useWorkspace } from "@app/context";
import { useProject } from "@app/context";
import { getProjectBaseURL } from "@app/helpers/project";
import {
useCreateProjectRole,
@@ -38,8 +38,8 @@ export const RoleModal = ({ popUp, handlePopUpToggle }: Props) => {
roleSlug: string;
};
const { currentWorkspace } = useWorkspace();
const projectId = currentWorkspace?.id || "";
const { currentProject } = useProject();
const projectId = currentProject?.id || "";
const { data: role } = useGetProjectRoleBySlug(projectId, popupData?.roleSlug ?? "");
@@ -101,7 +101,7 @@ export const RoleModal = ({ popUp, handlePopUpToggle }: Props) => {
});
navigate({
to: `${getProjectBaseURL(currentWorkspace.type)}/roles/$roleSlug` as const,
to: `${getProjectBaseURL(currentProject.type)}/roles/$roleSlug` as const,
params: {
roleSlug: newRole.slug,
projectId
@@ -8,12 +8,12 @@ import { zodResolver } from "@hookform/resolvers/zod";
import { createNotification } from "@app/components/notifications";
import { AccessTree } from "@app/components/permissions";
import { Button } from "@app/components/v2";
import { ProjectPermissionSub, useWorkspace } from "@app/context";
import { ProjectPermissionSub, useProject } from "@app/context";
import { ProjectPermissionSet } from "@app/context/ProjectPermissionContext";
import { evaluatePermissionsAbility } from "@app/helpers/permissions";
import { useGetProjectRoleBySlug, useUpdateProjectRole } from "@app/hooks/api";
import { ProjectMembershipRole } from "@app/hooks/api/roles/types";
import { ProjectType } from "@app/hooks/api/workspace/types";
import { ProjectType } from "@app/hooks/api/projects/types";
import { AddPoliciesButton } from "./AddPoliciesButton";
import { DynamicSecretPermissionConditions } from "./DynamicSecretPermissionConditions";
@@ -84,10 +84,10 @@ export const renderConditionalComponents = (
};
export const RolePermissionsSection = ({ roleSlug, isDisabled }: Props) => {
const { currentWorkspace } = useWorkspace();
const projectId = currentWorkspace?.id || "";
const { currentProject } = useProject();
const projectId = currentProject?.id || "";
const { data: role, isPending } = useGetProjectRoleBySlug(
currentWorkspace?.id ?? "",
currentProject?.id ?? "",
roleSlug as string
);
@@ -126,7 +126,7 @@ export const RolePermissionsSection = ({ roleSlug, isDisabled }: Props) => {
(role?.slug ?? "") as ProjectMembershipRole
);
const isSecretManagerProject = currentWorkspace.type === ProjectType.SecretManager;
const isSecretManagerProject = currentProject.type === ProjectType.SecretManager;
const permissions = form.watch("permissions");
@@ -178,7 +178,7 @@ export const RolePermissionsSection = ({ roleSlug, isDisabled }: Props) => {
Save
</Button>
<div className="ml-2 border-l border-mineshaft-500 pl-4">
<AddPoliciesButton isDisabled={isDisabled} projectType={currentWorkspace.type} />
<AddPoliciesButton isDisabled={isDisabled} projectType={currentProject.type} />
</div>
</div>
)}