Skip to content

Commit

Permalink
Upgrade to latest NextJS + switch to turbopack (#3027)
Browse files Browse the repository at this point in the history
* Upgrade to NextJS 15 + use turbopacK

* Remove unintended change

* Update nextjs version

* Remove override

* Upgrade react

* Fix charts

* Style

* Style

* Fix prettier

* slight modification

---------

Co-authored-by: pablodanswer <pablo@danswer.ai>
  • Loading branch information
Weves and pablonyx authored Nov 3, 2024
1 parent 70f703c commit 938d578
Show file tree
Hide file tree
Showing 36 changed files with 2,002 additions and 1,531 deletions.
1 change: 0 additions & 1 deletion web/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const { withSentryConfig } = require("@sentry/nextjs");
/** @type {import('next').NextConfig} */
const nextConfig = {
output: "standalone",
swcMinify: true,
publicRuntimeConfig: {
version,
},
Expand Down
2,611 changes: 1,255 additions & 1,356 deletions web/package-lock.json

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.2-dev",
"private": true,
"scripts": {
"dev": "next dev",
"dev": "next dev --turbopack",
"build": "next build",
"start": "next start",
"lint": "next lint"
Expand All @@ -12,6 +12,8 @@
"@dnd-kit/core": "^6.1.0",
"@dnd-kit/modifiers": "^7.0.0",
"@dnd-kit/sortable": "^8.0.0",
"@dnd-kit/utilities": "^3.2.2",
"@headlessui/react": "^2.2.0",
"@headlessui/tailwindcss": "^0.2.1",
"@phosphor-icons/react": "^2.0.8",
"@radix-ui/react-dialog": "^1.0.5",
Expand Down Expand Up @@ -39,7 +41,7 @@
"lodash": "^4.17.21",
"lucide-react": "^0.454.0",
"mdast-util-find-and-replace": "^3.0.1",
"next": "^14.2.3",
"next": "^15.0.2",
"npm": "^10.8.0",
"postcss": "^8.4.31",
"posthog-js": "^1.176.0",
Expand Down Expand Up @@ -71,5 +73,8 @@
"eslint": "^8.48.0",
"eslint-config-next": "^14.1.0",
"prettier": "2.8.8"
},
"overrides": {
"react-is": "^19.0.0-rc-69d4b800-20241021"
}
}
536 changes: 535 additions & 1 deletion web/public/Wikipedia.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion web/src/app/admin/assistants/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import { AdminPageTitle } from "@/components/admin/Title";
import CardSection from "@/components/admin/CardSection";
import Title from "@/components/ui/title";

export default async function Page({ params }: { params: { id: string } }) {
export default async function Page(props: { params: Promise<{ id: string }> }) {
const params = await props.params;
const [values, error] = await fetchAssistantEditorInfoSS(params.id);

let body;
Expand Down
3 changes: 2 additions & 1 deletion web/src/app/admin/bot/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import {
} from "@/lib/assistants/fetchAssistantsSS";
import { getStandardAnswerCategoriesIfEE } from "@/components/standardAnswers/getStandardAnswerCategoriesIfEE";

async function Page({ params }: { params: { id: string } }) {
async function Page(props: { params: Promise<{ id: string }> }) {
const params = await props.params;
const tasks = [
fetchSS("/manage/admin/slack-bot/config"),
fetchSS("/manage/document-set"),
Expand Down
5 changes: 3 additions & 2 deletions web/src/app/admin/connector/[ccPairId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { Button } from "@/components/ui/button";
import Title from "@/components/ui/title";
import { Separator } from "@/components/ui/separator";
import { useRouter } from "next/navigation";
import { useCallback, useEffect, useRef, useState } from "react";
import { useCallback, useEffect, useRef, useState, use } from "react";
import useSWR, { mutate } from "swr";
import { AdvancedConfigDisplay, ConfigDisplay } from "./ConfigDisplay";
import { DeletionButton } from "./DeletionButton";
Expand Down Expand Up @@ -278,7 +278,8 @@ function Main({ ccPairId }: { ccPairId: number }) {
);
}

export default function Page({ params }: { params: { ccPairId: string } }) {
export default function Page(props: { params: Promise<{ ccPairId: string }> }) {
const params = use(props.params);
const ccPairId = parseInt(params.ccPairId);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ import {
import { processCookies } from "@/lib/userSS";

export const GET = async (request: NextRequest) => {
const requestCookies = await cookies();
const connector = request.url.includes("gmail") ? "gmail" : "google-drive";
const callbackEndpoint = `/manage/connector/${connector}/callback`;
const url = new URL(buildUrl(callbackEndpoint));
url.search = request.nextUrl.search;

const response = await fetch(url.toString(), {
headers: {
cookie: processCookies(cookies()),
cookie: processCookies(requestCookies),
},
});

Expand All @@ -33,7 +34,7 @@ export const GET = async (request: NextRequest) => {
? GMAIL_AUTH_IS_ADMIN_COOKIE_NAME
: GOOGLE_DRIVE_AUTH_IS_ADMIN_COOKIE_NAME;

if (cookies().get(authCookieName)?.value?.toLowerCase() === "true") {
if (requestCookies.get(authCookieName)?.value?.toLowerCase() === "true") {
return NextResponse.redirect(
new URL(`/admin/connectors/${connector}`, getDomain(request))
);
Expand Down
7 changes: 3 additions & 4 deletions web/src/app/admin/connectors/[connector]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { ConfigurableSources } from "@/lib/types";
import ConnectorWrapper from "./ConnectorWrapper";

export default async function Page({
params,
}: {
params: { connector: string };
export default async function Page(props: {
params: Promise<{ connector: string }>;
}) {
const params = await props.params;
return (
<ConnectorWrapper
connector={params.connector.replace("-", "_") as ConfigurableSources}
Expand Down
7 changes: 3 additions & 4 deletions web/src/app/admin/documents/explorer/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ import { ZoomInIcon } from "@/components/icons/icons";
import { Explorer } from "./Explorer";
import { fetchValidFilterInfo } from "@/lib/search/utilsSS";

const Page = async ({
searchParams,
}: {
searchParams: { [key: string]: string };
const Page = async (props: {
searchParams: Promise<{ [key: string]: string }>;
}) => {
const searchParams = await props.searchParams;
const { connectors, documentSets } = await fetchValidFilterInfo();

return (
Expand Down
8 changes: 4 additions & 4 deletions web/src/app/admin/documents/sets/[documentSetId]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"use client";
import { use } from "react";

import { ErrorCallout } from "@/components/ErrorCallout";
import { refreshDocumentSets, useDocumentSets } from "../hooks";
Expand Down Expand Up @@ -93,11 +94,10 @@ function Main({ documentSetId }: { documentSetId: number }) {
);
}

export default function Page({
params,
}: {
params: { documentSetId: string };
export default function Page(props: {
params: Promise<{ documentSetId: string }>;
}) {
const params = use(props.params);
const documentSetId = parseInt(params.documentSetId);

return (
Expand Down
4 changes: 3 additions & 1 deletion web/src/app/admin/indexing/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"use client";
import { use } from "react";

import { BackButton } from "@/components/BackButton";
import { ErrorCallout } from "@/components/ErrorCallout";
Expand Down Expand Up @@ -46,7 +47,8 @@ function Main({ id }: { id: number }) {
);
}

export default function Page({ params }: { params: { id: string } }) {
export default function Page(props: { params: Promise<{ id: string }> }) {
const params = use(props.params);
const id = parseInt(params.id);

return (
Expand Down
91 changes: 47 additions & 44 deletions web/src/app/admin/indexing/status/CCPairIndexingStatusTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
TableHead,
TableBody,
TableCell,
TableHeader,
} from "@/components/ui/table";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
Expand Down Expand Up @@ -363,52 +364,54 @@ export function CCPairIndexingStatusTable({

return (
<Table>
<ConnectorRow
invisible
ccPairsIndexingStatus={{
cc_pair_id: 1,
name: "Sample File Connector",
cc_pair_status: ConnectorCredentialPairStatus.ACTIVE,
last_status: "success",
connector: {
<TableHeader>
<ConnectorRow
invisible
ccPairsIndexingStatus={{
cc_pair_id: 1,
name: "Sample File Connector",
source: "file",
input_type: "poll",
connector_specific_config: {
file_locations: ["/path/to/sample/file.txt"],
cc_pair_status: ConnectorCredentialPairStatus.ACTIVE,
last_status: "success",
connector: {
name: "Sample File Connector",
source: "file",
input_type: "poll",
connector_specific_config: {
file_locations: ["/path/to/sample/file.txt"],
},
refresh_freq: 86400,
prune_freq: null,
indexing_start: new Date("2023-07-01T12:00:00Z"),
id: 1,
credential_ids: [],
time_created: "2023-07-01T12:00:00Z",
time_updated: "2023-07-01T12:00:00Z",
},
refresh_freq: 86400,
prune_freq: null,
indexing_start: new Date("2023-07-01T12:00:00Z"),
id: 1,
credential_ids: [],
time_created: "2023-07-01T12:00:00Z",
time_updated: "2023-07-01T12:00:00Z",
},
credential: {
id: 1,
name: "Sample Credential",
source: "file",
user_id: "1",
time_created: "2023-07-01T12:00:00Z",
time_updated: "2023-07-01T12:00:00Z",
credential_json: {},
admin_public: false,
},
access_type: "public",
docs_indexed: 1000,
last_success: "2023-07-01T12:00:00Z",
last_finished_status: "success",
latest_index_attempt: null,
owner: "1",
error_msg: "",
deletion_attempt: null,
is_deletable: true,
in_progress: false,
groups: [], // Add this line
}}
isEditable={false}
/>
credential: {
id: 1,
name: "Sample Credential",
source: "file",
user_id: "1",
time_created: "2023-07-01T12:00:00Z",
time_updated: "2023-07-01T12:00:00Z",
credential_json: {},
admin_public: false,
},
access_type: "public",
docs_indexed: 1000,
last_success: "2023-07-01T12:00:00Z",
last_finished_status: "success",
latest_index_attempt: null,
owner: "1",
error_msg: "",
deletion_attempt: null,
is_deletable: true,
in_progress: false,
groups: [], // Add this line
}}
isEditable={false}
/>
</TableHeader>
<div className="flex -mt-12 items-center w-0 m4 gap-x-2">
<input
type="text"
Expand Down
5 changes: 4 additions & 1 deletion web/src/app/admin/tools/edit/[toolId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import { AdminPageTitle } from "@/components/admin/Title";
import { BackButton } from "@/components/BackButton";
import { ToolIcon } from "@/components/icons/icons";

export default async function Page({ params }: { params: { toolId: string } }) {
export default async function Page(props: {
params: Promise<{ toolId: string }>;
}) {
const params = await props.params;
const tool = await fetchToolByIdSS(params.toolId);

let body;
Expand Down
21 changes: 14 additions & 7 deletions web/src/app/api/[...path]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,50 +6,57 @@ each request type >:( */

export async function GET(
request: NextRequest,
{ params }: { params: { path: string[] } }
props: { params: Promise<{ path: string[] }> }
) {
const params = await props.params;
return handleRequest(request, params.path);
}

export async function POST(
request: NextRequest,
{ params }: { params: { path: string[] } }
props: { params: Promise<{ path: string[] }> }
) {
const params = await props.params;
return handleRequest(request, params.path);
}

export async function PUT(
request: NextRequest,
{ params }: { params: { path: string[] } }
props: { params: Promise<{ path: string[] }> }
) {
const params = await props.params;
return handleRequest(request, params.path);
}

export async function PATCH(
request: NextRequest,
{ params }: { params: { path: string[] } }
props: { params: Promise<{ path: string[] }> }
) {
const params = await props.params;
return handleRequest(request, params.path);
}

export async function DELETE(
request: NextRequest,
{ params }: { params: { path: string[] } }
props: { params: Promise<{ path: string[] }> }
) {
const params = await props.params;
return handleRequest(request, params.path);
}

export async function HEAD(
request: NextRequest,
{ params }: { params: { path: string[] } }
props: { params: Promise<{ path: string[] }> }
) {
const params = await props.params;
return handleRequest(request, params.path);
}

export async function OPTIONS(
request: NextRequest,
{ params }: { params: { path: string[] } }
props: { params: Promise<{ path: string[] }> }
) {
const params = await props.params;
return handleRequest(request, params.path);
}

Expand Down
3 changes: 2 additions & 1 deletion web/src/app/assistants/edit/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import { DeletePersonaButton } from "@/app/admin/assistants/[id]/DeletePersonaBu
import { LargeBackButton } from "../../LargeBackButton";
import Title from "@/components/ui/title";

export default async function Page({ params }: { params: { id: string } }) {
export default async function Page(props: { params: Promise<{ id: string }> }) {
const params = await props.params;
const [values, error] = await fetchAssistantEditorInfoSS(params.id);

let body;
Expand Down
Loading

0 comments on commit 938d578

Please sign in to comment.