From 04aabf1108aa3cc594b829659c7a7cf3d282528f Mon Sep 17 00:00:00 2001 From: Stefan Oancea Date: Mon, 4 Feb 2019 16:31:52 +0200 Subject: [PATCH 1/7] Add EXPLORER_URL env --- app/components/NetStats/BigChart/index.js | 6 ++++-- .../NetStats/BigChartsSectionItem/TopLeft/index.js | 5 +++-- .../HistoricalBigChartsSectionItem/TopLeft/index.js | 5 +++-- app/components/NetStats/SmallChart/index.js | 10 ++++++---- app/routes/index.js | 1 + config.js.example | 3 ++- 6 files changed, 19 insertions(+), 11 deletions(-) diff --git a/app/components/NetStats/BigChart/index.js b/app/components/NetStats/BigChart/index.js index 47318c8..6a2f3a3 100644 --- a/app/components/NetStats/BigChart/index.js +++ b/app/components/NetStats/BigChart/index.js @@ -1,6 +1,7 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { connect } from 'react-redux'; +import { EXPLORER_URL } from 'config'; import { BarChart, Bar, Tooltip, YAxis, ReferenceLine } from 'recharts'; import { convertHashes, numberWithCommas, prepareChartData } from 'utils/helpers'; import { BigNumber } from 'bignumber.js'; @@ -11,6 +12,7 @@ import Container from './Container'; import Label from './Label'; import Value from './Value'; import spinner from 'resources/img/Eclipse.svg'; + const BAR_WIDTH = 8; const CHART_HEIGHT = 91; const CHART_MARGINS = { @@ -24,7 +26,7 @@ class BigChart extends Component { handleClickAction(data) { let blockNr = data.block.match(/\d/g); blockNr = blockNr.join(''); - window.open(`https://ethstats.io/block/${blockNr}`, '_blank'); + window.open(`${EXPLORER_URL}/block/${blockNr}`, '_blank'); } render() { const {dataKey, tooltipKey, measureUnit, hasDomain, hasNavigation, color, chartStateData, labelPrefix, valuePrefix} = this.props; @@ -102,7 +104,7 @@ class BigChart extends Component { }/> { hasNavigation ? - } onClick={this.handleClickAction}/> + } onClick={ EXPLORER_URL ? this.handleClickAction : null}/> : } />} {hasDomain && } diff --git a/app/components/NetStats/BigChartsSectionItem/TopLeft/index.js b/app/components/NetStats/BigChartsSectionItem/TopLeft/index.js index 16dfe08..de769b0 100644 --- a/app/components/NetStats/BigChartsSectionItem/TopLeft/index.js +++ b/app/components/NetStats/BigChartsSectionItem/TopLeft/index.js @@ -1,6 +1,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import { connect } from 'react-redux'; +import { EXPLORER_URL } from 'config'; import { numberWithCommas, convertHashes } from 'utils/helpers'; import Title from '../Title'; import Value from '../Value'; @@ -10,7 +11,7 @@ class TopLeft extends React.Component { handleClickAction(data) { let blockNr = data.match(/\d/g); blockNr = blockNr.join(''); - window.open(`https://ethstats.io/block/${blockNr}`, '_blank'); + window.open(`${EXPLORER_URL}/block/${blockNr}`, '_blank'); } render() { const { mainTitle, color, chartStateData, reducerName } = this.props; @@ -28,7 +29,7 @@ class TopLeft extends React.Component {
{mainTitle} { chartStateData && - this.handleClickAction(finalValue) : null } + this.handleClickAction(finalValue) : null } className={ reducerName === 'lastBlock' ? 'pointer' : ''}> {finalValue} } diff --git a/app/components/NetStats/HistoricalBigChartsSectionItem/TopLeft/index.js b/app/components/NetStats/HistoricalBigChartsSectionItem/TopLeft/index.js index 45c319f..721643b 100644 --- a/app/components/NetStats/HistoricalBigChartsSectionItem/TopLeft/index.js +++ b/app/components/NetStats/HistoricalBigChartsSectionItem/TopLeft/index.js @@ -1,5 +1,6 @@ import React from 'react'; import PropTypes from 'prop-types'; +import { EXPLORER_URL } from 'config.js'; import Title from 'components/NetStats/BigChartsSectionItem/Title'; import Value from 'components/NetStats/BigChartsSectionItem/Value'; @@ -9,14 +10,14 @@ class TopLeft extends React.Component { handleClickAction(data) { let blockNr = data.match(/\d/g); blockNr = blockNr.join(''); - window.open(`https://ethstats.io/block/${blockNr}`, '_blank'); + window.open(`${EXPLORER_URL}/block/${blockNr}`, '_blank'); } render() { const { title, value, color } = this.props; return (
{title} - this.handleClickAction(value) } className={ title === 'Block number' ? 'pointer' : '' }> + this.handleClickAction(value) : null } className={ title === 'Block number' ? 'pointer' : '' }> {value}
diff --git a/app/components/NetStats/SmallChart/index.js b/app/components/NetStats/SmallChart/index.js index e254ea6..fbea076 100644 --- a/app/components/NetStats/SmallChart/index.js +++ b/app/components/NetStats/SmallChart/index.js @@ -1,6 +1,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import { connect } from 'react-redux'; +import { EXPLORER_URL } from 'config'; import {BarChart, ComposedChart, Line, Bar, Tooltip, YAxis} from 'recharts'; import ChartTooltip from 'components/ChartTooltip'; import {prepareChartData, prepareUncleChartData, preparePropagationChartData, prepareETHPendingChartData, prepareGasPriceChartData} from 'utils/helpers'; @@ -8,6 +9,7 @@ import RoundedBar from './RoundedBar'; import SpinnerContainer from './SpinnerContainer'; import spinnerImgRes from 'resources/img/Eclipse.svg'; import Spinner from '../BigChartsSectionItem/Spinner'; + const BAR_WIDTH = 6; const CHART_HEIGHT = 62; const CHART_MARGINS = { @@ -22,7 +24,7 @@ class SmallChart extends React.Component { handleClickAction(data) { let blockNr = data.block.match(/\d/g); blockNr = blockNr.join(''); - window.open(`https://ethstats.io/block/${blockNr}`, '_blank'); + window.open(`${EXPLORER_URL}/block/${blockNr}`, '_blank'); } render() { const { dataKey, tooltipKey, measureUnit, hasDomain, hasNavigation, color, full, chartStateData, labelPrefix, valuePrefix} = this.props; @@ -72,7 +74,7 @@ class SmallChart extends React.Component { className="pointer"> }/> {hasNavigation ? - } onClick={this.handleClickAction}/> + } onClick={EXPLORER_URL ? this.handleClickAction : null}/> : }/>} {hasDomain && } @@ -85,7 +87,7 @@ class SmallChart extends React.Component { className="pointer"> }/> {hasNavigation ? - } onClick={this.handleClickAction}/> : + } onClick={EXPLORER_URL ? this.handleClickAction : null}/> : }/>} {hasDomain && } : @@ -97,7 +99,7 @@ class SmallChart extends React.Component { className="pointer"> }/> {hasNavigation ? - } onClick={this.handleClickAction}/> : + } onClick={EXPLORER_URL ? this.handleClickAction : null}/> : }/>} {hasDomain && } :
diff --git a/app/routes/index.js b/app/routes/index.js index fa37146..8b66499 100755 --- a/app/routes/index.js +++ b/app/routes/index.js @@ -1,5 +1,6 @@ import React from 'react'; import { Route, IndexRoute, browserHistory } from 'react-router'; +import config from 'config'; import App from 'containers/App'; diff --git a/config.js.example b/config.js.example index 1549e7a..713af74 100644 --- a/config.js.example +++ b/config.js.example @@ -3,5 +3,6 @@ const config = { DS_URL: '127.0.0.1:6020', DS_USER: 'frontend', DS_PASS: '', - DS_NAMESPACE: 'ethstats/' + DS_NAMESPACE: 'ethstats/', + EXPLORER_URL: 'https://ethstats.io/' }; From b6ed46915ea388f701ed6d4b9647ab0dc51e12c8 Mon Sep 17 00:00:00 2001 From: Stefan Oancea Date: Mon, 4 Feb 2019 16:54:27 +0200 Subject: [PATCH 2/7] Remove unused import --- app/routes/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/app/routes/index.js b/app/routes/index.js index 8b66499..fa37146 100755 --- a/app/routes/index.js +++ b/app/routes/index.js @@ -1,6 +1,5 @@ import React from 'react'; import { Route, IndexRoute, browserHistory } from 'react-router'; -import config from 'config'; import App from 'containers/App'; From 22e5b7f67f56448d0da8725d42d72247b1183f81 Mon Sep 17 00:00:00 2001 From: baxy Date: Wed, 6 Feb 2019 13:02:26 +0200 Subject: [PATCH 3/7] Fixed missing config on block history --- app/index.tpl.html | 2 +- config.js.example | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/index.tpl.html b/app/index.tpl.html index 96b78a1..6e70a57 100755 --- a/app/index.tpl.html +++ b/app/index.tpl.html @@ -26,7 +26,7 @@ gtag('config', 'UA-132898370-1'); - +
diff --git a/config.js.example b/config.js.example index 713af74..58f9c1c 100644 --- a/config.js.example +++ b/config.js.example @@ -4,5 +4,5 @@ const config = { DS_USER: 'frontend', DS_PASS: '', DS_NAMESPACE: 'ethstats/', - EXPLORER_URL: 'https://ethstats.io/' + EXPLORER_URL: 'https://ethstats.io' }; From ace435df2fcd2cde5ed68bf73b6ff2674d6bba39 Mon Sep 17 00:00:00 2001 From: baxy Date: Wed, 6 Feb 2019 13:39:52 +0200 Subject: [PATCH 4/7] Removed garbage code --- app/routes/pages/DemoCallGraphs/index.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/routes/pages/DemoCallGraphs/index.js b/app/routes/pages/DemoCallGraphs/index.js index bdb55a8..9676f3a 100644 --- a/app/routes/pages/DemoCallGraphs/index.js +++ b/app/routes/pages/DemoCallGraphs/index.js @@ -1,5 +1,4 @@ import React from 'react'; -import PropTypes from 'prop-types'; import Graph from 'react-graph-vis'; import TxIcon from 'resources/img/Transaction.png'; import ContractMsgIcon from 'resources/img/ContractMsg.png'; @@ -10,9 +9,6 @@ import accountInteractionGraph from 'resources/dummyData/accountInteractionGraph import messageGraph from 'resources/dummyData/messageGraph'; import SelectorType from './SelectorType'; -const prefix = 'https://stage.ethstats.io/'; - - class DemoCallGraphs extends React.Component { constructor(props) { super(props); From 6bcb1f50e1a1041209cb965be3612c6d70f7ea1e Mon Sep 17 00:00:00 2001 From: Stefan Oancea Date: Wed, 6 Feb 2019 13:58:22 +0200 Subject: [PATCH 5/7] Remove cursor pointer from live mode charts, best block, and historical block number when EXPLORER_URL is missing --- app/components/NetStats/BigChart/index.js | 4 ++-- .../NetStats/BigChartsSectionItem/TopLeft/index.js | 2 +- .../HistoricalBigChartsSectionItem/TopLeft/index.js | 3 ++- app/components/NetStats/SmallChart/index.js | 10 +++++----- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/app/components/NetStats/BigChart/index.js b/app/components/NetStats/BigChart/index.js index 6a2f3a3..6b9a918 100644 --- a/app/components/NetStats/BigChart/index.js +++ b/app/components/NetStats/BigChart/index.js @@ -92,10 +92,10 @@ class BigChart extends Component { { chartStateData ?
+ className={EXPLORER_URL ? 'pointer' : '' }> diff --git a/app/components/NetStats/BigChartsSectionItem/TopLeft/index.js b/app/components/NetStats/BigChartsSectionItem/TopLeft/index.js index de769b0..55a232f 100644 --- a/app/components/NetStats/BigChartsSectionItem/TopLeft/index.js +++ b/app/components/NetStats/BigChartsSectionItem/TopLeft/index.js @@ -30,7 +30,7 @@ class TopLeft extends React.Component { {mainTitle} { chartStateData && this.handleClickAction(finalValue) : null } - className={ reducerName === 'lastBlock' ? 'pointer' : ''}> + className={ reducerName === 'lastBlock' && EXPLORER_URL ? 'pointer' : ''}> {finalValue} }
diff --git a/app/components/NetStats/HistoricalBigChartsSectionItem/TopLeft/index.js b/app/components/NetStats/HistoricalBigChartsSectionItem/TopLeft/index.js index 721643b..a6b2f7c 100644 --- a/app/components/NetStats/HistoricalBigChartsSectionItem/TopLeft/index.js +++ b/app/components/NetStats/HistoricalBigChartsSectionItem/TopLeft/index.js @@ -17,7 +17,8 @@ class TopLeft extends React.Component { return (
{title} - this.handleClickAction(value) : null } className={ title === 'Block number' ? 'pointer' : '' }> + this.handleClickAction(value) : null } + className={ title === 'Block number' && EXPLORER_URL ? 'pointer' : '' }> {value}
diff --git a/app/components/NetStats/SmallChart/index.js b/app/components/NetStats/SmallChart/index.js index fbea076..fb0a3a6 100644 --- a/app/components/NetStats/SmallChart/index.js +++ b/app/components/NetStats/SmallChart/index.js @@ -68,10 +68,10 @@ class SmallChart extends React.Component {
{dataKey === 'histogram' ? + className={EXPLORER_URL && 'pointer'}> }/> {hasNavigation ? } onClick={EXPLORER_URL ? this.handleClickAction : null}/> @@ -84,7 +84,7 @@ class SmallChart extends React.Component { cursor="default" width={chartWidth} height={CHART_HEIGHT} data={data} margin={CHART_MARGINS} - className="pointer"> + className={EXPLORER_URL && 'pointer'}> }/> {hasNavigation ? } onClick={EXPLORER_URL ? this.handleClickAction : null}/> : @@ -93,10 +93,10 @@ class SmallChart extends React.Component { : chartStateData ? + className={EXPLORER_URL && 'pointer'}> }/> {hasNavigation ? } onClick={EXPLORER_URL ? this.handleClickAction : null}/> : From 174644c1aa3aaad451a39140dacc117250ddfde7 Mon Sep 17 00:00:00 2001 From: Stefan Oancea Date: Wed, 6 Feb 2019 14:03:40 +0200 Subject: [PATCH 6/7] Add PRIVACY_POLICY env var that enables/disables pp page and add/remove pp brn from footer --- app/components/NetStats/Footer/index.js | 3 ++- app/routes/index.js | 3 ++- config.js.example | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/components/NetStats/Footer/index.js b/app/components/NetStats/Footer/index.js index 247ae37..cee4c0c 100644 --- a/app/components/NetStats/Footer/index.js +++ b/app/components/NetStats/Footer/index.js @@ -1,4 +1,5 @@ import React from 'react'; +import { PRIVACY_POLICY } from 'config'; import Container from './Container'; import IconContainer from './IconContainer'; import FlexRow from './FlexRow'; @@ -23,7 +24,7 @@ class Footer extends React.Component { { this.props.hasGuideTour && guideTour} - + {PRIVACY_POLICY && } EthStats.io (beta) powered by diff --git a/app/routes/index.js b/app/routes/index.js index fa37146..bd6bca6 100755 --- a/app/routes/index.js +++ b/app/routes/index.js @@ -1,5 +1,6 @@ import React from 'react'; import { Route, IndexRoute, browserHistory } from 'react-router'; +import { PRIVACY_POLICY } from 'config.js'; import App from 'containers/App'; @@ -13,7 +14,7 @@ export default () => { - + { PRIVACY_POLICY && } } /> { browserHistory.replace('/'); diff --git a/config.js.example b/config.js.example index 58f9c1c..6ac0fc7 100644 --- a/config.js.example +++ b/config.js.example @@ -4,5 +4,6 @@ const config = { DS_USER: 'frontend', DS_PASS: '', DS_NAMESPACE: 'ethstats/', - EXPLORER_URL: 'https://ethstats.io' + EXPLORER_URL: 'https://ethstats.io', + PRIVACY_POLICY: true, }; From c9c9814e21713d7c7da1649c871fe17802cf1377 Mon Sep 17 00:00:00 2001 From: baxy Date: Wed, 6 Feb 2019 17:58:31 +0200 Subject: [PATCH 7/7] Fixed config issues --- .circleci/config.yml | 3 +++ .../HistoricalBigChartsSectionItem/TopLeft/index.js | 4 ++-- app/routes/index.js | 2 +- config.js.example | 2 +- set-env-vars.js | 6 +++++- 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index aed653d..1dea128 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -7,6 +7,9 @@ jobs: working_directory: ~/repo steps: - checkout + - run: + name: Init Config + command: ./set-env-vars.js > config.js - run: name: Yarn Install command: yarn install diff --git a/app/components/NetStats/HistoricalBigChartsSectionItem/TopLeft/index.js b/app/components/NetStats/HistoricalBigChartsSectionItem/TopLeft/index.js index a6b2f7c..52b2c70 100644 --- a/app/components/NetStats/HistoricalBigChartsSectionItem/TopLeft/index.js +++ b/app/components/NetStats/HistoricalBigChartsSectionItem/TopLeft/index.js @@ -1,6 +1,6 @@ import React from 'react'; import PropTypes from 'prop-types'; -import { EXPLORER_URL } from 'config.js'; +import { EXPLORER_URL } from 'config'; import Title from 'components/NetStats/BigChartsSectionItem/Title'; import Value from 'components/NetStats/BigChartsSectionItem/Value'; @@ -17,7 +17,7 @@ class TopLeft extends React.Component { return (
{title} - this.handleClickAction(value) : null } + this.handleClickAction(value) : null } className={ title === 'Block number' && EXPLORER_URL ? 'pointer' : '' }> {value} diff --git a/app/routes/index.js b/app/routes/index.js index bd6bca6..4de0472 100755 --- a/app/routes/index.js +++ b/app/routes/index.js @@ -1,6 +1,6 @@ import React from 'react'; import { Route, IndexRoute, browserHistory } from 'react-router'; -import { PRIVACY_POLICY } from 'config.js'; +import { PRIVACY_POLICY } from 'config'; import App from 'containers/App'; diff --git a/config.js.example b/config.js.example index 6ac0fc7..991ca59 100644 --- a/config.js.example +++ b/config.js.example @@ -5,5 +5,5 @@ const config = { DS_PASS: '', DS_NAMESPACE: 'ethstats/', EXPLORER_URL: 'https://ethstats.io', - PRIVACY_POLICY: true, + PRIVACY_POLICY: true }; diff --git a/set-env-vars.js b/set-env-vars.js index 1a9f833..f57df4b 100755 --- a/set-env-vars.js +++ b/set-env-vars.js @@ -25,7 +25,11 @@ config = JSON.parse(config); Object.keys(config).forEach(item => { if (process.env[item]) { - config[item] = process.env[item]; + if (item === 'PRIVACY_POLICY') { + config[item] = process.env[item] === 'true'; + } else { + config[item] = process.env[item]; + } } });