feat(dashboard): manifest-driven dataSource for stats-block + chart widgets#186
Merged
Merged
Conversation
… 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.
Contributor
|
🎉 This PR is included in version 1.0.0-beta.29 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
useGraphQL+useDataSource— thin reactive wrappers aroundaxios.postagainst OpenRegister's GraphQL endpoint, with a tiny dot-path selector helper (selectByPath) for the manifest selectors map.CnStatsBlockWidget— wrapsCnStatsBlock; readswidgetDef.dataSource; forwards the resolved count.CnDashboardPagedispatcher gains atype: 'stats-block'branch between the chart and NC-API branches.CnChartWidgetaccepts an optionaldataSourceprop; staticseries/categories/labelsprops become the fallback while the GraphQL request is pending.widgetDef.dataSourceaccepts 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
dataSourceblock is documented via the schema and consumed by bothstats-blockandchartwidgets, 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.useGraphQL.spec.js+useDataSource.spec.jscover dot-path selectors,[]flat-maps, GraphQLerrors[], transport errors, the shorthand → totalCount path, and the raw selectors path.Related
groupBy+aggregateon Connection types so chart widgets can drive themselves from one query.