Skip to content

feat(contexts): carry the menu through export and import - #3138

Open
rubenvdlinde wants to merge 22 commits into
feat/noid/app-menu-modelfrom
feat/noid/app-menu-export-import
Open

rubenvdlinde wants to merge 22 commits into
feat/noid/app-menu-modelfrom
feat/noid/app-menu-export-import

Conversation

@rubenvdlinde

@rubenvdlinde rubenvdlinde commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Part of the stack on #3133, on top of #3135 (menu API). Implements the export and import part of the menu proposal on #3100. A menu now travels with its application through a scheme export and import, and when a user's data is moved to another instance. This replaces #3138.

Size: 631 lines: 375 code, 231 tests and 25 generated OpenAPI.

What changes

  • Export writes each item with pages by their slug ({page: <slug>}), tables and views by uuid (by the table's technical name once Technical name for tables and applications, CRUD routes by application and table #3094 lands), and the group of an item by the group's position in the exported menu. Items have no technical name. The title an item shows is written along, for the preview.
  • Import replaces the menu. It finds pages by slug, in the scheme import and the user data import alike, including the pages the same import created. An automatic page_<id> slug never matches a page on import. It finds tables and views among the nodes of the application, the way importContext() maps nodes, so a menu never adds a table to an application. Every item is checked like the API checks it; an item that fails or whose target didn't come along is skipped and logged with the reason, and so is every item past the 200th. An item whose group didn't come before it, or was skipped, moves to the top level. Importing an empty menu, or one where every item is skipped, leaves the menu as it is, and the skipped items are listed with their reason.
  • Moving a user's data (TablesMigrator) carries the menu: links, items for the moved application's pages, and items for the moved table. View items are skipped for now, because that import has no mapping from old view ids to new ones.
  • The scheme preview shows the menu the import would save next to the current one, and the items it would skip. A scheme imported into an existing application has nothing else linking its pages to the application's, so the preview matches them once, the start page to the start page and any other page by slug, and hands back items that point at pages of the application.
  • The import screen has a Menu switch, like Resources. When it's on (the default), the menu from the file is sent with the import; when it's off, the application keeps its menu.

How it was tested

After the reviews, on Nextcloud 34 with PostgreSQL:

  • MenuServiceTest against the database: a menu with a group, a link, a table and a page through a scheme export and importScheme(); a user migration through importContext(); an item following its page when the import drops the page's name; scheme pages matched by start page and slug; items an import can't use, each skipped with its reason (data provider); an item whose group didn't come first moves to the top
  • the full unit suite on this branch: 644 tests
  • psalm and php-cs-fixer, clean; OpenAPI in step with the code

By hand on a test instance, through the API, with #3201 on top: exported an application whose menu has an item on a page with an automatic name. The export named that page by its exported id then; imported into another application, the page got a new automatic name and the menu item followed it. That check ran before pages were exported by slug; MenuServiceTest now covers the slug export and an application's own export importing back unchanged. User migration was not tested by hand.

🖼️ Screenshots

One small UI change: the Menu switch on the import screen, with the menu before and after and the items that would be skipped.

🏁 Checklist

  • ⛑️ Tests (unit and/or integration) are included or not needed
  • 🔙 Backport requests are created or not needed: /backport to stableX.X
  • 📅 Milestone is set
  • 🌸 PR title is meaningful (if it should be in the changelog: is it meaningful to users?)

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI

@samin-z samin-z 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.

thank you @rubenvdlinde

i tested the pr manually for now, what i found is the API part works fine, the exported file contains 'menuItems' and the import saves them when they are in the body. however the import screen does not send them.

from what i see, ImportContextSchemePreview.vue builds the import body in emitPayload() from the name, icon,description, tables and nodes. 'menuItems' is left out, so the application keeps the menu it already has. the preview response already returns the menu under 'menuItem' and it needs to be included in the import request, otherwise a user of the screen never gets the menu from the file.

@rubenvdlinde
rubenvdlinde force-pushed the feat/noid/app-menu-export-import branch from bfdf4e9 to e2404c1 Compare October 30, 2026 09:51
@rubenvdlinde

Copy link
Copy Markdown
Contributor Author

Thanks @samin-z, good catch. The preview already returned the menu, but the screen never sent it with the import.

The import screen now has a Menu switch, like Title, Icon and Resources. It shows the current menu, the menu after the import, and the items that would be skipped. When the switch is on (the default), the import sends the menu from the file. When it's off, the application keeps the menu it has. A Cypress component test covers both cases.

The menu now travels with its application through a scheme export and
import, and when a user's data is moved to another instance.

An export writes each item with pages by technical name, tables and
views by uuid, and the group of an item by the group's position in the
exported menu. The title it shows is written along, for the import
preview. An import replaces the menu: it finds pages by technical
name and tables and views among the nodes of the application, so a menu
never adds a table to it. Every item is checked like the API checks it,
and an item that fails or whose target did not come along is skipped and
logged with the reason, as is every item past the 200th. An item whose
group did not come before it, or was skipped, moves to the top level.

Moving a user's data keeps the links, the items for the pages and the
items for the moved table. View items are skipped, as that import has no
mapping from old view ids to new ones yet.

The scheme preview shows the menu the import would save, next to the
current one, and the items it would skip. The import screen has a Menu
switch, like Resources: when it is off, the application keeps its menu.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Ruben van der Linde <ruben@conduction.nl>
A technical name is a mutable alias, and an import can change it. A scheme imported into
an existing application still has to match pages, so the preview does that once and hands
back items that point at pages of the application.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Ruben van der Linde <ruben@conduction.nl>
Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Ruben van der Linde <ruben@conduction.nl>
A fresh database, as on CI with SQLite, can hold a page 99.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Ruben van der Linde <ruben@conduction.nl>
… the application and the preview's menu

The menu part of the scheme preview moves into MenuService::previewSchemeImport(),
so the preview and the import it feeds are tested together.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Ruben van der Linde <ruben@conduction.nl>
…efore it is skipped

The preview's menu kept the group position each item had in the scheme,
while the import counts positions in the shorter list it gets, so an item
after a skipped one landed in another group or at the top level. The
preview now names the group by its position among the items it keeps.

Assisted-by: ClaudeCode:claude-opus-5-5

Signed-off-by: Ruben van der Linde <ruben@conduction.nl>
…ts items

Importing an empty menu, or one of which every item was skipped, deleted
the menu of the application, start page item included. The import now
leaves the menu alone in that case and still returns the skipped items,
and the preview leaves out a scheme menu without items, so the dialog
does not offer to import it.

Assisted-by: ClaudeCode:claude-opus-5-5

Signed-off-by: Ruben van der Linde <ruben@conduction.nl>
…olds

The limit of 200 counted only the items an import kept, so every entry
past it was still checked, looked up and logged. The import now reads
the first 200 entries, skips the rest with one record that says how many
were left out, and logs the skipped items in one line.

Assisted-by: ClaudeCode:claude-opus-5-5

Signed-off-by: Ruben van der Linde <ruben@conduction.nl>
The import built and checked its items by a copy of create()'s steps and
checked links and pages of the application with its own branches and
messages, so a rule added to the API would not reach imports. The import
now only translates an exported page, table or view into the page or node
relation of the application, hands links and pages to the API's target
check, and builds every item through the same helper as create().

Assisted-by: ClaudeCode:claude-opus-5-5

Signed-off-by: Ruben van der Linde <ruben@conduction.nl>
… cannot use

An imported item whose icon this instance does not have, or whose title
or description was too long, was skipped, and the items of a skipped
group moved to the top level. Such an item is now kept without that
field, the way pages and widgets are imported, and a group keeps its
title cut to the length, as a group needs one.

Assisted-by: ClaudeCode:claude-opus-5-5

Signed-off-by: Ruben van der Linde <ruben@conduction.nl>
The pages of a scheme were matched to the pages of the application by
technical name whatever their type, so a grid page named like the start
page stood for the start page, and its menu item opened the start page a
second time. A grid page now only matches a grid page, and is skipped
otherwise.

Assisted-by: ClaudeCode:claude-opus-5-5

Signed-off-by: Ruben van der Linde <ruben@conduction.nl>
…rt a reader's menu as read

The export loaded the tables and views of the menu twice, once for their
titles and once for their uuids. It now loads them once per type and
takes both from the same entities. The account export also wrote every
menu as a manager sees it, empty groups included, for applications the
user can only read; it now leaves those out like reading the menu does.

Assisted-by: ClaudeCode:claude-opus-5-5

Signed-off-by: Ruben van der Linde <ruben@conduction.nl>
…e application's own

The scheme import looked each menu item's table or view up across the
instance by uuid, one query per item, and a view uuid that two tables
share made the import fail. The import now maps the uuids of the
application's own tables and views to their node relations once, with
one query per type, and looks the items up in that map.

Assisted-by: ClaudeCode:claude-opus-5-5

Signed-off-by: Ruben van der Linde <ruben@conduction.nl>
The account import brings an application once for each of its tables,
and each copy keeps only the menu items for its own table, so items for
the other tables and for views are left out. The docblock now says so,
and the log line names that as the reason instead of saying the table
is not part of the application.

Assisted-by: ClaudeCode:claude-opus-5-5

Signed-off-by: Ruben van der Linde <ruben@conduction.nl>
…ll it back

The scheme import let a refused request, something not found and an
internal error escape the controller, so documented 400s came back as
500 and the transaction stayed open. Each now rolls the import back and
answers 400, 404 or 500.

Assisted-by: ClaudeCode:claude-opus-5-5

Signed-off-by: Ruben van der Linde <ruben@conduction.nl>
…eeps and list what it skipped

The preview checked the menu's tables and views against the scheme's
resources, while an import with the Resources switch off keeps the
application's own, so items under "To" were dropped silently. The
preview now also judges the menu against the current resources, and the
dialog shows and sends that menu when the switch is off. The import
answers with the menu items it skipped, and the dialog lists them.

Assisted-by: ClaudeCode:claude-opus-5-5

Signed-off-by: Ruben van der Linde <ruben@conduction.nl>
…rt preview

The menu preview listed a title per item only: no kind, no link address,
no grouping and no reason for a skipped item, and an untitled entry was
an empty bullet. Each item now shows what it opens, a link with its full
address and a table or view with its name, the items of a group sit in
it, a skipped item shows the reason, and an untitled item gets a visible
name. A page item shows the title it gets in this application, so the
start page shows this application's name.

Assisted-by: ClaudeCode:claude-opus-5-5

Signed-off-by: Ruben van der Linde <ruben@conduction.nl>
Assisted-by: ClaudeCode:claude-opus-5-5

Signed-off-by: Ruben van der Linde <ruben@conduction.nl>
…gs no menu

An imported application got the item that opens its start page before its
exported menu was imported. The import replaced it whenever it kept an item,
so the seed was written only to be deleted. The item is now added only when
the export carries no menu or when none of its items is kept.

Assisted-by: ClaudeCode:claude-opus-5-5

Signed-off-by: Ruben van der Linde <ruben@conduction.nl>
An exported menu names a page by its slug, and the scheme import, its
preview and the account import resolve that slug to a page of the
application. The preview hands back the slug of the matched page, so the
{pageId} form and withLocalPages() are gone, and an application's own
scheme export imports back with its start page item.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Ruben van der Linde <ruben@conduction.nl>
Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Ruben van der Linde <ruben@conduction.nl>
A page_<id> slug names a page of the instance the scheme was exported from, so on
another instance it can name an unrelated page. Only a chosen slug matches a page
of the application.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Ruben van der Linde <ruben@conduction.nl>
@rubenvdlinde
rubenvdlinde force-pushed the feat/noid/app-menu-export-import branch from c0627d7 to b57a52f Compare November 21, 2026 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants