diff --git a/frontend/app/studio/[brainId]/BrainManagementTabs/BrainManagementTabs.tsx b/frontend/app/studio/[brainId]/BrainManagementTabs/BrainManagementTabs.tsx index 6c75fc6b6..69db87470 100644 --- a/frontend/app/studio/[brainId]/BrainManagementTabs/BrainManagementTabs.tsx +++ b/frontend/app/studio/[brainId]/BrainManagementTabs/BrainManagementTabs.tsx @@ -1,7 +1,7 @@ /* eslint-disable max-lines */ import { useRouter } from "next/navigation"; -import { useEffect, useState } from "react"; +import { useState } from "react"; import { Icon } from "@/lib/components/ui/Icon/Icon"; import { LoaderIcon } from "@/lib/components/ui/LoaderIcon/LoaderIcon"; @@ -22,27 +22,20 @@ export const BrainManagementTabs = (): JSX.Element => { const { allKnowledge } = useAddedKnowledge({ brainId: brainId ?? undefined }); const router = useRouter(); - const { brain, isLoading } = useBrainFetcher({ + const { isLoading } = useBrainFetcher({ brainId, }); - const knowledgeTabDisabled = (): boolean => { - return ( - !hasEditRights || - (brain?.integration_description?.max_files === 0 && - brain.brain_type !== "doc") - ); - }; - const brainManagementTabs: Tab[] = [ { - label: `Knowledge${allKnowledge.length > 1 ? "s" : ""} (${ - allKnowledge.length - })`, + label: hasEditRights + ? `Knowledge${allKnowledge.length > 1 ? "s" : ""} (${ + allKnowledge.length + })` + : "Knowledge", isSelected: selectedTab === "Knowledge", onClick: () => setSelectedTab("Knowledge"), iconName: "file", - disabled: knowledgeTabDisabled(), }, { label: "Settings", @@ -59,10 +52,6 @@ export const BrainManagementTabs = (): JSX.Element => { }, ]; - useEffect(() => { - brainManagementTabs[2].disabled = knowledgeTabDisabled(); - }, [hasEditRights]); - if (!brainId) { return
; } @@ -89,7 +78,9 @@ export const BrainManagementTabs = (): JSX.Element => {
- {selectedTab === "Settings" && } + {selectedTab === "Settings" && ( + + )} {selectedTab === "People" && } {selectedTab === "Knowledge" && ( { const { isPending } = useAddedKnowledge({ brainId, }); const { setShouldDisplayFeedCard } = useKnowledgeToFeedContext(); + if (hasEditRights) { + return ( +
+
+ + You don't have permission to access the knowledge in this + brain. + +
+
+ ); + } + if (isPending) { return ; } diff --git a/frontend/app/studio/[brainId]/BrainManagementTabs/components/SettingsTab/SettingsTab.module.scss b/frontend/app/studio/[brainId]/BrainManagementTabs/components/SettingsTab/SettingsTab.module.scss index 53ce2a2cc..a41f6b25f 100644 --- a/frontend/app/studio/[brainId]/BrainManagementTabs/components/SettingsTab/SettingsTab.module.scss +++ b/frontend/app/studio/[brainId]/BrainManagementTabs/components/SettingsTab/SettingsTab.module.scss @@ -61,7 +61,6 @@ display: flex; justify-content: center; align-items: center; - cursor: pointer; font-size: Typography.$very_large; } @@ -72,6 +71,12 @@ font-size: Typography.$small; gap: Spacings.$spacing03; } + + &.clickable { + .brain_snippet { + cursor: pointer; + } + } } .general_information { diff --git a/frontend/app/studio/[brainId]/BrainManagementTabs/components/SettingsTab/SettingsTab.tsx b/frontend/app/studio/[brainId]/BrainManagementTabs/components/SettingsTab/SettingsTab.tsx index 21d6d264d..09c88cb9a 100644 --- a/frontend/app/studio/[brainId]/BrainManagementTabs/components/SettingsTab/SettingsTab.tsx +++ b/frontend/app/studio/[brainId]/BrainManagementTabs/components/SettingsTab/SettingsTab.tsx @@ -14,7 +14,6 @@ import { GeneralInformation } from "./components/GeneralInformation/GeneralInfor import { ModelSelection } from "./components/ModelSelection/ModelSelection"; import { Prompt } from "./components/Prompt/Prompt"; import { useBrainFormState } from "./hooks/useBrainFormState"; -import { usePermissionsController } from "./hooks/usePermissionsController"; import { UsePromptProps } from "./hooks/usePrompt"; import { useSettingsTab } from "./hooks/useSettingsTab"; @@ -22,20 +21,18 @@ import { useBrainFetcher } from "../../hooks/useBrainFetcher"; type SettingsTabProps = { brainId: UUID; + hasEditRights: boolean; }; export const SettingsTabContent = ({ brainId, + hasEditRights, }: SettingsTabProps): JSX.Element => { const { t } = useTranslation(["translation", "brain", "config"]); const [editSnippet, setEditSnippet] = useState(false); const [snippetColor, setSnippetColor] = useState(""); const [snippetEmoji, setSnippetEmoji] = useState(""); - const { hasEditRights } = usePermissionsController({ - brainId, - }); - const { brain } = useBrainFetcher({ brainId, }); @@ -81,7 +78,11 @@ export const SettingsTabContent = ({
{editSnippet && ( -
+
{ - if (!editSnippet) { + if (!editSnippet && hasEditRights) { setEditSnippet(true); } }} > {snippetEmoji}
- setEditSnippet(true)} - small={true} - /> + {hasEditRights && ( + setEditSnippet(true)} + small={true} + /> + )}
- {(!!brain.integration_description?.allow_model_change || - brain.brain_type === "doc") && ( + {brain.brain_type === "doc" && (
{ +export const SettingsTab = ({ + brainId, + hasEditRights, +}: SettingsTabProps): JSX.Element => { const methods = useForm(); return ( - + ); };