2021-05-11 21:27:42 +00:00
|
|
|
import React, { useContext } from "react"
|
2021-04-21 13:08:54 +00:00
|
|
|
import Style from "./Sidebar.module.css"
|
|
|
|
import classNames from "classnames"
|
2021-04-29 14:58:31 +00:00
|
|
|
import Logo from "../interactive/Logo"
|
|
|
|
import ButtonSidebar from "../base/ButtonSidebar"
|
2021-05-24 12:13:24 +00:00
|
|
|
import { faCog, faHome, faKey, faUserCog } from "@fortawesome/free-solid-svg-icons"
|
2021-04-29 14:58:31 +00:00
|
|
|
import ContextUser from "../../contexts/ContextUser"
|
2021-05-24 12:13:24 +00:00
|
|
|
import useStrings from "../../hooks/useStrings"
|
2021-04-21 13:08:54 +00:00
|
|
|
|
|
|
|
|
2021-04-23 00:18:06 +00:00
|
|
|
/**
|
|
|
|
* The sidebar of the website, with the logo, buttons to switch between the various pages and a notification counter.
|
|
|
|
*
|
|
|
|
* @param className - Additional class(es) to be added to the outer container.
|
|
|
|
* @param props - Additional props to be passed to the outer container.
|
|
|
|
* @returns {JSX.Element}
|
|
|
|
* @constructor
|
|
|
|
*/
|
|
|
|
export default function Sidebar({ className, ...props }) {
|
2021-05-11 14:37:15 +00:00
|
|
|
const { user } = useContext(ContextUser)
|
2021-05-24 12:13:24 +00:00
|
|
|
const strings = useStrings()
|
2021-04-25 15:22:52 +00:00
|
|
|
|
2021-04-21 13:08:54 +00:00
|
|
|
return (
|
2021-04-26 16:36:41 +00:00
|
|
|
<aside className={classNames(Style.Sidebar, className)} {...props}>
|
2021-04-21 13:37:12 +00:00
|
|
|
<Logo/>
|
2021-04-25 15:22:52 +00:00
|
|
|
{
|
2021-04-26 16:36:41 +00:00
|
|
|
user ?
|
2021-05-11 21:27:42 +00:00
|
|
|
<>
|
2021-05-24 01:51:14 +00:00
|
|
|
<ButtonSidebar to={"/repositories"} icon={faHome}>{strings.dashboard}</ButtonSidebar>
|
2021-05-18 00:04:06 +00:00
|
|
|
<ButtonSidebar to={"/settings"} icon={faCog}>{strings.settings}</ButtonSidebar>
|
2021-05-11 21:27:42 +00:00
|
|
|
</>
|
2021-05-11 14:37:15 +00:00
|
|
|
:
|
2021-05-11 21:27:42 +00:00
|
|
|
<>
|
2021-05-26 20:57:06 +00:00
|
|
|
<ButtonSidebar to={"/"} icon={faKey}>{strings.login}</ButtonSidebar>
|
2021-05-11 21:27:42 +00:00
|
|
|
</>
|
|
|
|
}
|
|
|
|
{
|
2021-05-12 14:44:39 +00:00
|
|
|
user && user.isAdmin ?
|
2021-05-11 21:27:42 +00:00
|
|
|
<>
|
2021-05-18 00:04:06 +00:00
|
|
|
<ButtonSidebar to={"/users"} icon={faUserCog}>{strings.users}</ButtonSidebar>
|
2021-05-11 21:27:42 +00:00
|
|
|
</>
|
2021-05-12 14:44:39 +00:00
|
|
|
:
|
2021-05-11 21:27:42 +00:00
|
|
|
null
|
2021-04-25 15:22:52 +00:00
|
|
|
}
|
2021-04-26 16:36:41 +00:00
|
|
|
</aside>
|
2021-04-21 13:08:54 +00:00
|
|
|
)
|
|
|
|
}
|