import React from "react"; import { connect } from "react-redux"; import { AnchorButton, Icon } from "@blueprintjs/core"; import Truncate from "../util/truncate"; import HistogramBrush from "../brushableHistogram"; import * as globals from "../../globals"; import actions from "../../actions"; @connect((state, ownProps) => { const { gene } = ownProps; return { isColorAccessor: state.colors.colorAccessor === gene, isScatterplotXXaccessor: state.controls.scatterplotXXaccessor === gene, isScatterplotYYaccessor: state.controls.scatterplotYYaccessor === gene, }; }) class Gene extends React.Component { constructor(props) { super(props); this.state = { geneIsExpanded: false, }; } onColorChangeClick = () => { const { dispatch, gene } = this.props; dispatch(actions.requestSingleGeneExpressionCountsForColoringPOST(gene)); }; handleGeneExpandClick = () => { const { geneIsExpanded } = this.state; this.setState({ geneIsExpanded: !geneIsExpanded }); }; handleSetGeneAsScatterplotX = () => { const { dispatch, gene } = this.props; dispatch({ type: "set scatterplot x", data: gene, }); }; handleSetGeneAsScatterplotY = () => { const { dispatch, gene } = this.props; dispatch({ type: "set scatterplot y", data: gene, }); }; handleDeleteGeneFromSet = () => { const { dispatch, gene, geneset } = this.props; dispatch(actions.genesetDeleteGenes(geneset, [gene])); }; render() { const { gene, isColorAccessor, isScatterplotXXaccessor, isScatterplotYYaccessor, isDiffExp, pvalAdj, logFoldChange, } = this.props; const { geneIsExpanded } = this.state; const genesetNameLengthVisible = 310; /* this magic number determines how much of a long geneset name we see */ return (
{}} style={{ cursor: "pointer", display: "flex", justifyContent: "space-between", width: "100%", }} >
{gene}
{!geneIsExpanded ? ( isDiffExp ? ( ) : ( ) ) : null}
{!isDiffExp ? ( } /> ) : null} x y } style={{ marginRight: 2 }} /> } />
{geneIsExpanded && (isDiffExp ? ( ) : ( ))}
); } } export default Gene;