Files
cellxgene/client/src/reducers/graphSelection.js
2020-07-21 12:51:39 -07:00

63 lines
1.2 KiB
JavaScript

const GraphSelection = (
state = {
tool: "lasso", // what selection tool mode (lasso, brush, ...)
selection: { mode: "all" }, // current selection, which is tool specific
},
action
) => {
switch (action.type) {
case "set clip quantiles":
case "subset to selection":
case "reset subset":
case "set layout choice": {
return {
...state,
selection: {
mode: "all",
},
};
}
case "graph brush end":
case "graph brush change": {
const { brushCoords } = action;
return {
...state,
selection: {
mode: "within-rect",
brushCoords,
},
};
}
case "graph lasso end": {
const { polygon } = action;
return {
...state,
selection: {
mode: "within-polygon",
polygon,
},
};
}
case "graph lasso cancel":
case "graph brush cancel":
case "graph lasso deselect":
case "graph brush deselect": {
return {
...state,
selection: {
mode: "all",
},
};
}
default: {
return state;
}
}
};
export default GraphSelection;