1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-11-25 06:24:19 +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 { Route, Switch } from "react-router"
import PageLogin from "./routes/PageLogin"
import PageRepositories from "./routes/PageRepositories"
import PageAlerts from "./routes/PageAlerts"
import PageRepositoriesList from "./routes/PageRepositoriesList"
import PageRepositoryAlerts from "./routes/PageRepositoryAlerts"
import PageSettings from "./routes/PageSettings"
import PageDashboard from "./routes/PageDashboard"
import PageRoot from "./routes/PageRoot"
import PageEdit from "./routes/PageEdit"
import PageRepositoryCreate from "./routes/PageRepositoryCreate"
import PageRepositoryEdit from "./routes/PageRepositoryEdit"
import PageUsers from "./routes/PageUsers"
import PageRepository from "./routes/PageRepository"
import PageRepositoryAnalyze from "./routes/PageRepositoryAnalyze"
import PageShare from "./routes/PageShare"
@ -16,34 +15,31 @@ export default function PageSwitcher({ ...props }) {
return (
<Switch {...props}>
<Route path={"/repositories/:id/alerts"} exact={true}>
<PageAlerts/>
<PageRepositoryAlerts/>
</Route>
<Route path={"/repositories/:id/share"} exact={true}>
<PageShare/>
</Route>
<Route path={"/repositories/:id/edit"} exact={true}>
<PageEdit/>
<PageRepositoryEdit/>
</Route>
<Route path={"/repositories/:id"} exact={true}>
<PageRepository/>
</Route>
<Route path={"/login"} exact={true}>
<PageLogin/>
<PageRepositoryAnalyze/>
</Route>
<Route path={"/users"} exact={true}>
<PageUsers/>
</Route>
<Route path={"/repositories"} exact={true}>
<PageRepositories/>
<PageRepositoriesList/>
</Route>
<Route path={"/settings"} exact={true}>
<PageSettings/>
</Route>
<Route path={"/dashboard"} exact={true}>
<PageDashboard/>
<PageRepositoryCreate/>
</Route>
<Route path={"/"}>
<PageRoot/>
<PageLogin/>
</Route>
</Switch>
)

View file

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

View file

@ -26,8 +26,7 @@ export default function Sidebar({ className, ...props }) {
{
user ?
<>
<ButtonSidebar to={"/dashboard"} icon={faHome}>{strings.dashboard}</ButtonSidebar>
<ButtonSidebar to={"/repositories"} icon={faFolder}>{strings.repositories}</ButtonSidebar>
<ButtonSidebar to={"/repositories"} icon={faHome}>{strings.dashboard}</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 classNames from "classnames"
import BoxSetServer from "../components/interactive/BoxSetServer"
import BoxLogin from "../components/interactive/BoxLogin"
import ContextUser from "../contexts/ContextUser"
import { Redirect } from "react-router"
export default function PageLogin({ className, ...props }) {
const {user} = useContext(ContextUser)
if(user) {
return <Redirect to={"/repositories"}/>
}
return (
<div className={classNames(Style.PageLogin, className)} {...props}>
<BoxSetServer/>

View file

@ -1,5 +1,5 @@
import React, { useCallback, useContext } from "react"
import Style from "./PageRepositories.module.css"
import Style from "./PageRepositoriesList.module.css"
import classNames from "classnames"
import useBackendViewset from "../hooks/useBackendViewset"
import BoxRepositories from "../components/interactive/BoxRepositories"
@ -8,7 +8,7 @@ import ContextLanguage from "../contexts/ContextLanguage"
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 history = useHistory()
const { strings } = useContext(ContextLanguage)

View file

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

View file

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

View file

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

View file

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