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

Add back iDPreset param to external custom editor url #3734

Merged
merged 1 commit into from
Oct 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions frontend/src/utils/openEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@ export function getPotlatch2Url(centroid, zoomLevel) {
}

export function getIdUrl(project, centroid, zoomLevel, selectedTasks, customUrl) {
const base = customUrl
? formatCustomUrl(customUrl)
: `${ID_EDITOR_URL}`;
const base = customUrl ? formatCustomUrl(customUrl) : `${ID_EDITOR_URL}`;
let url = base + '#map=' + [zoomLevel, centroid[1], centroid[0]].join('/');
if (project.changesetComment) {
url += '&comment=' + encodeURIComponent(project.changesetComment);
Expand All @@ -83,6 +81,9 @@ export function getIdUrl(project, centroid, zoomLevel, selectedTasks, customUrl)
if (project.projectId && selectedTasks) {
url += '&gpx=' + encodeURIComponent(getTaskGpxUrl(project.projectId, selectedTasks).href);
}
if (customUrl !== '?editor=ID' && project.idPresets) {
url += '&presets=' + encodeURIComponent(project.idPresets.join(','));
}
return url;
}

Expand Down
17 changes: 16 additions & 1 deletion frontend/src/utils/tests/openEditor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,29 @@ describe('test if getIdUrl', () => {
);
});

it('with idPresets returns the correct formatted url', () => {
it('with idPresets returns the url param', () => {
const testProject = {
changesetComment: '#hotosm-project-5522 #osm_in #2018IndiaFloods #mmteamarm',
projectId: 1234,
idPresets: ['building', 'highway', 'natural/water'],
};
expect(getIdUrl(testProject, [120.25684, -9.663953], 18, [1])).toBe(
'https://www.openstreetmap.org/edit?editor=id&' +
'#map=18/-9.663953/120.25684' +
'&comment=%23hotosm-project-5522%20%23osm_in%20%232018IndiaFloods%20%23mmteamarm' +
'&gpx=http%3A%2F%2F127.0.0.1%3A5000%2Fapi%2Fv2%2Fprojects%2F1234%2Ftasks%2Fqueries%2Fgpx%2F%3Ftasks%3D1' +
'&presets=building%2Chighway%2Cnatural%2Fwater',
);
});

it('with idPresets and internal iD does not return the url param', () => {
const testProject = {
changesetComment: '#hotosm-project-5522 #osm_in #2018IndiaFloods #mmteamarm',
projectId: 1234,
idPresets: ['building', 'highway', 'natural/water'],
};
expect(getIdUrl(testProject, [120.25684, -9.663953], 18, [1], '?editor=ID')).toBe(
'?editor=ID' +
'#map=18/-9.663953/120.25684' +
'&comment=%23hotosm-project-5522%20%23osm_in%20%232018IndiaFloods%20%23mmteamarm' +
'&gpx=http%3A%2F%2F127.0.0.1%3A5000%2Fapi%2Fv2%2Fprojects%2F1234%2Ftasks%2Fqueries%2Fgpx%2F%3Ftasks%3D1',
Expand Down