From 7e0091edf64d15488c42532175cab6b3aab1b9e5 Mon Sep 17 00:00:00 2001 From: Armen Zambrano G Date: Tue, 5 Jun 2018 10:12:14 -0400 Subject: [PATCH 1/5] Fix regression from 2ef8399d9d08d6e255020f6a93913fe149d0929b --- src/utils/coverage.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/utils/coverage.js b/src/utils/coverage.js index f8f102f..e3bd267 100644 --- a/src/utils/coverage.js +++ b/src/utils/coverage.js @@ -145,7 +145,7 @@ export const getChangesetCoverage = async (node) => { if (!node) { throw Error(`No node for cset: ${node}`); } - let coverage = { show: false, node }; + let coverage = { show: false }; const res = await queryChangesetCoverage(node); if (res.status === 202) { // This is the only case when we poll again @@ -158,6 +158,7 @@ export const getChangesetCoverage = async (node) => { } else { console.warning(`Unexpected HTTP code (${res.status}) for ${coverage}`); } + coverage.node = node; return coverage; }; From 464618f755f35b2e2739d8fcaba27816be4d9153 Mon Sep 17 00:00:00 2001 From: Armen Zambrano G Date: Tue, 5 Jun 2018 10:12:54 -0400 Subject: [PATCH 2/5] Issue #188 - TypeError: coverageMap[cset.node] is undefined --- src/containers/summary.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/containers/summary.jsx b/src/containers/summary.jsx index 9a43147..b90c2d4 100644 --- a/src/containers/summary.jsx +++ b/src/containers/summary.jsx @@ -117,7 +117,7 @@ export default class SummaryContainer extends Component { const viewableCsetsMap = {}; changesets.forEach((cset) => { - if (coverageMap[cset.node].show && + if (coverageMap[cset.node] && coverageMap[cset.node].show && cset.desc.search(descriptionFilterValue) !== -1) { viewableCsetsMap[cset.node] = cset; } From d6ac66049a7e7de757ed085272bd82542f7ba928 Mon Sep 17 00:00:00 2001 From: Armen Zambrano G Date: Tue, 5 Jun 2018 09:07:17 -0400 Subject: [PATCH 3/5] Add default error boundary --- src/components/errorBoundary.jsx | 22 ++++++++++++++++++++++ src/components/genericErrorMessage.jsx | 10 ++++++++++ src/containers/summary.jsx | 6 ++---- src/index.jsx | 5 ++++- 4 files changed, 38 insertions(+), 5 deletions(-) create mode 100644 src/components/errorBoundary.jsx create mode 100644 src/components/genericErrorMessage.jsx diff --git a/src/components/errorBoundary.jsx b/src/components/errorBoundary.jsx new file mode 100644 index 0000000..0142bc9 --- /dev/null +++ b/src/components/errorBoundary.jsx @@ -0,0 +1,22 @@ +import Raven from 'raven-js'; +import { Component } from 'react'; +import GenericErrorMessage from './genericErrorMessage'; + +class ErrorBoundary extends Component { + state = { hasError: false } + + componentDidCatch(error, info) { + this.setState({ info, error }); + Raven.captureException(error); + Raven.captureMessage(info); + } + + render() { + if (this.state.hasError) { + return ; + } + return this.props.children; + } +} + +export default ErrorBoundary; diff --git a/src/components/genericErrorMessage.jsx b/src/components/genericErrorMessage.jsx new file mode 100644 index 0000000..ba0fed0 --- /dev/null +++ b/src/components/genericErrorMessage.jsx @@ -0,0 +1,10 @@ +import settings from '../settings'; + +const GenericErrorMessage = () => ( +

+ There has been a critical error. Please + file an issue. +

+); + +export default GenericErrorMessage; diff --git a/src/containers/summary.jsx b/src/containers/summary.jsx index b90c2d4..3ee31af 100644 --- a/src/containers/summary.jsx +++ b/src/containers/summary.jsx @@ -3,6 +3,7 @@ import ReactInterval from 'react-interval'; import Summary from '../components/summary'; import ChangesetFilter from '../components/changesetFilter'; +import GenericErrorMessage from '../components/genericErrorMessage'; import settings from '../settings'; import { arrayToMap, mapToArray } from '../utils/data'; import { getCoverage } from '../utils/coverage'; @@ -148,10 +149,7 @@ export default class SummaryContainer extends Component { /> } {(!pollingEnabled && Object.keys(viewableCsetsMap) === 0) && -

- There is currently no coverage data to show. Please - file an issue. -

+ } {Object.keys(changesets).length === 0 && (

{LOADING}

) diff --git a/src/index.jsx b/src/index.jsx index dfc234c..8cda3b7 100644 --- a/src/index.jsx +++ b/src/index.jsx @@ -3,6 +3,7 @@ import { render } from 'react-dom'; import { AppContainer } from 'react-hot-loader'; import { HashRouter } from 'react-router-dom'; import App from './components/app'; +import Boundary from './components/errorBoundary'; Raven.config('https://60b05bc4ef794a6c9e30e86e6a316083@sentry.io/300397').install(); @@ -10,7 +11,9 @@ const root = document.getElementById('root'); const load = () => render( - + + + , root, From 3d44b59beb6a1779e52a6276161026aa5448fc59 Mon Sep 17 00:00:00 2001 From: Armen Zambrano G Date: Tue, 5 Jun 2018 09:23:42 -0400 Subject: [PATCH 4/5] Only enable Raven if we're in production There's no need to try to report to sentry.io if we're doing local development. --- src/index.jsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/index.jsx b/src/index.jsx index 8cda3b7..35c21bd 100644 --- a/src/index.jsx +++ b/src/index.jsx @@ -5,7 +5,9 @@ import { HashRouter } from 'react-router-dom'; import App from './components/app'; import Boundary from './components/errorBoundary'; -Raven.config('https://60b05bc4ef794a6c9e30e86e6a316083@sentry.io/300397').install(); +if (process.env.NODE_ENV === 'production') { + Raven.config('https://60b05bc4ef794a6c9e30e86e6a316083@sentry.io/300397').install(); +} const root = document.getElementById('root'); const load = () => render( From 97df61bd703de2513cf6cd062918f3c1c7b7a1de Mon Sep 17 00:00:00 2001 From: Armen Zambrano G Date: Tue, 5 Jun 2018 09:32:10 -0400 Subject: [PATCH 5/5] refactor: Drop BACKEND entry from settings --- src/settings.js | 1 - src/utils/coverage.js | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/settings.js b/src/settings.js index 20e0a8d..d14e993 100644 --- a/src/settings.js +++ b/src/settings.js @@ -1,6 +1,5 @@ const settings = { ACTIVE_DATA: 'https://activedata.allizom.org', - BACKEND: 'https://coverage.moz.tools', BZ_URL: 'https://bugzilla.mozilla.org', CACHE_CONFIG: { SECONDS_TO_EXPIRE: 1 * 60 * 60, // 1 hour diff --git a/src/utils/coverage.js b/src/utils/coverage.js index e3bd267..6ef3094 100644 --- a/src/utils/coverage.js +++ b/src/utils/coverage.js @@ -4,12 +4,12 @@ import { jsonPost, jsonFetch, plainFetch } from './fetch'; import { queryCacheWithFallback } from './localCache'; const { - ACTIVE_DATA, BACKEND, CCOV_BACKEND, CODECOV_GECKO_DEV, GH_GECKO_DEV, + ACTIVE_DATA, CCOV_BACKEND, CODECOV_GECKO_DEV, GH_GECKO_DEV, } = settings; export const githubUrl = gitCommit => `${GH_GECKO_DEV}/commit/${gitCommit}`; export const codecovUrl = gitCommit => (`${CODECOV_GECKO_DEV}/commit/${gitCommit}`); -export const ccovBackendUrl = node => (`${BACKEND}/coverage/changeset/${node}`); +export const ccovBackendUrl = node => (`${CCOV_BACKEND}/coverage/changeset/${node}`); const queryChangesetCoverage = node => plainFetch(`${CCOV_BACKEND}/coverage/changeset/${node}`);