@@ -31,7 +31,12 @@ import { loadDatasetCompoundsWithScores, loadDataSets } from '../datasets/redux/
31
31
import { SelectedCompoundList } from '../datasets/selectedCompoundsList' ;
32
32
import { DatasetSelectorMenuButton } from '../datasets/datasetSelectorMenuButton' ;
33
33
import ArrowDropDownIcon from '@material-ui/icons/ArrowDropDown' ;
34
- import { setMoleculeListIsLoading , setAllInspirations } from '../datasets/redux/actions' ;
34
+ import {
35
+ setMoleculeListIsLoading ,
36
+ setSelectedDatasetIndex ,
37
+ setTabValue ,
38
+ setAllInspirations
39
+ } from '../datasets/redux/actions' ;
35
40
36
41
const hitNavigatorWidth = 504 ;
37
42
@@ -91,14 +96,15 @@ const Preview = memo(({ isStateLoaded, hideProjects }) => {
91
96
const dispatch = useDispatch ( ) ;
92
97
93
98
const customDatasets = useSelector ( state => state . datasetsReducers . datasets ) ;
94
- const [ selectedDatasetIndex , setSelectedDatasetIndex ] = useState ( 0 ) ;
99
+ const selectedDatasetIndex = useSelector ( state => state . datasetsReducers . selectedDatasetIndex ) ;
95
100
const currentDataset = customDatasets [ selectedDatasetIndex ] ;
96
101
const target_on = useSelector ( state => state . apiReducers . target_on ) ;
97
102
const isTrackingRestoring = useSelector ( state => state . trackingReducers . isTrackingCompoundsRestoring ) ;
98
103
99
104
const all_mol_lists = useSelector ( state => state . apiReducers . all_mol_lists ) ;
100
105
const moleculeLists = useSelector ( state => state . datasetsReducers . moleculeLists ) ;
101
106
const isLoadingMoleculeList = useSelector ( state => state . datasetsReducers . isLoadingMoleculeList ) ;
107
+ const tabValue = useSelector ( state => state . datasetsReducers . tabValue ) ;
102
108
103
109
/*
104
110
Loading datasets
@@ -109,7 +115,7 @@ const Preview = memo(({ isStateLoaded, hideProjects }) => {
109
115
dispatch ( loadDataSets ( target_on ) )
110
116
. then ( results => {
111
117
if ( Array . isArray ( results ) && results . length > 0 ) {
112
- setSelectedDatasetIndex ( 0 ) ;
118
+ dispatch ( setSelectedDatasetIndex ( 0 ) ) ;
113
119
}
114
120
return dispatch ( loadDatasetCompoundsWithScores ( ) ) ;
115
121
} )
@@ -189,14 +195,26 @@ const Preview = memo(({ isStateLoaded, hideProjects }) => {
189
195
) } px - ${ summaryViewHeight } px - ${ projectHistoryHeight } px - ${ TABS_HEADER_HEIGHT } px )`;
190
196
const [ showHistory , setShowHistory ] = useState ( false ) ;
191
197
192
- const [ tabValue , setTabValue ] = useState ( 0 ) ;
193
198
const getTabValue = ( ) => {
194
199
if ( tabValue === 2 ) {
195
200
return tabValue + selectedDatasetIndex ;
196
201
}
197
202
return tabValue ;
198
203
} ;
199
204
205
+ const getTabName = ( ) => {
206
+ if ( tabValue === 0 ) {
207
+ return 'Vector selector' ;
208
+ }
209
+ if ( tabValue === 1 ) {
210
+ return 'Selected compounds' ;
211
+ }
212
+ if ( tabValue >= 2 ) {
213
+ return currentDataset ?. title ;
214
+ }
215
+ return '' ;
216
+ } ;
217
+
200
218
useEffect ( ( ) => {
201
219
// Unmount Preview - reset NGL state
202
220
return ( ) => {
@@ -253,13 +271,25 @@ const Preview = memo(({ isStateLoaded, hideProjects }) => {
253
271
aria-label = "outlined primary button group"
254
272
className = { classes . tabButtonGroup }
255
273
>
256
- < Button size = "small" variant = { getTabValue ( ) === 0 ? 'contained' : 'text' } onClick = { ( ) => setTabValue ( 0 ) } >
274
+ < Button
275
+ size = "small"
276
+ variant = { getTabValue ( ) === 0 ? 'contained' : 'text' }
277
+ onClick = { ( ) => dispatch ( setTabValue ( tabValue , 0 , 'Vector selector' , getTabName ( ) ) ) }
278
+ >
257
279
Vector selector
258
280
</ Button >
259
- < Button size = "small" variant = { getTabValue ( ) === 1 ? 'contained' : 'text' } onClick = { ( ) => setTabValue ( 1 ) } >
281
+ < Button
282
+ size = "small"
283
+ variant = { getTabValue ( ) === 1 ? 'contained' : 'text' }
284
+ onClick = { ( ) => dispatch ( setTabValue ( tabValue , 1 , 'Selected compounds' , getTabName ( ) ) ) }
285
+ >
260
286
Selected compounds
261
287
</ Button >
262
- < Button size = "small" variant = { getTabValue ( ) >= 2 ? 'contained' : 'text' } onClick = { ( ) => setTabValue ( 2 ) } >
288
+ < Button
289
+ size = "small"
290
+ variant = { getTabValue ( ) >= 2 ? 'contained' : 'text' }
291
+ onClick = { ( ) => dispatch ( setTabValue ( tabValue , 2 , currentDataset ?. title , getTabName ( ) ) ) }
292
+ >
263
293
{ currentDataset ?. title }
264
294
</ Button >
265
295
< Button
0 commit comments