From e3925bcbc0362bc05d4f8d222340c0ee2dec64f3 Mon Sep 17 00:00:00 2001
From: Mamadou DICKO <63923024+mamadoudicko@users.noreply.github.com>
Date: Tue, 31 Oct 2023 19:02:26 +0100
Subject: [PATCH] feat(brainSettings): rework knowledge tab (#1534)
Issue: https://github.com/StanGirard/quivr/issues/1435
- feat(knowledgeTab): update structure
- refactor: change AddKnowledge structure
- feat: change AddKnowledge component structure
- feat: rework sources logic
- feat: change knowledge tab upload process
- fix: change knowledge tab fetch, create, update logic
- feat: improve added knowledge ui
- style: improve responsivity
Fix:
- https://github.com/StanGirard/quivr/issues/1516
- https://github.com/StanGirard/quivr/issues/1336
- https://github.com/StanGirard/quivr/issues/1204
https://github.com/StanGirard/quivr/assets/63923024/f2917bf3-4ff8-42c6-8149-0b36287441b4
---
.../components/KnowledgeTab/AddKnowledge.tsx | 52 -------------------
.../KnowledgeItem/CrawledKnowledgeItem.tsx | 31 -----------
.../KnowledgeItem/UploadedKnowledgeItem.tsx | 28 ----------
.../KnowledgeTab/KnowledgeItem/index.tsx | 21 --------
.../KnowledgeTab/KnowledgeTable.tsx | 23 --------
.../components/AddKnowledge/AddKnowledge.tsx | 24 +++++++++
.../AddKnowledge/hooks/useAddKnowledge.ts | 31 +++++++++++
.../AddKnowledge}/hooks/useFeedBrain.ts | 8 +--
.../hooks/useFeedBrainHandler.ts | 0
.../AddKnowledge}/hooks/useKnowledgeToFeed.ts | 0
.../AddedKnowledge/AddedKnowledge.tsx | 46 ++++++++++++++++
.../AddedKnowledge/hooks/useAddedKnowledge.ts | 44 ++++++++++++++++
.../KnowledgeTable/KnowledgeTable.tsx | 19 +++++++
.../components/CrawledKnowledgeItem.tsx | 11 ++++
.../components}/DeleteKnowledge.tsx | 15 +++---
.../components}/DownloadUploadedKnowledge.tsx | 19 ++++---
.../KnowledgeItem/hooks}/useKnowledgeItem.ts | 15 +++---
.../components/KnowledgeItem/index.tsx | 51 ++++++++++++++++++
.../components/KnowledgeTab/index.tsx | 38 ++++----------
.../GeneralInformation/GeneralInformation.tsx | 39 +++++++-------
.../hooks/useBrainManagementTabs.ts | 1 +
frontend/lib/hooks/useBrainIdFromUrl.ts | 19 +++++++
22 files changed, 303 insertions(+), 232 deletions(-)
delete mode 100644 frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/AddKnowledge.tsx
delete mode 100644 frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/KnowledgeItem/CrawledKnowledgeItem.tsx
delete mode 100644 frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/KnowledgeItem/UploadedKnowledgeItem.tsx
delete mode 100644 frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/KnowledgeItem/index.tsx
delete mode 100644 frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/KnowledgeTable.tsx
create mode 100644 frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/components/AddKnowledge/AddKnowledge.tsx
create mode 100644 frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/components/AddKnowledge/hooks/useAddKnowledge.ts
rename frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/{ => components/AddKnowledge}/hooks/useFeedBrain.ts (90%)
rename frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/{ => components/AddKnowledge}/hooks/useFeedBrainHandler.ts (100%)
rename frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/{ => components/AddKnowledge}/hooks/useKnowledgeToFeed.ts (100%)
create mode 100644 frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/components/AddedKnowledge/AddedKnowledge.tsx
create mode 100644 frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/components/AddedKnowledge/hooks/useAddedKnowledge.ts
create mode 100644 frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/components/KnowledgeTable/KnowledgeTable.tsx
create mode 100644 frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/components/KnowledgeTable/components/KnowledgeItem/components/CrawledKnowledgeItem.tsx
rename frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/{KnowledgeItem => components/KnowledgeTable/components/KnowledgeItem/components}/DeleteKnowledge.tsx (57%)
rename frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/{KnowledgeItem => components/KnowledgeTable/components/KnowledgeItem/components}/DownloadUploadedKnowledge.tsx (67%)
rename frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/{KnowledgeItem => components/KnowledgeTable/components/KnowledgeItem/hooks}/useKnowledgeItem.ts (83%)
create mode 100644 frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/components/KnowledgeTable/components/KnowledgeItem/index.tsx
create mode 100644 frontend/lib/hooks/useBrainIdFromUrl.ts
diff --git a/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/AddKnowledge.tsx b/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/AddKnowledge.tsx
deleted file mode 100644
index 22548e83b..000000000
--- a/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/AddKnowledge.tsx
+++ /dev/null
@@ -1,52 +0,0 @@
-"use client";
-
-import { useEffect, useState } from "react";
-import { AiOutlineLoading3Quarters } from "react-icons/ai";
-
-import { KnowledgeToFeedInput } from "@/lib/components/KnowledgeToFeedInput";
-import { useBrainContext } from "@/lib/context/BrainProvider/hooks/useBrainContext";
-
-import { useFeedBrain } from "./hooks/useFeedBrain";
-import { useKnowledge } from "./hooks/useKnowledge";
-
-export const AddKnowledge = (): JSX.Element => {
- const [shouldDisplayModal, setShouldDisplayModal] = useState(false);
- const { currentBrain } = useBrainContext();
- const { invalidateKnowledgeDataKey } = useKnowledge({
- brainId: currentBrain?.id,
- });
-
- const { feedBrain, hasPendingRequests, setHasPendingRequests } = useFeedBrain(
- {
- dispatchHasPendingRequests: () => setHasPendingRequests(true),
- closeFeedInput: () => setShouldDisplayModal(false),
- }
- );
-
- useEffect(() => {
- if (!hasPendingRequests) {
- invalidateKnowledgeDataKey();
- }
- }, [hasPendingRequests, invalidateKnowledgeDataKey]);
-
- return (
- <>
-
- {hasPendingRequests && (
-
- )}
- {shouldDisplayModal && (
- void feedBrain()} />
- )}
- >
- );
-};
diff --git a/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/KnowledgeItem/CrawledKnowledgeItem.tsx b/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/KnowledgeItem/CrawledKnowledgeItem.tsx
deleted file mode 100644
index bf3c8c7a8..000000000
--- a/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/KnowledgeItem/CrawledKnowledgeItem.tsx
+++ /dev/null
@@ -1,31 +0,0 @@
-"use client";
-
-import { MdLink } from "react-icons/md";
-
-import { CrawledKnowledge } from "@/lib/types/Knowledge";
-
-import { DeleteKnowledge } from "./DeleteKnowledge";
-
-export const CrawledKnowledgeItem = ({
- knowledge,
-}: {
- knowledge: CrawledKnowledge;
-}): JSX.Element => {
- return (
-
-
-
-
-
- |
-
-
- |
-
-
- |
-
- );
-};
diff --git a/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/KnowledgeItem/UploadedKnowledgeItem.tsx b/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/KnowledgeItem/UploadedKnowledgeItem.tsx
deleted file mode 100644
index 772d69ed1..000000000
--- a/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/KnowledgeItem/UploadedKnowledgeItem.tsx
+++ /dev/null
@@ -1,28 +0,0 @@
-"use client";
-
-import { UploadedKnowledge } from "@/lib/types/Knowledge";
-
-import { DeleteKnowledge } from "./DeleteKnowledge";
-import { DownloadUploadedKnowledge } from "./DownloadUploadedKnowledge";
-
-export const UploadedKnowledgeItem = ({
- knowledge,
-}: {
- knowledge: UploadedKnowledge;
-}): JSX.Element => {
- return (
-
-
-
- |
-
-
- |
-
-
- |
-
- );
-};
diff --git a/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/KnowledgeItem/index.tsx b/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/KnowledgeItem/index.tsx
deleted file mode 100644
index 8715fae76..000000000
--- a/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/KnowledgeItem/index.tsx
+++ /dev/null
@@ -1,21 +0,0 @@
-"use client";
-
-import { isUploadedKnowledge, Knowledge } from "@/lib/types/Knowledge";
-
-import { CrawledKnowledgeItem } from "./CrawledKnowledgeItem";
-import { UploadedKnowledgeItem } from "./UploadedKnowledgeItem";
-
-const KnowledgeItem = ({
- knowledge,
-}: {
- knowledge: Knowledge;
-}): JSX.Element => {
- return isUploadedKnowledge(knowledge) ? (
-
- ) : (
-
- );
-};
-
-KnowledgeItem.displayName = "KnowledgeItem";
-export default KnowledgeItem;
diff --git a/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/KnowledgeTable.tsx b/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/KnowledgeTable.tsx
deleted file mode 100644
index 5c347fe04..000000000
--- a/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/KnowledgeTable.tsx
+++ /dev/null
@@ -1,23 +0,0 @@
-import { Knowledge } from "@/lib/types/Knowledge";
-
-import KnowledgeItem from "./KnowledgeItem";
-
-interface KnowledgeTableProps {
- knowledgeList: Knowledge[];
-}
-
-export const KnowledgeTable = ({
- knowledgeList,
-}: KnowledgeTableProps): JSX.Element => {
- return (
-
-
-
- {knowledgeList.map((knowledge) => (
-
- ))}
-
-
-
- );
-};
diff --git a/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/components/AddKnowledge/AddKnowledge.tsx b/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/components/AddKnowledge/AddKnowledge.tsx
new file mode 100644
index 000000000..995a038cc
--- /dev/null
+++ b/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/components/AddKnowledge/AddKnowledge.tsx
@@ -0,0 +1,24 @@
+"use client";
+
+import { AiOutlineLoading3Quarters } from "react-icons/ai";
+
+import { KnowledgeToFeedInput } from "@/lib/components/KnowledgeToFeedInput";
+
+import { useAddKnowledge } from "./hooks/useAddKnowledge";
+
+export const AddKnowledge = (): JSX.Element => {
+ const { hasPendingRequests, feedBrain } = useAddKnowledge();
+
+ return (
+ <>
+ {hasPendingRequests && (
+
+ )}
+
+ void feedBrain()} />
+
+ >
+ );
+};
diff --git a/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/components/AddKnowledge/hooks/useAddKnowledge.ts b/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/components/AddKnowledge/hooks/useAddKnowledge.ts
new file mode 100644
index 000000000..230499f80
--- /dev/null
+++ b/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/components/AddKnowledge/hooks/useAddKnowledge.ts
@@ -0,0 +1,31 @@
+import { useEffect } from "react";
+
+import { useUrlBrain } from "@/lib/hooks/useBrainIdFromUrl";
+
+import { useFeedBrain } from "./useFeedBrain";
+import { useKnowledge } from "../../../hooks/useKnowledge";
+
+// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
+export const useAddKnowledge = () => {
+ const { brainId } = useUrlBrain();
+ const { invalidateKnowledgeDataKey } = useKnowledge({
+ brainId,
+ });
+
+ const { feedBrain, hasPendingRequests, setHasPendingRequests } = useFeedBrain(
+ {
+ dispatchHasPendingRequests: () => setHasPendingRequests(true),
+ }
+ );
+
+ useEffect(() => {
+ if (!hasPendingRequests) {
+ invalidateKnowledgeDataKey();
+ }
+ }, [hasPendingRequests, invalidateKnowledgeDataKey]);
+
+ return {
+ feedBrain,
+ hasPendingRequests,
+ };
+};
diff --git a/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/hooks/useFeedBrain.ts b/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/components/AddKnowledge/hooks/useFeedBrain.ts
similarity index 90%
rename from frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/hooks/useFeedBrain.ts
rename to frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/components/AddKnowledge/hooks/useFeedBrain.ts
index e3b34afd3..99eb8cc12 100644
--- a/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/hooks/useFeedBrain.ts
+++ b/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/components/AddKnowledge/hooks/useFeedBrain.ts
@@ -2,9 +2,9 @@ import { useState } from "react";
import { useTranslation } from "react-i18next";
import { useChatApi } from "@/lib/api/chat/useChatApi";
-import { useBrainContext } from "@/lib/context/BrainProvider/hooks/useBrainContext";
import { useKnowledgeToFeedContext } from "@/lib/context/KnowledgeToFeedProvider/hooks/useKnowledgeToFeedContext";
import { useToast } from "@/lib/hooks";
+import { useUrlBrain } from "@/lib/hooks/useBrainIdFromUrl";
import { useFeedBrainHandler } from "./useFeedBrainHandler";
@@ -18,14 +18,14 @@ export const useFeedBrain = ({
}) => {
const { publish } = useToast();
const { t } = useTranslation(["upload"]);
- const { currentBrainId } = useBrainContext();
+ const { brainId } = useUrlBrain();
const { setKnowledgeToFeed, knowledgeToFeed } = useKnowledgeToFeedContext();
const [hasPendingRequests, setHasPendingRequests] = useState(false);
const { handleFeedBrain } = useFeedBrainHandler();
const { createChat, deleteChat } = useChatApi();
const feedBrain = async (): Promise => {
- if (currentBrainId === null) {
+ if (brainId === undefined) {
publish({
variant: "danger",
text: t("selectBrainFirst"),
@@ -51,7 +51,7 @@ export const useFeedBrain = ({
closeFeedInput?.();
setHasPendingRequests(true);
await handleFeedBrain({
- brainId: currentBrainId,
+ brainId,
chatId: currentChatId,
});
diff --git a/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/hooks/useFeedBrainHandler.ts b/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/components/AddKnowledge/hooks/useFeedBrainHandler.ts
similarity index 100%
rename from frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/hooks/useFeedBrainHandler.ts
rename to frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/components/AddKnowledge/hooks/useFeedBrainHandler.ts
diff --git a/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/hooks/useKnowledgeToFeed.ts b/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/components/AddKnowledge/hooks/useKnowledgeToFeed.ts
similarity index 100%
rename from frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/hooks/useKnowledgeToFeed.ts
rename to frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/components/AddKnowledge/hooks/useKnowledgeToFeed.ts
diff --git a/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/components/AddedKnowledge/AddedKnowledge.tsx b/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/components/AddedKnowledge/AddedKnowledge.tsx
new file mode 100644
index 000000000..b7b15c9a6
--- /dev/null
+++ b/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/components/AddedKnowledge/AddedKnowledge.tsx
@@ -0,0 +1,46 @@
+import { UUID } from "crypto";
+import { AnimatePresence, motion } from "framer-motion";
+import { useTranslation } from "react-i18next";
+
+import Spinner from "@/lib/components/ui/Spinner";
+
+import { useAddedKnowledge } from "./hooks/useAddedKnowledge";
+import { KnowledgeTable } from "../KnowledgeTable/KnowledgeTable";
+
+type AddedKnowledgeProps = {
+ brainId: UUID;
+};
+export const AddedKnowledge = ({
+ brainId,
+}: AddedKnowledgeProps): JSX.Element => {
+ const { isPending, allKnowledge } = useAddedKnowledge({
+ brainId,
+ });
+
+ const { t } = useTranslation("explore");
+
+ if (isPending) {
+ return ;
+ }
+
+ if (allKnowledge.length === 0) {
+ return (
+
+
+
{t("empty", { ns: "explore" })}
+
+ {t("feed_brain_instructions", { ns: "explore" })}
+
+
+
+ );
+ }
+
+ return (
+
+
+
+
+
+ );
+};
diff --git a/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/components/AddedKnowledge/hooks/useAddedKnowledge.ts b/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/components/AddedKnowledge/hooks/useAddedKnowledge.ts
new file mode 100644
index 000000000..984a997b5
--- /dev/null
+++ b/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/components/AddedKnowledge/hooks/useAddedKnowledge.ts
@@ -0,0 +1,44 @@
+import { useQuery, useQueryClient } from "@tanstack/react-query";
+import { UUID } from "crypto";
+
+import { getKnowledgeDataKey } from "@/lib/api/knowledge/config";
+import { useKnowledgeApi } from "@/lib/api/knowledge/useKnowledgeApi";
+
+// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
+export const useAddedKnowledge = ({ brainId }: { brainId?: UUID }) => {
+ const queryClient = useQueryClient();
+
+ const { getAllKnowledge } = useKnowledgeApi();
+
+ const fetchKnowledge = () => {
+ if (brainId !== undefined) {
+ return getAllKnowledge({ brainId });
+ }
+ };
+
+ const { data: allKnowledge, isLoading: isPending } = useQuery({
+ queryKey: brainId !== undefined ? [getKnowledgeDataKey(brainId)] : [],
+ queryFn: fetchKnowledge,
+ enabled: brainId !== undefined,
+ });
+
+ if (brainId === undefined) {
+ return {
+ invalidateKnowledgeDataKey: () => void {},
+ isPending: false,
+ allKnowledge: [],
+ };
+ }
+
+ const knowledge_data_key = getKnowledgeDataKey(brainId);
+
+ const invalidateKnowledgeDataKey = () => {
+ void queryClient.invalidateQueries({ queryKey: [knowledge_data_key] });
+ };
+
+ return {
+ invalidateKnowledgeDataKey,
+ isPending,
+ allKnowledge: allKnowledge ?? [],
+ };
+};
diff --git a/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/components/KnowledgeTable/KnowledgeTable.tsx b/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/components/KnowledgeTable/KnowledgeTable.tsx
new file mode 100644
index 000000000..39a0b26d4
--- /dev/null
+++ b/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/components/KnowledgeTable/KnowledgeTable.tsx
@@ -0,0 +1,19 @@
+import { Knowledge } from "@/lib/types/Knowledge";
+
+import KnowledgeItem from "./components/KnowledgeItem";
+
+interface KnowledgeTableProps {
+ knowledgeList: Knowledge[];
+}
+
+export const KnowledgeTable = ({
+ knowledgeList,
+}: KnowledgeTableProps): JSX.Element => {
+ return (
+
+ {knowledgeList.map((knowledge) => (
+
+ ))}
+
+ );
+};
diff --git a/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/components/KnowledgeTable/components/KnowledgeItem/components/CrawledKnowledgeItem.tsx b/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/components/KnowledgeTable/components/KnowledgeItem/components/CrawledKnowledgeItem.tsx
new file mode 100644
index 000000000..15568cccb
--- /dev/null
+++ b/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/components/KnowledgeTable/components/KnowledgeItem/components/CrawledKnowledgeItem.tsx
@@ -0,0 +1,11 @@
+"use client";
+
+export const CrawledKnowledgeItem = ({ url }: { url: string }): JSX.Element => {
+ return (
+
+
+
+ );
+};
diff --git a/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/KnowledgeItem/DeleteKnowledge.tsx b/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/components/KnowledgeTable/components/KnowledgeItem/components/DeleteKnowledge.tsx
similarity index 57%
rename from frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/KnowledgeItem/DeleteKnowledge.tsx
rename to frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/components/KnowledgeTable/components/KnowledgeItem/components/DeleteKnowledge.tsx
index f532db704..dc6f8c20f 100644
--- a/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/KnowledgeItem/DeleteKnowledge.tsx
+++ b/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/components/KnowledgeTab/components/KnowledgeTable/components/KnowledgeItem/components/DeleteKnowledge.tsx
@@ -3,20 +3,20 @@
import { AiOutlineLoading3Quarters } from "react-icons/ai";
import { MdDelete } from "react-icons/md";
-import { useBrainContext } from "@/lib/context/BrainProvider/hooks/useBrainContext";
+import { useUrlBrain } from "@/lib/hooks/useBrainIdFromUrl";
import { Knowledge } from "@/lib/types/Knowledge";
-import { useKnowledgeItem } from "./useKnowledgeItem";
+import { useKnowledgeItem } from "../hooks/useKnowledgeItem";
+
export const DeleteKnowledge = ({
knowledge,
}: {
knowledge: Knowledge;
}): JSX.Element => {
const { isDeleting, onDeleteKnowledge } = useKnowledgeItem();
+ const { brain } = useUrlBrain();
- const { currentBrain } = useBrainContext();
-
- const canDeleteFile = currentBrain?.role === "Owner";
+ const canDeleteFile = brain?.role === "Owner";
if (!canDeleteFile) {
return <>>;
@@ -25,10 +25,7 @@ export const DeleteKnowledge = ({
return isDeleting ? (
) : (
-