-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor caraml ai app into generic streamlit placeholders
- Loading branch information
1 parent
ab32304
commit b5afa85
Showing
7 changed files
with
50 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,39 @@ | ||
import React from "react"; | ||
import React, { useContext } from "react"; | ||
import { Home, Project } from "./pages"; | ||
import { ProjectCreation } from "./project_setting/ProjectCreation"; | ||
import ProjectSetting from "./project_setting/ProjectSetting"; | ||
import { Navigate, Route, Routes } from "react-router-dom"; | ||
import { StreamlitPlaceholderPage } from "./streamlit_placeholder_page/StreamlitPlaceholderPage"; | ||
import { ApplicationsContext } from "@caraml-dev/ui-lib"; | ||
|
||
export const AppRoutes = () => ( | ||
<Routes> | ||
{/* LANDING */} | ||
<Route index element={<Home />} /> | ||
export const AppRoutes = () => { | ||
const { apps, isLoaded } = useContext(ApplicationsContext); | ||
|
||
<Route path="projects"> | ||
{/* PROJECT LANDING PAGE */} | ||
<Route path=":projectId" element={<Project />} /> | ||
{/* PROJECT SETTING */} | ||
<Route path=":projectId/settings/*" element={<ProjectSetting />} /> | ||
{/* New Project */} | ||
<Route path="create" element={<ProjectCreation />} /> | ||
</Route> | ||
// If the apps have not been loaded yet, we do not render any of the app related routes - the additional streamlit | ||
// apps need to be retrieved from the MLP API v2/applications endpoint first before we generate each route for them. | ||
// Once those apps are loaded, AppRoutes will be re-rendered, | ||
return isLoaded && ( | ||
<Routes> | ||
{/* LANDING */} | ||
<Route index element={<Home />} /> | ||
|
||
{/* DEFAULT */} | ||
<Route path="*" element={<Navigate to="/pages/404" replace={true} />} /> | ||
</Routes> | ||
); | ||
{apps?.map(app => !!app.streamlit_placeholder_page_config && | ||
<Route key={app.name} path={app.homepage} element={<StreamlitPlaceholderPage app={app} />} />) | ||
} | ||
|
||
<Route path="projects"> | ||
{/* PROJECT LANDING PAGE */} | ||
<Route path=":projectId" element={<Project />} /> | ||
{/* PROJECT SETTING */} | ||
<Route path=":projectId/settings/*" element={<ProjectSetting />} /> | ||
{/* New Project */} | ||
<Route path="create" element={<ProjectCreation />} /> | ||
</Route> | ||
|
||
{/* DEFAULT */} | ||
<Route path="*" element={<Navigate to="/pages/404" replace={true} />} /> | ||
</Routes> | ||
) | ||
}; | ||
|
||
export default AppRoutes; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters