Disallow adding groups to E2EE projects

This commit is contained in:
Tuan Dang
2024-04-11 19:52:10 -07:00
parent c98ef0eca8
commit fa1b236f26
2 changed files with 21 additions and 13 deletions
@@ -68,6 +68,7 @@ export const groupProjectServiceFactory = ({
}); });
if (!project) throw new BadRequestError({ message: `Failed to find project with slug ${projectSlug}` }); if (!project) throw new BadRequestError({ message: `Failed to find project with slug ${projectSlug}` });
if (project.version < 2) throw new BadRequestError({ message: `Failed to add group to E2EE project` });
const { permission } = await permissionService.getProjectPermission( const { permission } = await permissionService.getProjectPermission(
actor, actor,
@@ -2,7 +2,7 @@
import { motion } from "framer-motion"; import { motion } from "framer-motion";
import { Tab, TabList, TabPanel, Tabs } from "@app/components/v2"; import { Tab, TabList, TabPanel, Tabs } from "@app/components/v2";
import { ProjectPermissionActions, ProjectPermissionSub } from "@app/context"; import { ProjectPermissionActions, ProjectPermissionSub, useWorkspace } from "@app/context";
import { withProjectPermission } from "@app/hoc"; import { withProjectPermission } from "@app/hoc";
import { GroupsTab, IdentityTab, MemberListTab, ProjectRoleListTab, ServiceTokenTab } from "./components"; import { GroupsTab, IdentityTab, MemberListTab, ProjectRoleListTab, ServiceTokenTab } from "./components";
@@ -17,6 +17,9 @@ enum TabSections {
export const MembersPage = withProjectPermission( export const MembersPage = withProjectPermission(
() => { () => {
const { currentWorkspace } = useWorkspace();
console.log("currentWorkspace: ", currentWorkspace);
return ( return (
<div className="container mx-auto flex flex-col justify-between bg-bunker-800 text-white"> <div className="container mx-auto flex flex-col justify-between bg-bunker-800 text-white">
<div className="mx-auto mb-6 w-full max-w-7xl py-6 px-6"> <div className="mx-auto mb-6 w-full max-w-7xl py-6 px-6">
@@ -24,7 +27,9 @@ export const MembersPage = withProjectPermission(
<Tabs defaultValue={TabSections.Member}> <Tabs defaultValue={TabSections.Member}>
<TabList> <TabList>
<Tab value={TabSections.Member}>People</Tab> <Tab value={TabSections.Member}>People</Tab>
<Tab value={TabSections.Groups}>Groups</Tab> {currentWorkspace?.version && currentWorkspace.version > 1 && (
<Tab value={TabSections.Groups}>Groups</Tab>
)}
<Tab value={TabSections.Identities}> <Tab value={TabSections.Identities}>
<div className="flex items-center"> <div className="flex items-center">
<p>Machine Identities</p> <p>Machine Identities</p>
@@ -36,17 +41,19 @@ export const MembersPage = withProjectPermission(
<TabPanel value={TabSections.Member}> <TabPanel value={TabSections.Member}>
<MemberListTab /> <MemberListTab />
</TabPanel> </TabPanel>
<TabPanel value={TabSections.Groups}> {currentWorkspace?.version && currentWorkspace.version > 1 && (
<motion.div <TabPanel value={TabSections.Groups}>
key="panel-1" <motion.div
transition={{ duration: 0.15 }} key="panel-1"
initial={{ opacity: 0, translateX: 30 }} transition={{ duration: 0.15 }}
animate={{ opacity: 1, translateX: 0 }} initial={{ opacity: 0, translateX: 30 }}
exit={{ opacity: 0, translateX: 30 }} animate={{ opacity: 1, translateX: 0 }}
> exit={{ opacity: 0, translateX: 30 }}
<GroupsTab /> >
</motion.div> <GroupsTab />
</TabPanel> </motion.div>
</TabPanel>
)}
<TabPanel value={TabSections.Identities}> <TabPanel value={TabSections.Identities}>
<IdentityTab /> <IdentityTab />
</TabPanel> </TabPanel>