Skip to content

Container widget #3428

Todo
Todo

Description

@rubenvdlinde

Is your feature request related to a problem? Please describe.

Why this is needed

Describe the solution you'd like

  • A widget that holds other widgets in its own grid, with an optional title and border, so a part of a page can be moved and resized as one.
Diagram
classDiagram
    class Page {
        tables_contexts_page
        slug
        version
    }
    class Widget {
        tables_contexts_widget
        type
        gridX, gridY, gridWidth, gridHeight
        settings
        parentId
        parentTab
    }
    class Container {
        type container, new
        title
        border
    }
    class Tabs {
        type tabs, from #3212
        tabs
    }
    Page "1" --> "*" Widget : holds
    Widget <|-- Container
    Widget <|-- Tabs
    Container "1" --> "*" Widget : parentId
    Tabs "1" --> "*" Widget : parentId and parentTab
Loading
Acceptance Criteria
  • Listed by GET /api/2/widget-types with its settings schema.
  • A widget inside a container names the container as its parent, the way a widget names a tab in feat(pages): let widgets sit in the tabs of a tabs widget #3212.
  • Deleting a container deletes the widgets inside it, after a confirmation.
  • Containers do not nest in containers or tabs.
  • Export and import keep the parent links.
  • Unit tests, a Playwright spec that moves a filled container.
  • Settings are stored as JSON text in the settings text column of tables_contexts_widget (at most 60000 bytes, GridWidgetTypes::SETTINGS_MAX_BYTES), not in a database JSON column, as advised on Grid pages in applications (frontend) #3099. Nothing is filtered or sorted on them.
  • Widgets are saved through the page route PATCH api/2/contexts/{contextId}/pages/{pageId}, which declares #[RequirePermission] for managing the application, and the service checks the same right before it writes. A test saves a page with the new widget as a reader of the application and expects 403, as learned in the review of feat(contexts): give applications a menu with its own API #3135.
  • No new database column: the container reuses parent_id of feat(pages): let widgets sit in the tabs of a tabs widget #3212, so no migration of its own. Deleting a container deletes its widgets in the same transaction as the container.
  • The bordered container uses NcCard (feat: add NcCard component nextcloud-libraries/nextcloud-vue#9144). A title on the container is not repeated inside it (jancborchardt on Grid pages in applications (frontend) #3099). At phone width its grid stacks to one column.
  • Usable at 360 px wide: nothing cut off and no horizontal scroll of the page. Every action works with the keyboard alone.
Components
  • CnContainerWidget (keep, week 44): the container widget type, copied as is: its own grid with an optional title and border.
Out of scope

Describe alternatives you've considered

Questions for maintainers

  1. A separate container type, or a tabs widget with one tab and no tab bar? Options: (a) a separate type on the parent link of feat(pages): let widgets sit in the tabs of a tabs widget #3212, (b) a setting on the tabs widget. We would go with (a): it maps one to one to buildiq's container, and the tabs widget keeps one behaviour.
  2. What happens to the widgets inside when a container is deleted? Options: (a) deleted with it, after a confirmation that says how many, (b) moved onto the page. We would go with (a), as the draft says, because (b) drops widgets in places the builder did not choose.

Additional context

Linking to other objects
Relevant files:
Related issues

Drafted with AI assistance from the project plan; @remko48 reviews it. Part of #3419.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions