-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathLayout.tsx
More file actions
65 lines (55 loc) · 1.69 KB
/
Layout.tsx
File metadata and controls
65 lines (55 loc) · 1.69 KB
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
import React from "react";
import {
EuiPage,
EuiPageSidebar,
EuiPageBody,
EuiErrorBoundary,
EuiHorizontalRule,
EuiSpacer,
} from "@elastic/eui";
import { Outlet } from "react-router-dom";
import RegistryPathContext from "../contexts/RegistryPathContext";
import { useParams } from "react-router-dom";
import { useLoadProjectsList } from "../contexts/ProjectListContext";
import ProjectSelector from "../components/ProjectSelector";
import Sidebar from "./Sidebar";
import FeastWordMark from "../graphics/FeastWordMark";
const Layout = () => {
// Registry Path Context has to be inside Layout
// because it has to be under routes
// in order to use useParams
let { projectName } = useParams();
const { data } = useLoadProjectsList();
const currentProject = data?.projects.find((project) => {
return project.id === projectName;
});
const registryPath = currentProject?.registryPath || "";
return (
<RegistryPathContext.Provider value={registryPath}>
<EuiPage paddingSize="none" style={{ background: "transparent" }}>
<EuiPageSidebar
paddingSize="l"
sticky={{ offset: 0 }}
role={"navigation"}
aria-label={"Top Level"}
>
<FeastWordMark />
<EuiSpacer size="s" />
<ProjectSelector />
{registryPath && (
<React.Fragment>
<EuiHorizontalRule margin="s" />
<Sidebar />
</React.Fragment>
)}
</EuiPageSidebar>
<EuiPageBody>
<EuiErrorBoundary>
<Outlet />
</EuiErrorBoundary>
</EuiPageBody>
</EuiPage>
</RegistryPathContext.Provider>
);
};
export default Layout;