mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2025-01-10 18:27:25 +03:00
Merge pull request #121 from acelaya/feature/fix-empty-locations
Feature/fix empty locations
This commit is contained in:
commit
24bbbf6cb1
5 changed files with 38 additions and 11 deletions
23
CHANGELOG.md
23
CHANGELOG.md
|
@ -4,6 +4,29 @@ All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org).
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org).
|
||||||
|
|
||||||
|
## [Unreleased]
|
||||||
|
|
||||||
|
#### Added
|
||||||
|
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
#### Changed
|
||||||
|
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
#### Deprecated
|
||||||
|
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
#### Removed
|
||||||
|
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
#### Fixed
|
||||||
|
|
||||||
|
* [#120](https://github.com/shlinkio/shlink-web-client/issues/120) Fixed crash when visits page is loaded and there are no visits with known cities.
|
||||||
|
|
||||||
|
|
||||||
## 2.0.2 - 2019-03-04
|
## 2.0.2 - 2019-03-04
|
||||||
|
|
||||||
#### Added
|
#### Added
|
||||||
|
|
|
@ -3,7 +3,7 @@ import * as PropTypes from 'prop-types';
|
||||||
import './ErrorHandler.scss';
|
import './ErrorHandler.scss';
|
||||||
import { Button } from 'reactstrap';
|
import { Button } from 'reactstrap';
|
||||||
|
|
||||||
const ErrorHandler = ({ location }) => class ErrorHandler extends React.Component {
|
const ErrorHandler = ({ location }, { error }) => class ErrorHandler extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
children: PropTypes.node.isRequired,
|
children: PropTypes.node.isRequired,
|
||||||
};
|
};
|
||||||
|
@ -17,6 +17,12 @@ const ErrorHandler = ({ location }) => class ErrorHandler extends React.Componen
|
||||||
return { hasError: true };
|
return { hasError: true };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentDidCatch(e) {
|
||||||
|
if (process.env.NODE_ENV !== 'development') {
|
||||||
|
error(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
if (this.state.hasError) {
|
if (this.state.hasError) {
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -7,6 +7,7 @@ import ErrorHandler from '../ErrorHandler';
|
||||||
|
|
||||||
const provideServices = (bottle, connect, withRouter) => {
|
const provideServices = (bottle, connect, withRouter) => {
|
||||||
bottle.constant('window', global.window);
|
bottle.constant('window', global.window);
|
||||||
|
bottle.constant('console', global.console);
|
||||||
|
|
||||||
bottle.serviceFactory('ScrollToTop', ScrollToTop, 'window');
|
bottle.serviceFactory('ScrollToTop', ScrollToTop, 'window');
|
||||||
bottle.decorator('ScrollToTop', withRouter);
|
bottle.decorator('ScrollToTop', withRouter);
|
||||||
|
@ -31,7 +32,7 @@ const provideServices = (bottle, connect, withRouter) => {
|
||||||
|
|
||||||
bottle.serviceFactory('AsideMenu', AsideMenu, 'DeleteServerButton');
|
bottle.serviceFactory('AsideMenu', AsideMenu, 'DeleteServerButton');
|
||||||
|
|
||||||
bottle.serviceFactory('ErrorHandler', ErrorHandler, 'window');
|
bottle.serviceFactory('ErrorHandler', ErrorHandler, 'window', 'console');
|
||||||
};
|
};
|
||||||
|
|
||||||
export default provideServices;
|
export default provideServices;
|
||||||
|
|
|
@ -76,6 +76,7 @@ const ShortUrlVisits = ({ processStatsFromVisits }) => class ShortUrlVisits exte
|
||||||
const { os, browsers, referrers, countries, cities, citiesForMap } = processStatsFromVisits(
|
const { os, browsers, referrers, countries, cities, citiesForMap } = processStatsFromVisits(
|
||||||
{ id: this.memoizationId, visits }
|
{ id: this.memoizationId, visits }
|
||||||
);
|
);
|
||||||
|
const mapLocations = values(citiesForMap);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="row">
|
<div className="row">
|
||||||
|
@ -109,14 +110,9 @@ const ShortUrlVisits = ({ processStatsFromVisits }) => class ShortUrlVisits exte
|
||||||
<SortableBarGraph
|
<SortableBarGraph
|
||||||
stats={cities}
|
stats={cities}
|
||||||
title="Cities"
|
title="Cities"
|
||||||
extraHeaderContent={[
|
extraHeaderContent={
|
||||||
() => (
|
[ () => mapLocations.length > 0 && <OpenMapModalBtn modalTitle="Cities" locations={mapLocations} /> ]
|
||||||
<OpenMapModalBtn
|
}
|
||||||
modalTitle="Cities"
|
|
||||||
locations={values(citiesForMap)}
|
|
||||||
/>
|
|
||||||
),
|
|
||||||
]}
|
|
||||||
sortingItems={{
|
sortingItems={{
|
||||||
name: 'City name',
|
name: 'City name',
|
||||||
amount: 'Visits amount',
|
amount: 'Visits amount',
|
||||||
|
|
|
@ -9,10 +9,11 @@ describe('<ErrorHandler />', () => {
|
||||||
reload: jest.fn(),
|
reload: jest.fn(),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
const console = { error: jest.fn() };
|
||||||
let wrapper;
|
let wrapper;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
const ErrorHandler = createErrorHandler(window);
|
const ErrorHandler = createErrorHandler(window, console);
|
||||||
|
|
||||||
wrapper = shallow(<ErrorHandler children={<span>Foo</span>} />);
|
wrapper = shallow(<ErrorHandler children={<span>Foo</span>} />);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue