Skip to content

Add download patrol track#1533

Merged
jeslefcourt merged 8 commits intodevelopfrom
ERA-13106
Apr 15, 2026
Merged

Add download patrol track#1533
jeslefcourt merged 8 commits intodevelopfrom
ERA-13106

Conversation

@jeslefcourt
Copy link
Copy Markdown
Contributor

@jeslefcourt jeslefcourt commented Apr 13, 2026

What does this PR do?

This pull request adds a new "Download Patrol Track" feature to the patrol options menu, allowing users to download the patrol track as a GeoJSON file. The feature is implemented with localization support across multiple languages and integrates with analytics tracking.

Feature: Download Patrol Track

  • Added a new "Download Patrol Track" option to the KebabMenu in the PatrolMenu component, which allows users to download the patrol track as a .geojson file for the patrol leader. The download uses the patrol's serial number and leader's name for the filename, and includes analytics tracking. (src/PatrolMenu/index.js) [1] [2]
  • Imported the necessary DownloadArrowIcon, TRACKS_API_URL, and downloadFileFromUrl utilities to support the download functionality. (src/PatrolMenu/index.js) [1] [2]

Localization Updates

  • Added the "downloadTrackButton" translation key for English, Spanish, French, Nepali, Portuguese, and Swahili locales to support the new menu option. (public/locales/en-US/patrols.json, public/locales/es/patrols.json, public/locales/fr/patrols.json, public/locales/ne-NP/patrols.json, public/locales/pt/patrols.json, public/locales/sw/patrols.json) [1] [2] [3] [4] [5] [6]

Evidence

Relevant link(s)

Notes

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 13, 2026

🚀 PR Environment Deployed

App Sync Health Image
pr-web-era-13106 ✅ Synced ✅ Healthy 53fab0b99666453af0ca865f9de147869925e7b6

Access: https://era-13106.dev.pamdas.org

View in ArgoCD

@jeslefcourt jeslefcourt requested a review from luixlive April 13, 2026 16:33
Copy link
Copy Markdown
Contributor

@luixlive luixlive left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Translations seem fine. The main changes in PatrolMenu are minimal and elegant. No blocker. Just before approving, I have a couple things for you to think about.

1- Should we include a new button in our "Exports" section of the hamburger menu?
Image

That would definitely increase the scope since we may need to add a modal, to select the patrol and the filter dates. Not sure if that makes sense.

2- The only condition we have now to show or not the new "Download" button is if the patrol has a leader, even if the leader has no tracks within the patrol bounds. This means that we can download GeoJSON files with no meaningful data. I'd suggest to improve the current condition to only allow downloading if there are tracks, what do you think?
Image

Comment thread src/PatrolMenu/index.js Outdated

This comment was marked as resolved.

Copy link
Copy Markdown
Contributor

@luixlive luixlive left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved 🎉

I still added a couple recommendations worth taking a look at. If they make sense and you have 5 minutes, go for them! But this is ready to be merged.

Comment thread public/locales/ne-NP/patrols.json
Comment thread src/PatrolMenu/index.js Outdated
Comment thread src/PatrolMenu/index.js Outdated
Comment thread src/PatrolMenu/index.test.js

This comment was marked as resolved.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 10 changed files in this pull request and generated 4 comments.

Comment thread src/PatrolMenu/index.js
Comment on lines +66 to +71
// Track times are sorted newest-first; check range overlap using only the first/last entries
const trackNewest = new Date(patrolLeaderTrackTimes[0]).getTime();
const trackOldest = new Date(patrolLeaderTrackTimes[patrolLeaderTrackTimes.length - 1]).getTime();

return (!patrolStartTimestamp || trackNewest >= patrolStartTimestamp)
&& (!patrolEndTimestamp || trackOldest <= patrolEndTimestamp);
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The “tracks within patrol time range” check only compares the newest and oldest track timestamps. If the patrol has both a start_time and end_time, this can return true even when there are no track points inside the closed interval (e.g., all points are after end_time and/or before start_time but the overall span overlaps). Consider verifying at least one timestamp falls within [start_time, end_time] (binary search against the sorted times array would avoid scanning the whole array).

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Patrol tracks don't come from start/stop - This is okay

Comment thread src/PatrolMenu/index.js
Comment on lines 16 to 18
import { DAS_HOST, PATROL_UI_STATES, PATROL_API_STATES } from '../constants';
import { TRACKS_API_URL } from '../ducks/tracks';
import { usePatrolsPermissions } from '../hooks/usePermissions';
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Importing TRACKS_API_URL from the tracks duck pulls in the entire ducks/tracks module (including reducer/actions and its dependency chain into utils/tracks, which imports the global store). Since this component only needs the URL builder, consider moving TRACKS_API_URL to a lightweight constants/api-urls module or constructing the URL from API_URL here to reduce coupling and avoid store side effects during module import (notably in tests).

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a common pattern through the project.

Comment thread src/PatrolMenu/index.js
Comment thread src/PatrolMenu/index.js
@jeslefcourt jeslefcourt merged commit c836d1b into develop Apr 15, 2026
6 checks passed
@jeslefcourt jeslefcourt deleted the ERA-13106 branch April 15, 2026 23:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants