feat(frontend): user & organisation preferences UI (IFC-2720)
Why
Backend PR #9550 adds the StandardNode preferences model + the scope-parameterized InfrahubPreferences / InfrahubSetPreferences GraphQL API. This adds the UI: users manage their own timezone & date format, and holders of manage_global_preferences manage the organisation defaults.
Depends on #9550 — this PR is based on ple-user-preferences-backend; retarget to develop once the backend merges. Part of epic IFC-2718.
What changed
entities/preferences/data layer on the scope API:useEffectivePreferences()readsInfrahubPreferences(EFFECTIVE) as a keyed{ value, source }map (sourceuser/global/default, no user-vs-global comparison in the UI);useGlobalPreferences()readsInfrahubPreferences(scope: GLOBAL)for the org editor; both writes go throughInfrahubSetPreferences(scope, …).- Personal preferences — a "Preferences" card on the Profile tab, below the account details (via an
ObjectDetailsleftColumnExtraslot, so spacing matches the other cards). Object-details-style rows with icons, full-bleed separators. - Organisation defaults — its own tab, gated on
can_edit_global_preferences; edits the raw global scope. - "Automatic" option in both dropdowns (= inherit / no override; selecting it clears the override — replaces a reset button). A right-aligned (i) tooltip explains each value's source: your preference / organisation default / browser.
- Both dropdowns are the same shared
ComboboxFieldat equal width; date-format options are pattern-only with a live example beside the input;@date-fns/tzgroundwork for tz-aware formatting. - Browser fallback when neither user nor global is set.
Testing
Full frontend suite 864 passed; biome clean; betterer baseline unchanged; gql.tada types in sync. Deterministic browser-mode tests (fake clock + native-select helper).
Not included (follow-ups)
- PR3 / IFC-2721 — routing app-wide
DateDisplayrendering through the effective preferences (with browser-locale fallback). - PR4 / IFC-2737 — docs + changelog.
🤖 Generated with Claude Code
Summary by cubic
Adds user and organisation date/time preferences: a Preferences card on the Profile tab and a permission-gated Organisation defaults page. Implements IFC-2720 on a typed GraphQL API with a DateFormat enum, resolved value+source reads, and a reselect‑to‑clear UX with an “Automatic (inherited)” placeholder.
-
New Features
- Data:
useEffectivePreferences,useGlobalPreferences,useUpdateMyUserPreferences,useUpdateGlobalPreferencesvia@tanstack/react-query; reads useInfrahubEffectivePreferences/InfrahubGlobalPreferences; writes go throughInfrahubSetPreferences(scope)(USER/GLOBAL withDateFormat); global writes invalidate effective + global. - Permissions: gate
/profile/organisation-defaultsonmanage_global_preferencesviaInfrahubPermissions; stringified numeric decisions "2"/"4"/"6" grant andsuper_adminbypasses; providedRequireGlobalPermission,useGlobalPermission, anduseCanManageGlobalPreferences. - UI:
UserPreferencesCardon the Profile tab’s main column; Organisation defaults at/profile/organisation-defaults; sharedComboboxFieldandTimezoneFieldwith live inline example and reselect‑to‑clear; fixed‑width inputs with aligned (i) tooltips; “UTC” always present;DetailRowrows with full‑bleed separators; sharedDetailsColumnslayout.
- Data:
-
Bug Fixes
- Saves: disabled while pristine or pending; failed saves re‑throw so forms stay dirty; shared
Formswallows submit rejections. - Combobox: active item stays in sync with selection, highlights, and scrolls into view on open.
- Resilience: browser locale/timezone used when neither user nor org is set; unknown preference sources log a warning; user tab stays usable if the org defaults query fails.
- Permissions: fix global‑permission check to accept numeric granting decisions, restoring the Organisation defaults tab.
- Saves: disabled while pristine or pending; failed saves re‑throw so forms stay dirty; shared