From 6383918f7b7088be280c0880e8ea8a9fd75c43cc Mon Sep 17 00:00:00 2001 From: Antoine Dewez <44063631+Zewed@users.noreply.github.com> Date: Wed, 14 Feb 2024 16:37:33 -0800 Subject: [PATCH] feat(frontend): new brain creation modal (#2192) # Description Please include a summary of the changes and the related issue. Please also include relevant motivation and context. ## Checklist before requesting a review Please delete options that are not relevant. - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my code - [ ] I have commented hard-to-understand areas - [ ] I have ideally added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged ## Screenshots (if appropriate): --- frontend/app/App.tsx | 2 +- .../components/MentionsList/MentionsList.tsx | 2 +- .../KnowledgeToFeed.module.scss | 3 + .../KnowledgeToFeed/KnowledgeToFeed.tsx | 32 +++--- .../FromDocuments/FromDocuments.module.scss | 5 + frontend/app/chat/[chatId]/page.tsx | 2 +- frontend/app/search/page.tsx | 2 +- frontend/app/studio/page.tsx | 2 +- .../AddBrainModal/AddBrainModal.module.scss | 21 ++++ .../AddBrainModal/AddBrainModal.tsx | 36 +++++- .../brainCreation-provider.tsx | 12 +- .../AddBrainSteps/AddBrainSteps.tsx | 44 -------- .../BrainKnowledgeStep/BrainKnowledgeStep.tsx | 80 ------------- .../components/KnowledgeToFeedInput.tsx | 26 ----- .../hooks/useBrainCreationHandler.ts | 52 --------- .../hooks/useBrainKnowledgeStep.ts | 24 ---- .../BrainParamsStep/BrainParamsStep.tsx | 96 ---------------- .../PublicAccessConfirmationModal.tsx | 42 ------- .../hooks/useBrainParamsStep.ts | 16 --- .../hooks/useBrainStatusOptions.ts | 25 ----- .../hooks/usePublicAccessConfirmationModal.ts | 43 ------- .../BrainTypeSelectionStep.tsx | 56 ---------- .../hooks/useBrainTypeSelectionStep.ts | 21 ---- .../hooks/useKnowledgeSourceLabel.ts | 35 ------ .../components/Stepper/Stepper.tsx | 31 ------ .../components/Stepper/components/Step.tsx | 39 ------- .../components/AddBrainSteps/index.ts | 1 - .../components/AddBrainSteps/types.ts | 6 - .../BrainKnowledgeStep.module.scss | 19 ++++ .../BrainKnowledgeStep/BrainKnowledgeStep.tsx | 51 +++++++++ .../ConnectableBrain/ConnectableBrain.tsx | 0 .../hooks/useConnectableBrain.ts | 2 +- .../CompositeBrainConnections.tsx | 0 .../hooks/useBrainCreationApi.ts | 22 ++-- .../BrainMainInfosStep.module.scss | 25 +++++ .../BrainMainInfosStep/BrainMainInfosStep.tsx | 76 +++++++++++++ .../BrainTypeSelection.module.scss | 47 ++++++++ .../BrainTypeSelection/BrainTypeSelection.tsx | 41 +++++++ .../BrainTypeSelectionStep.module.scss | 31 ++++++ .../BrainTypeSelectionStep.tsx | 69 ++++++++++++ .../components/Stepper/Stepper.module.scss | 105 ++++++++++++++++++ .../components/Stepper/Stepper.tsx | 58 ++++++++++ .../AddBrainModal/components/index.ts | 1 - .../hooks/useBrainCreationSteps.ts | 7 +- .../AddBrainModal/{ => types}/types.ts | 14 +++ .../hooks/useParamsDefinitionDefaultValues.ts | 2 +- .../useSecretsDefinitionDefaultValues.ts | 2 +- .../lib/components/ui/Modal/Modal.module.scss | 2 +- .../TextAreaInput/TextAreaInput.module.scss | 35 ++++++ .../ui/TextAreaInput/TextAreaInput.tsx | 32 ++++++ frontend/lib/helpers/iconList.ts | 8 ++ frontend/lib/hooks/useDropzone.ts | 2 +- frontend/styles/_Colors.module.scss | 3 + frontend/styles/_Radius.module.scss | 1 + frontend/styles/_Typography.module.scss | 1 + 55 files changed, 729 insertions(+), 683 deletions(-) create mode 100644 frontend/lib/components/AddBrainModal/AddBrainModal.module.scss rename frontend/lib/components/AddBrainModal/{components/AddBrainSteps => }/brainCreation-provider.tsx (74%) delete mode 100644 frontend/lib/components/AddBrainModal/components/AddBrainSteps/AddBrainSteps.tsx delete mode 100644 frontend/lib/components/AddBrainModal/components/AddBrainSteps/components/BrainKnowledgeStep/BrainKnowledgeStep.tsx delete mode 100644 frontend/lib/components/AddBrainModal/components/AddBrainSteps/components/BrainKnowledgeStep/components/KnowledgeToFeedInput.tsx delete mode 100644 frontend/lib/components/AddBrainModal/components/AddBrainSteps/components/BrainKnowledgeStep/hooks/useBrainCreationHandler.ts delete mode 100644 frontend/lib/components/AddBrainModal/components/AddBrainSteps/components/BrainKnowledgeStep/hooks/useBrainKnowledgeStep.ts delete mode 100644 frontend/lib/components/AddBrainModal/components/AddBrainSteps/components/BrainParamsStep/BrainParamsStep.tsx delete mode 100644 frontend/lib/components/AddBrainModal/components/AddBrainSteps/components/BrainParamsStep/components/PublicAccessConfirmationModal.tsx delete mode 100644 frontend/lib/components/AddBrainModal/components/AddBrainSteps/components/BrainParamsStep/hooks/useBrainParamsStep.ts delete mode 100644 frontend/lib/components/AddBrainModal/components/AddBrainSteps/components/BrainParamsStep/hooks/useBrainStatusOptions.ts delete mode 100644 frontend/lib/components/AddBrainModal/components/AddBrainSteps/components/BrainParamsStep/hooks/usePublicAccessConfirmationModal.ts delete mode 100644 frontend/lib/components/AddBrainModal/components/AddBrainSteps/components/BrainTypeSelectionStep/BrainTypeSelectionStep.tsx delete mode 100644 frontend/lib/components/AddBrainModal/components/AddBrainSteps/components/BrainTypeSelectionStep/hooks/useBrainTypeSelectionStep.ts delete mode 100644 frontend/lib/components/AddBrainModal/components/AddBrainSteps/components/BrainTypeSelectionStep/hooks/useKnowledgeSourceLabel.ts delete mode 100644 frontend/lib/components/AddBrainModal/components/AddBrainSteps/components/Stepper/Stepper.tsx delete mode 100644 frontend/lib/components/AddBrainModal/components/AddBrainSteps/components/Stepper/components/Step.tsx delete mode 100644 frontend/lib/components/AddBrainModal/components/AddBrainSteps/index.ts delete mode 100644 frontend/lib/components/AddBrainModal/components/AddBrainSteps/types.ts create mode 100644 frontend/lib/components/AddBrainModal/components/BrainKnowledgeStep/BrainKnowledgeStep.module.scss create mode 100644 frontend/lib/components/AddBrainModal/components/BrainKnowledgeStep/BrainKnowledgeStep.tsx rename frontend/lib/components/AddBrainModal/components/{AddBrainSteps/components => }/BrainKnowledgeStep/components/CompositeBrainConnections/Components/ConnectableBrain/ConnectableBrain.tsx (100%) rename frontend/lib/components/AddBrainModal/components/{AddBrainSteps/components => }/BrainKnowledgeStep/components/CompositeBrainConnections/Components/ConnectableBrain/hooks/useConnectableBrain.ts (98%) rename frontend/lib/components/AddBrainModal/components/{AddBrainSteps/components => }/BrainKnowledgeStep/components/CompositeBrainConnections/CompositeBrainConnections.tsx (100%) rename frontend/lib/components/AddBrainModal/components/{AddBrainSteps/components => }/BrainKnowledgeStep/hooks/useBrainCreationApi.ts (88%) create mode 100644 frontend/lib/components/AddBrainModal/components/BrainMainInfosStep/BrainMainInfosStep.module.scss create mode 100644 frontend/lib/components/AddBrainModal/components/BrainMainInfosStep/BrainMainInfosStep.tsx create mode 100644 frontend/lib/components/AddBrainModal/components/BrainTypeSelectionStep/BrainTypeSelection/BrainTypeSelection.module.scss create mode 100644 frontend/lib/components/AddBrainModal/components/BrainTypeSelectionStep/BrainTypeSelection/BrainTypeSelection.tsx create mode 100644 frontend/lib/components/AddBrainModal/components/BrainTypeSelectionStep/BrainTypeSelectionStep.module.scss create mode 100644 frontend/lib/components/AddBrainModal/components/BrainTypeSelectionStep/BrainTypeSelectionStep.tsx create mode 100644 frontend/lib/components/AddBrainModal/components/Stepper/Stepper.module.scss create mode 100644 frontend/lib/components/AddBrainModal/components/Stepper/Stepper.tsx delete mode 100644 frontend/lib/components/AddBrainModal/components/index.ts rename frontend/lib/components/AddBrainModal/{components/AddBrainSteps => }/hooks/useBrainCreationSteps.ts (92%) rename frontend/lib/components/AddBrainModal/{ => types}/types.ts (54%) create mode 100644 frontend/lib/components/ui/TextAreaInput/TextAreaInput.module.scss create mode 100644 frontend/lib/components/ui/TextAreaInput/TextAreaInput.tsx diff --git a/frontend/app/App.tsx b/frontend/app/App.tsx index bad51005b..19b929595 100644 --- a/frontend/app/App.tsx +++ b/frontend/app/App.tsx @@ -5,7 +5,7 @@ import { posthog } from "posthog-js"; import { PostHogProvider } from "posthog-js/react"; import { PropsWithChildren, useEffect } from "react"; -import { BrainCreationProvider } from "@/lib/components/AddBrainModal/components/AddBrainSteps/brainCreation-provider"; +import { BrainCreationProvider } from "@/lib/components/AddBrainModal/brainCreation-provider"; import { Menu } from "@/lib/components/Menu/Menu"; import { useOutsideClickListener } from "@/lib/components/Menu/hooks/useOutsideClickListener"; import SearchModal from "@/lib/components/SearchModal/SearchModal"; diff --git a/frontend/app/chat/[chatId]/components/ActionsBar/components/ChatInput/components/ChatEditor/components/Editor/components/MentionsList/MentionsList.tsx b/frontend/app/chat/[chatId]/components/ActionsBar/components/ChatInput/components/ChatEditor/components/Editor/components/MentionsList/MentionsList.tsx index d15394afa..db77ab007 100644 --- a/frontend/app/chat/[chatId]/components/ActionsBar/components/ChatInput/components/ChatEditor/components/Editor/components/MentionsList/MentionsList.tsx +++ b/frontend/app/chat/[chatId]/components/ActionsBar/components/ChatInput/components/ChatEditor/components/Editor/components/MentionsList/MentionsList.tsx @@ -2,7 +2,7 @@ import { SuggestionKeyDownProps } from "@tiptap/suggestion"; import { forwardRef } from "react"; import { FaAngleDoubleDown } from "react-icons/fa"; -import { useBrainCreationContext } from "@/lib/components/AddBrainModal/components/AddBrainSteps/brainCreation-provider"; +import { useBrainCreationContext } from "@/lib/components/AddBrainModal/brainCreation-provider"; import TextButton from "@/lib/components/ui/TextButton/TextButton"; import { AddNewPromptButton } from "./components/AddNewPromptButton"; diff --git a/frontend/app/chat/[chatId]/components/ActionsBar/components/KnowledgeToFeed/KnowledgeToFeed.module.scss b/frontend/app/chat/[chatId]/components/ActionsBar/components/KnowledgeToFeed/KnowledgeToFeed.module.scss index 7da93fdb2..db6d9ff01 100644 --- a/frontend/app/chat/[chatId]/components/ActionsBar/components/KnowledgeToFeed/KnowledgeToFeed.module.scss +++ b/frontend/app/chat/[chatId]/components/ActionsBar/components/KnowledgeToFeed/KnowledgeToFeed.module.scss @@ -9,6 +9,7 @@ padding-block: Spacings.$spacing05; width: 100%; gap: Spacings.$spacing05; + overflow: hidden; .single_selector_wrapper { width: 30%; @@ -37,6 +38,7 @@ overflow: scroll; flex-direction: column; gap: Spacings.$spacing02; + flex-grow: 1; overflow: scroll; .uploaded_knowledge { @@ -46,6 +48,7 @@ justify-content: space-between; width: 100%; overflow: hidden; + font-size: Typography.$small; .left { display: flex; diff --git a/frontend/app/chat/[chatId]/components/ActionsBar/components/KnowledgeToFeed/KnowledgeToFeed.tsx b/frontend/app/chat/[chatId]/components/ActionsBar/components/KnowledgeToFeed/KnowledgeToFeed.tsx index b3fc9e6db..37477dbd0 100644 --- a/frontend/app/chat/[chatId]/components/ActionsBar/components/KnowledgeToFeed/KnowledgeToFeed.tsx +++ b/frontend/app/chat/[chatId]/components/ActionsBar/components/KnowledgeToFeed/KnowledgeToFeed.tsx @@ -13,7 +13,11 @@ import { FromDocuments } from "./components/FromDocuments/FromDocuments"; import { FromWebsites } from "./components/FromWebsites/FromWebsites"; import { formatMinimalBrainsToSelectComponentInput } from "./utils/formatMinimalBrainsToSelectComponentInput"; -export const KnowledgeToFeed = (): JSX.Element => { +export const KnowledgeToFeed = ({ + hideBrainSelector, +}: { + hideBrainSelector?: boolean; +}): JSX.Element => { const { allBrains, setCurrentBrainId, currentBrain } = useBrainContext(); const [selectedTab, setSelectedTab] = useState("From documents"); const { knowledgeToFeed, removeKnowledgeToFeed } = @@ -46,18 +50,20 @@ export const KnowledgeToFeed = (): JSX.Element => { return (