-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathBottomPanel.tsx
More file actions
118 lines (108 loc) · 3.39 KB
/
Copy pathBottomPanel.tsx
File metadata and controls
118 lines (108 loc) · 3.39 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
import React, { useEffect, useMemo } from "react";
import { connect, useSelector } from "react-redux";
import { useCellTypesQuery } from "common/queries/cellType";
import { RootState } from "reducers";
import { ChromatinViewerProvider } from "common/queries/useChromatinViewerSelectedGene";
import { ChromosomeMap } from "./components/ChromosomeMap/ChromosomeMap";
import { Props, mapStateToProps } from "./types";
import { GeneSelect } from "./components/GeneSelect/GeneSelect";
import {
BottomPanelHeader,
BottomPanelHeaderTitle,
BottomPanelWrapper,
BottomPanelButton,
BottomPanelHeaderActions,
} from "./style";
const MAX_CELL_TYPES = 2;
const BottomSideBar = ({
dispatch,
bottomPanelMinimized,
bottomPanelHidden,
}: Props) => {
const cellTypesQuery = useCellTypesQuery({
enabled: !bottomPanelHidden && !bottomPanelMinimized,
});
const { selectedCellTypes } = useSelector((state: RootState) => ({
selectedCellTypes: state.controls.chromatinSelectedCellTypes,
}));
const cellTypes = useMemo(
() => cellTypesQuery.data ?? [],
[cellTypesQuery.data]
);
useEffect(() => {
if (selectedCellTypes.length === 0 && cellTypes.length > 0) {
// Add initial histogram if none are selected.
dispatch({
type: "toggle chromatin histogram",
cellType: cellTypes[0],
});
}
}, [cellTypes, dispatch, selectedCellTypes.length]);
return (
<BottomPanelWrapper isHidden={bottomPanelHidden}>
<ChromatinViewerProvider>
<BottomPanelHeader>
<BottomPanelHeaderTitle>
Chromatin Accessibility
</BottomPanelHeaderTitle>
<BottomPanelHeaderActions>
<GeneSelect />
<BottomPanelButton
active={false}
data-testid="add-cell-type"
minimal
text="Add Cell Type"
icon="plus"
onClick={() => {
const cellType = cellTypes.find(
(type) => !selectedCellTypes.includes(type)
);
if (!cellType) {
return;
}
dispatch({
type: "toggle chromatin histogram",
cellType,
});
}}
disabled={
cellTypesQuery.isLoading ||
selectedCellTypes.length === MAX_CELL_TYPES
}
/>
<BottomPanelButton
active={false}
data-testid="minimize-bottom-panel"
minimal
text=""
rightIcon={bottomPanelMinimized ? "maximize" : "minimize"}
onClick={() =>
dispatch({
type: "toggle minimize multiome viz panel",
})
}
/>
<BottomPanelButton
active={false}
data-testid="close-bottom-panel"
minimal
text=""
rightIcon="cross"
onClick={() =>
dispatch({
type: "close multiome viz panel",
})
}
/>
</BottomPanelHeaderActions>
</BottomPanelHeader>
{!bottomPanelMinimized && (
<div>
<ChromosomeMap />
</div>
)}
</ChromatinViewerProvider>
</BottomPanelWrapper>
);
};
export default connect(mapStateToProps)(BottomSideBar);