diff --git a/web/src/app/page.tsx b/web/src/app/page.tsx index aab5736ed626..e469ad8edf06 100644 --- a/web/src/app/page.tsx +++ b/web/src/app/page.tsx @@ -5,14 +5,30 @@ import { redirect } from "next/navigation"; import { DISABLE_AUTH } from "@/lib/constants"; import { HealthCheckBanner } from "@/components/health/healthcheck"; import { ApiKeyModal } from "@/components/openai/ApiKeyModal"; +import { buildUrl } from "@/lib/utilsSS"; +import { User } from "@/lib/types"; export default async function Home() { - let user = null; - if (!DISABLE_AUTH) { - user = await getCurrentUserSS(); - if (!user && !DISABLE_AUTH) { - return redirect("/auth/login"); - } + const tasks = [ + DISABLE_AUTH ? (async () => null)() : getCurrentUserSS(), + fetch(buildUrl("/manage/connector"), { + next: { revalidate: 0 }, + }), + ]; + + const results = await Promise.all(tasks); + const user = results[0] as User | null; + const connectorsResponse = results[1] as Response; + + if (!DISABLE_AUTH && !user) { + return redirect("/auth/login"); + } + + let connectors = null; + if (connectorsResponse.ok) { + connectors = await connectorsResponse.json(); + } else { + console.log(`Failed to fetch connectors - ${connectorsResponse.status}`); } return ( @@ -24,7 +40,7 @@ export default async function Home() {
- +
diff --git a/web/src/components/search/Filters.tsx b/web/src/components/search/Filters.tsx index 3c6e82e70765..81a3dbc4291b 100644 --- a/web/src/components/search/Filters.tsx +++ b/web/src/components/search/Filters.tsx @@ -2,11 +2,7 @@ import React from "react"; import { Source } from "./interfaces"; import { getSourceIcon } from "../source"; import { Funnel } from "@phosphor-icons/react"; - -interface SourceSelectorProps { - selectedSources: Source[]; - setSelectedSources: React.Dispatch>; -} +import { ValidSources } from "@/lib/types"; const sources: Source[] = [ { displayName: "Google Drive", internalName: "google_drive" }, @@ -16,9 +12,16 @@ const sources: Source[] = [ { displayName: "Web", internalName: "web" }, ]; +interface SourceSelectorProps { + selectedSources: Source[]; + setSelectedSources: React.Dispatch>; + existingSources: ValidSources[]; +} + export function SourceSelector({ selectedSources, setSelectedSources, + existingSources, }: SourceSelectorProps) { const handleSelect = (source: Source) => { setSelectedSources((prev: Source[]) => { @@ -36,24 +39,26 @@ export function SourceSelector({

Filters

- {sources.map((source) => ( -
handleSelect(source)} - > - {getSourceIcon(source.internalName, "16")} - - {source.displayName} - -
- ))} + {sources + .filter((source) => existingSources.includes(source.internalName)) + .map((source) => ( +
handleSelect(source)} + > + {getSourceIcon(source.internalName, "16")} + + {source.displayName} + +
+ ))} ); } diff --git a/web/src/components/search/SearchSection.tsx b/web/src/components/search/SearchSection.tsx index 38aca87dc0bc..db09348ab301 100644 --- a/web/src/components/search/SearchSection.tsx +++ b/web/src/components/search/SearchSection.tsx @@ -6,6 +6,7 @@ import { SearchResultsDisplay } from "./SearchResultsDisplay"; import { Quote, Document, SearchResponse } from "./types"; import { SourceSelector } from "./Filters"; import { Source } from "./interfaces"; +import { Connector } from "@/lib/types"; const initialSearchResponse: SearchResponse = { answer: null, @@ -160,7 +161,11 @@ const searchRequestStreamed = async ({ return { answer, quotes, relevantDocuments }; }; -export const SearchSection: React.FC<{}> = () => { +interface SearchSectionProps { + connectors: Connector[]; +} + +export const SearchSection: React.FC = ({ connectors }) => { // Search const [searchResponse, setSearchResponse] = useState( null @@ -176,6 +181,7 @@ export const SearchSection: React.FC<{}> = () => { connector.source)} />
diff --git a/web/src/lib/userSS.ts b/web/src/lib/userSS.ts index 2006ebe51bfe..602ffab223c9 100644 --- a/web/src/lib/userSS.ts +++ b/web/src/lib/userSS.ts @@ -16,6 +16,7 @@ export const getGoogleOAuthUrlSS = async (): Promise => { export const getCurrentUserSS = async (): Promise => { const response = await fetch(buildUrl("/users/me"), { credentials: "include", + next: { revalidate: 0 }, headers: { cookie: cookies() .getAll()