Repository navigation
feat(contexts): data model for grid pages - #3131
Conversation
9467b93 to
2f8eafc
Compare
4489199 to
5d26395
Compare
| $table->addColumn('grid_y', Types::INTEGER, ['notnull' => true, 'default' => 0]); | ||
| $table->addColumn('grid_width', Types::SMALLINT, ['notnull' => true, 'default' => 1]); | ||
| $table->addColumn('grid_height', Types::SMALLINT, ['notnull' => true, 'default' => 1]); | ||
| $table->addColumn('settings', Types::TEXT, ['notnull' => false]); |
There was a problem hiding this comment.
i thought we said we're using JSON?
There was a problem hiding this comment.
We did, sorry. The column is Types::JSON now. Nextcloud maps it per database: json on PostgreSQL, JSON on MySQL, LONGTEXT on MariaDB and text on SQLite. I ran the tests on PostgreSQL and SQLite; nothing compares the stored text, so MySQL normalising the JSON doesn't matter. The Widget entity maps the field as Types::JSON too and reads and writes it as an array. That part is in #3133, where the settings type moves into ResponseDefinitions anyway.
d20afd0 to
ada0004
Compare
- a table or view added to an application later gets a widget at the bottom of the start page, so the start page follows the Edit application dialog and Import scheme - a new, migrated or imported start page is filled with one call, its header passing the header schema with the description cut to 2000 characters; a start page that cannot show every table or view logs how many it shows - an imported application that gets a new start page has it filled as well - the migration step sorts after the steps of #2476 and #3131, copies its layout instead of using GridWidgetTypes, reads all start pages with two queries, prepares its inserts once, commits per hundred pages and reports progress - the migration test runs in a transaction it rolls back, instead of emptying every Tables table of the instance - the docs say page where the start page now counts as well Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Ruben van der Linde <ruben@conduction.nl>
c142eed to
b2f3392
Compare
- a table or view added to an application later gets a widget at the bottom of the start page, so the start page follows the Edit application dialog and Import scheme - a new, migrated or imported start page is filled with one call, its header passing the header schema with the description cut to 2000 characters; a start page that cannot show every table or view logs how many it shows - an imported application that gets a new start page has it filled as well - the migration step sorts after the steps of #2476 and #3131, copies its layout instead of using GridWidgetTypes, reads all start pages with two queries, prepares its inserts once, commits per hundred pages and reports progress - the migration test runs in a transaction it rolls back, instead of emptying every Tables table of the instance - the docs say page where the start page now counts as well Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Ruben van der Linde <ruben@conduction.nl>
b2f3392 to
9a723b0
Compare
- a table or view added to an application later gets a widget at the bottom of the start page, so the start page follows the Edit application dialog and Import scheme - a new, migrated or imported start page is filled with one call, its header passing the header schema with the description cut to 2000 characters; a start page that cannot show every table or view logs how many it shows - an imported application that gets a new start page has it filled as well - the migration step sorts after the steps of #2476 and #3131, copies its layout instead of using GridWidgetTypes, reads all start pages with two queries, prepares its inserts once, commits per hundred pages and reports progress - the migration test runs in a transaction it rolls back, instead of emptying every Tables table of the instance - the docs say page where the start page now counts as well Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Ruben van der Linde <ruben@conduction.nl>
enjeck
left a comment
There was a problem hiding this comment.
looks good to me except for the unresolved comments. We can merge if those are addressed now or plan to be addressed later
9a723b0 to
94493d0
Compare
- a table or view added to an application later gets a widget at the bottom of the start page, so the start page follows the Edit application dialog and Import scheme - a new, migrated or imported start page is filled with one call, its header passing the header schema with the description cut to 2000 characters; a start page that cannot show every table or view logs how many it shows - an imported application that gets a new start page has it filled as well - the migration step sorts after the steps of #2476 and #3131, copies its layout instead of using GridWidgetTypes, reads all start pages with two queries, prepares its inserts once, commits per hundred pages and reports progress - the migration test runs in a transaction it rolls back, instead of emptying every Tables table of the instance - the docs say page where the start page now counts as well Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Ruben van der Linde <ruben@conduction.nl>
94493d0 to
544f2e0
Compare
- a table or view added to an application later gets a widget at the bottom of the start page, so the start page follows the Edit application dialog and Import scheme - a new, migrated or imported start page is filled with one call, its header passing the header schema with the description cut to 2000 characters; a start page that cannot show every table or view logs how many it shows - an imported application that gets a new start page has it filled as well - the migration step sorts after the steps of #2476 and #3131, copies its layout instead of using GridWidgetTypes, reads all start pages with two queries, prepares its inserts once, commits per hundred pages and reports progress - the migration test runs in a transaction it rolls back, instead of emptying every Tables table of the instance - the docs say page where the start page now counts as well Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Ruben van der Linde <ruben@conduction.nl>
Pages get a title, a named icon, a description and a technical name that is unique within their application. Without a name a page is called page_<id>, the start page dashboard, and page_<number> is kept for those automatic names. Widgets get their own table: the page, the type, an optional title, icon and description, the position and size on the grid, and the settings as one JSON object. A widget source links a data widget to a table or view of the same application. One migration adds all of it and names the pages that already exist. The technical name format is checked by one validator, now also used for views and columns. The app version moves to 2.5.0-dev.0 so that instances on 2.4.0 run the migration. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Ruben van der Linde <ruben@conduction.nl>
…e atomically Types::JSON is deprecated for columns since Nextcloud 33. An import reads pages in the snake case the mapper exports, so the camel case fallbacks go. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Ruben van der Linde <ruben@conduction.nl>
- chunk the IN lists of the widget mappers for Oracle - freeze the migration: literals instead of class constants, and a date after the steps of #2476 so it sorts after them - an imported grid page without a title is titled by its technical name, and an imported application without a start page gets one with all its tables and views - the reserved automatic name lives in TechnicalNameValidator - the stricter technical name rule refuses a trailing newline for views and columns too; importView() drops one from names stored by older versions - widgets have one serialised shape, so Widget is no longer JsonSerializable - naming a page after its id only updates its technical name - the icon check calls IconHelper directly, the view name test goes through create(), the database error stub moves to the pull request that uses it, and the source mapper test uses ids no real row has Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Ruben van der Linde <ruben@conduction.nl>
…dget A data widget now stores its node relation in a nullable, indexed node_rel_id column, as menu items do, instead of in a separate tables_contexts_widget_source table. WidgetSource and its mapper go; WidgetMapper::clearNodeRelIds() unlinks the widgets of removed relations. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Ruben van der Linde <ruben@conduction.nl>
…le, icon and description of its pages Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Ruben van der Linde <ruben@conduction.nl>
A page is named by its slug, as agreed in #3094: the column, the unique index, the entity field, the export and import key. A new page gets page_<id> and the start page dashboard. Columns and views keep their technical name. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Ruben van der Linde <ruben@conduction.nl>
544f2e0 to
e52a7b7
Compare
- a table or view added to an application later gets a widget at the bottom of the start page, so the start page follows the Edit application dialog and Import scheme - a new, migrated or imported start page is filled with one call, its header passing the header schema with the description cut to 2000 characters; a start page that cannot show every table or view logs how many it shows - an imported application that gets a new start page has it filled as well - the migration step sorts after the steps of #2476 and #3131, copies its layout instead of using GridWidgetTypes, reads all start pages with two queries, prepares its inserts once, commits per hundred pages and reports progress - the migration test runs in a transaction it rolls back, instead of emptying every Tables table of the instance - the docs say page where the start page now counts as well Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Ruben van der Linde <ruben@conduction.nl>
There was a problem hiding this comment.
Oh, this should be renamed in a follow-up.
- a table or view added to an application later gets a widget at the bottom of the start page, so the start page follows the Edit application dialog and Import scheme - a new, migrated or imported start page is filled with one call, its header passing the header schema with the description cut to 2000 characters; a start page that cannot show every table or view logs how many it shows - an imported application that gets a new start page has it filled as well - the migration step sorts after the steps of #2476 and #3131, copies its layout instead of using GridWidgetTypes, reads all start pages with two queries, prepares its inserts once, commits per hundred pages and reports progress - the migration test runs in a transaction it rolls back, instead of emptying every Tables table of the instance - the docs say page where the start page now counts as well Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Ruben van der Linde <ruben@conduction.nl>
Part of #3099. This adds the data model from #3100, and nothing uses it yet. It's the first of seven pull requests that build the backend for grid pages and application menus. They're stacked, each on the one before:
Splitting it this way lets you review the schema on its own, before any behaviour depends on it.
Size: 1380 lines: 681 code and 691 tests, plus the version bump.
What changes
tables_contexts_page) gettitle,iconanddescription. A new page typegridsits next tostartpage.slug, unique within its application, that doesn't change once it's set. The column, the unique index, the entity and the export and import key all useslug. Existing start pages getdashboard.tables_contexts_widget): the page, the type, an optional title, icon and description, the position and size on the 12-column grid, the settings in oneJSONcolumn, and for a data widget its table or view as a nullable, indexednode_rel_id, the way menu items keep theirs. Settings are read back ordered by name, because MySQL'sJSONcolumn type does not keep the order they were written in, so every database answers the same.startpageandgridpages only, and at most one start page per application. Other pages are skipped with a warning in the log, like other invalid import data. The import of an application runs in one transaction and keeps a page's title, icon and description.One migration,
Version2500Date20261109000000, adds the columns and tables, including the unique index on the page's application and slug, and then fills in a slug for every existing page. Tables runs on PostgreSQL, MySQL and SQLite, which all treat NULL values in a unique index as distinct (not empty strings, which the code never writes), so the index can be created before the names are filled in. It also serves lookups by application, so there's no separate index oncontext_id. The column itself allows NULL: a new page gets itspage_<id>right after it's inserted, the same way views get theirs.Where it differs from #3100
We agreed these with @enjeck:
And two small ones on top:
iconinstead of anemoji. It's a named icon from the same set applications use, so applications, pages, menu items and widgets share one icon picker.How the slugs work
They work the same way as technical names for views and columns:
page_<id>, likeview_<id>andcolumn_<id>. The start page of an application isdashboard.page_<number>is reserved for the automatic names, the way columns keep reserved names, so a name someone types can never collide with a later automatic one. The API refuses it from feat(api): pages and widgets on api/2 #3133 on; imports treat it as no name.^[a-z][a-z0-9_]*$, at most 200 characters, no trailing newline), now also used by views and columns, so the rule lives in one place.Why nothing breaks
The new tables start empty, and the new page columns are empty, except the slug. Existing start pages get
dashboard, and new applications get the same when their start page is created. Nothing reads the rest yet, so existing applications, start pages and API responses stay as they are.The app version goes to
2.5.0-dev.0(ininfo.xml,package.jsonandpackage-lock.json, the way main went to2.4.0-dev.0after 2.3.2), so instances on the released 2.4.0 run the migration. The migrations of this stack are namedVersion2500Date…for the same reason.How it was tested
On Nextcloud 34 with PostgreSQL:
WidgetTest, plus new database testsWidgetMapperTestandPageTestpage_<id>, filling in existing pages, refusing a name that's already used, a trailing newlineocc upgradeto this stack; both migrations ran, the start pages becamedashboardand another pagepage_<id>composer cs:check, psalm and rector, all clean🖼️ Screenshots
Backend only, no UI changes.
🏁 Checklist
/backport to stableX.X🤖 AI (if applicable)