Skip to content

Commit de03129

Browse files
authored
Spinner on color by geneset when closed (#2412)
* take 2 * take 2.1 * bruce test * remove component did mount * working
1 parent 2715dba commit de03129

File tree

1 file changed

+34
-5
lines changed

1 file changed

+34
-5
lines changed

client/src/components/geneExpression/menus/genesetMenus.js

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,47 @@ import {
1313
PopoverInteractionKind,
1414
} from "@blueprintjs/core";
1515

16+
import { createColorQuery } from "../../../util/stateManager/colorHelpers";
17+
1618
import * as globals from "../../../globals";
1719
import actions from "../../../actions";
1820
import AddGeneToGenesetDialogue from "./addGeneToGenesetDialogue";
1921

2022
@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+
}))
2429
class GenesetMenus extends React.PureComponent {
2530
constructor(props) {
2631
super(props);
27-
this.state = {};
32+
this.state = {
33+
dataIsFetching: false,
34+
};
2835
}
2936

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+
3057
activateAddGeneToGenesetMode = () => {
3158
const { dispatch, geneset } = this.props;
3259
dispatch({
@@ -46,7 +73,7 @@ class GenesetMenus extends React.PureComponent {
4673

4774
handleColorByEntireGeneset = () => {
4875
const { dispatch, geneset } = this.props;
49-
76+
this.fetchOurData(); // just in case data was flushed from cache
5077
dispatch({
5178
type: "color by geneset mean expression",
5279
geneset,
@@ -60,6 +87,7 @@ class GenesetMenus extends React.PureComponent {
6087

6188
render() {
6289
const { geneset, genesetsEditable, createText, colorAccessor } = this.props;
90+
const { dataIsFetching } = this.state;
6391

6492
const isColorBy = geneset === colorAccessor;
6593

@@ -123,6 +151,7 @@ class GenesetMenus extends React.PureComponent {
123151
>
124152
<AnchorButton
125153
active={isColorBy}
154+
loading={dataIsFetching}
126155
intent={isColorBy ? "primary" : "none"}
127156
style={{ marginLeft: 0 }}
128157
onClick={this.handleColorByEntireGeneset}

0 commit comments

Comments
 (0)