Uh oh!
There was an error while loading. Please reload this page.
refactor(dataset-render): share measure formatting + header labels; fix binary-file NUL; register report.total - #1841
Merged
Conversation
…ix binary-file NUL; register report.total Follow-up cleanup to PR #1830. The dashboard `DatasetWidget` and the report `DatasetReportRenderer` had drifted into two copies of the same dataset-result formatting logic — which is exactly why the currency/label/i18n bug had to be fixed twice. This hoists the shared logic and removes a latent tooling hazard. core (@object-ui/core): - New utils/dataset-format.ts: `formatMeasure` (currency-aware), `formatDimensionValue`, `buildDatasetFieldHelpers` (field label → i18n fieldLabel → raw name), and the `DatasetResultField` type. Pure, no React/i18n (fieldLabel is injected). Unit-tested. i18n (@object-ui/i18n): - New `useSafeTranslate()` hook: per-call graceful `t(keyOrKeys, fallback)` with an ordered key-fallback chain — the inline pattern both renderers duplicated. - Register `report.total` in all 10 locale bundles (reusing each locale's existing dashboard total translation) so the report's "Total" is genuinely translatable, not just an English fallback. renderers: - `DatasetReportRenderer` and `DatasetWidget` now import the shared core/i18n helpers (net −235 lines of duplication). `PivotTable`'s two local graceful-translate helpers also fold into `useSafeTranslate`. - Fix the 2 literal NUL bytes in `DatasetReportRenderer` (the matrix bucket-key separator) that made the `.tsx` register as a BINARY file to grep/ripgrep/ editors — now a normal space (matching the dashboard's pivot separator). data-objectstack: - Widen `queryDataset`'s declared `fields` type to include `label`/`format`/ `currency` (it already ships them at runtime) so consumers stop re-declaring and casting. Tests: plugin-report 40 passed (+ positive i18n test: zh provider → 总计), plugin-dashboard 4031 passed, i18n 150 passed, core dataset-format 10 passed. type-check green across core/i18n/data-objectstack/plugin-report/plugin-dashboard. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
✅ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
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 freeto 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.
What & why
Follow-up cleanup to #1830. The dashboard
DatasetWidgetand the reportDatasetReportRendererhad drifted into two copies of the same dataset-result formatting logic — which is precisely why the currency/label/i18n bug had to be fixed in both. This hoists the shared logic, removes a latent tooling hazard, and makes the report's "Total" genuinely translatable.Changes
@object-ui/core— newutils/dataset-format.ts:formatMeasure(v, format?, currency?)— currency via the field's declaredcurrency(Intlsymbol), never a misleading$.formatDimensionValue(v),buildDatasetFieldHelpers(fields, object, fieldLabel?)(field label → i18nfieldLabel→ raw name), and theDatasetResultFieldtype.fieldLabelis injected). Unit-tested (10 cases).@object-ui/i18n:useSafeTranslate()— per-call gracefult(keyOrKeys, fallback)with an ordered key-fallback chain. This is the inline pattern both renderers (andPivotTable) duplicated.report.totalin all 10 locale bundles (reusing each locale's existingdashboard.totalvalue), so the report's "Total" is a real translation, not just an English fallback.Renderers:
DatasetReportRendererandDatasetWidgetnow import the shared core/i18n helpers (net −235 lines of duplication).PivotTable's two local graceful-translate helpers fold intouseSafeTranslate.DatasetReportRenderer(the matrix bucket-key separator) that made the.tsxregister as a binary file to grep/ripgrep/editors — now a normal space, matching the dashboard's pivot separator.@object-ui/data-objectstack:queryDataset's declaredfieldstype to includelabel/format/currency(already shipped at runtime) so consumers stop re-declaring + casting.Behavior
No user-facing behavior change intended — this is a refactor. The one observable improvement: the report's "Total" now picks up the mounted locale (e.g. zh → 总计) instead of only the English fallback.
Tests
plugin-report→ 40 passed (incl. a new positive i18n test: zh provider → 总计)plugin-dashboard→ 4031 passedi18n→ 150 passed;coredataset-format → 10 passedtype-checkgreen across core / i18n / data-objectstack / plugin-report / plugin-dashboard🤖 Generated with Claude Code