mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-17 15:42:24 +00:00
fix(dashboard): open the body fat page from the body fat tile
The body fat tile was the one strip tile that led nowhere. Its href map said there was no dedicated sub-page, which was true: body fat percentage was tiled and charted on the dashboard but never got the Insights page every body-composition sibling has. Add /insights/body-fat on the generic metric-page scaffold (body group, tab-strip pill, seven locales, manual-entry empty state) and link the tile to it. Move the tile href map out of the page into tile-destinations.ts, keyed by the tile-capable widget id and typed against the sub-page slug union, so a missing or non-existent destination fails to compile. The link passes the destination's insights-page surface gate, so it never points at a page a switched-off module hides. A guard derives the tile set from TILE_CAPABLE_WIDGET_IDS and from the ids the dashboard actually pushes into its strip, and fails when a tile's metric has a sub-page the tile does not open, when a destination has no route, or when a tile links to a page owned by another module. Tiles that deliberately lead nowhere need a written reason; there are none today. The reverse-lookup test pinned BODY_FAT as having no page; it now resolves to body-fat. Refs #1084
This commit is contained in:
1 parent
2ea9dc3936
commit
885efaafd9
17 files changed
+440
-48
No files matched your search
@@ -34,10 +34,12 @@ describe("type → insights sub-page slug", () => {
|
||||
expect(subPageSlugForType("ACTIVITY_STEPS")).toBe("steps");
|
||||
expect(subPageSlugForType("MOOD")).toBe("mood");
|
||||
expect(subPageSlugForType("BLOOD_GLUCOSE")).toBe("blood-glucose");
|
||||
// Body fat gained its own page so the dashboard tile has somewhere to go;
|
||||
// it used to fall back to the filtered measurements list.
|
||||
expect(subPageSlugForType("BODY_FAT")).toBe("body-fat");
|
||||
});
|
||||
|
||||
it("returns undefined for a type with no sub-page", () => {
|
||||
expect(subPageSlugForType("BODY_FAT")).toBeUndefined();
|
||||
expect(subPageSlugForType("RECOVERY_SCORE")).toBeUndefined();
|
||||
expect(subPageSlugForType("NOT_A_REAL_TYPE")).toBeUndefined();
|
||||
});
|
||||
|
||||
@@ -82,6 +82,9 @@ export type InsightMetric =
|
||||
| "BLOOD_GLUCOSE"
|
||||
| "TOTAL_BODY_WATER"
|
||||
| "BONE_MASS"
|
||||
// Body fat percentage, keyed on its MeasurementType like the rest of the
|
||||
// body-composition pages.
|
||||
| "BODY_FAT"
|
||||
| "FLIGHTS_CLIMBED"
|
||||
| "WALKING_RUNNING_DISTANCE"
|
||||
| "FAT_FREE_MASS"
|
||||
|
||||
@@ -66,6 +66,10 @@ const SUB_PAGE_METRIC = {
|
||||
weight: ["WEIGHT"],
|
||||
// BMI is derived from WEIGHT + profile height (no separate series).
|
||||
bmi: ["WEIGHT"],
|
||||
// Body fat percentage. The dashboard has tiled and charted it since the
|
||||
// first release, but it never had a page of its own, so its tile led
|
||||
// nowhere while every sibling below opened one.
|
||||
"body-fat": ["BODY_FAT"],
|
||||
// v1.7.0 — Withings / Apple body-composition tail.
|
||||
"body-water": ["TOTAL_BODY_WATER"],
|
||||
"bone-mass": ["BONE_MASS"],
|
||||
@@ -199,6 +203,7 @@ export const SUB_PAGE_GROUP: Partial<Record<SubPageSlug, SubPageGroup>> = {
|
||||
"respiratory-rate": "vitals",
|
||||
// body composition (v1.7.0)
|
||||
bmi: "body",
|
||||
"body-fat": "body",
|
||||
"body-water": "body",
|
||||
"bone-mass": "body",
|
||||
"fat-free-mass": "body",
|
||||
@@ -387,7 +392,7 @@ export const SUB_PAGE_MANAGER_GROUP_SLUGS: Record<
|
||||
* `WEIGHT`) the first in `SUB_PAGE_SLUGS` order wins (`weight`). A type that
|
||||
* only ever appears on a multi-metric page (the two blood-pressure
|
||||
* components, the two HRV flavours) falls back to that page. Types with no
|
||||
* sub-page at all (BODY_FAT, RECOVERY_SCORE, the `*_EVENT` series, most
|
||||
* sub-page at all (RECOVERY_SCORE, the `*_EVENT` series, most
|
||||
* device scores) are absent — the caller falls back to the filtered
|
||||
* measurements list.
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user