Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor auth routes with <Outlet />s (#6334)
* Refactor auth routes with <Outlet />s * Eliminate all route components except the index routing tree
- Loading branch information
1 parent
48470a8
commit 60b98cb
Showing
34 changed files
with
360 additions
and
522 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,61 @@ | ||
import React from "react"; | ||
|
||
import React, {useEffect, useState} from "react"; | ||
import {Outlet, useOutletContext} from "react-router-dom"; | ||
import Container from "react-bootstrap/Container"; | ||
import Row from "react-bootstrap/Row"; | ||
import Col from "react-bootstrap/Col"; | ||
import Nav from "react-bootstrap/Nav"; | ||
import Card from "react-bootstrap/Card"; | ||
|
||
import Layout from "../layout"; | ||
import {Link} from "../nav"; | ||
import {useLoginConfigContext} from "../../hooks/conf"; | ||
|
||
|
||
export const AuthLayout = ({ children, activeTab }) => { | ||
export const AuthLayout = () => { | ||
const [activeTab, setActiveTab] = useState("credentials"); | ||
const {RBAC: rbac} = useLoginConfigContext(); | ||
const [setIsLogged] = useOutletContext(); | ||
useEffect(() => { | ||
setIsLogged(true); | ||
}, [setIsLogged]); | ||
return ( | ||
<Layout> | ||
<Container fluid="xl"> | ||
<Row className="mt-5"> | ||
<Col md={{span: 3}}> | ||
<Card> | ||
<Card.Header> | ||
<Card.Title>Access Control</Card.Title> | ||
</Card.Header> | ||
<Card.Body> | ||
<Nav variant="pills" className="flex-column"> | ||
<Link component={Nav.Link} href="/auth/credentials" active={activeTab === 'credentials'}> | ||
My Credentials | ||
</Link> | ||
</Nav> | ||
|
||
<hr/> | ||
|
||
<Nav variant="pills" className="flex-column"> | ||
<Link component={Nav.Link} href="/auth/users" active={activeTab === 'users'}> | ||
Users | ||
</Link> | ||
|
||
<Link component={Nav.Link} href="/auth/groups" active={activeTab === 'groups'}> | ||
Groups | ||
</Link> | ||
{rbac !== 'simplified' && | ||
<Link component={Nav.Link} href="/auth/policies" active={activeTab === 'policies'}> | ||
Policies | ||
</Link>} | ||
</Nav> | ||
</Card.Body> | ||
</Card> | ||
|
||
</Col> | ||
<Col md={{span: 9}}> | ||
{children} | ||
</Col> | ||
</Row> | ||
</Container> | ||
</Layout> | ||
<Container fluid="xl"> | ||
<Row className="mt-5"> | ||
<Col md={{span: 3}}> | ||
<Card> | ||
<Card.Header> | ||
<Card.Title>Access Control</Card.Title> | ||
</Card.Header> | ||
<Card.Body> | ||
<Nav variant="pills" className="flex-column"> | ||
<Link component={Nav.Link} href="/auth/credentials" active={activeTab === 'credentials'}> | ||
My Credentials | ||
</Link> | ||
</Nav> | ||
|
||
<hr/> | ||
|
||
<Nav variant="pills" className="flex-column"> | ||
<Link component={Nav.Link} href="/auth/users" active={activeTab === 'users'}> | ||
Users | ||
</Link> | ||
|
||
<Link component={Nav.Link} href="/auth/groups" active={activeTab === 'groups'}> | ||
Groups | ||
</Link> | ||
{rbac !== 'simplified' && | ||
<Link component={Nav.Link} href="/auth/policies" active={activeTab === 'policies'}> | ||
Policies | ||
</Link>} | ||
</Nav> | ||
</Card.Body> | ||
</Card> | ||
|
||
</Col> | ||
<Col md={{span: 9}}> | ||
<Outlet context={[setActiveTab]} /> | ||
</Col> | ||
</Row> | ||
</Container> | ||
); | ||
}; | ||
|
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,16 +1,21 @@ | ||
import React from "react"; | ||
import React, {useState} from "react"; | ||
import { Outlet } from "react-router-dom"; | ||
import { StorageConfigProvider } from "../hooks/storageConfig"; | ||
|
||
import TopNav from './navbar'; | ||
|
||
const Layout = ({ logged = true, children }) => { | ||
const Layout = ({ logged }) => { | ||
const [isLogged, setIsLogged] = useState(logged ?? true); | ||
return ( | ||
<> | ||
<TopNav logged={logged}/> | ||
<TopNav logged={isLogged}/> | ||
<div className="main-app"> | ||
{children} | ||
<StorageConfigProvider> | ||
<Outlet context={[setIsLogged]} /> | ||
</StorageConfigProvider> | ||
</div> | ||
</> | ||
); | ||
}; | ||
|
||
export default Layout; | ||
export default Layout; |
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 was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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
Oops, something went wrong.