From 1a4923cbdfefe1bba5eb22ac8fc15cf83a9f66f0 Mon Sep 17 00:00:00 2001 From: Alex G Rice Date: Mon, 13 Apr 2020 16:38:30 -0600 Subject: [PATCH 1/5] Table.js throw exception when headers are missing from i18n glossary. - previously the exception was TypeError: column.Header is undefined --- components/common/Table.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/components/common/Table.js b/components/common/Table.js index 0069635f7..47872c8f5 100644 --- a/components/common/Table.js +++ b/components/common/Table.js @@ -80,7 +80,11 @@ function selectCellFormatter (datatype, idMap, countryMap, campaignMap) { } function prepareAllHeaders (table) { - const headers = glossary.filter(term => Object.keys(table.headers).includes(term.id)) + const tableHeaders = Object.keys(table.headers) + const headers = glossary.filter(term => tableHeaders.includes(term.id)) + if (headers.length !== tableHeaders.length) { + throw new Error('Header(s) are missing from the i18n glossary') + } // appends a boolean property to headers to indicate whether the tooltip is showing headers.map(header => ( table.displaysTooltip.includes(header.id) ? ( From 04cd526919ccce0fa61f457ebbcc02740b159552 Mon Sep 17 00:00:00 2001 From: Alex G Rice Date: Mon, 13 Apr 2020 17:01:05 -0600 Subject: [PATCH 2/5] Remove normalizeHashtag() - the format of hashtags should be enforced by the api and database, not as a formatting task. - opened issue https://github.com/developmentseed/osm-teams/issues/174 - we prefer to display hashtags without # prefix. --- lib/utils/format.js | 13 ------------- pages/team.js | 4 ++-- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/lib/utils/format.js b/lib/utils/format.js index 7ebabae8c..2a38dfb24 100644 --- a/lib/utils/format.js +++ b/lib/utils/format.js @@ -49,16 +49,3 @@ export function formatEditTimeDescription (timeVar) { export function formatUpdateDescription (timeVar) { return `${distanceInWords(timeVar, new Date())} ago` } - -/** - * Prefix with '#' for consistent display of hashtag. - * - * @param {string} hashtag - * @returns {string} - */ -export function normalizeHashtag (hashtag) { - if (/^#/.test(hashtag)) { - return hashtag - } - return `#${hashtag}` -} diff --git a/pages/team.js b/pages/team.js index 7ae12de08..235bb2768 100644 --- a/pages/team.js +++ b/pages/team.js @@ -9,7 +9,7 @@ import TeamStatsTable from '../components/campaign/CampaignTable' import Table from '../components/common/Table' import Blurb from '../components/teams/TeamBlurb' import Link from '../components/Link' -import { formatDecimal, normalizeHashtag } from '../lib/utils/format' +import { formatDecimal } from '../lib/utils/format' import { actions } from '../lib/store' import { calculateBlurbStats, @@ -113,7 +113,7 @@ export class Team extends Component {