Skip to content

feat(contexts): keep widgets in step with pages and applications - #3132

Open
rubenvdlinde wants to merge 1 commit into
feat/noid/grid-page-modelfrom
feat/noid/grid-widget-lifecycle
Open

rubenvdlinde wants to merge 1 commit into
feat/noid/grid-page-modelfrom
feat/noid/grid-widget-lifecycle

Conversation

@rubenvdlinde

@rubenvdlinde rubenvdlinde commented Oct 22, 2026 •

Copy link
Copy Markdown

Part of #3099, on top of #3131 (data model). This adds the behaviour #3100 describes for widgets, still without an API or UI.

Size: 1717 lines: 627 code, 1090 tests.

  • Saving a page replaces its widgets in one transaction, matched by id. Existing widgets are updated, new ones added, and missing ones removed.
  • Deleting a page or an application deletes its widgets and their sources.
  • Removing a table or view from an application deletes only the source rows that point at it, first and in the same transaction as the rest. The widget stays, and later shows that it needs a new table.
  • Moving a user's data (TablesMigrator) carries an application's pages, widgets and settings. A widget source only comes along when it points at the table being imported: importContext() maps every node to that table, so a source for another table would land on the wrong one. Imported widgets and page texts are checked the same way as saved ones, and invalid ones are skipped with a warning in the log.
  • Exporting and importing an application's scheme doesn't carry pages and widgets yet. We'd like to add that in a follow-up pull request.
  • Widget types (header, text, table or view) are defined in one place on the server, each with the schema its settings are checked against. Colours must be #rgb or #rrggbb.
  • Limits: at most 100 widgets per page and 60,000 bytes of settings per widget (under MySQL's 64 KB for TEXT). An import skips what goes over.
  • A widget's source must be a table or view of the page's own application. The service checks this itself, not only the API.

Data exported with widgets can't be imported into an older version of Tables. That belongs in the changelog.

Three smaller changes come with it:

  • Context responses now carry each page's title, icon, description and technical name.
  • A grid page no longer gets an empty entry in the start page list.
  • Importing skips a start page entry whose table didn't come along. Before, it wrote an empty value into a column that doesn't allow one.

The widget types aren't in ResponseDefinitions yet, because the OpenAPI generator refuses schemas that no endpoint uses. They move there together with the endpoints in the next pull request.

Why nothing breaks

There is still no way to create a widget, so all of this runs on empty tables. Deleting an application or removing a table behaves as before; it now also checks two more tables.

How it was tested

On Nextcloud 34 with PostgreSQL:

  • WidgetServiceTest (database, including clearing a widget title back to empty, and refusing a widget id from another page)
  • GridWidgetTypesTest and ContextServiceTest
  • ContextPagesRoundTripTest (database: export, import, removing a table, deleting an application)
  • ContextMapperTest and TablesMigratorTest
  • a broken export file and a two-table user migration
  • the full unit suite on the top of the stack (feat(contexts): carry the menu through export and import #3138), on PostgreSQL and SQLite: 665 tests
  • composer cs:check, psalm and rector, all clean

🖼️ Screenshots

Backend only, no UI changes.

🏁 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

@rubenvdlinde
rubenvdlinde added this pull request to stack #3134 October 22, 2026 11:01
@rubenvdlinde
rubenvdlinde force-pushed the feat/noid/grid-widget-lifecycle branch from 9c0151e to bcce8b6 Compare October 22, 2026 11:37
@rubenvdlinde
rubenvdlinde removed this pull request from stack #3134 October 22, 2026 11:42
@rubenvdlinde
rubenvdlinde added this pull request to stack #3139 October 22, 2026 11:42
@rubenvdlinde
rubenvdlinde force-pushed the feat/noid/grid-widget-lifecycle branch from bcce8b6 to 390968d Compare October 22, 2026 13:25
@rubenvdlinde
rubenvdlinde force-pushed the feat/noid/grid-widget-lifecycle branch 2 times, most recently from 3dedb5e to 669999e Compare October 24, 2026 08:09
Saving a page syncs its widgets by id in one transaction. Deleting a
page or an application deletes its widgets and their sources, and
removing a table or view from an application deletes only the sources
that point at it, so the widget stays.

Moving a user's data carries pages, widgets and sources, remapped to
the imported nodes and checked like a save. The header, text and data
widget types are defined in one place with the schema their settings
are checked against.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Ruben van der Linde <ruben@conduction.nl>
@rubenvdlinde
rubenvdlinde force-pushed the feat/noid/grid-widget-lifecycle branch from 669999e to af7e75b Compare October 26, 2026 09:24
@rubenvdlinde
rubenvdlinde marked this pull request as ready for review October 26, 2026 09:25
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.

2 participants