diff --git a/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/BrainManagementTabs.tsx b/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/BrainManagementTabs.tsx
index 31fcb798b..7ec26a520 100644
--- a/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/BrainManagementTabs.tsx
+++ b/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/BrainManagementTabs.tsx
@@ -1,14 +1,18 @@
import { Content, List, Root } from "@radix-ui/react-tabs";
-import { BrainTabTrigger } from "./components";
+import { BrainTabTrigger, PeopleTab } from "./components";
import { useBrainManagementTabs } from "./hooks/useBrainManagementTabs";
export const BrainManagementTabs = (): JSX.Element => {
- const { selectedTab, setSelectedTab } = useBrainManagementTabs();
+ const { selectedTab, setSelectedTab, brainId } = useBrainManagementTabs();
+
+ if (brainId === undefined) {
+ return
;
+ }
return (
@@ -31,9 +35,15 @@ export const BrainManagementTabs = (): JSX.Element => {
onChange={setSelectedTab}
/>
-
- coming soon
-
+
+
+
+ coming soon
+
+
+
+
+
);
};
diff --git a/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/PeopleTab/PeopleTab.tsx b/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/PeopleTab/PeopleTab.tsx
new file mode 100644
index 000000000..bf969027a
--- /dev/null
+++ b/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/PeopleTab/PeopleTab.tsx
@@ -0,0 +1,93 @@
+/* eslint-disable max-lines */
+"use client";
+
+import { UUID } from "crypto";
+import { ImUserPlus } from "react-icons/im";
+import { MdContentPaste, MdLink } from "react-icons/md";
+
+import { BrainUsers } from "@/lib/components/BrainUsers/BrainUsers";
+import { UserToInvite } from "@/lib/components/UserToInvite";
+import Button from "@/lib/components/ui/Button";
+import { useShareBrain } from "@/lib/hooks/useShareBrain";
+
+type ShareBrainModalProps = {
+ brainId: UUID;
+};
+
+export const PeopleTab = ({ brainId }: ShareBrainModalProps): JSX.Element => {
+ const {
+ roleAssignations,
+ handleCopyInvitationLink,
+ updateRoleAssignation,
+ removeRoleAssignation,
+ inviteUsers,
+ addNewRoleAssignationRole,
+ sendingInvitation,
+ canAddNewRow,
+ } = useShareBrain(brainId);
+
+ return (
+ <>
+
+
+ Users with access
+
+ >
+ );
+};
diff --git a/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/PeopleTab/index.ts b/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/PeopleTab/index.ts
new file mode 100644
index 000000000..96fcab0c8
--- /dev/null
+++ b/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/PeopleTab/index.ts
@@ -0,0 +1 @@
+export * from "./PeopleTab";
diff --git a/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/index.ts b/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/index.ts
index 8f6088c41..2103f4f59 100644
--- a/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/index.ts
+++ b/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/index.ts
@@ -1 +1,2 @@
export * from "./BrainTabTrigger";
+export * from "./PeopleTab";
diff --git a/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/hooks/useBrainManagementTabs.ts b/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/hooks/useBrainManagementTabs.ts
index 24b9012a4..145a62463 100644
--- a/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/hooks/useBrainManagementTabs.ts
+++ b/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/hooks/useBrainManagementTabs.ts
@@ -1,3 +1,5 @@
+import { UUID } from "crypto";
+import { useParams } from "next/navigation";
import { useState } from "react";
import { BrainManagementTab } from "../types";
@@ -7,8 +9,13 @@ export const useBrainManagementTabs = () => {
const [selectedTab, setSelectedTab] =
useState("settings");
+ const params = useParams();
+
+ const brainId = params?.brainId as UUID | undefined;
+
return {
selectedTab,
setSelectedTab,
+ brainId,
};
};
diff --git a/frontend/app/brains-management/[brainId]/components/index.ts b/frontend/app/brains-management/[brainId]/components/index.ts
index 6c35a27e7..39f9dbe52 100644
--- a/frontend/app/brains-management/[brainId]/components/index.ts
+++ b/frontend/app/brains-management/[brainId]/components/index.ts
@@ -1,3 +1,4 @@
export * from "./BrainListItem";
+export * from "./BrainManagementTabs";
export * from "./BrainSearchBar";
export * from "./BrainsList";
diff --git a/frontend/app/brains-management/[brainId]/page.tsx b/frontend/app/brains-management/[brainId]/page.tsx
index dbe2b8ee1..a8b2bdbd9 100644
--- a/frontend/app/brains-management/[brainId]/page.tsx
+++ b/frontend/app/brains-management/[brainId]/page.tsx
@@ -3,7 +3,7 @@
import { UUID } from "crypto";
import { useParams } from "next/navigation";
-import { BrainManagementTabs } from "./components/BrainManagementTabs/BrainManagementTabs";
+import { BrainManagementTabs } from "./components";
const BrainsManagement = (): JSX.Element => {
const params = useParams();
@@ -21,7 +21,7 @@ const BrainsManagement = (): JSX.Element => {
}
return (
-
+
);
diff --git a/frontend/lib/components/NavBar/components/NavItems/components/BrainsDropDown/components/BrainActions/components/ShareBrain/components/BrainUsers/BrainUsers.tsx b/frontend/lib/components/BrainUsers/BrainUsers.tsx
similarity index 100%
rename from frontend/lib/components/NavBar/components/NavItems/components/BrainsDropDown/components/BrainActions/components/ShareBrain/components/BrainUsers/BrainUsers.tsx
rename to frontend/lib/components/BrainUsers/BrainUsers.tsx
diff --git a/frontend/lib/components/NavBar/components/NavItems/components/BrainsDropDown/components/BrainActions/components/ShareBrain/components/BrainUsers/components/BrainUser/BrainUser.tsx b/frontend/lib/components/BrainUsers/components/BrainUser/BrainUser.tsx
similarity index 85%
rename from frontend/lib/components/NavBar/components/NavItems/components/BrainsDropDown/components/BrainActions/components/ShareBrain/components/BrainUsers/components/BrainUser/BrainUser.tsx
rename to frontend/lib/components/BrainUsers/components/BrainUser/BrainUser.tsx
index eb79fc8d7..4280f4f69 100644
--- a/frontend/lib/components/NavBar/components/NavItems/components/BrainsDropDown/components/BrainActions/components/ShareBrain/components/BrainUsers/components/BrainUser/BrainUser.tsx
+++ b/frontend/lib/components/BrainUsers/components/BrainUser/BrainUser.tsx
@@ -6,8 +6,8 @@ import { useBrainContext } from "@/lib/context/BrainProvider/hooks/useBrainConte
import { RemoveAccessIcon } from "./components/RemoveAccessIcon";
import { useBrainUser } from "./hooks/useBrainUser";
-import { BrainRoleType } from "../../../../../../types";
-import { availableRoles } from "../../../../types";
+import { availableRoles } from "../../../NavBar/components/NavItems/components/BrainsDropDown/components/BrainActions/components/ShareBrain/types";
+import { BrainRoleType } from "../../../NavBar/components/NavItems/components/BrainsDropDown/components/BrainActions/types";
type BrainUserProps = {
email: string;
diff --git a/frontend/lib/components/NavBar/components/NavItems/components/BrainsDropDown/components/BrainActions/components/ShareBrain/components/BrainUsers/components/BrainUser/components/RemoveAccessIcon.tsx b/frontend/lib/components/BrainUsers/components/BrainUser/components/RemoveAccessIcon.tsx
similarity index 100%
rename from frontend/lib/components/NavBar/components/NavItems/components/BrainsDropDown/components/BrainActions/components/ShareBrain/components/BrainUsers/components/BrainUser/components/RemoveAccessIcon.tsx
rename to frontend/lib/components/BrainUsers/components/BrainUser/components/RemoveAccessIcon.tsx
diff --git a/frontend/lib/components/NavBar/components/NavItems/components/BrainsDropDown/components/BrainActions/components/ShareBrain/components/BrainUsers/components/BrainUser/hooks/useBrainUser.ts b/frontend/lib/components/BrainUsers/components/BrainUser/hooks/useBrainUser.ts
similarity index 95%
rename from frontend/lib/components/NavBar/components/NavItems/components/BrainsDropDown/components/BrainActions/components/ShareBrain/components/BrainUsers/components/BrainUser/hooks/useBrainUser.ts
rename to frontend/lib/components/BrainUsers/components/BrainUser/hooks/useBrainUser.ts
index 9907730c8..ed8b0bf83 100644
--- a/frontend/lib/components/NavBar/components/NavItems/components/BrainsDropDown/components/BrainActions/components/ShareBrain/components/BrainUsers/components/BrainUser/hooks/useBrainUser.ts
+++ b/frontend/lib/components/BrainUsers/components/BrainUser/hooks/useBrainUser.ts
@@ -5,7 +5,7 @@ import { useBrainApi } from "@/lib/api/brain/useBrainApi";
import { useBrainContext } from "@/lib/context/BrainProvider/hooks/useBrainContext";
import { useToast } from "@/lib/hooks";
-import { BrainRoleType } from "../../../../../../../types";
+import { BrainRoleType } from "../../../../NavBar/components/NavItems/components/BrainsDropDown/components/BrainActions/types";
type UseBrainUserProps = {
fetchBrainUsers: () => Promise;
diff --git a/frontend/lib/components/NavBar/components/NavItems/components/BrainsDropDown/components/BrainActions/components/ShareBrain/components/BrainUsers/components/index.ts b/frontend/lib/components/BrainUsers/components/index.ts
similarity index 100%
rename from frontend/lib/components/NavBar/components/NavItems/components/BrainsDropDown/components/BrainActions/components/ShareBrain/components/BrainUsers/components/index.ts
rename to frontend/lib/components/BrainUsers/components/index.ts
diff --git a/frontend/lib/components/NavBar/components/NavItems/components/BrainsDropDown/components/BrainActions/components/ShareBrain/components/BrainUsers/hooks/useBrainUsers.ts b/frontend/lib/components/BrainUsers/hooks/useBrainUsers.ts
similarity index 100%
rename from frontend/lib/components/NavBar/components/NavItems/components/BrainsDropDown/components/BrainActions/components/ShareBrain/components/BrainUsers/hooks/useBrainUsers.ts
rename to frontend/lib/components/BrainUsers/hooks/useBrainUsers.ts
diff --git a/frontend/lib/components/NavBar/components/NavItems/components/BrainsDropDown/components/BrainActions/components/ShareBrain/ShareBrain.tsx b/frontend/lib/components/NavBar/components/NavItems/components/BrainsDropDown/components/BrainActions/components/ShareBrain/ShareBrain.tsx
index 088587b02..fcbe6f7ca 100644
--- a/frontend/lib/components/NavBar/components/NavItems/components/BrainsDropDown/components/BrainActions/components/ShareBrain/ShareBrain.tsx
+++ b/frontend/lib/components/NavBar/components/NavItems/components/BrainsDropDown/components/BrainActions/components/ShareBrain/ShareBrain.tsx
@@ -5,12 +5,11 @@ import { UUID } from "crypto";
import { ImUserPlus } from "react-icons/im";
import { MdContentPaste, MdShare } from "react-icons/md";
+import { BrainUsers } from "@/lib/components/BrainUsers/BrainUsers";
+import { UserToInvite } from "@/lib/components/UserToInvite";
import Button from "@/lib/components/ui/Button";
import { Modal } from "@/lib/components/ui/Modal";
-
-import { BrainUsers } from "./components/BrainUsers/BrainUsers";
-import { UserToInvite } from "./components/UserToInvite";
-import { useShareBrain } from "./hooks/useShareBrain";
+import { useShareBrain } from "@/lib/hooks/useShareBrain";
type ShareBrainModalProps = {
brainId: UUID;
@@ -32,13 +31,9 @@ export const ShareBrain = ({
sendingInvitation,
setIsShareModalOpen,
isShareModalOpen,
+ canAddNewRow,
} = useShareBrain(brainId);
- const canAddNewRow =
- roleAssignations.length === 0 ||
- roleAssignations.filter((invitingUser) => invitingUser.email === "")
- .length === 0;
-
return (
void;
@@ -25,10 +28,6 @@ export const UserToInvite = ({
const [email, setEmail] = useState(roleAssignation.email);
const { currentBrain } = useBrainContext();
- if (currentBrain === undefined) {
- throw new Error("Brain is undefined");
- }
-
useEffect(() => {
onChange({
...roleAssignation,
@@ -37,6 +36,10 @@ export const UserToInvite = ({
});
}, [email, selectedRole]);
+ if (currentBrain === undefined) {
+ return ;
+ }
+
return (
{
@@ -102,6 +102,10 @@ export const useShareBrain = (brainId: string) => {
const addNewRoleAssignationRole = () => {
setRoleAssignation([...roleAssignations, generateBrainAssignation()]);
};
+ const canAddNewRow =
+ roleAssignations.length === 0 ||
+ roleAssignations.filter((invitingUser) => invitingUser.email === "")
+ .length === 0;
return {
roleAssignations,
@@ -114,5 +118,6 @@ export const useShareBrain = (brainId: string) => {
sendingInvitation,
setIsShareModalOpen,
isShareModalOpen,
+ canAddNewRow,
};
};