Skip to content

feat(dashboard): manifest-driven dataSource for stats-block + chart widgets#186

Merged
rubenvdlinde merged 2 commits into
betafrom
feat/dashboard-datasource-stats-block
May 10, 2026
Merged

feat(dashboard): manifest-driven dataSource for stats-block + chart widgets#186
rubenvdlinde merged 2 commits into
betafrom
feat/dashboard-datasource-stats-block

Conversation

@rubenvdlinde
Copy link
Copy Markdown
Contributor

Summary

  • New composables useGraphQL + useDataSource — thin reactive wrappers around axios.post against OpenRegister's GraphQL endpoint, with a tiny dot-path selector helper (selectByPath) for the manifest selectors map.
  • New widget CnStatsBlockWidget — wraps CnStatsBlock; reads widgetDef.dataSource; forwards the resolved count.
  • CnDashboardPage dispatcher gains a type: 'stats-block' branch between the chart and NC-API branches.
  • CnChartWidget accepts an optional dataSource prop; static series/categories/labels props become the fallback while the GraphQL request is pending.
  • Manifest schema widgetDef.dataSource accepts two forms — shorthand ({ register, schema, filter?, aggregate: 'count' }) and raw ({ graphql: { query, variables?, selectors } }).

Why

Decidesk's dashboard manifest declares three type: 'stats-block' widgets. Without a dispatcher branch they fall through to the 'Widget not available' placeholder. This PR adds the lib-level support so every consumer (decidesk, mydash, procest, pipelinq) can wire dashboard counts straight from manifest JSON.

The dataSource block is documented via the schema and consumed by both stats-block and chart widgets, so future widget types share the resolver.

Test plan

  • npm test — 871 / 871 passing (one pre-existing test-suite failure for CnMapWidget's missing leaflet dep is unrelated).
  • npm run check:docs — green.
  • 16 new tests across useGraphQL.spec.js + useDataSource.spec.js cover dot-path selectors, [] flat-maps, GraphQL errors[], transport errors, the shorthand → totalCount path, and the raw selectors path.
  • CI green.
  • Visual check via decidesk's dashboard once that PR ships.

Related

  • Companion server-side fix: openregister #1456 / PR #1457 — RBAC/MT bypass during GraphQL schema generation so consumer-app schemas (e.g. decidesk meeting/decision/action-item) appear in the introspected schema.
  • Future work: openregister #1455groupBy + aggregate on Connection types so chart widgets can drive themselves from one query.

… resolution

useGraphQL is a thin reactive wrapper around axios.post against OR's
GraphQL endpoint. selectByPath reads dot-paths with [] flat-maps for
the manifest selectors map.

useDataSource resolves a manifest 'dataSource' block into reactive
{ data, loading, error }. Two forms supported: shorthand
{ register, schema, filter, aggregate: 'count' } that builds a
{ <slug>(filter:...) { totalCount } } query, and raw graphql
{ query, variables, selectors } for richer aggregates.

CnStatsBlockWidget is a thin wrapper around CnStatsBlock that
consumes useDataSource and forwards the resolved count. Mounted by
the type='stats-block' dispatcher in CnDashboardPage (next commit).
…idgets

CnDashboardPage gets a stats-block dispatcher branch between chart
and NC API. Mounts the new CnStatsBlockWidget (committed earlier)
which forwards a GraphQL-resolved count from widgetDef.dataSource
into CnStatsBlock.

CnChartWidget gains an optional dataSource prop. When set, series /
categories / labels resolve from the GraphQL response via the
selectors map; static props remain the fallback while the request
is pending or when no dataSource is configured.

Manifest schema's widgetDef gets a dataSource sub-schema with two
forms: shorthand { register, schema, filter, aggregate: 'count' }
and raw { graphql: { query, variables, selectors } }.

Public barrels re-export the new composables (useGraphQL,
useDataSource, selectByPath, buildCountQuery) and the new
component (CnStatsBlockWidget) so consumer apps can adopt the
manifest pattern without lib internals.

Tests: 16 new across useGraphQL.spec.js + useDataSource.spec.js;
full suite at 871/871 (one pre-existing leaflet-missing test
suite failure is unrelated). Docs coverage check green.
@rubenvdlinde rubenvdlinde merged commit e23cc30 into beta May 10, 2026
1 of 3 checks passed
@rubenvdlinde rubenvdlinde deleted the feat/dashboard-datasource-stats-block branch May 10, 2026 15:07
@github-actions
Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 1.0.0-beta.29 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant