mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-10-03 08:48:11 +08:00
Fix centroid label + continuous color-by interactions (#1484)
* add case to removing labels * add disabled state to centroid button * fix centroid test button clicking order * don't accidentally un-toggle first color
This commit is contained in:
@@ -326,13 +326,16 @@ describe("ui elements don't error", () => {
|
|||||||
|
|
||||||
describe("centroid labels", () => {
|
describe("centroid labels", () => {
|
||||||
test("labels are created", async () => {
|
test("labels are created", async () => {
|
||||||
await utils.clickOn("centroid-label-toggle");
|
|
||||||
const labels = Object.keys(data.categorical);
|
const labels = Object.keys(data.categorical);
|
||||||
|
|
||||||
|
await utils.clickOn(`colorby-${labels[0]}`);
|
||||||
|
await utils.clickOn("centroid-label-toggle");
|
||||||
/* eslint-disable no-await-in-loop */
|
/* eslint-disable no-await-in-loop */
|
||||||
// Toggle colorby for each category and check to see if labels are generated
|
// Toggle colorby for each category and check to see if labels are generated
|
||||||
for (let i = 0, { length } = labels; i < length; i += 1) {
|
for (let i = 0, { length } = labels; i < length; i += 1) {
|
||||||
const label = labels[i];
|
const label = labels[i];
|
||||||
await utils.clickOn(`colorby-${label}`);
|
// first label is already enabled
|
||||||
|
if (i !== 0) await utils.clickOn(`colorby-${label}`);
|
||||||
const generatedLabels = await utils.getAllByClass("centroid-label");
|
const generatedLabels = await utils.getAllByClass("centroid-label");
|
||||||
// Number of labels generated should be equal to size of the object
|
// Number of labels generated should be equal to size of the object
|
||||||
expect(generatedLabels).toHaveLength(
|
expect(generatedLabels).toHaveLength(
|
||||||
@@ -346,8 +349,8 @@ describe("centroid labels", () => {
|
|||||||
describe("graph overlay", () => {
|
describe("graph overlay", () => {
|
||||||
test("transform centroids correctly", async () => {
|
test("transform centroids correctly", async () => {
|
||||||
const category = Object.keys(data.categorical)[0];
|
const category = Object.keys(data.categorical)[0];
|
||||||
await utils.clickOn("centroid-label-toggle");
|
|
||||||
await utils.clickOn(`colorby-${category}`);
|
await utils.clickOn(`colorby-${category}`);
|
||||||
|
await utils.clickOn("centroid-label-toggle");
|
||||||
await utils.clickOn("mode-pan-zoom");
|
await utils.clickOn("mode-pan-zoom");
|
||||||
const panCoords = await cxgActions.calcDragCoordinates(
|
const panCoords = await cxgActions.calcDragCoordinates(
|
||||||
"layout-graph",
|
"layout-graph",
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ import DiffexpButtons from "./diffexpButtons";
|
|||||||
showCentroidLabels: state.centroidLabels.showLabels,
|
showCentroidLabels: state.centroidLabels.showLabels,
|
||||||
tosURL: state.config?.parameters?.["about_legal_tos"],
|
tosURL: state.config?.parameters?.["about_legal_tos"],
|
||||||
privacyURL: state.config?.parameters?.["about_legal_privacy"],
|
privacyURL: state.config?.parameters?.["about_legal_privacy"],
|
||||||
|
categoricalSelection: state.categoricalSelection,
|
||||||
}))
|
}))
|
||||||
class MenuBar extends React.Component {
|
class MenuBar extends React.Component {
|
||||||
static isValidDigitKeyEvent(e) {
|
static isValidDigitKeyEvent(e) {
|
||||||
@@ -203,9 +204,13 @@ class MenuBar extends React.Component {
|
|||||||
showCentroidLabels,
|
showCentroidLabels,
|
||||||
privacyURL,
|
privacyURL,
|
||||||
tosURL,
|
tosURL,
|
||||||
|
categoricalSelection,
|
||||||
|
colorAccessor,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
const { pendingClipPercentiles } = this.state;
|
const { pendingClipPercentiles } = this.state;
|
||||||
|
|
||||||
|
const isColoredByCategorical = !!categoricalSelection?.[colorAccessor];
|
||||||
|
|
||||||
// constants used to create selection tool button
|
// constants used to create selection tool button
|
||||||
const [selectionTooltip, selectionButtonIcon] =
|
const [selectionTooltip, selectionButtonIcon] =
|
||||||
selectionTool === "brush"
|
selectionTool === "brush"
|
||||||
@@ -267,6 +272,7 @@ class MenuBar extends React.Component {
|
|||||||
onClick={this.handleCentroidChange}
|
onClick={this.handleCentroidChange}
|
||||||
active={showCentroidLabels}
|
active={showCentroidLabels}
|
||||||
intent={showCentroidLabels ? "primary" : "none"}
|
intent={showCentroidLabels ? "primary" : "none"}
|
||||||
|
disabled={!isColoredByCategorical}
|
||||||
/>
|
/>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<ButtonGroup className={styles.menubarButton}>
|
<ButtonGroup className={styles.menubarButton}>
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ const centroidLabels = (state = initialState, action, sharedNextState) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
case "color by continuous metadata":
|
case "color by continuous metadata":
|
||||||
|
case "color by expression":
|
||||||
return { ...state, labels: [] };
|
return { ...state, labels: [] };
|
||||||
|
|
||||||
case "reset centroid labels":
|
case "reset centroid labels":
|
||||||
|
|||||||
Reference in New Issue
Block a user