Skip to content

Include tags in item export and restore them on import#1567

Merged
KodeStar merged 2 commits into
2.xfrom
fix/export-import-tags
Jul 8, 2026
Merged

Include tags in item export and restore them on import#1567
KodeStar merged 2 commits into
2.xfrom
fix/export-import-tags

Conversation

@KodeStar

@KodeStar KodeStar commented Jul 8, 2026

Copy link
Copy Markdown
Member

Problem

Resolves #1555.

Exporting a Heimdall config and re-importing it into another instance loses every item's tag/section assignment — all items land back on the default dashboard. Two causes:

  1. The export endpoint (GET api/item) only emitted title, colour, url, description, appid, appdescription — no tags.
  2. The import client (itemImport.js) hard-coded tags: [0] for every item.

Change

  • Export (ItemRestController::index): each exported item now includes a tags array of its assigned tag titles, excluding the root/default dashboard tag (id 0). Existing fields are unchanged; parents is eager-loaded to avoid N+1.
  • Import backend (ItemRestController::store): incoming tags titles are resolved to local tag ids before the item is stored — an existing tag with that title is reused, a missing one is created (same shape as TagController::store). Resolution is idempotent, so many items sharing a tag only ever create it once. Empty/omitted tags default to [0]. The normal web-form path (ItemController::store) is untouched.
  • Import client (resources/assets/js/itemImport.js + recompiled public/js/app.js): forwards the item's exported tags instead of hard-coding [0].

Tags round-trip by title, so a config can be moved between instances without reassigning each item by hand.

Tests

  • Updated ItemExportTest::test_returns_exactly_the_defined_fields for the new tags key.
  • Added ItemExportTest::test_exports_assigned_tag_titles_excluding_the_root_tag.
  • Added tests/Feature/ItemImportTest.php: creating+assigning a tag from a title, reusing an existing tag for the same title, and root-only imports creating no stray tags.

Full suite green (38 passing, 1 pre-existing skip). phpcs clean on the changed controller.

The export endpoint (api/item) now emits each item's assigned tag titles,
excluding the root/default dashboard tag. On import, those titles are
resolved back to local tags - reusing an existing tag or creating a missing
one - instead of dropping every imported item onto the default dashboard.

Tags round-trip by title so a config can be moved between instances without
having to reassign each item to its section by hand.

Resolves #1555
@KodeStar KodeStar mentioned this pull request Jul 8, 2026
@KodeStar
KodeStar merged commit caa4f39 into 2.x Jul 8, 2026
1 check passed
@LinuxServer-CI LinuxServer-CI moved this from PRs to Done in Issue & PR Tracker Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

Export to include 'tag'

2 participants