feat(frontend): set from connections by default in knowledge to feed (#2680)

# 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):
This commit is contained in:
Antoine Dewez 2024-06-17 11:43:27 +02:00 committed by GitHub
parent a22fa9bb55
commit bfec25be0e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -22,7 +22,7 @@ export const KnowledgeToFeed = ({
}): JSX.Element => { }): JSX.Element => {
const { allBrains, setCurrentBrainId, currentBrainId, currentBrain } = const { allBrains, setCurrentBrainId, currentBrainId, currentBrain } =
useBrainContext(); useBrainContext();
const [selectedTab, setSelectedTab] = useState("Documents"); const [selectedTab, setSelectedTab] = useState("Connections");
const { knowledgeToFeed } = useKnowledgeToFeedContext(); const { knowledgeToFeed } = useKnowledgeToFeedContext();
const { openedConnections, setOpenedConnections, setCurrentSyncId } = const { openedConnections, setOpenedConnections, setCurrentSyncId } =
useFromConnectionsContext(); useFromConnectionsContext();
@ -40,6 +40,14 @@ export const KnowledgeToFeed = ({
); );
const knowledgesTabs: Tab[] = [ const knowledgesTabs: Tab[] = [
{
label: "Connections",
isSelected: selectedTab === "Connections",
onClick: () => setSelectedTab("Connections"),
iconName: "sync",
badge: openedConnections.filter((connection) => connection.submitted)
.length,
},
{ {
label: "Documents", label: "Documents",
isSelected: selectedTab === "Documents", isSelected: selectedTab === "Documents",
@ -57,14 +65,6 @@ export const KnowledgeToFeed = ({
badge: knowledgeToFeed.filter((knowledge) => knowledge.source === "crawl") badge: knowledgeToFeed.filter((knowledge) => knowledge.source === "crawl")
.length, .length,
}, },
{
label: "Connections",
isSelected: selectedTab === "Connections",
onClick: () => setSelectedTab("Connections"),
iconName: "sync",
badge: openedConnections.filter((connection) => connection.submitted)
.length,
},
]; ];
useEffect(() => { useEffect(() => {
@ -123,9 +123,9 @@ export const KnowledgeToFeed = ({
)} )}
<Tabs tabList={knowledgesTabs} /> <Tabs tabList={knowledgesTabs} />
<div className={styles.tabs_content_wrapper}> <div className={styles.tabs_content_wrapper}>
{selectedTab === "Connections" && <FromConnections />}
{selectedTab === "Documents" && <FromDocuments />} {selectedTab === "Documents" && <FromDocuments />}
{selectedTab === "Websites" && <FromWebsites />} {selectedTab === "Websites" && <FromWebsites />}
{selectedTab === "Connections" && <FromConnections />}
</div> </div>
</div> </div>
); );