Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: prevent subset when 0 cells are selected #921

Merged
merged 2 commits into from
May 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions client/src/components/hotkeys/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useHotkeys, InputGroup } from "@blueprintjs/core";
import React, { FC, useMemo } from "react";
import { connect } from "react-redux";
import { AppDispatch } from "../../reducers";
import { AppDispatch, GetState } from "../../reducers";
import { track } from "../../analytics";
import { subsetAction, resetSubsetAction } from "../../actions/viewStack";
import { EVENTS } from "../../analytics/events";
Expand All @@ -15,6 +15,19 @@ interface DispatchProps {
}
type Props = DispatchProps;

const performSubset = () => (dispatch: AppDispatch, getState: GetState) => {
const state = getState();
const crossfilter = state.obsCrossfilter;
const selectedCount = crossfilter.countSelected();
const subsetPossible =
selectedCount !== 0 && selectedCount !== crossfilter.size();

if (subsetPossible) {
track(EVENTS.EXPLORER_SUBSET_BUTTON_CLICKED);
dispatch(subsetAction());
}
};

const mapDispatchToProps = (dispatch: AppDispatch): DispatchProps => ({
undo: () => {
track(EVENTS.EXPLORER_UNDO_BUTTON_CLICKED);
Expand All @@ -24,10 +37,7 @@ const mapDispatchToProps = (dispatch: AppDispatch): DispatchProps => ({
track(EVENTS.EXPLORER_REDO_BUTTON_CLICKED);
dispatch({ type: "@@undoable/redo" });
},
subset: () => {
track(EVENTS.EXPLORER_SUBSET_BUTTON_CLICKED);
dispatch(subsetAction());
},
subset: () => dispatch(performSubset()),
unsubset: () => {
track(EVENTS.EXPLORER_RESET_SUBSET_BUTTON_CLICKED);
dispatch(resetSubsetAction());
Expand Down
Loading