Skip to content

feat(grid): grid canvas and widget components (#3100/#3099, step 3) - #48

Open
rubenvdlinde wants to merge 1 commit into
stack/r2-page-apifrom
stack/r3-grid-widgets
Open

rubenvdlinde wants to merge 1 commit into
stack/r2-page-apifrom
stack/r3-grid-widgets

Conversation

@rubenvdlinde

Copy link
Copy Markdown
Collaborator

Step 3 of the page rework on nextcloud#3100 / nextcloud#3099 (follows the review on nextcloud#3075). Stacked on #47. Components only; the page that uses them follows in step 4.

What

  • src/modules/grid/: GridCanvas (GridStack, 12 columns, reflows to 6 and then 1 column on narrow canvases via a ResizeObserver; only the 12 column layout is ever emitted), GridWidget (card with title, edit menu with configure, remove and keyboard move/resize steps), SchemaForm (settings form from the type schema), widgetRegistry (each type registers its component in one place), widgets HeaderWidget, TextWidget, DataWidget.
  • gridLayout.js: converts between the API page (widgets[] with settings and source.nodeRelId) and the editable grid, and back to the PATCH payload (saved widgets keep their id; source only for types with hasSource).
  • AddWidget dialog: type, optional title, settings form; a data widget offers only the application's own tables and views (Grid pages in applications (frontend)聽nextcloud/tables#3099 screenshot 5).
  • A data widget without a source, or whose table or view left the application, says "Pick a table or view in the widget settings" in edit mode and shows an empty state ("No table or view to show") in view mode.
  • A widget shows its title when it has one (Grid pages in applications (frontend)聽nextcloud/tables#3099 behaviour); the showTitle flag of the earlier stack is gone.
  • Store: loadWidgetTypes() (one shared request). Dependency: gridstack@^13.3.0 (MIT, checked on the npm registry; lockfile adds only that package).

nextcloud#3099 points covered

"The grid has 12 columns and changes to 6 and then 1 column on narrow screens", "A widget shows its title when it has one", "If a table or view leaves the application, its widget stays on the page and asks the editor to pick another one", "Each widget type registers its component in one place", the data widget's own-tables-only picker.

Tests

  • env -u ELECTRON_RUN_AS_NODE npx cypress run --component --spec cypress/component/gridLayout.cy.js,cypress/component/GridWidget.cy.js: All specs passed! 14 14 (layout conversion, own-node options, save payload, reflow breakpoints, title, pick/empty states)
  • npm run lint: 0 errors, 1 inherited warning (src/store/store.js:176, jsdoc on an existing action); npm run stylelint: clean; npm run build: built.

Size: 1,556 changed lines excluding the lockfile, just over the 1,500 guideline; splitting the canvas from the widgets would leave either half untestable on its own, so it stays one PR.

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

Carries the grid frontend over from the earlier stack onto the widget
shape of the nextcloud#3100 API: a settings map per widget and a source node
relation for data widgets. The canvas places widgets on 12 columns and
reflows to 6 and 1 on narrow screens; the add widget dialog renders the
settings form from the type schema and offers only the application's own
tables and views. A data widget without a source asks the editor to pick
one and shows an empty state to viewers.

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