mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-09-24 18:18:11 +08:00
Improve front-end HTTP error handling (#397)
* UI for HTTP error handing in diffexp route * HTTP error handling for other routes * clean up toasters
This commit is contained in:
@@ -1,12 +1,24 @@
|
||||
import { Position, Toaster, Intent } from "@blueprintjs/core";
|
||||
|
||||
/** Singleton toaster instance. Create separate instances for different options. */
|
||||
export const ErrorToastTopCenter = Toaster.create({
|
||||
|
||||
const ErrorToastTopCenter = Toaster.create({
|
||||
className: "recipe-toaster",
|
||||
position: Position.TOP,
|
||||
intent: Intent.WARNING
|
||||
position: Position.TOP
|
||||
});
|
||||
|
||||
export default {
|
||||
ErrorToastTopCenter
|
||||
};
|
||||
/*
|
||||
A "user" error - eg, bad input
|
||||
*/
|
||||
export const postUserErrorToast = message =>
|
||||
ErrorToastTopCenter.show({ message, intent: Intent.WARNING });
|
||||
|
||||
/*
|
||||
a hard network error
|
||||
*/
|
||||
export const postNetworkErrorToast = message =>
|
||||
ErrorToastTopCenter.show({
|
||||
message,
|
||||
timeout: 30000,
|
||||
intent: Intent.DANGER
|
||||
});
|
||||
|
||||
@@ -9,7 +9,7 @@ import { Button, Tooltip } from "@blueprintjs/core";
|
||||
import HistogramBrush from "../brushableHistogram";
|
||||
import * as globals from "../../globals";
|
||||
import actions from "../../actions";
|
||||
import { ErrorToastTopCenter } from "../framework/toasters";
|
||||
import { postUserErrorToast } from "../framework/toasters";
|
||||
import ExpressionButtons from "./expressionButtons";
|
||||
|
||||
@connect(state => {
|
||||
@@ -47,18 +47,13 @@ class GeneExpression extends React.Component {
|
||||
const { gene } = this.state;
|
||||
|
||||
if (userDefinedGenes.indexOf(gene) !== -1) {
|
||||
ErrorToastTopCenter.show({
|
||||
message: "That gene already exists"
|
||||
});
|
||||
postUserErrorToast("That gene already exists");
|
||||
} else if (userDefinedGenes.length > 15) {
|
||||
ErrorToastTopCenter.show({
|
||||
message:
|
||||
"That's too many genes, you can have at most 15 user defined genes"
|
||||
});
|
||||
postUserErrorToast(
|
||||
"That's too many genes, you can have at most 15 user defined genes"
|
||||
);
|
||||
} else if (!_.find(world.varAnnotations, { name: gene })) {
|
||||
ErrorToastTopCenter.show({
|
||||
message: "That doesn't appear to be a valid gene name."
|
||||
});
|
||||
postUserErrorToast("That doesn't appear to be a valid gene name.");
|
||||
} else {
|
||||
dispatch(actions.requestUserDefinedGene(gene));
|
||||
dispatch({
|
||||
|
||||
Reference in New Issue
Block a user