Skip to content

Commit ac4961d

Browse files
authored
Optionally add task URL to changeset comment (#1609)
* add changeset url to comment * fix warning * add .env variable * change to browse url * add unit tests
1 parent ae8a427 commit ac4961d

File tree

7 files changed

+655
-374
lines changed

7 files changed

+655
-374
lines changed

.env

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,3 +168,7 @@ REACT_APP_DEBUG='disabled'
168168
# Require Challenge Owners to provide an email
169169
# Supported values = ["required", undefined]
170170
REACT_APP_EMAIL_ENFORCEMENT='required'
171+
172+
# Include ability to add changeset URL
173+
# Supported values = ["enabled", "disabled", undefined]
174+
REACT_APP_CHANGESET_URL='enabled'

src/components/AdminPane/Manage/ManageChallenges/EditChallenge/Messages.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,12 @@ will not be able to make sense of it.
791791
defaultMessage: "Customize OSM changeset info",
792792
},
793793

794+
changesetUrlDescription: {
795+
id: "Admin.EditChallenge.form.steps.changesetUrl.description",
796+
defaultMessage:
797+
"Automatically append challenge link to the changeset comment",
798+
},
799+
794800
basemapStepHeader: {
795801
id: "Admin.EditChallenge.form.steps.basemap.header",
796802
defaultMessage: "Basemap",
Lines changed: 55 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import AsEditableChallenge
2-
from '../../../../../../interactions/Challenge/AsEditableChallenge'
3-
import messages from '../Messages'
1+
import AsEditableChallenge from "../../../../../../interactions/Challenge/AsEditableChallenge";
2+
import messages from "../Messages";
43

5-
const STEP_ID = "OSMCommit"
4+
const STEP_ID = "OSMCommit";
65

76
/**
87
* Generates a JSON Schema describing OSM commit fields of Edit Challenge
@@ -17,9 +16,15 @@ const STEP_ID = "OSMCommit"
1716
*
1817
* @author [Neil Rotstan](https://github.com/nrotstan)
1918
*/
20-
export const jsSchema = (intl, user, challengeData, extraErrors, options={}) => {
19+
export const jsSchema = (
20+
intl,
21+
user,
22+
challengeData,
23+
extraErrors,
24+
options = {}
25+
) => {
2126
const schemaFields = {
22-
"$schema": "http://json-schema.org/draft-07/schema#",
27+
$schema: "http://json-schema.org/draft-07/schema#",
2328
type: "object",
2429
properties: {
2530
checkinComment: {
@@ -30,8 +35,12 @@ export const jsSchema = (intl, user, challengeData, extraErrors, options={}) =>
3035
title: intl.formatMessage(messages.checkinSourceLabel),
3136
type: "string",
3237
},
38+
changesetUrl: {
39+
type: "boolean",
40+
default: false,
41+
},
3342
},
34-
}
43+
};
3544

3645
// For new challenges, offer option to toggle #maproulette tag on commit comment.
3746
// The hashtag will be injected into the comment when the challenge is created, so
@@ -42,14 +51,16 @@ export const jsSchema = (intl, user, challengeData, extraErrors, options={}) =>
4251
title: " ", // blank title
4352
type: "boolean",
4453
enum: [true, false],
45-
enumNames: [intl.formatMessage(messages.includeCheckinHashtagTrueLabel),
46-
intl.formatMessage(messages.includeCheckinHashtagFalseLabel)],
54+
enumNames: [
55+
intl.formatMessage(messages.includeCheckinHashtagTrueLabel),
56+
intl.formatMessage(messages.includeCheckinHashtagFalseLabel),
57+
],
4758
default: true,
48-
}
59+
};
4960
}
5061

51-
return schemaFields
52-
}
62+
return schemaFields;
63+
};
5364

5465
/**
5566
* uiSchema configuration to assist react-jsonschema-form in determining
@@ -61,20 +72,38 @@ export const jsSchema = (intl, user, challengeData, extraErrors, options={}) =>
6172
* > the form configuration will help the RJSFFormFieldAdapter generate the
6273
* > proper markup
6374
*/
64-
export const uiSchema = (intl, user, challengeData, extraErrors, options={}) => {
65-
const isCollapsed = options.longForm && (options.collapsedGroups || []).indexOf(STEP_ID) !== -1
66-
const toggleCollapsed = options.longForm && options.toggleCollapsed ? () => options.toggleCollapsed(STEP_ID) : undefined
75+
export const uiSchema = (
76+
intl,
77+
user,
78+
challengeData,
79+
extraErrors,
80+
options = {}
81+
) => {
82+
const isCollapsed =
83+
options.longForm && (options.collapsedGroups || []).indexOf(STEP_ID) !== -1;
84+
const toggleCollapsed =
85+
options.longForm && options.toggleCollapsed
86+
? () => options.toggleCollapsed(STEP_ID)
87+
: undefined;
88+
89+
const changesetUrl =
90+
process.env.REACT_APP_CHANGESET_URL === "enabled" ? "changesetUrl" : null;
6791

6892
const uiSchemaFields = {
6993
"ui:order": [
70-
"checkinComment", "includeCheckinHashtag", "checkinSource",
94+
"checkinComment",
95+
"includeCheckinHashtag",
96+
"checkinSource",
97+
changesetUrl,
7198
],
7299
checkinComment: {
73100
"ui:emptyValue": "",
74101
"ui:help": intl.formatMessage(messages.checkinCommentDescription),
75102
"ui:collapsed": isCollapsed,
76103
"ui:toggleCollapsed": toggleCollapsed,
77-
"ui:groupHeader": options.longForm ? intl.formatMessage(messages.osmCommitStepHeader) : undefined,
104+
"ui:groupHeader": options.longForm
105+
? intl.formatMessage(messages.osmCommitStepHeader)
106+
: undefined,
78107
},
79108
checkinSource: {
80109
"ui:help": intl.formatMessage(messages.checkinSourceDescription),
@@ -85,7 +114,13 @@ export const uiSchema = (intl, user, challengeData, extraErrors, options={}) =>
85114
"ui:help": intl.formatMessage(messages.includeCheckinHashtagDescription),
86115
"ui:collapsed": isCollapsed,
87116
},
88-
}
117+
changesetUrl: {
118+
"ui:title": "Changeset URL",
119+
"ui:widget": "radio",
120+
"ui:help": intl.formatMessage(messages.changesetUrlDescription),
121+
"ui:collapsed": isCollapsed,
122+
},
123+
};
89124

90-
return uiSchemaFields
91-
}
125+
return uiSchemaFields;
126+
};

src/services/Challenge/Challenge.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,7 @@ export const saveChallenge = function (
909909
[
910910
"blurb",
911911
"challengeType",
912+
"changesetUrl",
912913
"checkinComment",
913914
"checkinSource",
914915
"customBasemap",

0 commit comments

Comments
 (0)