Skip to content

Add datastore_data_preview sub-module #4673

Draft
dcgoodwin2112 wants to merge 2 commits into2.xfrom
feature/datastore-data-preview
Draft

Add datastore_data_preview sub-module #4673
dcgoodwin2112 wants to merge 2 commits into2.xfrom
feature/datastore-data-preview

Conversation

@dcgoodwin2112
Copy link
Contributor

@dcgoodwin2112 dcgoodwin2112 commented Mar 5, 2026

Fixes #4672

Describe your changes

Add datastore_data_preview sub-module under modules/datastore/modules/ that renders datastore data as paginated, sortable HTML tables using Drupal core's TableSort and pager. No JavaScript frameworks required.

Integration points:

  • #type => 'data_preview' render element
  • Block plugin (configurable via Block UI)
  • Inline "Preview data" links on dataset edit forms
  • Standalone admin page at /admin/dkan/data-preview/{resource_id}
  • Preview links on the datastore dashboard

Services:

  • dkan.data_preview.resource_resolver — resolves distribution UUIDs or nodes to identifier__version resource IDs
  • dkan.data_preview.builder — builds paginated, sortable table render arrays
  • dkan.data_preview.datasource.database — direct DB queries to datastore tables
  • dkan.data_preview.datasource.api — HTTP queries to DKAN's REST API (supports external sites)

Also includes ArrayDataSource for in-memory data (not a service — instantiate directly).

QA Steps

  • Enable module: drush en datastore_data_preview
  • Visit /admin/dkan/data-preview/{resource_id} with a valid resource ID — verify paginated sortable table renders
  • Click column headers to sort, change page size, navigate pages
  • Edit a dataset node — verify "Preview data" links appear next to tabular distributions' download URLs
  • Visit /admin/dkan/datastore/status — verify preview links appear for importable resources
  • Place the Data Preview Table block via /admin/structure/block — verify it renders with a configured resource ID
  • Run phpcs --standard=Drupal,DrupalPractice modules/datastore/modules/datastore_data_preview/ — verify zero errors and warnings
  • Run phpunit modules/datastore/modules/datastore_data_preview/tests/ — verify all 112 tests pass

Checklist before requesting review

If any of these are left unchecked, please provide an explanation

  • I have updated or added tests to cover my code
  • I have updated or added documentation

…datastore data. Includes pluggable data sources (database, API, array), block plugin, render element, extra field, ResourceIdResolver service, and inline preview links on dataset edit forms and the datastore dashboard.
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.

Add datastore data preview sub-module for paginated, sortable HTML table display

1 participant