Skip to content

Commit

Permalink
Merge pull request #4502 from hotosm/develop
Browse files Browse the repository at this point in the history
v4.4.4 Release
  • Loading branch information
willemarcel authored Apr 13, 2021
2 parents fa14d8f + 66075a9 commit 7fccfbd
Show file tree
Hide file tree
Showing 53 changed files with 1,625 additions and 804 deletions.
4 changes: 3 additions & 1 deletion backend/services/messaging/message_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,16 @@ def __init__(self, message):
class MessageService:
@staticmethod
def send_welcome_message(user: User):
""" Sends welcome message to all new users at Sign up"""
"""Sends welcome message to new user at Sign up"""
org_code = current_app.config["ORG_CODE"]
text_template = get_txt_template("welcome_message_en.txt")
hot_welcome_section = get_txt_template("hot_welcome_section_en.txt")
replace_list = [
["[USERNAME]", user.username],
["[ORG_CODE]", org_code],
["[ORG_NAME]", current_app.config["ORG_NAME"]],
["[SETTINGS_LINK]", MessageService.get_user_settings_link()],
["[HOT_WELCOME]", hot_welcome_section if org_code == "HOT" else ""],
]
text_template = template_var_replacing(text_template, replace_list)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Check out the <a href="https://hotosm.org/welcome-letter">HOT Welcome Letter</a> for a more detailed introduction. It has links to great learning resources if you want to learn more right away!<br />
<br />
9 changes: 2 additions & 7 deletions backend/services/messaging/templates/welcome_message_en.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@ Hi [USERNAME],<br />
<br />
Welcome to the [ORG_CODE] Tasking Manager, we hope you will enjoy being part of the community that is helping map the world.<br />
<br />
In order to be notified on project updates and feedback on your mapping, you have to add your email address to your profile by clicking on the link below.<br />
<br />
[SETTINGS_LINK]<br />
[HOT_WELCOME]
In order to be notified on project updates and feedback on your mapping, please check if your email address is registered and verified on your [SETTINGS_LINK].<br />
<br />
Thank you very much!<br />
<br />
On behalf of the [ORG_NAME] volunteer and staff community we want to welcome you to humanitarian mapping and the wider OpenStreetMap community.<br />
<br />
For a much more detailed welcome letter, please visit <a href="https://wiki.openstreetmap.org/wiki/Humanitarian_OSM_Team/TM_Welcome_Letter">the OSM Wiki Tasking Manager Welcome page</a>. It has links to great learning resources if you want to learn more right away!
42 changes: 21 additions & 21 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"license": "BSD-2-Clause",
"private": false,
"dependencies": {
"@formatjs/intl-locale": "^2.4.21",
"@formatjs/intl-pluralrules": "^4.0.12",
"@formatjs/intl-relativetimeformat": "^8.1.3",
"@formatjs/intl-locale": "^2.4.22",
"@formatjs/intl-pluralrules": "^4.0.14",
"@formatjs/intl-relativetimeformat": "^8.1.5",
"@formatjs/macro": "^0.2.8",
"@hotosm/id": "^2.19.6",
"@hotosm/iso-countries-languages": "^1.1.0",
Expand All @@ -15,10 +15,10 @@
"@mapbox/mapbox-gl-draw": "^1.2.2",
"@mapbox/mapbox-gl-geocoder": "^4.7.0",
"@mapbox/mapbox-gl-language": "^0.10.1",
"@mapbox/togeojson": "^0.16.0",
"@reach/router": "^1.3.4",
"@sentry/react": "^6.2.3",
"@sentry/tracing": "^6.2.3",
"@sentry/react": "^6.2.5",
"@sentry/tracing": "^6.2.5",
"@tmcw/togeojson": "^4.4.0",
"@turf/area": "^6.3.0",
"@turf/bbox": "^6.3.0",
"@turf/bbox-polygon": "^6.3.0",
Expand All @@ -30,7 +30,7 @@
"@webscopeio/react-textarea-autocomplete": "^4.7.3",
"axios": "^0.21.1",
"chart.js": "^2.9.4",
"date-fns": "^2.19.0",
"date-fns": "^2.20.2",
"dompurify": "^2.2.7",
"downshift-hooks": "^0.8.1",
"final-form": "^4.20.2",
Expand All @@ -39,25 +39,25 @@
"immutable": "^4.0.0-rc.12",
"mapbox-gl": "^1.13.1",
"mapbox-gl-draw-rectangle-mode": "^1.0.4",
"marked": "^2.0.1",
"marked": "^2.0.3",
"osmtogeojson": "^3.0.0-beta.3",
"query-string": "^7.0.0",
"react": "^17.0.2",
"react-accessible-accordion": "^3.3.4",
"react-calendar-heatmap": "^1.8.1",
"react-chartjs-2": "^2.11.1",
"react-click-outside": "^3.0.1",
"react-datepicker": "^3.6.0",
"react-datepicker": "^3.7.0",
"react-dom": "^17.0.2",
"react-dropzone": "^11.3.1",
"react-dropzone": "^11.3.2",
"react-final-form": "^6.5.3",
"react-intl": "^5.15.5",
"react-intl": "^5.15.8",
"react-meta-elements": "^1.0.0",
"react-placeholder": "^4.1.0",
"react-redux": "^7.2.3",
"react-scripts": "^4.0.3",
"react-select": "^4.3.0",
"react-tooltip": "^4.2.13",
"react-tooltip": "^4.2.17",
"reactjs-popup": "^1.5.0",
"redux": "^4.0.5",
"redux-thunk": "^2.3.0",
Expand All @@ -69,11 +69,11 @@
"use-query-params": "^1.2.2",
"webfontloader": "^1.6.28",
"workbox-core": "^6.1.2",
"workbox-expiration": "^6.1.2",
"workbox-precaching": "^6.1.2",
"workbox-recipes": "^6.1.2",
"workbox-routing": "^6.1.2",
"workbox-strategies": "^6.1.2"
"workbox-expiration": "^6.1.5",
"workbox-precaching": "^6.1.5",
"workbox-recipes": "^6.1.5",
"workbox-routing": "^6.1.5",
"workbox-strategies": "^6.1.5"
},
"scripts": {
"build-locales": "combine-messages -i './src/**/messages.js' -o './src/locales/en.json'",
Expand Down Expand Up @@ -105,12 +105,12 @@
},
"devDependencies": {
"@testing-library/jest-dom": "^5.11.10",
"@testing-library/react": "^11.2.4",
"@testing-library/react-hooks": "^5.1.0",
"@testing-library/user-event": "^13.1.1",
"@testing-library/react": "^11.2.6",
"@testing-library/react-hooks": "^5.1.1",
"@testing-library/user-event": "^13.1.2",
"combine-react-intl-messages": "^4.0.0",
"jest-canvas-mock": "^2.3.1",
"msw": "^0.28.0",
"msw": "^0.28.1",
"prettier": "^2.2.1",
"react-select-event": "^5.3.0",
"react-test-renderer": "^17.0.2",
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/assets/styles/_extra.scss
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ div.messageBodyLinks {
}
}

#project-creation-map {
#project-creation-map, #priority-area-map {
.mapboxgl-ctrl-top-right {
top: 2.5rem;
}
Expand Down
41 changes: 41 additions & 0 deletions frontend/src/components/basemapMenu.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import React, { useState } from 'react';

import { MAPBOX_TOKEN, BASEMAP_OPTIONS } from '../config';

export const BasemapMenu = ({ map }) => {
// Remove elements that require mapbox token;
let styles = BASEMAP_OPTIONS;
if (!MAPBOX_TOKEN) {
styles = BASEMAP_OPTIONS.filter((s) => typeof s.value === 'object');
}

const [basemap, setBasemap] = useState(styles[0].label);

const handleClick = (style) => {
let styleValue = style.value;

if (typeof style.value === 'string') {
styleValue = 'mapbox://styles/mapbox/' + style.value;
}
map.setStyle(styleValue);
setBasemap(style.label);
};

return (
<div className="bg-white blue-dark flex mt2 ml2 f7 br1 shadow-1">
{styles.map((style, k) => {
return (
<div
key={k}
onClick={() => handleClick(style)}
className={`ttc pv2 ph3 pointer link + ${
basemap === style.label ? 'bg-grey-light fw6' : ''
}`}
>
{style.label}
</div>
);
})}
</div>
);
};
3 changes: 2 additions & 1 deletion frontend/src/components/header/signUp.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ const SignupForm = ({ data, setData, step, setStep }) => {
}

/* eslint-disable-next-line */
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(data.email) === false) {
const re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
if (re.test(data.email) === false) {
setStep({ ...step, errMessage: <FormattedMessage {...messages.invalidEmail} /> });
return;
}
Expand Down
129 changes: 33 additions & 96 deletions frontend/src/components/projectCreate/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import ReactPlaceholder from 'react-placeholder';
import area from '@turf/area';
import bbox from '@turf/bbox';
import { featureCollection } from '@turf/helpers';
import lineToPolygon from '@turf/line-to-polygon';
import truncate from '@turf/truncate';
import MapboxDraw from '@mapbox/mapbox-gl-draw';
import '@mapbox/mapbox-gl-draw/dist/mapbox-gl-draw.css';
Expand All @@ -24,14 +23,13 @@ import Review from './review';
import { AlertMessage } from './alertMessage';
import { fetchLocalJSONAPI } from '../../network/genericJSONRequest';
import { makeGrid } from './setTaskSizes';
import { MAX_AOI_AREA, MAX_FILESIZE } from '../../config';
import { MAX_AOI_AREA } from '../../config';
import { verifyFileSize, readGeoFile, verifyGeometry } from '../../utils/fileFunctions';

const ProjectCreationMap = React.lazy(() =>
import('./projectCreationMap' /* webpackChunkName: "projectCreationMap" */),
);

var toGeojson = require('@mapbox/togeojson');
var osmToGeojson = require('osmtogeojson');
var shpjs = require('shpjs');

const ProjectCreate = (props) => {
Expand All @@ -57,105 +55,44 @@ const ProjectCreate = (props) => {
}
};

const validateFeature = (e, supportedGeoms, err) => {
if (supportedGeoms.includes(e.geometry.type) === false) {
err.message = (
<FormattedMessage {...messages.unsupportedGeom} values={{ geometry: e.geometry.type }} />
);
throw err;
}
// Transform lineString to polygon
if (e.geometry.type === 'LineString') {
const coords = e.geometry.coordinates;
if (JSON.stringify(coords[0]) !== JSON.stringify(coords[coords.length - 1])) {
err.message = <FormattedMessage {...messages.closedLinestring} />;
throw err;
}
return lineToPolygon(e);
}
return e;
};
const uploadFile = (files) => {
let file = files[0];
if (!file) return null;

const verifyAndSetData = (event) => {
let err = { code: 403, message: null };
try {
if (event.type !== 'FeatureCollection') {
err.message = <FormattedMessage {...messages.noFeatureCollection} />;
throw err;
}
// Validate geometry for each feature.
const supportedGeoms = ['Polygon', 'MultiPolygon', 'LineString'];
event.features = event.features.map((e) => validateFeature(e, supportedGeoms, err));
setDataGeom(event, true);
} catch (e) {
deleteHandler();
setErr({ error: true, message: e.message });
}
};
let error = { code: 403, message: null };

const uploadFile = (files) => {
let file = files[0];
if (!file) {
return null;
}
if (file.size >= MAX_FILESIZE) {
setErr({
error: true,
message: (
<FormattedMessage {...messages.fileSize} values={{ fileSize: MAX_FILESIZE / 1000000 }} />
),
});
return null;
}
verifyFileSize(file, error);

const format = file.name.split('.')[1].toLowerCase();
const format = file.name.split('.')[1].toLowerCase();

const readFile = (e) => {
let geom = null;
switch (format) {
case 'json':
case 'geojson':
geom = JSON.parse(e.target.result);
break;
case 'kml':
let kml = new DOMParser().parseFromString(e.target.result, 'text/xml');
geom = toGeojson.kml(kml);
break;
case 'osm':
let osm = new DOMParser().parseFromString(e.target.result, 'text/xml');
geom = osmToGeojson(osm);
break;
case 'xml':
let xml = new DOMParser().parseFromString(e.target.result, 'text/xml');
geom = osmToGeojson(xml);
break;
case 'zip':
shpjs(e.target.result).then((geom) => verifyAndSetData(geom));
break;
default:
break;
}
if (format !== 'zip') {
verifyAndSetData(geom);
}
};
let fileReader = new FileReader();
fileReader.onload = (e) => {
try {
let geom = readGeoFile(e, format, error);
const supportedGeoms = ['Polygon', 'MultiPolygon', 'LineString'];

let fileReader = new FileReader();
fileReader.onload = (e) => {
try {
readFile(e);
} catch (err) {
setErr({
error: true,
message: <FormattedMessage {...messages.invalidFile} />,
});
if (format === 'zip') {
shpjs(e.target.result).then((geom) => {
let validGeometry = verifyGeometry(geom, error, supportedGeoms);
setDataGeom(validGeometry, true);
});
} else {
let validGeometry = verifyGeometry(geom, error, supportedGeoms);
setDataGeom(validGeometry, true);
}
} catch (err) {
deleteHandler();
setErr({ error: true, message: err.message });
}
};
if (format === 'zip') {
fileReader.readAsArrayBuffer(file);
} else {
fileReader.readAsText(file);
}
};

if (format === 'zip') {
fileReader.readAsArrayBuffer(file);
} else {
fileReader.readAsText(file);
} catch (e) {
setErr({ error: true, message: e.message });
}
};

Expand Down
Loading

0 comments on commit 7fccfbd

Please sign in to comment.