diff --git a/src/components/App.js b/src/components/App.js
index 0a74f3d..7121687 100644
--- a/src/components/App.js
+++ b/src/components/App.js
@@ -1,6 +1,6 @@
import React from "react";
import PropTypes from "prop-types";
-import Layout from "./Layout";
+import AppLayout from "./layout/AppLayout";
import { BrowserRouter, Switch, Redirect, Route } from "react-router-dom";
import { useTuitioToken } from "@flare/tuitio-client-react";
import LoginContainer from "../features/login/components/LoginContainer";
@@ -63,7 +63,7 @@ const App = () => {
-
+
);
diff --git a/src/components/Layout.js b/src/components/Layout.js
deleted file mode 100644
index 47b0b8c..0000000
--- a/src/components/Layout.js
+++ /dev/null
@@ -1,253 +0,0 @@
-import React from "react";
-import clsx from "clsx";
-import { makeStyles, useTheme } from "@material-ui/core/styles";
-import Drawer from "@material-ui/core/Drawer";
-import AppBar from "@material-ui/core/AppBar";
-import Toolbar from "@material-ui/core/Toolbar";
-import List from "@material-ui/core/List";
-import Typography from "@material-ui/core/Typography";
-import Divider from "@material-ui/core/Divider";
-import IconButton from "@material-ui/core/IconButton";
-import MenuIcon from "@material-ui/icons/Menu";
-import ChevronLeftIcon from "@material-ui/icons/ChevronLeft";
-import ChevronRightIcon from "@material-ui/icons/ChevronRight";
-import ListItem from "@material-ui/core/ListItem";
-import ListItemIcon from "@material-ui/core/ListItemIcon";
-import ListItemText from "@material-ui/core/ListItemText";
-import DeleteIcon from "@material-ui/icons/Delete";
-import DnsIcon from "@material-ui/icons/Dns";
-import MenuItem from "@material-ui/core/MenuItem";
-import Menu from "@material-ui/core/Menu";
-import AccountCircle from "@material-ui/icons/AccountCircle";
-import SettingsIcon from "@material-ui/icons/Settings";
-import DashboardIcon from "@material-ui/icons/Dashboard";
-import Main from "./layout/Main";
-import { useHistory } from "react-router-dom";
-import { useTuitioClient } from "@flare/tuitio-client-react";
-
-const drawerWidth = 240;
-
-const useStyles = makeStyles(theme => ({
- root: {
- display: "flex"
- },
- appBar: {
- zIndex: theme.zIndex.drawer + 1,
- transition: theme.transitions.create(["width", "margin"], {
- easing: theme.transitions.easing.sharp,
- duration: theme.transitions.duration.leavingScreen
- })
- },
- appBarShift: {
- marginLeft: drawerWidth,
- width: `calc(100% - ${drawerWidth}px)`,
- transition: theme.transitions.create(["width", "margin"], {
- easing: theme.transitions.easing.sharp,
- duration: theme.transitions.duration.enteringScreen
- })
- },
- menuButton: {
- marginRight: 36
- },
- hide: {
- display: "none"
- },
- drawer: {
- width: drawerWidth,
- flexShrink: 0,
- whiteSpace: "nowrap"
- },
- drawerOpen: {
- width: drawerWidth,
- transition: theme.transitions.create("width", {
- easing: theme.transitions.easing.sharp,
- duration: theme.transitions.duration.enteringScreen
- })
- },
- drawerClose: {
- transition: theme.transitions.create("width", {
- easing: theme.transitions.easing.sharp,
- duration: theme.transitions.duration.leavingScreen
- }),
- overflowX: "hidden",
- width: theme.spacing(7) + 1,
- [theme.breakpoints.up("sm")]: {
- width: theme.spacing(9) + 1
- }
- },
- toolbar: {
- display: "flex",
- alignItems: "center",
- justifyContent: "flex-end",
- padding: theme.spacing(0, 1),
- // necessary for content to be below app bar
- ...theme.mixins.toolbar
- },
- title: {
- flexGrow: 1
- },
- content: {
- flexGrow: 1,
- padding: theme.spacing(2)
- }
-}));
-
-export default function MiniDrawer() {
- const classes = useStyles();
- const theme = useTheme();
- const [open, setOpen] = React.useState(false);
- const history = useHistory();
- const { logout } = useTuitioClient();
-
- const handleDrawerOpen = () => {
- setOpen(true);
- };
-
- const handleDrawerClose = () => {
- setOpen(false);
- };
-
- const [userAnchorEl, setUserAnchorEl] = React.useState(null);
- const openUser = Boolean(userAnchorEl);
-
- const handleMenu = event => {
- setUserAnchorEl(event.currentTarget);
- };
-
- const handleClose = () => {
- setUserAnchorEl(null);
- };
-
- return (
-
-
-
-
-
-
-
- Network resurrector
-
-
-
-
-
-
-
- {theme.direction === "rtl" ? (
-
- ) : (
-
- )}
-
-
-
-
- history.push("/dashboard")}
- >
-
-
-
-
-
- history.push("/machines")}
- >
-
-
-
-
-
-
-
-
- history.push("/trash")}>
-
-
-
-
-
- history.push("/settings")}
- >
-
-
-
-
-
-
-
-
-
-
-
-
- );
-}
diff --git a/src/components/layout/AppLayout.js b/src/components/layout/AppLayout.js
new file mode 100644
index 0000000..70092b3
--- /dev/null
+++ b/src/components/layout/AppLayout.js
@@ -0,0 +1,34 @@
+import React, { useState } from "react";
+import { makeStyles } from "@material-ui/core/styles";
+import AppRoutes from "./AppRoutes";
+import TopBar from "./TopBar";
+import Sidebar from "./Sidebar";
+import styles from "./styles";
+
+const useStyles = makeStyles(styles);
+
+const AppLayout = () => {
+ const [open, setOpen] = useState(false);
+ const classes = useStyles();
+
+ const handleDrawerOpen = () => {
+ setOpen(true);
+ };
+
+ const handleDrawerClose = () => {
+ setOpen(false);
+ };
+
+ return (
+
+ );
+};
+
+export default AppLayout;
diff --git a/src/components/layout/Switcher.js b/src/components/layout/AppRoutes.js
similarity index 94%
rename from src/components/layout/Switcher.js
rename to src/components/layout/AppRoutes.js
index 14c57a5..69e207f 100644
--- a/src/components/layout/Switcher.js
+++ b/src/components/layout/AppRoutes.js
@@ -6,7 +6,7 @@ import NetworkContainer from "../../features/network/components/NetworkContainer
import SettingsContainer from "../../features/settings/components/SettingsContainer";
import DashboardContainer from "../../features/dashboard/components/DashboardContainer";
-const Switcher = () => {
+const AppRoutes = () => {
return (
@@ -18,4 +18,4 @@ const Switcher = () => {
);
};
-export default Switcher;
+export default AppRoutes;
diff --git a/src/components/layout/Main.js b/src/components/layout/Main.js
deleted file mode 100644
index 76aeafd..0000000
--- a/src/components/layout/Main.js
+++ /dev/null
@@ -1,13 +0,0 @@
-import React from "react";
-import Switcher from "./Switcher";
-import { useTuitioToken } from "@flare/tuitio-client-react";
-import LoginContainer from "../../features/login/components/LoginContainer";
-
-const Main = () => {
- const { validate: validateToken } = useTuitioToken();
- const tokenIsValid = validateToken();
-
- return <>{tokenIsValid ? : }>;
-};
-
-export default Main;
diff --git a/src/components/layout/Sidebar.js b/src/components/layout/Sidebar.js
new file mode 100644
index 0000000..766688b
--- /dev/null
+++ b/src/components/layout/Sidebar.js
@@ -0,0 +1,102 @@
+import React from "react";
+import PropTypes from "prop-types";
+import clsx from "clsx";
+import { makeStyles, useTheme } from "@material-ui/core/styles";
+import Drawer from "@material-ui/core/Drawer";
+import List from "@material-ui/core/List";
+import Divider from "@material-ui/core/Divider";
+import IconButton from "@material-ui/core/IconButton";
+import ChevronLeftIcon from "@material-ui/icons/ChevronLeft";
+import ChevronRightIcon from "@material-ui/icons/ChevronRight";
+import ListItem from "@material-ui/core/ListItem";
+import ListItemIcon from "@material-ui/core/ListItemIcon";
+import ListItemText from "@material-ui/core/ListItemText";
+import DeleteIcon from "@material-ui/icons/Delete";
+import DnsIcon from "@material-ui/icons/Dns";
+import SettingsIcon from "@material-ui/icons/Settings";
+import DashboardIcon from "@material-ui/icons/Dashboard";
+import { useHistory } from "react-router-dom";
+import styles from "./styles";
+
+const useStyles = makeStyles(styles);
+
+const Sidebar = ({ open, handleDrawerClose }) => {
+ const classes = useStyles();
+ const theme = useTheme();
+ const history = useHistory();
+
+ return (
+
+
+
+ {theme.direction === "rtl" ? (
+
+ ) : (
+
+ )}
+
+
+
+
+ history.push("/dashboard")}
+ >
+
+
+
+
+
+ history.push("/machines")}
+ >
+
+
+
+
+
+
+
+
+ history.push("/trash")}>
+
+
+
+
+
+ history.push("/settings")}
+ >
+
+
+
+
+
+
+
+ );
+};
+
+Sidebar.propTypes = {
+ open: PropTypes.bool.isRequired,
+ handleDrawerClose: PropTypes.func.isRequired
+};
+
+export default Sidebar;
diff --git a/src/components/layout/TopBar.js b/src/components/layout/TopBar.js
new file mode 100644
index 0000000..b4e54b4
--- /dev/null
+++ b/src/components/layout/TopBar.js
@@ -0,0 +1,104 @@
+import React, { useState } from "react";
+import PropTypes from "prop-types";
+import clsx from "clsx";
+import { makeStyles } from "@material-ui/core/styles";
+
+import AppBar from "@material-ui/core/AppBar";
+import Toolbar from "@material-ui/core/Toolbar";
+import Typography from "@material-ui/core/Typography";
+import IconButton from "@material-ui/core/IconButton";
+import MenuIcon from "@material-ui/icons/Menu";
+import MenuItem from "@material-ui/core/MenuItem";
+import Menu from "@material-ui/core/Menu";
+import AccountCircle from "@material-ui/icons/AccountCircle";
+import { useHistory } from "react-router-dom";
+import { useTuitioClient } from "@flare/tuitio-client-react";
+import styles from "./styles";
+
+const useStyles = makeStyles(styles);
+
+const TopBar = ({ open, handleDrawerOpen }) => {
+ const classes = useStyles();
+ const history = useHistory();
+ const { logout } = useTuitioClient();
+
+ const [userAnchorEl, setUserAnchorEl] = useState(null);
+ const openUserMenu = Boolean(userAnchorEl);
+
+ const handleMenu = event => {
+ setUserAnchorEl(event.currentTarget);
+ };
+
+ const handleClose = () => {
+ setUserAnchorEl(null);
+ };
+
+ return (
+
+
+
+
+
+
+ Network resurrector
+
+
+
+
+ );
+};
+
+TopBar.propTypes = {
+ open: PropTypes.bool.isRequired,
+ handleDrawerOpen: PropTypes.func.isRequired
+};
+
+export default TopBar;
diff --git a/src/components/layout/styles.js b/src/components/layout/styles.js
new file mode 100644
index 0000000..0c06cdf
--- /dev/null
+++ b/src/components/layout/styles.js
@@ -0,0 +1,68 @@
+const drawerWidth = 240;
+
+const styles = theme => ({
+ root: {
+ display: "flex"
+ },
+ appBar: {
+ zIndex: theme.zIndex.drawer + 1,
+ transition: theme.transitions.create(["width", "margin"], {
+ easing: theme.transitions.easing.sharp,
+ duration: theme.transitions.duration.leavingScreen
+ })
+ },
+ appBarShift: {
+ marginLeft: drawerWidth,
+ width: `calc(100% - ${drawerWidth}px)`,
+ transition: theme.transitions.create(["width", "margin"], {
+ easing: theme.transitions.easing.sharp,
+ duration: theme.transitions.duration.enteringScreen
+ })
+ },
+ menuButton: {
+ marginRight: 36
+ },
+ hide: {
+ display: "none"
+ },
+ drawer: {
+ width: drawerWidth,
+ flexShrink: 0,
+ whiteSpace: "nowrap"
+ },
+ drawerOpen: {
+ width: drawerWidth,
+ transition: theme.transitions.create("width", {
+ easing: theme.transitions.easing.sharp,
+ duration: theme.transitions.duration.enteringScreen
+ })
+ },
+ drawerClose: {
+ transition: theme.transitions.create("width", {
+ easing: theme.transitions.easing.sharp,
+ duration: theme.transitions.duration.leavingScreen
+ }),
+ overflowX: "hidden",
+ width: theme.spacing(7) + 1,
+ [theme.breakpoints.up("sm")]: {
+ width: theme.spacing(9) + 1
+ }
+ },
+ toolbar: {
+ display: "flex",
+ alignItems: "center",
+ justifyContent: "flex-end",
+ padding: theme.spacing(0, 1),
+ // necessary for content to be below app bar
+ ...theme.mixins.toolbar
+ },
+ title: {
+ flexGrow: 1
+ },
+ content: {
+ flexGrow: 1,
+ padding: theme.spacing(2)
+ }
+});
+
+export default styles;