mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-10-07 04:08:13 +08:00
Better input validation (#580)
This commit is contained in:
@@ -108,21 +108,29 @@ class GeneExpression extends React.Component {
|
|||||||
const { world, dispatch, userDefinedGenes } = this.props;
|
const { world, dispatch, userDefinedGenes } = this.props;
|
||||||
const { bulkAdd } = this.state;
|
const { bulkAdd } = this.state;
|
||||||
|
|
||||||
const genes = _.uniq(bulkAdd.split(", ").map(g => g.trim()));
|
/*
|
||||||
|
test:
|
||||||
|
Apod,,, Cd74,, ,,, Foo, Bar-2,,
|
||||||
|
*/
|
||||||
|
if (bulkAdd !== "") {
|
||||||
|
const genes = _.pull(_.uniq(bulkAdd.split(/[ ,]+/)), "");
|
||||||
|
|
||||||
genes.forEach(gene => {
|
genes.forEach(gene => {
|
||||||
if (userDefinedGenes.indexOf(gene) !== -1) {
|
if (userDefinedGenes.indexOf(gene) !== -1) {
|
||||||
keepAroundErrorToast("That gene already exists");
|
keepAroundErrorToast("That gene already exists");
|
||||||
} else if (!_.find(world.varAnnotations, { name: gene })) {
|
} else if (!_.find(world.varAnnotations, { name: gene })) {
|
||||||
keepAroundErrorToast(`${gene} doesn't appear to be a valid gene name.`);
|
keepAroundErrorToast(
|
||||||
} else {
|
`${gene} doesn't appear to be a valid gene name.`
|
||||||
dispatch(actions.requestUserDefinedGene(gene));
|
);
|
||||||
dispatch({
|
} else {
|
||||||
type: "user defined gene",
|
dispatch(actions.requestUserDefinedGene(gene));
|
||||||
data: gene
|
dispatch({
|
||||||
});
|
type: "user defined gene",
|
||||||
}
|
data: gene
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
this.setState({ bulkAdd: "" });
|
this.setState({ bulkAdd: "" });
|
||||||
}
|
}
|
||||||
@@ -230,9 +238,6 @@ class GeneExpression extends React.Component {
|
|||||||
<FormGroup
|
<FormGroup
|
||||||
helperText="Add a list of genes (comma delimited)"
|
helperText="Add a list of genes (comma delimited)"
|
||||||
labelFor="text-input-bulk-add"
|
labelFor="text-input-bulk-add"
|
||||||
onSubmit={() => {
|
|
||||||
console.log("heyo");
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<ControlGroup>
|
<ControlGroup>
|
||||||
<InputGroup
|
<InputGroup
|
||||||
|
|||||||
Reference in New Issue
Block a user