Skip to content

Commit 9811106

Browse files
authored
Merge pull request #452 from devinit/development
v3.4.0
2 parents a8d5179 + d791d9f commit 9811106

File tree

33 files changed

+5388
-8232
lines changed

33 files changed

+5388
-8232
lines changed

.storybook/config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { configure } from '@storybook/react';
2-
import Router from 'next/router'
2+
import Router from 'next/router';
33
import '../static/semantic.min.css';
44
import '../static/di-charts.min.css';
55
import '../static/mapbox-gl.min.css';

.storybook/webpack.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const SRC_PATH = path.join(__dirname, '../src');
99

1010
// load the default config generator.
1111
const genDefaultConfig = require('@storybook/react/dist/server/config/defaults/webpack.config.js');
12-
const API = process.env.API || packageJSON.config.API;
12+
const API = process.env.NODE_ENV === 'development' ? packageJSON.config.API_DEV : packageJSON.config.API;
1313

1414
const newRules = [
1515
{

.travis.yml

+6-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ node_js:
44
install:
55
- npm install --ignore-scripts
66
- npm install -g codecov
7+
jobs:
8+
include:
9+
- # for branches not master, set node environment to development
10+
if: branch != master
11+
env: NODE_ENV=development
712
script:
813
- npm run emit
914
- npm run lint
@@ -18,8 +23,7 @@ cache:
1823
- ~/.npm
1924
deploy:
2025
provider: releases
21-
api_key:
22-
secure: bszwAE9uRsIRqH080Ca7PWi+CH0VzLxkFVA/7ERcVFNau8mhMkhjR6oy/7zSXFtNIIKuVnQbJGfL7dTHpDB48c9Qp6TSJz4fnl2V9tuPfQzq5ytdtm51aXsP7BwWRwDfQ9RUgnP0O7vCYs4CbgJFmsJSHBlSkYZDpTQGpzgN6vIIlNtHvlihD93UivTnyiZra09vchzeAMjbc6rVUhwV9jdWDPGWM9khvl3pRYt2dgzRZWhS5SwO9kK3Y/a/AOAlXL7/lZGHA1J0b4sqMnZHNhEG/rL44h6LQuyrJD7lrLUhwlUKVjDksXLP2p6uAQvQWrRxsDa7nsThjP8SWV3pe4o1Hj/6DIhgd7vmVVWgyvVEJlxrqW43yfwp7BfJ/RL+qnFyYCIQ6v8hxMlNEBTd+wNJSvyaI9oNZbmyAJ6XbGPznX9TNdhqFgifZSH57s1iiXXLyo5q/70T2a5qoVPgNK8l/tzy2Kh0ohgnvcg4J5L0/XDVGIXmjCKsf9PDZZMKOMfvcEr369zKEzlGp5ZOGN0zXfQHm44Di1+Wgyd1IlZ0wBGycbYa56Ab5xtfVU4ZrzWAXJMrlRrHvTNnnlUJRCGxsTnKEcNiue3hgXu4rgDJzZ+QSCWTr/mWfJsmejl3iMExERSbg1RwcYCafbNpERNADILmHQfJjJgKQPk2duk=
26+
api_key: $GITHUB_KEY
2327
file_glob: true
2428
file: 'build.zip'
2529
skip_cleanup: true

README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ Installation
1111
1212
```
1313

14+
### Scripts/Commands
15+
16+
- `npm run pull` fetches updates from the CMS and syncs the appropriate project files. Be sure to specify the correct API URL, otherwise
17+
you may pull incorrect data.
18+
1419
TODO:
1520
_________
1621

@@ -54,4 +59,3 @@ The thing with installing with yarn, is that the charts library will stop workin
5459
may have to do with the way npm installs dependencies vs yarn.
5560

5661
- For some reason cypress tests fail on travis. Temporary measure is to have them run on the git push pre hook.
57-

next.config.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
44
const Webpack = require('webpack');
55
const withTypescript = require('@zeit/next-typescript');
66
const packageJSON = require('./package.json');
7-
const { ANALYZE } = process.env;
8-
const API = process.env.API || packageJSON.config.API;
7+
const { ANALYZE, NODE_ENV } = process.env;
8+
const API = NODE_ENV === 'development' ? packageJSON.config.API_DEV : packageJSON.config.API;
99

1010
module.exports = withTypescript({
1111
webpack(config, options) {

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
22
"name": "@devinit/dh-app",
3-
"version": "3.3.9",
3+
"version": "3.4.0",
44
"config": {
5-
"API": "http://212.111.41.68:9090/graphql",
5+
"API": "http://212.111.41.68:3000/graphql",
6+
"API_DEV": "http://212.111.41.68:9090/graphql",
67
"PUPPETEER_SKIP_CHROMIUM_DOWNLOAD": true,
78
"OLD_DATAHUB_URL": "http://212.111.41.68:8888"
89
},
@@ -15,7 +16,7 @@
1516
"scripts": {
1617
"emit": "tsc",
1718
"test": "jest src/components/pageData/pageData.test.ts",
18-
"coverage": "BABEL_ENV=test jest -u && codecov",
19+
"coverage": "BABEL_ENV=test NODE_ENV=test jest -u && codecov",
1920
"cypress:test": "start-server-and-test start http://localhost:8080 cypress:run",
2021
"cypress:run": "cypress run --record --key 13a9c637-1ce1-4f5f-8ebf-08896968b64f",
2122
"cypress:open": "npm run build:next && concurrently \"npm run start\" \"cypress open\"",

pages/kenya.tsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from 'react';
22
import { rehydrate } from 'glamor';
33
import withData from '../src/components/WithData';
4-
import {StateToShare} from '../src/components/molecules/ChartShare';
4+
import { StateToShare } from '../src/components/molecules/ChartShare';
55
import App from '../src/components/templates/RegionalProfile';
66

77
interface Props {
@@ -19,9 +19,10 @@ if (typeof window !== 'undefined') {
1919

2020
export default withData((props: Props) =>
2121
(<App
22-
id={props.url.query.id}
23-
state={props.url.query.state}
22+
id={ props.url.query.id }
23+
state={ props.url.query.state }
2424
currencyCode="KES"
2525
currencyUSD="constant 2015 USD"
2626
country="kenya"
27+
supportLocalCurrencyOnly={ false }
2728
/>));

pages/uganda.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@ export default withData((props: Props) =>
2424
currencyCode="UGX"
2525
currencyUSD="constant 2015 USD"
2626
country="uganda"
27+
supportLocalCurrencyOnly={ false }
2728
/>
2829
);

src/apollo/fragment.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import * as fetch from 'isomorphic-fetch';
55
import * as fs from 'fs-extra';
66
const packageJSON = require('../../package.json');
7-
const API = process.env.API || packageJSON.config.API;
7+
const API = process.env.NODE_ENV === 'development' ? packageJSON.config.API_DEV : packageJSON.config.API;
88

99
const main = (): void => {
1010
fetch(API, {

src/components/atoms/TreeChart/index.tsx

+28-8
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,41 @@ class Chart extends React.Component<Props> {
2828
}
2929

3030
componentDidMount() {
31+
this.drawChart(this.props);
32+
}
33+
34+
componentWillUpdate(props: Props) {
35+
if (this.chart) {
36+
if (props.data && props.data.length) {
37+
if (props.config && props.config.type === 'partition' && props.config.labeling) {
38+
this.chart.setLabeling(props.config.labeling);
39+
}
40+
this.chart.update(props.data);
41+
} else {
42+
this.chart.destroy();
43+
this.chart = undefined;
44+
this.removeElementChildren();
45+
}
46+
} else if (props.data && props.data.length) {
47+
this.drawChart(props);
48+
}
49+
}
50+
51+
drawChart(props: Props) {
3152
const element = this.element;
32-
const data = this.props.data;
33-
this.config = this.props.config || visboxConfigs;
53+
const data = props.data;
54+
this.config = props.config || visboxConfigs;
3455
draw({ element, data, config: this.config }).then(chart => {
3556
this.chart = chart;
36-
this.chart.onClick(this.props.onClick);
57+
this.chart.onClick(props.onClick);
3758
});
3859
}
3960

40-
componentWillUpdate(props: Props) {
41-
if (this.chart) {
42-
if (props.config && props.config.type === 'partition' && props.config.labeling) {
43-
this.chart.setLabeling(props.config.labeling);
61+
private removeElementChildren() {
62+
if (this.element && this.element.hasChildNodes()) {
63+
while (this.element.firstChild) {
64+
this.element.removeChild(this.element.firstChild);
4465
}
45-
this.chart.update(props.data);
4666
}
4767
}
4868
}

src/components/gql-types.ts

+2
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ export interface GovernmentFinanceQuery {
250250
// such as constant 2015 USD for tree map
251251
currencyCode: string | null,
252252
currencyUSD: string | null,
253+
supportLocalCurrencyOnly: boolean,
253254
// use resourcesRecipient sql
254255
expenditure: Array< {
255256
uid: string,
@@ -324,6 +325,7 @@ export interface LGvmntFinanceQuery {
324325
startYear: number,
325326
currencyCode: string,
326327
currencyUSD: string,
328+
supportLocalCurrencyOnly: boolean,
327329
expenditure: Array< {
328330
uid: string,
329331
year: number,

src/components/molecules/About/index.tsx

+24-21
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,74 @@
11
import * as React from 'react';
2-
import { P, Div } from 'glamorous';
2+
import { Div, P } from 'glamorous';
33
import { SectionHeader } from '../../atoms/Header';
44
import { red, white } from '../../theme/semantic';
5-
import { Container, Grid, Header, Icon, Button } from 'semantic-ui-react';
5+
import { Button, Container, Grid, Header, Icon } from 'semantic-ui-react';
66
import { DarkBg, LightBg } from '../../atoms/Container';
77
import Observer from 'react-intersection-observer';
8-
import {router as routerx} from '../../../utils';
9-
import {SingletonRouter} from 'next/router';
8+
import { router as routerx } from '../../../utils';
9+
import { SingletonRouter } from 'next/router';
1010
import pageData from '../../pageData/data';
1111

1212
const goToMethodologyPage = (router?: SingletonRouter) => () =>
1313
router ? router.push('/methodology') : routerx.push('/methodology');
1414

15-
if ((process as any).browser) require('intersection-observer');
15+
if ((process as any).browser) {
16+
require('intersection-observer');
17+
}
1618

17-
export default ({router}: {router?: SingletonRouter}) =>
19+
export default ({ router }: {router?: SingletonRouter}) =>
1820
<section id="about">
1921
<DarkBg>
20-
<SectionHeader color={red} fontColor={white}>
22+
<SectionHeader color={ red } fontColor={ white }>
2123
DATA VISUALISATIONS
2224
</SectionHeader>
2325
</DarkBg>
2426
<Container>
2527
<Grid>
2628
<Grid.Row centered>
27-
<Div paddingTop={'2em'} paddingBottom={'2em'}>
29+
<Div paddingTop={ '2em' } paddingBottom={ '2em' }>
2830
<SectionHeader>
2931
ABOUT THE <span>DEVELOPMENT DATA HUB</span>
3032
</SectionHeader>
3133
</Div>
3234
</Grid.Row>
3335
<Grid.Row centered>
3436
<Grid.Column width="8">
35-
<Header as="h3">{pageData.about[0].title}</Header>
37+
<Header as="h3">{ pageData.about[0].title }</Header>
3638
<p>
37-
{pageData.about[1].narrative}
39+
{ pageData.about[1].narrative }
3840
</p>
3941
</Grid.Column>
4042
<Grid.Column width="8">
4143
<Header as="h3">How does it work?</Header>
4244
<p>
43-
{pageData.about[2].narrative}
45+
{ pageData.about[2].narrative }
4446
</p>
4547
</Grid.Column>
4648
</Grid.Row>
4749
<Grid.Row centered>
4850
<Grid.Column width="12">
4951
<Observer>
50-
<iframe
51-
src="http://www.youtube.com/embed/2G1Gg2opKPg?rel=0&amp;showinfo=0"
52-
title="About Datahub"
53-
frameBorder="0"
54-
height="585"
55-
style={{ width: '100%' }}
56-
/>
52+
<iframe
53+
src="https://player.vimeo.com/video/296043249"
54+
title="About Datahub"
55+
frameBorder="0"
56+
height="585"
57+
style={ { width: '100%' } }
58+
allowFullScreen
59+
/>
5760
</Observer>
5861
</Grid.Column>
5962
</Grid.Row>
6063
</Grid>
6164
</Container>
6265
<LightBg>
6366
<Container textAlign="center">
64-
<SectionHeader color={white}>DATA SOURCES</SectionHeader>
65-
<P paddingTop={'2em'} paddingBottom={'2em'}>
67+
<SectionHeader color={ white }>DATA SOURCES</SectionHeader>
68+
<P paddingTop={ '2em' } paddingBottom={ '2em' }>
6669
For documentation and data downloads, navigate to the methodology page.
6770
</P>
68-
<Button color="grey" size="large" onClick={goToMethodologyPage(router)}>
71+
<Button color="grey" size="large" onClick={ goToMethodologyPage(router) }>
6972
Methodology and Data <Icon name="chevron right" />
7073
</Button>
7174
</Container>

0 commit comments

Comments
 (0)