-
Notifications
You must be signed in to change notification settings - Fork 105
Expand file tree
/
Copy pathApp.tsx
More file actions
161 lines (153 loc) · 4.77 KB
/
Copy pathApp.tsx
File metadata and controls
161 lines (153 loc) · 4.77 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
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
import "reflect-metadata";
import { container } from "tsyringe";
import { useEffect, useRef, useState } from "react";
import BounceLoader from "react-spinners/BounceLoader";
import { Dialog, dialogClasses } from "@mui/material";
import Divider from "@mui/material/Divider";
import AppBar from "@mui/material/AppBar";
import Toolbar from "@mui/material/Toolbar";
import IconButton from "@mui/material/IconButton";
import Typography from "@mui/material/Typography";
import CloseIcon from "@mui/icons-material/Close";
import MonoLogo from "assets/monoLogo.svg";
import {
BranchSelector,
Statistics,
TemporalFilter,
ThemeSelector,
VerticalClusterList,
StorylineChart,
} from "components";
import "./App.scss";
import type IDEPort from "ide/IDEPort";
import { useAnalayzedData } from "hooks";
import { RefreshButton } from "components/RefreshButton";
import type { IDESentEvents } from "types/IDESentEvents";
import { useBranchStore, useDataStore, useGithubInfo, useLoadingStore, useThemeStore } from "store";
import { THEME_INFO } from "components/ThemeSelector/ThemeSelector.const";
import { InsightsButton } from "components/InsightsButton";
import { pxToRem } from "utils";
const App = () => {
const initRef = useRef<boolean>(false);
const [showStorylineChartModal, setShowStorylineChartModal] = useState(false);
const { handleChangeAnalyzedData } = useAnalayzedData();
const filteredData = useDataStore((state) => state.filteredData);
const { handleChangeBranchList } = useBranchStore();
const { handleGithubInfo, repo } = useGithubInfo();
const { loading, setLoading } = useLoadingStore();
const { theme } = useThemeStore();
const ideAdapter = container.resolve<IDEPort>("IDEAdapter");
const handleOpenStorylineChartModal = () => {
setShowStorylineChartModal(true);
};
const handleCloseStorylineChartModal = () => {
setShowStorylineChartModal(false);
};
useEffect(() => {
if (initRef.current === false) {
const callbacks: IDESentEvents = {
handleChangeAnalyzedData,
handleChangeBranchList,
handleGithubInfo,
};
setLoading(true);
ideAdapter.addIDESentEventListener(callbacks);
ideAdapter.sendFetchAnalyzedDataMessage();
ideAdapter.sendFetchBranchListMessage();
ideAdapter.sendFetchGithubInfo();
initRef.current = true;
}
}, [handleChangeAnalyzedData, handleChangeBranchList, handleGithubInfo, ideAdapter, setLoading]);
if (loading) {
return (
<BounceLoader
color={THEME_INFO[theme as keyof typeof THEME_INFO].colors.primary}
loading={loading}
cssOverride={{
position: "fixed",
left: "50%",
top: "50%",
transform: "translate(-50%, 0)",
}}
/>
);
}
return (
<>
<div className="header-container">
<ThemeSelector />
<BranchSelector />
<div>
<RefreshButton />
<InsightsButton
isNew
sx={{
width: "1.875rem",
height: "1.875rem",
color: "white",
}}
onClick={handleOpenStorylineChartModal}
/>
</div>
</div>
<div className="top-container">
<TemporalFilter />
</div>
<div>
{filteredData.length !== 0 ? (
<div className="middle-container">
<VerticalClusterList />
<Statistics />
</div>
) : (
<div className="no-commits-container">
<MonoLogo />
<h1>No Commits Found.</h1>
<p>Make at least one commit to proceed.</p>
</div>
)}
</div>
{/* Storyline Chart Modal */}
{showStorylineChartModal && (
<Dialog
fullScreen
open={showStorylineChartModal}
onClose={handleCloseStorylineChartModal}
sx={{
[`& .${dialogClasses.paper}`]: {
backgroundColor: "#222324",
},
}}
>
<AppBar sx={{ position: "relative", backgroundColor: "#222324", paddingY: pxToRem(20) }}>
<Toolbar>
<Typography
sx={{ pl: pxToRem(25), flex: 1 }}
variant="h4"
component="div"
>
{`Storyline of ${repo}`}
</Typography>
<IconButton
edge="end"
color="inherit"
onClick={handleCloseStorylineChartModal}
size="large"
aria-label="close"
>
<CloseIcon />
</IconButton>
</Toolbar>
</AppBar>
<Divider
sx={{
backgroundColor: "#F7F7F780",
}}
/>
<StorylineChart />
</Dialog>
)}
</>
);
};
export default App;