-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: customise feed manage according to brain type
- Loading branch information
1 parent
3315ee5
commit 6b1f3fa
Showing
4 changed files
with
54 additions
and
6 deletions.
There are no files selected for viewing
12 changes: 6 additions & 6 deletions
12
...tionsModal/components/FeedCardTrigger.tsx → ...nents/FeedCardTrigger/FeedCardTrigger.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
.../ChatInput/components/ActionsModal/components/FeedCardTrigger/hooks/useFeedCardTrigger.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Fragment } from "react"; | ||
|
||
import { useBrainContext } from "@/lib/context/BrainProvider/hooks/useBrainContext"; | ||
|
||
import { useFeedCardTriggerUtils } from "./useFeedCardTriggerUtils"; | ||
|
||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types | ||
export const useFeedCardTrigger = () => { | ||
const { brainTypeToIcon, brainTypeToLabel } = useFeedCardTriggerUtils(); | ||
const { currentBrain } = useBrainContext(); | ||
|
||
const isBrainTypeDefined = currentBrain?.brain_type !== undefined; | ||
|
||
return { | ||
label: isBrainTypeDefined ? brainTypeToLabel[currentBrain.brain_type] : "", | ||
Icon: isBrainTypeDefined | ||
? brainTypeToIcon[currentBrain.brain_type] | ||
: Fragment, | ||
}; | ||
}; |
27 changes: 27 additions & 0 deletions
27
...Input/components/ActionsModal/components/FeedCardTrigger/hooks/useFeedCardTriggerUtils.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { useTranslation } from "react-i18next"; | ||
import { IconType } from "react-icons/lib"; | ||
import { LuBot, LuFilePlus, LuUnlock } from "react-icons/lu"; | ||
|
||
import { BrainType } from "@/lib/types/brainConfig"; | ||
|
||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types | ||
export const useFeedCardTriggerUtils = () => { | ||
const { t } = useTranslation(["chat", "brain"]); | ||
|
||
const brainTypeToLabel: Record<BrainType, string> = { | ||
doc: t("chat:add_document"), | ||
api: t("brain:update_secrets_button"), | ||
composite: t("brain:manage_brain"), | ||
}; | ||
|
||
const brainTypeToIcon: Record<BrainType, IconType> = { | ||
doc: LuFilePlus, | ||
api: LuUnlock, | ||
composite: LuBot, | ||
}; | ||
|
||
return { | ||
brainTypeToIcon, | ||
brainTypeToLabel, | ||
}; | ||
}; |
1 change: 1 addition & 0 deletions
1
...tionsBar/components/ChatInput/components/ActionsModal/components/FeedCardTrigger/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./FeedCardTrigger"; |