Skip to content

ERA-13735 Replace patrol track download with GeoJSON/CSV patrol exports#1656

Open
jeslefcourt wants to merge 3 commits into
developfrom
ERA-13735
Open

ERA-13735 Replace patrol track download with GeoJSON/CSV patrol exports#1656
jeslefcourt wants to merge 3 commits into
developfrom
ERA-13735

Conversation

@jeslefcourt

@jeslefcourt jeslefcourt commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Summary

Replaces the patrol kebab-menu option "Download Patrol Track" with two export options backed by the new patrol detail export API:

  • Export Patrol GeoJsonGET /activity/patrols/<id>?format=geojson&include_events=true&include_tracks=true, downloaded as Patrol_<serial>.geojson
  • Export Patrol CSVGET /activity/patrols/<id>?format=csv (patrol events export), downloaded as Patrol_<serial>.csv

Details

  • The previous implementation downloaded the leader's raw track via the subject tracks API trimmed to the patrol time range; the new endpoint exports patrol-scoped data (track and/or events) server-side.
  • Because the export includes events as well as tracks, the options no longer gate on the leader having track data within the patrol time range — they are disabled only for unsaved patrols.
  • Translation keys downloadTrackButton/noTrackDataTooltip replaced with exportPatrolGeoJsonButton, exportPatrolCsvButton, and noDataToExportTooltip across all locales.
  • Tests updated to cover both options (labels, disabled state, URL/params/filename per format).

Depends on

Backend API: https://github.com/PADAS/das/pull/4076

Jira

ERA-13735

🤖 Generated with Claude Code

Replace the "Download Patrol Track" kebab-menu option with two options,
"Export Patrol GeoJson" and "Export Patrol CSV", both backed by the new
patrol detail export API (PADAS/das#4076):

- GeoJson: GET /activity/patrols/<id>?format=geojson&include_events=true&include_tracks=true
- CSV: GET /activity/patrols/<id>?format=csv (patrol events export)

The options no longer gate on the leader's track availability since the
export also includes events; they are disabled only for unsaved patrols.
Translation keys updated across all locales.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the Patrol list-item kebab menu to replace the legacy “Download Patrol Track” (subject tracks API) with two server-backed export actions that download patrol-scoped data via the patrol detail export API, and updates tests/localizations accordingly.

Changes:

  • Replace “Download Patrol Track” with “Export Patrol GeoJson” and “Export Patrol CSV”, calling ${PATROLS_API_URL}${patrol.id} with format-specific query params.
  • Simplify enable/disable logic so exports are disabled only for unsaved patrols (no id), and update Jest tests to cover both export options.
  • Replace old translation keys with new export-related keys across all existing patrols.json locale files.

Reviewed changes

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

Show a summary per file
File Description
src/PatrolMenu/index.js Replaces track download logic with GeoJSON/CSV patrol exports and updates menu UI.
src/PatrolMenu/index.test.js Updates unit tests to validate export actions (labels, disabled state, URL/params/filename).
public/locales/en-US/patrols.json Replaces patrol menu translation keys for the new export actions/tooltips.
public/locales/es/patrols.json Replaces patrol menu translation keys for the new export actions/tooltips.
public/locales/fr/patrols.json Replaces patrol menu translation keys for the new export actions/tooltips.
public/locales/ne-NP/patrols.json Replaces patrol menu translation keys for the new export actions/tooltips.
public/locales/pt/patrols.json Replaces patrol menu translation keys for the new export actions/tooltips.
public/locales/sw/patrols.json Replaces patrol menu translation keys for the new export actions/tooltips.

Comment thread src/PatrolMenu/index.js
Comment thread src/PatrolMenu/index.js
Comment thread src/PatrolMenu/index.js
Comment thread src/PatrolMenu/index.js
- Guard both export handlers against unsaved patrols and use static
  tooltip ids in the disabled branches (Copilot review)
- Rethrow from downloadFileFromUrl's internal catch so callers get the
  real axios error, and show a translated error toast when an export
  fails instead of failing silently
- Make the disabled-option tooltip reachable by keyboard (tabIndex)
- Fix Swahili labels to use "hamisha" (export) instead of "nakili"
  (copy), which collided with the adjacent copy-link option
- Test coverage for the disabled guards and the error toast

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown

🚀 PR Environment Deployed

App Sync Health Image
pr-web-era-13735 ✅ Synced ✅ Healthy 153441d362bf9b408dd75e8ad770e1c93736425a

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

View in ArgoCD

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 9 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

src/utils/download.js:18

  • Axios normalizes response header keys to lowercase (e.g. response.headers['content-type']). Using headers['Content-Type'] here will typically be undefined, so the downloaded Blob may lose its MIME type (notably for CSV vs GeoJSON exports). Use the lowercase header key (optionally with a fallback) when setting the Blob type.
      throw error;
    });
  const link = document.createElement('a');

  const objectUrl = window.URL.createObjectURL(new Blob([data], { type: headers['Content-Type'] }));

Invalidates the cached translation bundles so the new patrolMenu keys
render instead of falling back to raw key names.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

2 participants