From 26e808d2a12aaa43a7cc81ba1523442afbbc1598 Mon Sep 17 00:00:00 2001 From: Weves Date: Wed, 6 Dec 2023 19:44:28 -0800 Subject: [PATCH] Fix welcome modal --- .../app/admin/bot/SlackBotConfigCreationForm.tsx | 5 ++--- web/src/app/admin/bot/[id]/page.tsx | 9 ++++++--- web/src/app/admin/bot/page.tsx | 2 ++ web/src/app/page.tsx | 2 ++ web/src/components/SSRAutoRefresh.tsx | 12 +++++++++++- web/src/components/WelcomeModal.tsx | 8 +++----- web/src/lib/utilsSS.ts | 13 +------------ 7 files changed, 27 insertions(+), 24 deletions(-) diff --git a/web/src/app/admin/bot/SlackBotConfigCreationForm.tsx b/web/src/app/admin/bot/SlackBotConfigCreationForm.tsx index c4c18d7ffbdf..fa4f383bff4e 100644 --- a/web/src/app/admin/bot/SlackBotConfigCreationForm.tsx +++ b/web/src/app/admin/bot/SlackBotConfigCreationForm.tsx @@ -41,7 +41,6 @@ export const SlackBotCreationForm = ({ existingSlackBotConfig?: SlackBotConfig; }) => { const isUpdate = existingSlackBotConfig !== undefined; - console.log(existingSlackBotConfig); const { popup, setPopup } = usePopup(); const router = useRouter(); @@ -209,8 +208,8 @@ export const SlackBotCreationForm = ({ NOTE: whichever tab you are when you submit the form will be the one that is used. For example, if you are on the - "Personas" tab, then the Persona will be used, even if you - have Document Sets selected. + "Personas" tab, then the Persona will be used, + even if you have Document Sets selected. diff --git a/web/src/app/admin/bot/[id]/page.tsx b/web/src/app/admin/bot/[id]/page.tsx index 23f8a640da3a..fd6c3aab8406 100644 --- a/web/src/app/admin/bot/[id]/page.tsx +++ b/web/src/app/admin/bot/[id]/page.tsx @@ -7,12 +7,13 @@ import { DocumentSet, SlackBotConfig } from "@/lib/types"; import { Text } from "@tremor/react"; import { BackButton } from "@/components/BackButton"; import { Persona } from "../../personas/interfaces"; +import { InstantSSRAutoRefresh } from "@/components/SSRAutoRefresh"; async function Page({ params }: { params: { id: string } }) { const tasks = [ - fetchSS("/manage/admin/slack-bot/config", undefined, true), - fetchSS("/manage/document-set", undefined, true), - fetchSS("/persona", undefined, true), + fetchSS("/manage/admin/slack-bot/config"), + fetchSS("/manage/document-set"), + fetchSS("/persona"), ]; const [slackBotsResponse, documentSetsResponse, personasResponse] = @@ -62,6 +63,8 @@ async function Page({ params }: { params: { id: string } }) { return (
+ + } diff --git a/web/src/app/admin/bot/page.tsx b/web/src/app/admin/bot/page.tsx index c1a318cc802e..fc27e0187f62 100644 --- a/web/src/app/admin/bot/page.tsx +++ b/web/src/app/admin/bot/page.tsx @@ -23,6 +23,7 @@ import { } from "@tremor/react"; import { FiArrowUpRight, FiChevronDown, FiChevronUp } from "react-icons/fi"; import Link from "next/link"; +import { InstantSSRAutoRefresh } from "@/components/SSRAutoRefresh"; const numToDisplay = 50; @@ -285,6 +286,7 @@ const Page = () => { icon={} title="Slack Bot Configuration" /> +
diff --git a/web/src/app/page.tsx b/web/src/app/page.tsx index 0f0ced4275ae..7fe058a46726 100644 --- a/web/src/app/page.tsx +++ b/web/src/app/page.tsx @@ -11,6 +11,7 @@ import { SearchType } from "@/lib/search/interfaces"; import { Persona } from "./admin/personas/interfaces"; import { WelcomeModal } from "@/components/WelcomeModal"; import { unstable_noStore as noStore } from "next/cache"; +import { InstantSSRAutoRefresh } from "@/components/SSRAutoRefresh"; export default async function Home() { // Disable caching so we always get the up to date connector / document set / persona info @@ -85,6 +86,7 @@ export default async function Home() { + {connectors.length === 0 && connectorsResponse?.ok && }
diff --git a/web/src/components/SSRAutoRefresh.tsx b/web/src/components/SSRAutoRefresh.tsx index 7e078348a534..6c816206fce7 100644 --- a/web/src/components/SSRAutoRefresh.tsx +++ b/web/src/components/SSRAutoRefresh.tsx @@ -13,7 +13,17 @@ export function SSRAutoRefresh({ refreshFreq = 5 }: { refreshFreq?: number }) { }, refreshFreq * 1000); return () => clearInterval(interval); - }); + }, []); + + return <>; +} + +export function InstantSSRAutoRefresh() { + const router = useRouter(); + + useEffect(() => { + router.refresh(); + }, []); return <>; } diff --git a/web/src/components/WelcomeModal.tsx b/web/src/components/WelcomeModal.tsx index 9814332c44f7..c106da2c90d7 100644 --- a/web/src/components/WelcomeModal.tsx +++ b/web/src/components/WelcomeModal.tsx @@ -3,8 +3,6 @@ import { Button } from "@tremor/react"; import { Modal } from "./Modal"; import Link from "next/link"; -import { useState } from "react"; -import { FiX } from "react-icons/fi"; export function WelcomeModal() { return ( @@ -29,9 +27,9 @@ export function WelcomeModal() {
- + + +
diff --git a/web/src/lib/utilsSS.ts b/web/src/lib/utilsSS.ts index cd1255ba2d43..6bb9574eba3c 100644 --- a/web/src/lib/utilsSS.ts +++ b/web/src/lib/utilsSS.ts @@ -8,11 +8,7 @@ export function buildUrl(path: string) { return `${INTERNAL_URL}/${path}`; } -export function fetchSS( - url: string, - options?: RequestInit, - addRandomTimestamp: boolean = false -) { +export function fetchSS(url: string, options?: RequestInit) { const init = options || { credentials: "include", cache: "no-store", @@ -23,12 +19,5 @@ export function fetchSS( .join("; "), }, }; - - // add a random timestamp to force NextJS to refetch rather than - // used cached data - if (addRandomTimestamp) { - const timestamp = Date.now(); - url = `${url}?u=${timestamp}`; - } return fetch(buildUrl(url), init); }