Skip to content

Commit

Permalink
Remove config import in react-app. Set pprivatewebsite flag in aws-ex…
Browse files Browse the repository at this point in the history
…ports.json
  • Loading branch information
bigadsoleiman committed Feb 8, 2024
1 parent f73581c commit ce424ff
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 16 deletions.
1 change: 1 addition & 0 deletions lib/user-interface/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export class UserInterface extends Construct {
default_cross_encoder_model: Utils.getDefaultCrossEncoderModel(
props.config
),
privateWebsite: props.config.privateWebsite ? true : false,
},
});

Expand Down
38 changes: 23 additions & 15 deletions lib/user-interface/react-app/src/app.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<div style={{ height: "100%" }}>
Expand Down Expand Up @@ -56,7 +64,7 @@ function App() {
<Route path="*" element={<NotFound />} />
</Routes>
</div>
</Router>
</Router>
</div>
);
}
Expand Down
1 change: 1 addition & 0 deletions lib/user-interface/react-app/src/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface AppConfig {
websocket_endpoint: string;
default_embeddings_model: string;
default_cross_encoder_model: string;
privateWebsite: boolean;
};
Storage: {
AWSS3: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export default function AppConfigured() {
},
}}
>
<App />
<App />
</Authenticator>
</ThemeProvider>
</AppContext.Provider>
Expand Down

0 comments on commit ce424ff

Please sign in to comment.