Skip to content

feat(client): import and export the catalogue as JSON - #426

Merged
mbarrenechea merged 4 commits into
developfrom
feat/catalogue-import-export
Oct 9, 2026
Merged

mbarrenechea merged 4 commits into
developfrom
feat/catalogue-import-export

Conversation

@mbarrenechea

Copy link
Copy Markdown
Member

Description

Topics, subtopics and indicators can now be exported and imported as JSON from the admin, so entries prepared in staging can be loaded into production from a file. Exports preselect every field, so an untouched export can be imported back whole. Imports and exports are admin-only, and JSON is the only format, because the plugin's CSV round-trip splits column names on _ and tears description_short apart.

The decision to push on: the catalogue can now be created only by import. catalogueAccess.create refuses everything else, which hides Create New, and the auto-increment hook is gone, so every row has to carry its own Content Code. The import marker rides on req.context, which only works with disableJobsQueue: true, so imports run inline in the request rather than as queued jobs.

Testing

  • As an admin, open Indicators in the CMS: there is no Create New button, and an Export action is available
  • Export indicators as JSON without touching "Fields to export": every field is preselected and the file has all of them, including localized values and resources
  • Edit one entry in the file (e.g. its Spanish name), import it back: the change shows up and nothing else moves
  • Import a file with a new indicator that has a Content Code, _status and English values: it is created with that Content Code and links to its subtopic
  • Import a row with no Content Code, or a new row without English: the import reports that row as an issue instead of counting it as imported
  • Repeat export and import for Topics and Subtopics
  • Log in as a non-admin editor: the import and export actions are not available

@mbarrenechea mbarrenechea self-assigned this Oct 9, 2026
@mbarrenechea
mbarrenechea requested a review from mitoperni October 9, 2026 07:22
@vercel

vercel Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
amazonia-360 Ignored Ignored Preview Oct 9, 2026 7:38am UTC

Request Review

@railway-app

railway-app Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

🚅 Deployed to the amazonia-360-pr-426 environment in amazonia-360

Service Status Web Updated
api ✅ Success (View Logs) Web Oct 9, 2026 at 8:20 am UTC
client ✅ Success (View Logs) Web Oct 9, 2026 at 8:03 am UTC

@railway-app
railway-app Bot temporarily deployed to amazonia-360 / amazonia-360-pr-426 October 9, 2026 07:22 Destroyed
Topics, subtopics and indicators get the import-export plugin, so
entries prepared in staging can be loaded into production from a file.
The catalogue is now created only by import: catalogueAccess.create
refuses anything but a catalogue import, which also hides Create New,
and the auto-increment hook is gone, so every row names its own
Content Code.

JSON only, both ways. The plugin rebuilds CSV rows by splitting column
names on `_`, which tears description_short apart, and a resource block
has no flat shape.

A before hook prepares each batch: values with no locale go to en,
every localized map leads with en (the plugin otherwise writes the
first locale it finds into the English slot), translated legend labels
inside a resource become per-locale copies, and relationships exported
at depth 1 are read back as Content Codes. Rows missing a Content Code
or _status, missing en on create, or leaving a required field empty in
a locale they write are flagged and then failed at write time, so they
show up as per-row issues instead of being logged and counted as
imported.

The import marker rides on req.context, which only works with
disableJobsQueue: true. Imports and exports are now admin-only.

Refs: AM-739
The plugin's "Fields to export" preselects the list view's columns,
so an untouched indicators export held id, name, subtopic and _status
and could not be imported back whole. The picker now preselects every
field for topics, subtopics and indicators; it can still be narrowed
by hand. Users keep the plugin's default.

Refs: AM-739
rowErrors splits into textErrors and requiredErrors (complexity 27 to
under 15), children drops its nested ternary, and the stored-row lookup
keys on normaliseId(row.id) instead of String(row.id). Error order and
messages are unchanged.

Refs: AM-739
@mbarrenechea
mbarrenechea force-pushed the feat/catalogue-import-export branch from 1814c3b to bb29775 Compare October 9, 2026 07:24
@railway-app
railway-app Bot temporarily deployed to amazonia-360 / amazonia-360-pr-426 October 9, 2026 07:24 Destroyed
@railway-app
railway-app Bot temporarily deployed to amazonia-360 / amazonia-360-pr-426 October 9, 2026 07:38 Destroyed
@alexeh alexeh closed this Oct 9, 2026
@alexeh alexeh reopened this Oct 9, 2026
@sonarqubecloud

sonarqubecloud Bot commented Oct 9, 2026

Copy link
Copy Markdown

@mbarrenechea
mbarrenechea merged commit 04a1b48 into develop Oct 9, 2026
20 checks passed
@mbarrenechea
mbarrenechea deleted the feat/catalogue-import-export branch October 9, 2026 08:29

This branch was successfully deployed

1 active (outdated) deployment
amazonia-360 / amazonia-360-pr-426 — f3c28b4e Deployed Oct 9, 2026 by railway-app[bot]
Preview — bb297757 Deployed Oct 9, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants