forked from y-scope/yscope-log-viewer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.tsx
99 lines (85 loc) · 2.83 KB
/
index.tsx
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
96
97
98
99
import {
useContext,
useState,
} from "react";
import {
Divider,
Sheet,
Stack,
Typography,
} from "@mui/joy";
import DescriptionIcon from "@mui/icons-material/Description";
import FileOpenIcon from "@mui/icons-material/FileOpen";
import SearchIcon from "@mui/icons-material/Search";
import SettingsIcon from "@mui/icons-material/Settings";
import {StateContext} from "../../contexts/StateContextProvider";
import {CURSOR_CODE} from "../../typings/worker";
import {openFile} from "../../utils/file";
import SettingsModal from "../modals/SettingsModal";
import ExportLogsButton from "./ExportLogsButton";
import NavigationBar from "./NavigationBar";
import SmallIconButton from "./SmallIconButton";
import "./index.css";
/**
* Renders a menu bar which displays file information and provides navigation and settings buttons.
*
* @return
*/
const MenuBar = () => {
const {fileName, loadFile, queryLogs} = useContext(StateContext);
const [isSettingsModalOpen, setIsSettingsModalOpen] = useState<boolean>(false);
const handleSearchButtonClick = () => {
queryLogs("scheduled", false, false);
};
const handleOpenFileButtonClick = () => {
openFile((file) => {
loadFile(file, {code: CURSOR_CODE.LAST_EVENT, args: null});
});
};
const handleSettingsModalClose = () => {
setIsSettingsModalOpen(false);
};
const handleSettingsModalOpen = () => {
setIsSettingsModalOpen(true);
};
return (
<>
<Sheet className={"menu-bar"}>
<Stack
alignItems={"center"}
className={"menu-bar-filename"}
direction={"row"}
flexGrow={1}
gap={0.5}
>
<DescriptionIcon/>
<Typography level={"body-md"}>
{fileName}
</Typography>
</Stack>
<Divider orientation={"vertical"}/>
<NavigationBar/>
<Divider orientation={"vertical"}/>
<SmallIconButton onClick={handleOpenFileButtonClick}>
<FileOpenIcon/>
</SmallIconButton>
<Divider orientation={"vertical"}/>
<SmallIconButton
onClick={handleSettingsModalOpen}
>
<SettingsIcon/>
</SmallIconButton>
<ExportLogsButton/>
<SmallIconButton
onClick={handleSearchButtonClick}
>
<SearchIcon/>
</SmallIconButton>
</Sheet>
<SettingsModal
isOpen={isSettingsModalOpen}
onClose={handleSettingsModalClose}/>
</>
);
};
export default MenuBar;