Skip to content

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

Open
mbarrenechea wants to merge 3 commits into
developfrom
feat/catalogue-import-export
Open

mbarrenechea wants to merge 3 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

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
@vercel

vercel Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
amazonia-360 Ready Ready Preview Oct 5, 2026 8:18am UTC

Request Review

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
@sonarqubecloud

sonarqubecloud Bot commented Oct 5, 2026

Copy link
Copy Markdown

This branch was successfully deployed

1 active deployment
Preview — 1814c3ba Deployed Oct 5, 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.

1 participant