@@ -13,20 +13,47 @@ import {
13
13
PopoverInteractionKind ,
14
14
} from "@blueprintjs/core" ;
15
15
16
+ import { createColorQuery } from "../../../util/stateManager/colorHelpers" ;
17
+
16
18
import * as globals from "../../../globals" ;
17
19
import actions from "../../../actions" ;
18
20
import AddGeneToGenesetDialogue from "./addGeneToGenesetDialogue" ;
19
21
20
22
@connect ( ( state ) => ( {
21
- genesetsUI : state . genesetsUI ,
22
- colorAccessor : state . colors . colorAccessor ,
23
- } ) )
23
+ annoMatrix : state . annoMatrix ,
24
+ schema : state . annoMatrix ?. schema ,
25
+ genesetsUI : state . genesetsUI ,
26
+ colorAccessor : state . colors . colorAccessor ,
27
+ genesets : state . genesets . genesets ,
28
+ } ) )
24
29
class GenesetMenus extends React . PureComponent {
25
30
constructor ( props ) {
26
31
super ( props ) ;
27
- this . state = { } ;
32
+ this . state = {
33
+ dataIsFetching : false ,
34
+ } ;
28
35
}
29
36
37
+ fetchOurData = ( ) => {
38
+ /*
39
+ fetch our data. serves two purposes: a) preload upon initial render,
40
+ and b) set busy/loading indicator on any controls that require the data
41
+ to be present, such as the color-by component.
42
+ */
43
+ const { geneset, schema, annoMatrix, genesets } = this . props ;
44
+ this . setState ( { dataIsFetching : true } ) ;
45
+ annoMatrix
46
+ . fetch (
47
+ ...createColorQuery (
48
+ "color by geneset mean expression" ,
49
+ geneset ,
50
+ schema ,
51
+ genesets
52
+ )
53
+ )
54
+ . then ( ( ) => this . setState ( { dataIsFetching : false } ) ) ;
55
+ } ;
56
+
30
57
activateAddGeneToGenesetMode = ( ) => {
31
58
const { dispatch, geneset } = this . props ;
32
59
dispatch ( {
@@ -46,7 +73,7 @@ class GenesetMenus extends React.PureComponent {
46
73
47
74
handleColorByEntireGeneset = ( ) => {
48
75
const { dispatch, geneset } = this . props ;
49
-
76
+ this . fetchOurData ( ) ; // just in case data was flushed from cache
50
77
dispatch ( {
51
78
type : "color by geneset mean expression" ,
52
79
geneset,
@@ -60,6 +87,7 @@ class GenesetMenus extends React.PureComponent {
60
87
61
88
render ( ) {
62
89
const { geneset, genesetsEditable, createText, colorAccessor } = this . props ;
90
+ const { dataIsFetching } = this . state ;
63
91
64
92
const isColorBy = geneset === colorAccessor ;
65
93
@@ -123,6 +151,7 @@ class GenesetMenus extends React.PureComponent {
123
151
>
124
152
< AnchorButton
125
153
active = { isColorBy }
154
+ loading = { dataIsFetching }
126
155
intent = { isColorBy ? "primary" : "none" }
127
156
style = { { marginLeft : 0 } }
128
157
onClick = { this . handleColorByEntireGeneset }
0 commit comments