From ce424ffa72ce981446e5b67f4789b7d85fd08753 Mon Sep 17 00:00:00 2001 From: Bigad Soleiman Date: Thu, 8 Feb 2024 15:06:04 +0000 Subject: [PATCH] Remove config import in react-app. Set pprivatewebsite flag in aws-exports.json --- lib/user-interface/index.ts | 1 + lib/user-interface/react-app/src/app.tsx | 38 +++++++++++-------- .../react-app/src/common/types.ts | 1 + .../src/components/app-configured.tsx | 2 +- 4 files changed, 26 insertions(+), 16 deletions(-) diff --git a/lib/user-interface/index.ts b/lib/user-interface/index.ts index 0cc25347d..43dda6589 100644 --- a/lib/user-interface/index.ts +++ b/lib/user-interface/index.ts @@ -99,6 +99,7 @@ export class UserInterface extends Construct { default_cross_encoder_model: Utils.getDefaultCrossEncoderModel( props.config ), + privateWebsite: props.config.privateWebsite ? true : false, }, }); diff --git a/lib/user-interface/react-app/src/app.tsx b/lib/user-interface/react-app/src/app.tsx index 3933c4081..695fc3732 100644 --- a/lib/user-interface/react-app/src/app.tsx +++ b/lib/user-interface/react-app/src/app.tsx @@ -1,25 +1,33 @@ -import { HashRouter, BrowserRouter, Routes, Route, Outlet } from "react-router-dom"; +import { useContext } from "react"; +import { + BrowserRouter, + HashRouter, + Outlet, + Route, + Routes, +} from "react-router-dom"; +import { AppContext } from "./common/app-context"; import GlobalHeader from "./components/global-header"; -import Dashboard from "./pages/rag/dashboard/dashboard"; +import Models from "./pages/chatbot/models/models"; +import MultiChatPlayground from "./pages/chatbot/playground/multi-chat-playground"; +import Playground from "./pages/chatbot/playground/playground"; import NotFound from "./pages/not-found"; -import Workspaces from "./pages/rag/workspaces/workspaces"; -import Engines from "./pages/rag/engines/engines"; +import AddData from "./pages/rag/add-data/add-data"; import CreateWorkspace from "./pages/rag/create-workspace/create-workspace"; -import Embeddings from "./pages/rag/embeddings/embeddings"; import CrossEncoders from "./pages/rag/cross-encoders/cross-encoders"; -import Welcome from "./pages/welcome"; -import Playground from "./pages/chatbot/playground/playground"; -import Models from "./pages/chatbot/models/models"; -import WorkspacePane from "./pages/rag/workspace/workspace"; +import Dashboard from "./pages/rag/dashboard/dashboard"; +import Embeddings from "./pages/rag/embeddings/embeddings"; +import Engines from "./pages/rag/engines/engines"; import SemanticSearch from "./pages/rag/semantic-search/semantic-search"; -import AddData from "./pages/rag/add-data/add-data"; -import "./styles/app.scss"; -import MultiChatPlayground from "./pages/chatbot/playground/multi-chat-playground"; import RssFeed from "./pages/rag/workspace/rss-feed"; -import * as InfraConfig from '../../../../bin/config.json'; +import WorkspacePane from "./pages/rag/workspace/workspace"; +import Workspaces from "./pages/rag/workspaces/workspaces"; +import Welcome from "./pages/welcome"; +import "./styles/app.scss"; function App() { - const Router = InfraConfig.privateWebsite ? HashRouter : BrowserRouter; + const appContext = useContext(AppContext); + const Router = appContext?.config.privateWebsite ? HashRouter : BrowserRouter; return (
@@ -56,7 +64,7 @@ function App() { } />
- + ); } diff --git a/lib/user-interface/react-app/src/common/types.ts b/lib/user-interface/react-app/src/common/types.ts index c13601aa6..9e1877d62 100644 --- a/lib/user-interface/react-app/src/common/types.ts +++ b/lib/user-interface/react-app/src/common/types.ts @@ -21,6 +21,7 @@ export interface AppConfig { websocket_endpoint: string; default_embeddings_model: string; default_cross_encoder_model: string; + privateWebsite: boolean; }; Storage: { AWSS3: { diff --git a/lib/user-interface/react-app/src/components/app-configured.tsx b/lib/user-interface/react-app/src/components/app-configured.tsx index 636819a06..01d09484d 100644 --- a/lib/user-interface/react-app/src/components/app-configured.tsx +++ b/lib/user-interface/react-app/src/components/app-configured.tsx @@ -156,7 +156,7 @@ export default function AppConfigured() { }, }} > - +