mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-10-08 03:18:12 +08:00
Spinner on color by geneset when closed (#2412)
* take 2 * take 2.1 * bruce test * remove component did mount * working
This commit is contained in:
@@ -13,20 +13,47 @@ import {
|
|||||||
PopoverInteractionKind,
|
PopoverInteractionKind,
|
||||||
} from "@blueprintjs/core";
|
} from "@blueprintjs/core";
|
||||||
|
|
||||||
|
import { createColorQuery } from "../../../util/stateManager/colorHelpers";
|
||||||
|
|
||||||
import * as globals from "../../../globals";
|
import * as globals from "../../../globals";
|
||||||
import actions from "../../../actions";
|
import actions from "../../../actions";
|
||||||
import AddGeneToGenesetDialogue from "./addGeneToGenesetDialogue";
|
import AddGeneToGenesetDialogue from "./addGeneToGenesetDialogue";
|
||||||
|
|
||||||
@connect((state) => ({
|
@connect((state) => ({
|
||||||
genesetsUI: state.genesetsUI,
|
annoMatrix: state.annoMatrix,
|
||||||
colorAccessor: state.colors.colorAccessor,
|
schema: state.annoMatrix?.schema,
|
||||||
}))
|
genesetsUI: state.genesetsUI,
|
||||||
|
colorAccessor: state.colors.colorAccessor,
|
||||||
|
genesets: state.genesets.genesets,
|
||||||
|
}))
|
||||||
class GenesetMenus extends React.PureComponent {
|
class GenesetMenus extends React.PureComponent {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {};
|
this.state = {
|
||||||
|
dataIsFetching: false,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fetchOurData = () => {
|
||||||
|
/*
|
||||||
|
fetch our data. serves two purposes: a) preload upon initial render,
|
||||||
|
and b) set busy/loading indicator on any controls that require the data
|
||||||
|
to be present, such as the color-by component.
|
||||||
|
*/
|
||||||
|
const { geneset, schema, annoMatrix, genesets } = this.props;
|
||||||
|
this.setState({ dataIsFetching: true });
|
||||||
|
annoMatrix
|
||||||
|
.fetch(
|
||||||
|
...createColorQuery(
|
||||||
|
"color by geneset mean expression",
|
||||||
|
geneset,
|
||||||
|
schema,
|
||||||
|
genesets
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.then(() => this.setState({ dataIsFetching: false }));
|
||||||
|
};
|
||||||
|
|
||||||
activateAddGeneToGenesetMode = () => {
|
activateAddGeneToGenesetMode = () => {
|
||||||
const { dispatch, geneset } = this.props;
|
const { dispatch, geneset } = this.props;
|
||||||
dispatch({
|
dispatch({
|
||||||
@@ -46,7 +73,7 @@ class GenesetMenus extends React.PureComponent {
|
|||||||
|
|
||||||
handleColorByEntireGeneset = () => {
|
handleColorByEntireGeneset = () => {
|
||||||
const { dispatch, geneset } = this.props;
|
const { dispatch, geneset } = this.props;
|
||||||
|
this.fetchOurData(); // just in case data was flushed from cache
|
||||||
dispatch({
|
dispatch({
|
||||||
type: "color by geneset mean expression",
|
type: "color by geneset mean expression",
|
||||||
geneset,
|
geneset,
|
||||||
@@ -60,6 +87,7 @@ class GenesetMenus extends React.PureComponent {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { geneset, genesetsEditable, createText, colorAccessor } = this.props;
|
const { geneset, genesetsEditable, createText, colorAccessor } = this.props;
|
||||||
|
const { dataIsFetching } = this.state;
|
||||||
|
|
||||||
const isColorBy = geneset === colorAccessor;
|
const isColorBy = geneset === colorAccessor;
|
||||||
|
|
||||||
@@ -123,6 +151,7 @@ class GenesetMenus extends React.PureComponent {
|
|||||||
>
|
>
|
||||||
<AnchorButton
|
<AnchorButton
|
||||||
active={isColorBy}
|
active={isColorBy}
|
||||||
|
loading={dataIsFetching}
|
||||||
intent={isColorBy ? "primary" : "none"}
|
intent={isColorBy ? "primary" : "none"}
|
||||||
style={{ marginLeft: 0 }}
|
style={{ marginLeft: 0 }}
|
||||||
onClick={this.handleColorByEntireGeneset}
|
onClick={this.handleColorByEntireGeneset}
|
||||||
|
|||||||
Reference in New Issue
Block a user