Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/refactor components #3393

Merged
merged 91 commits into from
May 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
a7a059d
group modals
edbrett Apr 24, 2018
653e568
move comps to ui folder
edbrett Apr 24, 2018
af6e150
experiment with moving widget container to parent
edbrett Apr 24, 2018
b1840ff
setting loading and errors correctly
edbrett Apr 24, 2018
4c72a35
sync map
edbrett Apr 24, 2018
379855b
tidy up container
edbrett Apr 24, 2018
74caa0c
move initialState to component
edbrett Apr 25, 2018
b6a73fd
sentences in config
edbrett Apr 25, 2018
c39a7c4
add plantations widget to new spec
edbrett Apr 25, 2018
f3d1e46
allow upstream merging for updated widgets
edbrett Apr 25, 2018
81bfcb5
Merge branch 'develop' of github.com:Vizzuality/gfw into feature/refa…
edbrett Apr 25, 2018
5646271
intact forest to new format
edbrett Apr 25, 2018
833ee4c
primary forests
edbrett Apr 25, 2018
a057363
wip: sentence transfer
edbrett Apr 25, 2018
999561f
update tree cover located
edbrett Apr 26, 2018
8b13273
Merge branch 'develop' of github.com:Vizzuality/gfw into feature/refa…
edbrett Apr 26, 2018
8cdd1cd
Refactor Historical Emmissions
01painadam Apr 26, 2018
6fa10c2
tree cover located
edbrett Apr 26, 2018
4363580
Refactors deforestation emissions widget
01painadam Apr 26, 2018
5eb4d65
tree cover ranked
edbrett Apr 26, 2018
dc66a1f
updat tree cover initial state
edbrett Apr 26, 2018
5b9a2e5
Refactors fires widget
01painadam Apr 26, 2018
c548b0f
Refactors glad-alerts widget. Does not have on hover tooltip
01painadam Apr 26, 2018
0695bca
wip
edbrett Apr 26, 2018
d3f96e7
senetence for ranked plantations
edbrett Apr 27, 2018
bb43d13
pull upstream
edbrett Apr 27, 2018
3f5c47b
Merge pull request #3386 from Vizzuality/feature/widget-refactoring
edbrett Apr 27, 2018
98cb35c
Refactor glads rankking widgets
01painadam Apr 27, 2018
d26e755
only fetch data when empty
edbrett Apr 27, 2018
c093d07
clear props
edbrett Apr 27, 2018
322af99
Loss initial commit
01painadam Apr 27, 2018
40c2fc3
remove errors in widgets
edbrett Apr 27, 2018
f64f4e6
Merge branch 'develop' of github.com:Vizzuality/gfw into reduce-widge…
edbrett Apr 27, 2018
515dfff
merge upstream
edbrett Apr 29, 2018
b3a01e7
remove errors from render
edbrett Apr 29, 2018
253270f
fix meta issues with selectors
edbrett Apr 30, 2018
344c884
Refactors tree loss located. Problem with admin lists
01painadam Apr 30, 2018
9ac0c18
fix plantations
edbrett Apr 30, 2018
779f1e7
fix settings and map layers buttons
edbrett Apr 30, 2018
e6d4f06
fix map selection from widget
edbrett Apr 30, 2018
3dec17a
Merge pull request #3388 from Vizzuality/reduce-widget-props
edbrett Apr 30, 2018
f84818d
Merge pull request #3389 from Vizzuality/feature/refactor-components-…
edbrett Apr 30, 2018
16b8c19
sync glad latest fetches with props updates
edbrett Apr 30, 2018
6f24102
remove old ranked
edbrett Apr 30, 2018
8f72d08
tree cover gain widget
edbrett Apr 30, 2018
2ce2d7c
Refactors loss ranked
01painadam Apr 30, 2018
e4187be
gain located widget
edbrett Apr 30, 2018
b3f1c26
Refactors loss plantations
01painadam Apr 30, 2018
95137b1
Refactors loss widget. No date selectors in settings
01painadam Apr 30, 2018
0bb5068
economic impact
edbrett Apr 30, 2018
ea1ad02
Refactors fao cover
01painadam Apr 30, 2018
6868456
forest employment
edbrett Apr 30, 2018
d566892
fix active widget error
edbrett Apr 30, 2018
4b1a3a0
check for previous settings defined
edbrett Apr 30, 2018
f9ec5c2
Refactors fao deforestation
01painadam Apr 30, 2018
387bf27
allow inherited state from config
edbrett Apr 30, 2018
d68d767
add correct folders
edbrett Apr 30, 2018
e905d19
Refactors fao reforest
01painadam Apr 30, 2018
212596f
Resolve conflicts and merge
01painadam Apr 30, 2018
cd0cb40
Relocates fao folder contents
01painadam Apr 30, 2018
707ff8a
Updates loaa and gain located widgets
01painadam Apr 30, 2018
46d14bf
interaction on glads
edbrett Apr 30, 2018
cf63fee
Merge pull request #3390 from Vizzuality/feature/refactor-components-…
edbrett Apr 30, 2018
ce53fac
remove old config
edbrett Apr 30, 2018
de1ee34
fix meta
edbrett Apr 30, 2018
c634714
remove dependacy on whatebodies blacklist
edbrett May 1, 2018
aa05053
rename folder
edbrett May 1, 2018
4779993
zoom buttons on tablet
edbrett May 1, 2018
f59981e
fix years selectors
edbrett May 3, 2018
4571b2e
consistent units for lists
edbrett May 3, 2018
ab32203
fix embeds
edbrett May 3, 2018
b188a1a
reduce functions adding parent widget component
edbrett May 3, 2018
49730d6
reduce location meta data functions
edbrett May 3, 2018
e6610d0
fix selector bug with persistence option after clear
edbrett May 3, 2018
99f64b2
update indicator logic within selectors
edbrett May 3, 2018
55d8c3e
update all widgets to handle new options structure
edbrett May 4, 2018
98550d1
sort ordering
edbrett May 4, 2018
e59120c
fix map and widget sync
edbrett May 4, 2018
c706436
new import paths
edbrett May 4, 2018
4d6edc4
correct sorting of locations meta
edbrett May 4, 2018
66a9a95
fix map interactions
edbrett May 4, 2018
3794020
small fixes for active widget selection between tabs
edbrett May 4, 2018
472601e
fires geostore from parent
edbrett May 4, 2018
aa1bf09
remove old styles
edbrett May 4, 2018
a68319c
show fires graph when enough data
edbrett May 7, 2018
72d92a0
sentence hight for interactivity
edbrett May 7, 2018
946a3a1
Merge branch 'develop' of github.com:Vizzuality/gfw into feature/refa…
edbrett May 7, 2018
b7e3338
remove vcrs
edbrett May 7, 2018
09e6633
new vcrs
edbrett May 7, 2018
c2a9dc1
fix vcrs
edbrett May 7, 2018
84e326c
fix version of cypress
edbrett May 7, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Binary file removed app/assets/images/country-icons-s70ae920e8d.png
Binary file not shown.
14 changes: 7 additions & 7 deletions app/controllers/country_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ class CountryController < ApplicationController
def show
@title = @country && @country["name"]
@desc = "Data about forest change, tenure, forest related employment and land use in #{@title}"
if params[:widget]
widgets_config = JSON.parse(File.read(Rails.root.join('app', 'javascript', 'components', 'widget', 'widget-config.json')))
widget_data = widgets_config[params[:widget]]
@og_title = "#{widget_data["title"]} in #{@title}"
# for dynamic widget image when the feature is ready
# @img = "widgets/#{@widget}.png"
end
# if params[:widget]
# widgets_config = JSON.parse(File.read(Rails.root.join('app', 'javascript', 'components', 'widget', 'widget-config.json')))
# widget_data = widgets_config[params[:widget]]
# @og_title = "#{widget_data["title"]} in #{@title}"
# # for dynamic widget image when the feature is ready
# # @img = "widgets/#{@widget}.png"
# end
end

def embed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class CustomComposedChart extends PureComponent {
handleMouseMove,
handleMouseLeave
} = this.props;

const { lines, bars, areas } = yKeys;
const maxYValue = this.findMaxValue(data, config);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import Button from 'components/button';
import Button from 'components/ui/button';
import { Field, reduxForm } from 'redux-form';

import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';

import Icon from 'components/icon';
import Icon from 'components/ui/icon';
import arrowIcon from 'assets/icons/flechita.svg';
import './items-list-styles.scss';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import React, { PureComponent } from 'react';
import Proptypes from 'prop-types';
import Sticky from 'react-stickynode';

import Button from 'components/button';
import Icon from 'components/icon';
import Button from 'components/ui/button';
import Icon from 'components/ui/icon';

import plusIcon from 'assets/icons/plus.svg';
import minusIcon from 'assets/icons/minus.svg';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { isTouch } from 'utils/browser';

import Button from 'components/button';
import Icon from 'components/icon';
import Tip from 'components/tip';
import Button from 'components/ui/button';
import Icon from 'components/ui/icon';
import Tip from 'components/ui/tip';

import linkIcon from 'assets/icons/link.svg';
import './mini-legend-styles.scss';
Expand Down
4 changes: 2 additions & 2 deletions app/javascript/components/map/map-component.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, { PureComponent } from 'react';
import Proptypes from 'prop-types';

import Loader from 'components/loader';
import NoContent from 'components/no-content';
import Loader from 'components/ui/loader';
import NoContent from 'components/ui/no-content';
import MiniLegend from 'components/map/components/mini-legend';

import './map-styles.scss';
Expand Down
13 changes: 6 additions & 7 deletions app/javascript/components/map/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,19 @@ export { default as reducers } from './map-reducers';
export { default as actions } from './map-actions';

const mapStateToProps = (
state,
{ isParentLoading, layers, parentLayersKey }
{ map, countryData, widgets },
{ isParentLoading, layers, widgetKey }
) => {
const { map, countryData } = state;
const parentSettings =
state[parentLayersKey] && state[parentLayersKey].settings;
const widget = widgets[widgetKey];
const widgetSettings = widget && widget.settings;
const activeLayers =
layers || (parentSettings && parentSettings.layers) || map.layers;
layers || (widgetSettings && widgetSettings.layers) || map.layers;
return {
loading: map.loading || isParentLoading,
error: map.error,
bounds: countryData.geostore.bounds,
layerSpec: map.layerSpec,
settings: { ...map.settings, ...parentSettings },
settings: { ...map.settings, ...widgetSettings },
options: map.options,
layers: getLayers({ layers: activeLayers, layerSpec: map.layerSpec }),
layersKeys: activeLayers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import isEmpty from 'lodash/isEmpty';
import lowerCase from 'lodash/lowerCase';
import ReactHtmlParser from 'react-html-parser';

import Modal from 'components/modal';
import Loader from 'components/loader';
import NoContent from 'components/no-content';
import Loader from 'components/ui/loader';
import NoContent from 'components/ui/no-content';
import Modal from '../modal';

import './modal-meta-styles.scss';
import './meta-styles.scss';

class ModalMeta extends PureComponent {
getContent() {
Expand Down Expand Up @@ -78,7 +78,8 @@ class ModalMeta extends PureComponent {
return (
<div>
{ReactHtmlParser(html, {
transform: node => { // eslint-disable-line
transform: node => {
// eslint-disable-line
if (node.name === 'a') {
return (
<a
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { connect } from 'react-redux';
import pick from 'lodash/pick';

import actions from './modal-meta-actions';
import reducers, { initialState } from './modal-meta-reducers';
import ModalMetaComponent from './modal-meta-component';
import actions from './meta-actions';
import reducers, { initialState } from './meta-reducers';
import ModalMetaComponent from './meta-component';

const MASTER_META_FIELDS = ['title', 'subtitle', 'citation', 'overview'];
const MASTER_TABLE_FIELDS = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { PureComponent } from 'react';
import Modal from 'react-modal';
import PropTypes from 'prop-types';

import Icon from 'components/icon';
import Icon from 'components/ui/icon';

import closeIcon from 'assets/icons/close.svg';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import Modal from 'components/modal';

import Button from 'components/button';
import Icon from 'components/icon/icon';
import Loader from 'components/loader';

import googleplusIcon from 'assets/icons/googleplus.svg';
import twitterIcon from 'assets/icons/twitter.svg';
import facebookIcon from 'assets/icons/facebook.svg';

import Button from 'components/ui/button';
import Icon from 'components/ui/icon/icon';
import Loader from 'components/ui/loader';
import Modal from '../modal';

import './share-styles.scss';

class Share extends PureComponent {
Expand Down Expand Up @@ -97,7 +97,9 @@ class Share extends PureComponent {
<Icon icon={googleplusIcon} className="googleplus-icon" />
</Button>
<Button
extLink={`https://twitter.com/intent/tweet?text=${socialText}&via=globalforests&url=${shareUrl}`}
extLink={`https://twitter.com/intent/tweet?text=${
socialText
}&via=globalforests&url=${shareUrl}`}
className="social-button -twitter"
trackingData={{
...data,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';

import Modal from 'components/modal';
import Modal from '../modal';

import './modal-video-styles.scss';
import './video-styles.scss';

class ModalVideo extends PureComponent {
getContent() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { connect } from 'react-redux';

import actions from './modal-video-actions';
import reducers, { initialState } from './modal-video-reducers';
import ModalVideoComponent from './modal-video-component';
import actions from './video-actions';
import reducers, { initialState } from './video-reducers';
import ModalVideoComponent from './video-component';

const mapStateToProps = ({ modalVideo }) => ({
open: modalVideo.open,
Expand Down
46 changes: 27 additions & 19 deletions app/javascript/components/numbered-list/numbered-list-component.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { PureComponent } from 'react';
import Link from 'redux-first-router-link';
import PropTypes from 'prop-types';
import { format } from 'd3-format';
import { format as unitFormat } from 'd3-format';

import Paginate from 'components/paginate';

Expand All @@ -17,7 +17,7 @@ class NumberedList extends PureComponent {
linksDisabled,
linksExt
} = this.props;
const { page, pageSize, unit, unitFormat } = settings;
const { page, pageSize, unit, format } = settings;
const pageData = pageSize
? data.slice(page * pageSize, (page + 1) * pageSize)
: data;
Expand All @@ -39,30 +39,38 @@ class NumberedList extends PureComponent {
<div className="item-name">{item.label}</div>
</div>
<div className="item-value">
{unitFormat
? unitFormat(item.value)
: format('.3s')(item.value)}
{format
? unitFormat(format)(item.value)
: unitFormat('.3s')(item.value)}
{unit}
</div>
</div>
);
return (
<li key={`${item.label}-${item.id}`}>
{linksExt ? (
<a
href={`http://${window.location.host}${item.path}`}
target="_blank"
rel="noopener nofollower"
>
{linkContent}
</a>
) : (
<Link
className={`${linksDisabled ? 'disabled' : ''}`}
to={item.path}
>
{item.path &&
linksExt && (
<a
href={`http://${window.location.host}${item.path}`}
target="_blank"
rel="noopener nofollower"
>
{linkContent}
</a>
)}
{item.path &&
!linksExt && (
<Link
className={`${linksDisabled ? 'disabled' : ''}`}
to={item.path}
>
{linkContent}
</Link>
)}
{!item.path && (
<div className={`${linksDisabled ? 'disabled' : ''}`}>
{linkContent}
</Link>
</div>
)}
</li>
);
Expand Down
4 changes: 2 additions & 2 deletions app/javascript/components/paginate/paginate-component.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';

import Button from 'components/button';
import Icon from 'components/icon';
import Button from 'components/ui/button';
import Icon from 'components/ui/icon';
import arrowDownIcon from 'assets/icons/arrow-down.svg';

import './paginate-styles.scss';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Link from 'redux-first-router-link';
import { isTouch } from 'utils/browser';

import { Tooltip } from 'react-tippy';
import Tip from 'components/tip';
import Tip from 'components/ui/tip';

import './button-styles.scss';
import './themes/button-light.scss'; // eslint-disable-line
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import Button from 'components/button';
import Button from 'components/ui/button';
import Dotdotdot from 'react-dotdotdot';

import './card-styles.scss';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import SlickSlider from 'react-slick';
import Button from 'components/button';
import Icon from 'components/icon';
import Button from 'components/ui/button';
import Icon from 'components/ui/icon';

import arrowIcon from 'assets/icons/arrow-down.svg';
import { SCREEN_M, SCREEN_XL } from 'utils/constants';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';
import PropTypes from 'prop-types';

import Icon from 'components/icon';
import Button from 'components/button';
import Icon from 'components/ui/icon';
import Button from 'components/ui/button';

import arrowDownIcon from 'assets/icons/arrow-down.svg';
import infoIcon from 'assets/icons/info.svg';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';

import Icon from 'components/icon';
import Icon from 'components/ui/icon';

import arrowDownIcon from 'assets/icons/arrow-down.svg';
import closeIcon from 'assets/icons/close.svg';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';

import Downshift from 'downshift';
import Button from 'components/button';
import Icon from 'components/icon';
import Button from 'components/ui/button';
import Icon from 'components/ui/icon';
import { Tooltip } from 'react-tippy';
import Tip from 'components/tip';
import Tip from 'components/ui/tip';

import infoIcon from 'assets/icons/info.svg';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ class DropdownContainer extends PureComponent {
if (changes && changes.selectedItem) {
this.setState({ isOpen: false, inputValue: '' });
}
if (Object.keys(changes).indexOf('isOpen') > -1) {
this.setState({ inputValue: '' });
}
if (
(changes && changes.highlightedIndex) ||
changes.highlightedIndex === 0
Expand Down Expand Up @@ -109,7 +112,7 @@ class DropdownContainer extends PureComponent {
handleClearSelection = () => {
const { onChange } = this.props;
onChange();
this.setState({ isOpen: false, showGroup: '' });
this.setState({ isOpen: false, showGroup: '', inputValue: '' });
};

handleSelectGroup = item => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import Icon from 'components/icon';
import Button from 'components/button';
import Icon from 'components/ui/icon';
import Button from 'components/ui/button';
import debounce from 'lodash/debounce';

import searchIcon from 'assets/icons/search.svg';
Expand Down
Loading