1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-11-22 04:54:18 +00:00

🔧 Reorganize pages tree

This commit is contained in:
Steffo 2021-05-24 03:51:14 +02:00
parent 230f0f66ce
commit ab919f351b
Signed by: steffo
GPG key ID: 6965406171929D01
13 changed files with 30 additions and 42 deletions

View file

@ -1,14 +1,13 @@
import React from "react" import React from "react"
import { Route, Switch } from "react-router" import { Route, Switch } from "react-router"
import PageLogin from "./routes/PageLogin" import PageLogin from "./routes/PageLogin"
import PageRepositories from "./routes/PageRepositories" import PageRepositoriesList from "./routes/PageRepositoriesList"
import PageAlerts from "./routes/PageAlerts" import PageRepositoryAlerts from "./routes/PageRepositoryAlerts"
import PageSettings from "./routes/PageSettings" import PageSettings from "./routes/PageSettings"
import PageDashboard from "./routes/PageDashboard" import PageRepositoryCreate from "./routes/PageRepositoryCreate"
import PageRoot from "./routes/PageRoot" import PageRepositoryEdit from "./routes/PageRepositoryEdit"
import PageEdit from "./routes/PageEdit"
import PageUsers from "./routes/PageUsers" import PageUsers from "./routes/PageUsers"
import PageRepository from "./routes/PageRepository" import PageRepositoryAnalyze from "./routes/PageRepositoryAnalyze"
import PageShare from "./routes/PageShare" import PageShare from "./routes/PageShare"
@ -16,34 +15,31 @@ export default function PageSwitcher({ ...props }) {
return ( return (
<Switch {...props}> <Switch {...props}>
<Route path={"/repositories/:id/alerts"} exact={true}> <Route path={"/repositories/:id/alerts"} exact={true}>
<PageAlerts/> <PageRepositoryAlerts/>
</Route> </Route>
<Route path={"/repositories/:id/share"} exact={true}> <Route path={"/repositories/:id/share"} exact={true}>
<PageShare/> <PageShare/>
</Route> </Route>
<Route path={"/repositories/:id/edit"} exact={true}> <Route path={"/repositories/:id/edit"} exact={true}>
<PageEdit/> <PageRepositoryEdit/>
</Route> </Route>
<Route path={"/repositories/:id"} exact={true}> <Route path={"/repositories/:id"} exact={true}>
<PageRepository/> <PageRepositoryAnalyze/>
</Route>
<Route path={"/login"} exact={true}>
<PageLogin/>
</Route> </Route>
<Route path={"/users"} exact={true}> <Route path={"/users"} exact={true}>
<PageUsers/> <PageUsers/>
</Route> </Route>
<Route path={"/repositories"} exact={true}> <Route path={"/repositories"} exact={true}>
<PageRepositories/> <PageRepositoriesList/>
</Route> </Route>
<Route path={"/settings"} exact={true}> <Route path={"/settings"} exact={true}>
<PageSettings/> <PageSettings/>
</Route> </Route>
<Route path={"/dashboard"} exact={true}> <Route path={"/dashboard"} exact={true}>
<PageDashboard/> <PageRepositoryCreate/>
</Route> </Route>
<Route path={"/"}> <Route path={"/"}>
<PageRoot/> <PageLogin/>
</Route> </Route>
</Switch> </Switch>
) )

View file

@ -35,7 +35,7 @@ export default function BoxLogin({ ...props }) {
setWorking(true) setWorking(true)
try { try {
await login(email, password) await login(email, password)
history.push("/dashboard") history.push("/repositories")
} }
catch(e) { catch(e) {
setError(e) setError(e)

View file

@ -26,8 +26,7 @@ export default function Sidebar({ className, ...props }) {
{ {
user ? user ?
<> <>
<ButtonSidebar to={"/dashboard"} icon={faHome}>{strings.dashboard}</ButtonSidebar> <ButtonSidebar to={"/repositories"} icon={faHome}>{strings.dashboard}</ButtonSidebar>
<ButtonSidebar to={"/repositories"} icon={faFolder}>{strings.repositories}</ButtonSidebar>
<ButtonSidebar to={"/settings"} icon={faCog}>{strings.settings}</ButtonSidebar> <ButtonSidebar to={"/settings"} icon={faCog}>{strings.settings}</ButtonSidebar>
</> </>
: :

View file

@ -1,11 +1,18 @@
import React from "react" import React, { useContext } from "react"
import Style from "./PageLogin.module.css" import Style from "./PageLogin.module.css"
import classNames from "classnames" import classNames from "classnames"
import BoxSetServer from "../components/interactive/BoxSetServer" import BoxSetServer from "../components/interactive/BoxSetServer"
import BoxLogin from "../components/interactive/BoxLogin" import BoxLogin from "../components/interactive/BoxLogin"
import ContextUser from "../contexts/ContextUser"
import { Redirect } from "react-router"
export default function PageLogin({ className, ...props }) { export default function PageLogin({ className, ...props }) {
const {user} = useContext(ContextUser)
if(user) {
return <Redirect to={"/repositories"}/>
}
return ( return (
<div className={classNames(Style.PageLogin, className)} {...props}> <div className={classNames(Style.PageLogin, className)} {...props}>
<BoxSetServer/> <BoxSetServer/>

View file

@ -1,5 +1,5 @@
import React, { useCallback, useContext } from "react" import React, { useCallback, useContext } from "react"
import Style from "./PageRepositories.module.css" import Style from "./PageRepositoriesList.module.css"
import classNames from "classnames" import classNames from "classnames"
import useBackendViewset from "../hooks/useBackendViewset" import useBackendViewset from "../hooks/useBackendViewset"
import BoxRepositories from "../components/interactive/BoxRepositories" import BoxRepositories from "../components/interactive/BoxRepositories"
@ -8,7 +8,7 @@ import ContextLanguage from "../contexts/ContextLanguage"
import ContextUser from "../contexts/ContextUser" import ContextUser from "../contexts/ContextUser"
export default function PageRepositories({ children, className, ...props }) { export default function PageRepositoriesList({ children, className, ...props }) {
const bv = useBackendViewset("/api/v1/repositories/", "id") const bv = useBackendViewset("/api/v1/repositories/", "id")
const history = useHistory() const history = useHistory()
const { strings } = useContext(ContextLanguage) const { strings } = useContext(ContextLanguage)

View file

@ -1,5 +1,5 @@
import React, { useContext } from "react" import React, { useContext } from "react"
import Style from "./PageAlerts.module.css" import Style from "./PageRepositoryAlerts.module.css"
import classNames from "classnames" import classNames from "classnames"
import BoxFull from "../components/base/BoxFull" import BoxFull from "../components/base/BoxFull"
import ContextLanguage from "../contexts/ContextLanguage" import ContextLanguage from "../contexts/ContextLanguage"
@ -7,7 +7,7 @@ import BoxHeader from "../components/base/BoxHeader"
import { useParams } from "react-router" import { useParams } from "react-router"
export default function PageAlerts({ children, className, ...props }) { export default function PageRepositoryAlerts({ children, className, ...props }) {
const { strings } = useContext(ContextLanguage) const { strings } = useContext(ContextLanguage)
const { id } = useParams() const { id } = useParams()

View file

@ -3,7 +3,7 @@ import { useParams } from "react-router"
import RepositoryViewer from "../components/providers/RepositoryViewer" import RepositoryViewer from "../components/providers/RepositoryViewer"
export default function PageRepository({ className, ...props }) { export default function PageRepositoryAnalyze({ className, ...props }) {
const { id } = useParams() const { id } = useParams()
return ( return (

View file

@ -1,12 +1,12 @@
import React, { useContext } from "react" import React, { useContext } from "react"
import Style from "./PageDashboard.module.css" import Style from "./PageRepositoryCreate.module.css"
import classNames from "classnames" import classNames from "classnames"
import BoxHeader from "../components/base/BoxHeader" import BoxHeader from "../components/base/BoxHeader"
import RepositoryEditor from "../components/providers/RepositoryEditor" import RepositoryEditor from "../components/providers/RepositoryEditor"
import ContextLanguage from "../contexts/ContextLanguage" import ContextLanguage from "../contexts/ContextLanguage"
export default function PageDashboard({ children, className, ...props }) { export default function PageRepositoryCreate({ children, className, ...props }) {
const { strings } = useContext(ContextLanguage) const { strings } = useContext(ContextLanguage)
return ( return (

View file

@ -1,5 +1,5 @@
import React, { useContext } from "react" import React, { useContext } from "react"
import Style from "./PageDashboard.module.css" import Style from "./PageRepositoryCreate.module.css"
import classNames from "classnames" import classNames from "classnames"
import BoxHeader from "../components/base/BoxHeader" import BoxHeader from "../components/base/BoxHeader"
import RepositoryEditor from "../components/providers/RepositoryEditor" import RepositoryEditor from "../components/providers/RepositoryEditor"
@ -10,7 +10,7 @@ import { useParams } from "react-router"
import ContextLanguage from "../contexts/ContextLanguage" import ContextLanguage from "../contexts/ContextLanguage"
export default function PageEdit({ className, ...props }) { export default function PageRepositoryEdit({ className, ...props }) {
const { strings } = useContext(ContextLanguage) const { strings } = useContext(ContextLanguage)
const { id } = useParams() const { id } = useParams()

View file

@ -1,14 +0,0 @@
import React, { useContext } from "react"
import ContextUser from "../contexts/ContextUser"
import { Redirect } from "react-router"
export default function PageRoot() {
const { state } = useContext(ContextUser)
if(!state) {
return <Redirect to={"/login"}/>
}
return <Redirect to={"/dashboard"}/>
}