From bb5bbaac8a52d8504ddbd42c5e01fe3281d46adc Mon Sep 17 00:00:00 2001 From: Colin Megill Date: Sun, 4 Jul 2021 20:36:16 -0700 Subject: [PATCH] reducer --- client/src/components/menubar/index.js | 13 +++++-------- client/src/reducers/dotplot.js | 24 ++++++++++++++++++++++++ client/src/reducers/layoutChoice.js | 10 +++++++++- 3 files changed, 38 insertions(+), 9 deletions(-) create mode 100644 client/src/reducers/dotplot.js diff --git a/client/src/components/menubar/index.js b/client/src/components/menubar/index.js index d36a4b23..350327d0 100644 --- a/client/src/components/menubar/index.js +++ b/client/src/components/menubar/index.js @@ -48,7 +48,7 @@ import { getEmbSubsetView } from "../../util/stateManager/viewStackHelpers"; tosURL: state.config?.parameters?.about_legal_tos, privacyURL: state.config?.parameters?.about_legal_privacy, categoricalSelection: state.categoricalSelection, - dotplotEnabled: true /* TODO(colinmegill) #632 wire dotplot*/, + dotplotEnabled: state.layoutChoice.dotplot, }; }) class MenuBar extends React.PureComponent { @@ -195,7 +195,10 @@ class MenuBar extends React.PureComponent { dispatch(actions.resetSubsetAction()); }; - handleDotplotToggle = () => {}; + handleDotplotToggle = () => { + const { dispatch } = this.props; + dispatch({ type: "toggle dotplot" }); + }; render() { const { @@ -265,9 +268,6 @@ class MenuBar extends React.PureComponent { { + switch (action.type) { + case "set dotplot row": + return { + ...state, + row: action.data, + }; + case "set dotplot column": + return { + ...state, + column: action.data, + }; + default: + return state; + } +}; + +export default Dotplot; diff --git a/client/src/reducers/layoutChoice.js b/client/src/reducers/layoutChoice.js index 6687af8e..54166d17 100644 --- a/client/src/reducers/layoutChoice.js +++ b/client/src/reducers/layoutChoice.js @@ -24,7 +24,7 @@ function setToDefaultLayout(schema) { const LayoutChoice = ( state = { available: [], // all available choices - dotplot: true /* todo(colinmegill) #632 wire up inputs */, + dotplot: true, // is the dotplot toggled on, or not current: undefined, // name of the current layout, eg, 'umap' currentDimNames: [], // dimension name }, @@ -41,6 +41,14 @@ const LayoutChoice = ( }; } + case "toggle dotplot": { + console.log("toggle: state, newstate", state.dotplot, !state.dotplot); + return { + ...state, + dotplot: !state.dotplot, + }; + } + case "set layout choice": { const { schema } = nextSharedState.annoMatrix; const current = action.layoutChoice;