From bf7d7342d563ecccdc2d2ba207ed57d089c0ad9b Mon Sep 17 00:00:00 2001 From: Bruce Martin Date: Fri, 28 Feb 2020 15:46:40 -0700 Subject: [PATCH] Improve label picking (#1179) * add simple error message helper * port all label name pickers to use the new LabelInput component * use pure components where possible * cleanup * more cleanup * lint * change new label prompt --- client/src/actions/index.js | 6 +- .../src/components/autosave/filenameDialog.js | 4 +- .../src/components/categorical/annoDialog.js | 10 +- .../categorical/annoDialogAddLabel.js | 75 +++----- .../annoDialogAddLabelFromOntology.js | 131 ------------- .../categorical/annoDialogEditCategoryName.js | 82 +++----- .../src/components/categorical/annoInputs.js | 48 ----- .../categorical/annoMenuCategory.js | 24 +-- .../src/components/categorical/annoSelect.js | 6 +- .../src/components/categorical/categorical.js | 66 +++---- client/src/components/categorical/category.js | 15 +- .../src/components/categorical/labelInput.js | 176 ++++++++++++++++++ .../src/components/categorical/labelUtil.js | 58 +++--- .../components/categorical/ontologySelect.js | 57 ------ client/src/components/categorical/value.js | 102 ++++------ .../src/components/continuous/continuous.js | 55 +++--- client/src/components/graph/graph.js | 2 +- client/src/components/menubar/index.js | 10 +- client/src/reducers/annotations.js | 34 ++-- client/src/reducers/categoricalSelection.js | 1 - client/src/reducers/crossfilter.js | 3 +- client/src/reducers/ontology.js | 9 +- client/src/reducers/undoableConfig.js | 2 - client/src/util/catLabelSort.js | 1 - .../src/util/stateManager/controlsHelpers.js | 8 +- client/src/util/stateManager/universe.js | 7 +- client/src/util/stateManager/world.js | 2 +- 27 files changed, 418 insertions(+), 576 deletions(-) delete mode 100644 client/src/components/categorical/annoDialogAddLabelFromOntology.js delete mode 100644 client/src/components/categorical/annoInputs.js create mode 100644 client/src/components/categorical/labelInput.js delete mode 100644 client/src/components/categorical/ontologySelect.js diff --git a/client/src/actions/index.js b/client/src/actions/index.js index 2c2b46be..992304a3 100644 --- a/client/src/actions/index.js +++ b/client/src/actions/index.js @@ -12,7 +12,7 @@ import { return promise to fetch the OBS annotations we need to load. Omit anything we don't need. */ -function obsAnnotationFetchAndLoad(dispatch, schema, universe) { +function obsAnnotationFetchAndLoad(dispatch, schema) { const obsAnnotations = schema?.schema?.annotations?.obs ?? {}; const columns = obsAnnotations.columns ?? []; const index = obsAnnotations.index ?? false; @@ -42,7 +42,7 @@ function obsAnnotationFetchAndLoad(dispatch, schema, universe) { /* return promise fetching VAR annotations we need to load. Only index is currently used. */ -function varAnnotationFetchAndLoad(dispatch, schema, universe) { +function varAnnotationFetchAndLoad(dispatch, schema) { const varAnnotations = schema?.schema?.annotations?.var ?? {}; const index = varAnnotations.index ?? false; const names = index ? [index] : []; @@ -71,7 +71,7 @@ function varAnnotationFetchAndLoad(dispatch, schema, universe) { /* return promise fetching layout we need */ -function layoutFetchAndLoad(dispatch, schema, universe) { +function layoutFetchAndLoad(dispatch) { return Promise.all( ["layout/obs"] .map(path => { diff --git a/client/src/components/autosave/filenameDialog.js b/client/src/components/autosave/filenameDialog.js index e8fb5c0d..8550b9f5 100644 --- a/client/src/components/autosave/filenameDialog.js +++ b/client/src/components/autosave/filenameDialog.js @@ -74,7 +74,7 @@ class FilenameDialog extends React.Component { color: Colors.ORANGE3 }} > - {"Name cannot be blank"} + Name cannot be blank ); } else if (err === "characters") { @@ -87,7 +87,7 @@ class FilenameDialog extends React.Component { color: Colors.ORANGE3 }} > - {"Only alphanumeric and underscore allowed"} + Only alphanumeric and underscore allowed ); } diff --git a/client/src/components/categorical/annoDialog.js b/client/src/components/categorical/annoDialog.js index 202ff251..2ddfa935 100644 --- a/client/src/components/categorical/annoDialog.js +++ b/client/src/components/categorical/annoDialog.js @@ -6,11 +6,9 @@ import { Button, Tooltip, Dialog, Classes, Colors } from "@blueprintjs/core"; colorAccessor: state.colors.colorAccessor, categoricalSelection: state.categoricalSelection, annotations: state.annotations, - universe: state.universe, - ontology: state.ontology, - ontologyLoading: state.ontology?.loading + universe: state.universe })) -class AnnoDialog extends React.Component { +class AnnoDialog extends React.PureComponent { constructor(props) { super(props); this.state = {}; @@ -26,7 +24,6 @@ class AnnoDialog extends React.Component { errorMessage, validationError, annoSelect, - ontologySelect, annoInput, handleCancel, handleSubmit, @@ -58,7 +55,6 @@ class AnnoDialog extends React.Component {

{annoSelect || null} - {ontologySelect || null}
@@ -76,7 +72,7 @@ class AnnoDialog extends React.Component { ) : null}