-
Notifications
You must be signed in to change notification settings - Fork 54
/
dashboard.js
95 lines (88 loc) · 3.14 KB
/
dashboard.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import React from "react";
import { HashRouter as Router, Switch, Route } from "react-router-dom";
import NavBar from "../NavBar";
import Sidebar from "../Sidebar";
import Page from "../Page";
import DashboardCell from "../Cell";
import { slugify } from "../utils";
class Dashboard extends React.Component {
render() {
const {
home,
logo,
title,
subtitle,
kernelName,
sourceCodeLink,
verticalLayout,
orientation,
meta,
pages,
} = this.props;
let metaCells = [];
if (meta && meta.length > 0) {
meta.forEach((cell, i) => {
metaCells.push(<DashboardCell key={i} {...cell} />);
});
}
let routes = [];
let globalSidebar;
if (pages && pages.length > 0) {
pages.forEach((page) => {
if (page.tags && page.tags.includes("sidebar")) {
globalSidebar = <Sidebar {...page.sections[0]} />;
} else {
const pageSlug = slugify(page.title);
const pagePath = routes.length == 0 ? "/" : `/${pageSlug}`;
const el = (
<Page
dashboardOrientation={orientation}
dashboardVerticalLayout={verticalLayout}
{...page}
/>
);
routes.push({ path: pagePath, component: el });
}
});
}
const routeComponents = routes.map(({ path, component }, key) => (
<Route exact path={path} key={key}>
{component}
</Route>
));
return (
<Router hashType="noslash">
<div className={`jupyter-flex`}>
<div className="meta-cells">{metaCells}</div>
<div className={`dashboard-${verticalLayout}`}>
<NavBar
home={home}
logo={logo}
title={title}
subtitle={subtitle}
sourceCodeLink={sourceCodeLink}
kernelName={kernelName}
pages={pages}
/>
<main
role="main"
className="content-wrapper container-fluid"
>
{globalSidebar}
<div
className={
globalSidebar !== undefined
? "ml-sm-auto col-md-8 col-lg-10 p-0"
: ""
}
>
<Switch>{routeComponents}</Switch>
</div>
</main>
</div>
</div>
</Router>
);
}
}
export default Dashboard;