Skip to content

Commit df1217a

Browse files
Merge pull request #7252 from hotosm/staging
v5.5.4 with ohsomeNow topics fix
2 parents c0c6b83 + 9d1d355 commit df1217a

19 files changed

Lines changed: 221 additions & 77 deletions

File tree

.github/workflows/frontend-build-deploy.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ jobs:
2323
- name: Clone repository
2424
uses: actions/checkout@v6
2525

26-
- name: Use Node.js 22.11.0
26+
- name: Use Node.js 22.12.0
2727
uses: actions/setup-node@v6
2828
with:
29-
node-version: 22.11.0
29+
node-version: 22.12.0
3030

3131
- name: Cache node_modules
3232
uses: actions/cache@v5

.github/workflows/pr_test_frontend.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ jobs:
2323
- name: Clone repository
2424
uses: actions/checkout@v6
2525

26-
- name: Use Node.js 22.11.0
26+
- name: Use Node.js 22.12.0
2727
uses: actions/setup-node@v6
2828
with:
29-
node-version: 22.11.0
29+
node-version: 22.12.0
3030

3131
- name: Cache node_modules
3232
uses: actions/cache@v5

frontend/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@
7070
"tachyons": "^4.12.0",
7171
"terra-draw": "^1.18.1",
7272
"tributejs": "^5.1.3",
73+
"turndown": "^7.2.4",
74+
"turndown-plugin-gfm": "^1.0.2",
7375
"use-query-params": "^2.2.1",
7476
"webfontloader": "^1.6.28",
7577
"workbox-core": "^7.0.0",

frontend/src/api/stats.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,29 @@ export const useOsmStatsQuery = ({ topics = [] }) => {
6161
};
6262

6363
export const useOsmHashtagStatsQuery = (defaultComment) => {
64+
const hashtag = defaultComment?.[0]?.replace(/^#/, '').trim().toLowerCase();
65+
6466
const fetchOsmStats = ({ signal }) => {
65-
return api().get(`${OHSOME_STATS_API_URL}/stats/${defaultComment[0].replace('#', '')}`, {
66-
signal,
67-
});
67+
return api().get(
68+
`${OHSOME_STATS_API_URL}/stats?topics=contributor,road,building,edit&hashtag=${encodeURIComponent(hashtag)}`,
69+
{ signal },
70+
);
6871
};
6972

7073
return useQuery({
71-
queryKey: ['osm-hashtag-stats'],
74+
queryKey: ['osm-hashtag-stats', hashtag],
7275
queryFn: fetchOsmStats,
7376
useErrorBoundary: true,
74-
enabled: Boolean(defaultComment?.[0]),
75-
select: (data) => data.data.result,
77+
enabled: Boolean(hashtag),
78+
select: (data) => {
79+
const topics = data.data.result?.topics || {};
80+
return {
81+
changesets: topics.contributor?.value,
82+
edits: topics.edit?.value,
83+
buildings: topics.building?.value,
84+
roads: topics.road?.value,
85+
};
86+
},
7687
});
7788
};
7889

frontend/src/components/comments/commentInput.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import HashtagPaste from './hashtagPaste';
1313
import FileRejections from './fileRejections';
1414
import DropzoneUploadStatus from './uploadStatus';
1515
import { DROPZONE_SETTINGS } from '../../config';
16-
import { formatUserNamesToLink } from '../../utils/htmlFromMarkdown';
16+
import { formatUserNamesToLink, markdownFromHtml } from '../../utils/htmlFromMarkdown';
1717
import { iconConfig } from './editorIconConfig';
1818
import messages from './messages';
1919
import { CurrentUserAvatar } from '../user/avatar';
@@ -32,11 +32,13 @@ function CommentInputField({
3232
isShowUserPicture = false,
3333
placeholderMsg = messages.leaveAComment,
3434
markdownTextareaProps = {},
35+
enableMappersHashtag = false,
3536
}: Object) {
3637
const token = useSelector((state) => state.auth.token);
3738
const textareaRef = useRef();
3839
const fileInputRef = useRef(null);
3940
const isBundle = useRef(false);
41+
const lastConvertedRef = useRef(null);
4042
const [isShowPreview, setIsShowPreview] = useState(false);
4143

4244
const appendImgToComment = (url) => setComment(`${comment}\n![image](${url})\n`);
@@ -149,7 +151,21 @@ function CommentInputField({
149151
sessionStorage.setItem(sessionkey, comment);
150152
}, [comment, sessionkey]);
151153

152-
console.log(comment, 'comment');
154+
useEffect(() => {
155+
if (
156+
comment &&
157+
comment !== lastConvertedRef.current &&
158+
/<\/?(?:p|div|h[1-6]|ul|ol|li|br|strong|em|a|table|thead|tbody|tr|th|td|blockquote|pre|code|span)[\s>]/i.test(comment) &&
159+
document.activeElement !== textareaRef.current?.textarea
160+
) {
161+
const converted = markdownFromHtml(comment);
162+
if (converted !== comment) {
163+
lastConvertedRef.current = converted;
164+
setComment(converted);
165+
}
166+
}
167+
// eslint-disable-next-line react-hooks/exhaustive-deps
168+
}, [comment]);
153169

154170
return (
155171
<div {...getRootProps()}>
@@ -291,6 +307,12 @@ function CommentInputField({
291307
<HashtagPaste text={comment} setFn={setComment} hashtag="#contributors" />
292308
</>
293309
)}
310+
{enableMappersHashtag && (
311+
<>
312+
<span>, </span>
313+
<HashtagPaste text={comment} setFn={setComment} hashtag="#mappers" />
314+
</>
315+
)}
294316
</span>
295317
)}
296318
<DropzoneUploadStatus

frontend/src/components/comments/messages.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ export default defineMessages({
3636
id: 'comment.hashtags.help.contributors',
3737
defaultMessage: 'Add "{hashtag}" to notify the task contributors about your comment.',
3838
},
39+
mappersHashtagTip: {
40+
id: 'comment.hashtags.help.mappers',
41+
defaultMessage: 'Add "{hashtag}" to notify the task mappers about your comment.',
42+
},
3943
nothingToPreview: {
4044
id: 'comment.preview.nothingToPreview',
4145
defaultMessage: 'Nothing to preview',

frontend/src/components/projectDetail/questionsAndComments.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export const PostProjectComment = ({ projectId, refetchComments, contributors })
5656
contributors={
5757
Array.isArray(contributors) ? contributors.map((user) => user.username) : undefined
5858
}
59+
enableMappersHashtag
5960
/>
6061
</Suspense>
6162
</div>

frontend/src/components/taskSelection/actionSidebars.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ export function CompletionTabForMapping({
277277
enableHashtagPaste={true}
278278
enableContributorsHashtag
279279
isShowTabNavs
280+
enableMappersHashtag
280281
/>
281282
</Suspense>
282283
</div>
@@ -662,6 +663,7 @@ const TaskValidationSelector = ({
662663
enableHashtagPaste
663664
enableContributorsHashtag
664665
isShowTabNavs
666+
enableMappersHashtag
665667
/>
666668
</Suspense>
667669
</div>

frontend/src/components/taskSelection/taskActivity.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ const PostComment = ({ projectId, taskId, contributors, setCommentPayload }) =>
6565
enableContributorsHashtag
6666
isShowUserPicture
6767
isShowTabNavs
68+
enableMappersHashtag
6869
/>
6970
</Suspense>
7071
<div className="ml-auto mb5 flex flex-column gap-1 items-end">

frontend/src/network/tests/mockData/userStats.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { formatISO } from 'date-fns';
2+
import { TM_DEFAULT_CHANGESET_COMMENT } from '../../../config';
23

34
export const newUsersStats = {
45
total: 1044,
@@ -79,14 +80,16 @@ export const ohsomeNowUserStats = {
7980
},
8081
};
8182

83+
const projectHashtag = `${TM_DEFAULT_CHANGESET_COMMENT.replace(/^#/, '')}-1`;
84+
8285
export const osmStatsProject = {
8386
result: {
84-
changesets: 987654321,
85-
users: 112,
86-
roads: 5658.62006919192,
87-
buildings: 12923,
88-
edits: 123456789,
89-
latest: '2020-10-05T23:21:22.000Z',
87+
topics: {
88+
contributor: { value: 987654321 },
89+
edit: { value: 123456789 },
90+
road: { value: 5658.62, added: 5000, modified: { count_modified: 500 }, deleted: 0 },
91+
building: { value: 12923, added: 12800, modified: { count_modified: 100 }, deleted: 0 },
92+
},
9093
},
9194
};
9295

0 commit comments

Comments
 (0)