From 0a69af98c5db239a9f053448b6d97522b7b942c9 Mon Sep 17 00:00:00 2001 From: Colin Megill Date: Sat, 1 May 2021 16:50:10 -0700 Subject: [PATCH] break out load and err --- client/src/components/dotplot/err.js | 20 ++++ client/src/components/dotplot/index.js | 151 +++++++++---------------- client/src/components/dotplot/load.js | 30 +++++ 3 files changed, 104 insertions(+), 97 deletions(-) create mode 100644 client/src/components/dotplot/err.js create mode 100644 client/src/components/dotplot/load.js diff --git a/client/src/components/dotplot/err.js b/client/src/components/dotplot/err.js new file mode 100644 index 00000000..d8f1b86c --- /dev/null +++ b/client/src/components/dotplot/err.js @@ -0,0 +1,20 @@ +import React from "react"; +import * as globals from "../../globals"; + +const ErrorLoading = ({ error, width, height }) => { + console.log(error); // log to console as this is an unepected error + return ( +
+ Failure loading dotplot +
+ ); +}; + +export default ErrorLoading; diff --git a/client/src/components/dotplot/index.js b/client/src/components/dotplot/index.js index 80019785..7f0f313e 100644 --- a/client/src/components/dotplot/index.js +++ b/client/src/components/dotplot/index.js @@ -5,7 +5,9 @@ import Async from "react-async"; import memoize from "memoize-one"; // import * as d3 from "d3"; -import * as globals from "../../globals"; +import ErrorLoading from "./err"; +import StillLoading from "./load"; + import { createCategorySummaryFromDfCol } from "../../util/stateManager/controlsHelpers"; import { @@ -233,109 +235,64 @@ class Dotplot extends React.Component { left: 0, }} > - - - - - - {(error) => ( - - )} - - - {(asyncProps) => { - const { - colorAccessor, - categoryData, - width, - height, - categorySummary, - colorData, - } = asyncProps; - return ( - + + + + + {(error) => ( + - {this.dotplot( - "tissue", - categoryData, - categorySummary, - colorAccessor, - colorData, - width, - height - )} - - ); - }} - - + error={error} + /> + )} + + + {(asyncProps) => { + const { + colorAccessor, + categoryData, + width, + height, + categorySummary, + colorData, + } = asyncProps; + return this.dotplot( + "tissue", + categoryData, + categorySummary, + colorAccessor, + colorData, + width, + height + ); + }} + + + ); } } -const ErrorLoading = ({ error, width, height }) => { - console.log(error); // log to console as this is an unepected error - return ( -
- Failure loading dotplot -
- ); -}; - -const StillLoading = ({ width, height }) => { - /* - Render a busy/loading indicator - */ - return ( -
-
- Loading dotplot -
-
- ); -}; - export default Dotplot; diff --git a/client/src/components/dotplot/load.js b/client/src/components/dotplot/load.js new file mode 100644 index 00000000..3f25b08d --- /dev/null +++ b/client/src/components/dotplot/load.js @@ -0,0 +1,30 @@ +import React from "react"; + +const StillLoading = ({ width, height }) => { + /* + Render a busy/loading indicator + */ + return ( +
+
+ Loading dotplot +
+
+ ); +}; + +export default StillLoading;