mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-04-08 03:00:28 -04:00
remove lang and comment out backend provider
This commit is contained in:
@@ -24,7 +24,6 @@
|
||||
],
|
||||
"dependencies": {
|
||||
"@faker-js/faker": "^9.2.0",
|
||||
"@formatjs/intl-localematcher": "^0.5.5",
|
||||
"@hookform/resolvers": "^3.9.1",
|
||||
"@next/third-parties": "^15.0.3",
|
||||
"@radix-ui/react-alert-dialog": "^1.1.2",
|
||||
@@ -64,7 +63,6 @@
|
||||
"geist": "^1.3.1",
|
||||
"lucide-react": "^0.460.0",
|
||||
"moment": "^2.30.1",
|
||||
"negotiator": "^1.0.0",
|
||||
"next": "^14.2.13",
|
||||
"next-themes": "^0.4.3",
|
||||
"react": "^18",
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
import "server-only";
|
||||
|
||||
const dictionaries: Record<string, () => Promise<any>> = {
|
||||
en: () => import("./dictionaries/en.json").then((module) => module.default),
|
||||
es: () => import("./dictionaries/es.json").then((module) => module.default),
|
||||
};
|
||||
|
||||
export const getDictionary = async (locale: string): Promise<any> => {
|
||||
const localeKey = locale || "en";
|
||||
if (!dictionaries[localeKey]) {
|
||||
return dictionaries["en"]();
|
||||
}
|
||||
return dictionaries[localeKey]();
|
||||
};
|
||||
@@ -1,9 +1,7 @@
|
||||
import { redirect } from "next/navigation";
|
||||
|
||||
export default async function Page({
|
||||
params: { lang },
|
||||
}: {
|
||||
params: { lang: string };
|
||||
}) {
|
||||
redirect("/store");
|
||||
}
|
||||
@@ -3,7 +3,6 @@
|
||||
import * as React from "react";
|
||||
import { ThemeProvider as NextThemesProvider } from "next-themes";
|
||||
import { ThemeProviderProps } from "next-themes/dist/types";
|
||||
import { BackendAPIProvider } from "@/lib/autogpt-server-api";
|
||||
import { TooltipProvider } from "@/components/ui/tooltip";
|
||||
import SupabaseProvider from "@/components/providers/SupabaseProvider";
|
||||
import CredentialsProvider from "@/components/integrations/credentials-provider";
|
||||
@@ -17,11 +16,9 @@ export function Providers({
|
||||
return (
|
||||
<NextThemesProvider {...props}>
|
||||
<SupabaseProvider initialUser={initialUser}>
|
||||
<BackendAPIProvider>
|
||||
<CredentialsProvider>
|
||||
<TooltipProvider>{children}</TooltipProvider>
|
||||
</CredentialsProvider>
|
||||
</BackendAPIProvider>
|
||||
</SupabaseProvider>
|
||||
</NextThemesProvider>
|
||||
);
|
||||
|
||||
@@ -50,9 +50,7 @@ async function getDashboardData() {
|
||||
}
|
||||
|
||||
export default function Page({
|
||||
params: { lang },
|
||||
}: {
|
||||
params: { lang: string };
|
||||
}) {
|
||||
const [submissions, setSubmissions] = useState<StoreSubmissionsResponse>();
|
||||
const [openPopout, setOpenPopout] = useState<boolean>(false);
|
||||
@@ -37,9 +37,7 @@ async function getProfileData() {
|
||||
}
|
||||
|
||||
export default async function Page({
|
||||
params: { lang },
|
||||
}: {
|
||||
params: { lang: string };
|
||||
}) {
|
||||
const { profile } = await getProfileData();
|
||||
|
||||
@@ -28,14 +28,13 @@ export async function generateMetadata({
|
||||
// return agents.agents.map((agent) => ({
|
||||
// creator: agent.creator,
|
||||
// slug: agent.slug,
|
||||
// lang: "en",
|
||||
// }));
|
||||
// }
|
||||
|
||||
export default async function Page({
|
||||
params,
|
||||
}: {
|
||||
params: { lang: string; creator: string; slug: string };
|
||||
params: { creator: string; slug: string };
|
||||
}) {
|
||||
const api = new AutoGPTServerAPI();
|
||||
const agent = await api.getStoreAgent(params.creator, params.slug);
|
||||
@@ -28,14 +28,13 @@ export async function generateMetadata({
|
||||
// const creators = await api.getStoreCreators({ featured: true });
|
||||
// return creators.creators.map((creator) => ({
|
||||
// creator: creator.username,
|
||||
// lang: "en",
|
||||
// }));
|
||||
// }
|
||||
|
||||
export default async function Page({
|
||||
params,
|
||||
}: {
|
||||
params: { lang: string; creator: string };
|
||||
params: { creator: string };
|
||||
}) {
|
||||
const api = new AutoGPTServerAPI();
|
||||
|
||||
@@ -158,9 +158,7 @@ export const metadata: Metadata = {
|
||||
};
|
||||
|
||||
export default async function Page({
|
||||
params: { lang },
|
||||
}: {
|
||||
params: { lang: string };
|
||||
}) {
|
||||
// Get data server-side
|
||||
const { featuredAgents, topAgents, featuredCreators } = await getStoreData();
|
||||
@@ -1,7 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import { useState, useEffect } from "react";
|
||||
import AutoGPTServerAPIClient from "@/lib/autogpt-server-api/client";
|
||||
import { AutoGPTServerAPI } from "@/lib/autogpt-server-api/client";
|
||||
import { AgentsSection } from "@/components/agptui/composite/AgentsSection";
|
||||
import { SearchBar } from "@/components/agptui/SearchBar";
|
||||
import { FeaturedCreators } from "@/components/agptui/composite/FeaturedCreators";
|
||||
@@ -10,10 +10,8 @@ import { SearchFilterChips } from "@/components/agptui/SearchFilterChips";
|
||||
import { SortDropdown } from "@/components/agptui/SortDropdown";
|
||||
|
||||
export default function Page({
|
||||
params,
|
||||
searchParams,
|
||||
}: {
|
||||
params: { lang: string };
|
||||
searchParams: { searchTerm?: string; sort?: string };
|
||||
}) {
|
||||
return (
|
||||
@@ -40,7 +38,7 @@ function SearchResults({
|
||||
useEffect(() => {
|
||||
const fetchData = async () => {
|
||||
setIsLoading(true);
|
||||
const api = new AutoGPTServerAPIClient();
|
||||
const api = new AutoGPTServerAPI();
|
||||
|
||||
try {
|
||||
const [agentsRes, creatorsRes] = await Promise.all([
|
||||
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { logout } from "@/app/[lang]/login/actions";
|
||||
import { logout } from "@/app/login/actions";
|
||||
import { IconLogOut } from "@/components/ui/icons";
|
||||
|
||||
export const ProfilePopoutMenuLogoutButton = () => {
|
||||
|
||||
@@ -16,7 +16,7 @@ import {
|
||||
MyAgentsResponse,
|
||||
} from "@/lib/autogpt-server-api";
|
||||
import { createClient } from "@/lib/supabase/client";
|
||||
import AutoGPTServerAPI from "@/lib/autogpt-server-api/client";
|
||||
import { AutoGPTServerAPI } from "@/lib/autogpt-server-api/client";
|
||||
import { useRouter } from "next/navigation";
|
||||
interface PublishAgentPopoutProps {
|
||||
trigger?: React.ReactNode;
|
||||
|
||||
@@ -1,28 +1,28 @@
|
||||
import { AutoGPTServerAPI } from "./client";
|
||||
import React, { createContext, useMemo } from "react";
|
||||
// import { AutoGPTServerAPI } from "./client";
|
||||
// import React, { createContext, useMemo } from "react";
|
||||
|
||||
const BackendAPIProviderContext = createContext<AutoGPTServerAPI | null>(null);
|
||||
// const BackendAPIProviderContext = createContext<AutoGPTServerAPI | null>(null);
|
||||
|
||||
export function BackendAPIProvider({
|
||||
children,
|
||||
}: {
|
||||
children?: React.ReactNode;
|
||||
}): React.ReactNode {
|
||||
const api = useMemo(() => new AutoGPTServerAPI(), []);
|
||||
// export function BackendAPIProvider({
|
||||
// children,
|
||||
// }: {
|
||||
// children?: React.ReactNode;
|
||||
// }): React.ReactNode {
|
||||
// const api = useMemo(() => new AutoGPTServerAPI(), []);
|
||||
|
||||
return (
|
||||
<BackendAPIProviderContext.Provider value={api}>
|
||||
{children}
|
||||
</BackendAPIProviderContext.Provider>
|
||||
);
|
||||
}
|
||||
// return (
|
||||
// <BackendAPIProviderContext.Provider value={api}>
|
||||
// {children}
|
||||
// </BackendAPIProviderContext.Provider>
|
||||
// );
|
||||
// }
|
||||
|
||||
export function useBackendAPI(): AutoGPTServerAPI {
|
||||
const context = React.useContext(BackendAPIProviderContext);
|
||||
if (!context) {
|
||||
throw new Error(
|
||||
"useBackendAPI must be used within a BackendAPIProviderContext",
|
||||
);
|
||||
}
|
||||
return context;
|
||||
}
|
||||
// export function useBackendAPI(): AutoGPTServerAPI {
|
||||
// const context = React.useContext(BackendAPIProviderContext);
|
||||
// if (!context) {
|
||||
// throw new Error(
|
||||
// "useBackendAPI must be used within a BackendAPIProviderContext",
|
||||
// );
|
||||
// }
|
||||
// return context;
|
||||
// }
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { createServerClient } from "@supabase/ssr";
|
||||
import { NextResponse, type NextRequest } from "next/server";
|
||||
import { LOCALES } from "@/lib/utils";
|
||||
|
||||
// TODO: Update the protected pages list
|
||||
const PROTECTED_PAGES = [
|
||||
@@ -12,7 +11,7 @@ const PROTECTED_PAGES = [
|
||||
];
|
||||
const ADMIN_PAGES = ["/admin"];
|
||||
|
||||
export async function updateSession(request: NextRequest, locale: string) {
|
||||
export async function updateSession(request: NextRequest) {
|
||||
let supabaseResponse = NextResponse.next({
|
||||
request,
|
||||
});
|
||||
@@ -63,44 +62,34 @@ export async function updateSession(request: NextRequest, locale: string) {
|
||||
const userRole = user?.role;
|
||||
const url = request.nextUrl.clone();
|
||||
const pathname = request.nextUrl.pathname;
|
||||
const pathnameHasLocale = LOCALES.some(
|
||||
(locale) =>
|
||||
pathname.startsWith(`/${locale}/`) || pathname === `/${locale}`,
|
||||
);
|
||||
const lang = pathnameHasLocale ? `/${pathname.split("/")[1]}` : "";
|
||||
|
||||
// AUTH REDIRECTS
|
||||
// If not logged in and trying to access a protected page, redirect to login
|
||||
if (
|
||||
(!user &&
|
||||
PROTECTED_PAGES.some((page) => {
|
||||
const combinedPath = `${lang}${page}`;
|
||||
const combinedPath = `${page}`;
|
||||
// console.log("Checking pathname:", request.nextUrl.pathname, "against:", combinedPath);
|
||||
return request.nextUrl.pathname.startsWith(combinedPath);
|
||||
})) ||
|
||||
ADMIN_PAGES.some((page) => {
|
||||
const combinedPath = `${lang}${page}`;
|
||||
const combinedPath = `${page}`;
|
||||
// console.log("Checking pathname:", request.nextUrl.pathname, "against:", combinedPath);
|
||||
return request.nextUrl.pathname.startsWith(combinedPath);
|
||||
})
|
||||
) {
|
||||
// no user, potentially respond by redirecting the user to the login page
|
||||
url.pathname = `${locale}/login`;
|
||||
url.pathname = `/login`;
|
||||
return NextResponse.redirect(url);
|
||||
}
|
||||
if (
|
||||
user &&
|
||||
userRole != "admin" &&
|
||||
ADMIN_PAGES.some((page) =>
|
||||
request.nextUrl.pathname.startsWith(`${lang}${page}`),
|
||||
request.nextUrl.pathname.startsWith(`${page}`),
|
||||
)
|
||||
) {
|
||||
// no user, potentially respond by redirecting the user to the login page
|
||||
url.pathname = `${locale}/monitoring`;
|
||||
return NextResponse.redirect(url);
|
||||
}
|
||||
if (locale) {
|
||||
url.pathname = `${locale}${pathname}`;
|
||||
url.pathname = `/store`;
|
||||
return NextResponse.redirect(url);
|
||||
}
|
||||
|
||||
|
||||
@@ -244,11 +244,6 @@ export function getBehaveAs(): BehaveAs {
|
||||
: BehaveAs.LOCAL;
|
||||
}
|
||||
|
||||
export const LOCALES = process.env.NEXT_PUBLIC_LOCALES
|
||||
? process.env.NEXT_PUBLIC_LOCALES.split(",").filter(Boolean)
|
||||
: ["en"];
|
||||
export const DEFAULT_LOCALE = process.env.NEXT_PUBLIC_DEFAULT_LOCALE || "en";
|
||||
|
||||
function rectanglesOverlap(
|
||||
rect1: { x: number; y: number; width: number; height?: number },
|
||||
rect2: { x: number; y: number; width: number; height?: number },
|
||||
|
||||
@@ -1,37 +1,9 @@
|
||||
import { updateSession } from "@/lib/supabase/middleware";
|
||||
import { type NextRequest } from "next/server";
|
||||
import { NextResponse } from "next/server";
|
||||
import { match } from "@formatjs/intl-localematcher";
|
||||
import Negotiator from "negotiator";
|
||||
import { LOCALES, DEFAULT_LOCALE } from "@/lib/utils";
|
||||
|
||||
function getLocale(request: NextRequest) {
|
||||
try {
|
||||
let headers = Object.fromEntries(request.headers.entries());
|
||||
let languages = new Negotiator({ headers }).languages();
|
||||
if (languages.length === 0 || languages[0] === '*') {
|
||||
languages = ["en"];
|
||||
}
|
||||
return match(languages, LOCALES, DEFAULT_LOCALE);
|
||||
} catch (error) {
|
||||
console.error("Error getting locale, defaulting to English:", error);
|
||||
return "en";
|
||||
}
|
||||
}
|
||||
|
||||
export async function middleware(request: NextRequest) {
|
||||
// Check if there is any supported locale in the pathname
|
||||
const { pathname } = request.nextUrl;
|
||||
const pathnameHasLocale = LOCALES.some(
|
||||
(locale) => pathname.startsWith(`/${locale}/`) || pathname === `/${locale}`,
|
||||
);
|
||||
let locale = "";
|
||||
if (!pathnameHasLocale) {
|
||||
// Redirect if there is no locale
|
||||
locale = `/${getLocale(request)}`;
|
||||
}
|
||||
|
||||
return await updateSession(request, locale);
|
||||
return await updateSession(request);
|
||||
}
|
||||
|
||||
export const config = {
|
||||
|
||||
@@ -1243,13 +1243,6 @@
|
||||
resolved "https://registry.npmjs.org/@floating-ui/utils/-/utils-0.2.8.tgz"
|
||||
integrity sha512-kym7SodPp8/wloecOpcmSnWJsK7M0E5Wg8UcFA+uO4B9s5d0ywXOEro/8HM9x0rW+TljRzul/14UYz3TleT3ig==
|
||||
|
||||
"@formatjs/intl-localematcher@^0.5.5":
|
||||
version "0.5.8"
|
||||
resolved "https://registry.npmjs.org/@formatjs/intl-localematcher/-/intl-localematcher-0.5.8.tgz"
|
||||
integrity sha512-I+WDNWWJFZie+jkfkiK5Mp4hEDyRSEvmyfYadflOno/mmKJKcB17fEpEH0oJu/OWhhCJ8kJBDz2YMd/6cDl7Mg==
|
||||
dependencies:
|
||||
tslib "2"
|
||||
|
||||
"@hapi/hoek@^9.0.0", "@hapi/hoek@^9.3.0":
|
||||
version "9.3.0"
|
||||
resolved "https://registry.npmjs.org/@hapi/hoek/-/hoek-9.3.0.tgz"
|
||||
@@ -8963,11 +8956,6 @@ natural-compare@^1.4.0:
|
||||
resolved "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz"
|
||||
integrity sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==
|
||||
|
||||
negotiator@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.npmjs.org/negotiator/-/negotiator-1.0.0.tgz"
|
||||
integrity sha512-8Ofs/AUQh8MaEcrlq5xOX0CQ9ypTF5dl78mjlMNfOK08fzpgTHQRQPBxcPlEtIw0yRpws+Zo/3r+5WRby7u3Gg==
|
||||
|
||||
neo-async@^2.6.2:
|
||||
version "2.6.2"
|
||||
resolved "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz"
|
||||
@@ -11206,7 +11194,7 @@ tsconfig-paths@^4.0.0, tsconfig-paths@^4.1.2, tsconfig-paths@^4.2.0:
|
||||
minimist "^1.2.6"
|
||||
strip-bom "^3.0.0"
|
||||
|
||||
tslib@2, tslib@^2.0.0, tslib@^2.0.1, tslib@^2.0.3, tslib@^2.1.0, tslib@^2.4.0:
|
||||
tslib@^2.0.0, tslib@^2.0.1, tslib@^2.0.3, tslib@^2.1.0, tslib@^2.4.0:
|
||||
version "2.8.1"
|
||||
resolved "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz"
|
||||
integrity sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==
|
||||
|
||||
Reference in New Issue
Block a user