From f70cb2a4757c08979c1795d5a0261e589b830893 Mon Sep 17 00:00:00 2001
From: Enrico Fasoli
Date: Thu, 4 Oct 2018 12:07:15 +0200
Subject: [PATCH] allow user to check progress and submit another crawler
request
---
src/components/Reviews/index.js | 8 +-
src/containers/CrawlerStatus/index.js | 73 ++++++++++
src/containers/ImportReviews/ImportReviews.js | 96 +++++++++++++
src/containers/ImportReviews/form.js | 34 +++++
src/containers/ImportReviews/index.js | 80 +++++++----
src/containers/Layout/MainLayout.js | 2 +
src/containers/Reputation/index.js | 15 +-
src/containers/ReviewsIWrote/index.js | 4 +-
.../SignupWizard/WizardSteps/Step2.js | 49 +------
src/containers/Wallet/index.js | 19 ---
src/store/modules/data/crawler.js | 130 +++++++++---------
11 files changed, 334 insertions(+), 176 deletions(-)
create mode 100644 src/containers/CrawlerStatus/index.js
create mode 100644 src/containers/ImportReviews/ImportReviews.js
create mode 100644 src/containers/ImportReviews/form.js
delete mode 100644 src/containers/Wallet/index.js
diff --git a/src/components/Reviews/index.js b/src/components/Reviews/index.js
index 27ea257..8070185 100644
--- a/src/components/Reviews/index.js
+++ b/src/components/Reviews/index.js
@@ -17,7 +17,7 @@ const styles = {
class Reviews extends Component {
render() {
- const { classes, reviews = [], loading, crawling = false, onLoadMoreReviews, canLoadMore, ...otherProps } = this.props
+ const { classes, reviews = [], loading, onLoadMoreReviews, canLoadMore, ...otherProps } = this.props
const empty = !reviews || !reviews.length
return
@@ -30,17 +30,17 @@ class Reviews extends Component {
}
- {!loading && (empty || crawling) &&
+ {!loading && empty && }
title='There is nothing here yet'
- subheader={crawling ? 'Your reviews from other platforms are still being imported. Once done, they will be available to you on this page shortly after.' : 'No reviews to display yet'}
+ subheader='No reviews to display yet'
/>
}
- {!loading && !crawling && Array.isArray(reviews) && reviews.map((review, index) => {
+ {!loading && Array.isArray(reviews) && reviews.map((review, index) => {
return
{review.loading && this.props.push('/import')
+
+ render() {
+ const { classes, loading, starting, running } = this.props
+ const subtitle =
+ loading ? 'Checking Status...'
+ : starting ? 'Starting import process...'
+ : running ? 'An import operation is in progress'
+ : 'No import process running for your DID'
+ return (
+
+
+ }
+ title='Import Reviews'
+ subheader={subtitle}
+ />
+
+
+
+
+
+ )
+ }
+}
+
+const mapStateToProps = state => ({
+ loading: state.data.crawler.loading,
+ starting: state.data.crawler.starting,
+ running: state.data.crawler.running,
+})
+
+const mapDispatchToProps = {
+ pollCrawlerStatus,
+ push
+}
+
+export default compose(
+ withStyles(styles),
+ connect(mapStateToProps, mapDispatchToProps)
+)(CrawlerStatus)
\ No newline at end of file
diff --git a/src/containers/ImportReviews/ImportReviews.js b/src/containers/ImportReviews/ImportReviews.js
new file mode 100644
index 0000000..d629c07
--- /dev/null
+++ b/src/containers/ImportReviews/ImportReviews.js
@@ -0,0 +1,96 @@
+import React, { Component } from 'react'
+// Components
+import { Grid, CircularProgress } from '@material-ui/core'
+import RegularCard from 'components/MaterialDashboardPro/RegularCard'
+import NavPills from 'components/MaterialDashboardPro/NavPills'
+import InfoArea from 'components/MaterialDashboardPro/InfoArea'
+// Icons
+import Person from '@material-ui/icons/Person';
+import Business from '@material-ui/icons/Business';
+// Form
+import ImportReviewsForm from './form'
+// Redux
+import { connect } from 'react-redux'
+import { pollCrawlerStatus } from 'store/modules/data/crawler'
+
+class ImportReviews extends Component {
+
+ componentDidMount() {
+ this.props.pollCrawlerStatus()
+ }
+
+ render () {
+ const { running, starting, loading } = this.props
+
+ if (loading || starting) {
+ return (
+
+ )
+ } else if (running) {
+ return (
+
+ )
+ } else {
+ return (
+ To begin, simply enter your email & password for any of the sites below on which you have an active profile.
,
+
We extract, merge and decentrally store your reputation in a portable format so you own and control it.
+ ]}
+ content={}
+ />
+ )
+ },
+ {
+ tabButton: 'Businesses',
+ tabIcon: Business,
+ tabContent: (
+ To begin, simply enter your email & password for any of the sites below on which you have an active profile.,
+
We extract, merge and decentrally store your reputation in a portable format so you own and control it.
+ ]}
+ content={}
+ />
+ )
+ }
+ ]}
+ />
+
+
Chlu guarantees that no information submitted from this form is ever stored on our system
)
}
}
diff --git a/src/containers/SignupWizard/WizardSteps/Step2.js b/src/containers/SignupWizard/WizardSteps/Step2.js
index 90e03d4..812e884 100644
--- a/src/containers/SignupWizard/WizardSteps/Step2.js
+++ b/src/containers/SignupWizard/WizardSteps/Step2.js
@@ -4,20 +4,16 @@ import React from 'react';
import { Grid, InputAdornment, CircularProgress } from '@material-ui/core'
// custom components
-import RegularCard from 'components/MaterialDashboardPro/RegularCard'
-import NavPills from 'components/MaterialDashboardPro/NavPills'
import PictureUpload from 'components/MaterialDashboardPro/PictureUpload'
import CustomInput from 'components/MaterialDashboardPro/CustomInput'
import Button from 'components/MaterialDashboardPro/Button'
import InfoArea from 'components/MaterialDashboardPro/InfoArea'
-import ImportReviews from 'containers/ImportReviews'
+import ImportReviews from 'containers/ImportReviews/ImportReviews'
// icons
-import Person from '@material-ui/icons/Person';
import AccountBox from '@material-ui/icons/AccountBox';
import Web from '@material-ui/icons/Web';
import StarHalf from '@material-ui/icons/StarHalf';
-import Business from '@material-ui/icons/Business';
import Face from '@material-ui/icons/Face'
import DoneIcon from '@material-ui/icons/Done'
@@ -245,48 +241,7 @@ class Step3 extends React.Component {
/>
-
- To begin, simply enter your email & password for any of the sites below on which you have an active profile.,
-
We extract, merge and decentrally store your reputation in a portable format so you own and control it.
- ]}
- content={}
- />
- )
- },
- {
- tabButton: 'Businesses',
- tabIcon: Business,
- tabContent: (
- To begin, simply enter your email & password for any of the sites below on which you have an active profile.,
-
We extract, merge and decentrally store your reputation in a portable format so you own and control it.
- ]}
- content={}
- />
- )
- }
- ]}
- />
-
-
-
-
Chlu guarantees that no information submitted from this form is ever stored on our system