Skip to content

feat(pages): store grid pages and their widgets relationally (#3100, step 1) - #46

Open
rubenvdlinde wants to merge 1 commit into
main-forkedfrom
stack/r1-page-model
Open

rubenvdlinde wants to merge 1 commit into
main-forkedfrom
stack/r1-page-model

Conversation

@rubenvdlinde

Copy link
Copy Markdown
Collaborator

Step 1 of the page rework on the data model of nextcloud#3100 (follows the review on nextcloud#3075). No API or UI yet.

What

  • tables_contexts_page gets title, emoji, description (nullable) and an index on context_id; Page::TYPE_GRID.
  • New tables tables_contexts_widget (page_id, type, title, grid_x/y/width/height), tables_contexts_widget_setting (unique widget_id + name) and tables_contexts_widget_source (PK widget_id, index node_rel_id), with entities and mappers.
  • WidgetService reads widgets with their settings and source and writes them. Settings are stored one row per setting, JSON encoded, behind WidgetSettingMapper::findSettingsByWidgetIds() / replaceSettings(), so moving them to one JSON column later touches one class.
  • Deleting an application deletes its pages' widgets, settings and sources. Deleting a table or view, or removing a node from the application, deletes only the widget_source rows: the widget stays.
  • Context responses list the page title, emoji and description. A grid page without start page rows no longer gets an empty content entry from the mapper's join.
  • Scheme export (getScheme) and the user migration export carry each page's widgets; importContext() imports them and remaps the source through the existing $nodeRelMap (a source whose node was not imported is dropped).
  • App version 2.4.0-dev.5. tables_contexts_page_content and node_rel_id are unchanged.

nextcloud#3100 points covered

Schema (all of it), "deleting a page or an application deletes its widgets, settings and sources", "removing a table or view deletes only the source row", "scheme export and import copy widgets, settings and sources". Saving and the API follow in the next PR.

Tests (Nextcloud 34, PostgreSQL 16, in the container)

  • tests/unit/Service/WidgetServiceTest.php (real DB): OK (5 tests, 13 assertions)
  • tests/unit/Db/ContextMapperTest.php (real DB): OK (1 test, 5 assertions)
  • tests/unit/Service/ContextPagesRoundTripTest.php (real DB, export, import, node removal, application deletion): OK (2 tests, 10 assertions)
  • tests/unit/Service/ContextServiceTest.php: OK (6 tests, 18 assertions)
  • tests/unit/TablesMigratorTest.php: OK (12 tests, 20 assertions)
  • whole unit suite: OK (370 tests, 723 assertions)
  • composer cs:check: no files; psalm: no errors.

Prepared in the Conduction fork for porting upstream by @remko48. Prepared with Claude Code.

Adds the data model of nextcloud#3100: pages get a title, emoji and
description and the grid page type; widgets, their settings and the node a
data widget shows live in tables_contexts_widget, tables_contexts_widget_setting
and tables_contexts_widget_source. Deleting an application or page deletes
its widgets; removing a node deletes only the widget sources. Scheme and
user migration export carry the widgets, import remaps their node.

Assisted-by: ClaudeCode:claude-opus-5-5
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