mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-09-28 10:28:11 +08:00
* freeze objects * component rendering perf work * use PureComponent where safe * remove obsolete WorldUtil code * make brushable histogram a pure component
64 lines
1.8 KiB
JavaScript
64 lines
1.8 KiB
JavaScript
// jshint esversion: 6
|
|
import React from "react";
|
|
import { AnchorButton, Tooltip } from "@blueprintjs/core";
|
|
import { connect } from "react-redux";
|
|
import { World } from "../../util/stateManager";
|
|
import { tooltipHoverOpenDelay } from "../../globals";
|
|
|
|
@connect()
|
|
class CellSetButton extends React.PureComponent {
|
|
set() {
|
|
const {
|
|
differential,
|
|
crossfilter,
|
|
dispatch,
|
|
eitherCellSetOneOrTwo
|
|
} = this.props;
|
|
|
|
// Reducer and components assume that value will be null if
|
|
// no selection made. World..getSelectedByIndex() returns a
|
|
// zero length TypedArray when nothing is selected.
|
|
let set = World.getSelectedByIndex(crossfilter);
|
|
if (set.length === 0) set = null;
|
|
|
|
if (!differential.diffExp) {
|
|
/* diffexp needs to be cleared before we store a new set */
|
|
dispatch({
|
|
type: `store current cell selection as differential set ${eitherCellSetOneOrTwo}`,
|
|
data: set
|
|
});
|
|
}
|
|
}
|
|
|
|
render() {
|
|
const { differential, eitherCellSetOneOrTwo } = this.props;
|
|
const cellListName = `celllist${eitherCellSetOneOrTwo}`;
|
|
const cellsSelected = differential[cellListName]
|
|
? differential[cellListName].length
|
|
: 0;
|
|
return (
|
|
<Tooltip
|
|
content="Save current selection for differential expression computation"
|
|
position="bottom"
|
|
hoverOpenDelay={tooltipHoverOpenDelay}
|
|
>
|
|
<AnchorButton
|
|
type="button"
|
|
disabled={differential.diffExp}
|
|
onClick={this.set.bind(this)}
|
|
data-testid={`cellset-button-${eitherCellSetOneOrTwo}`}
|
|
>
|
|
{eitherCellSetOneOrTwo}
|
|
{": "}
|
|
<span data-testid={`cellset-count-${eitherCellSetOneOrTwo}`}>
|
|
{cellsSelected}
|
|
</span>
|
|
{" cells"}
|
|
</AnchorButton>
|
|
</Tooltip>
|
|
);
|
|
}
|
|
}
|
|
|
|
export default CellSetButton;
|