From b7b3dd4c4d08777462299a13350ff7148361b496 Mon Sep 17 00:00:00 2001 From: Linus Rath <139418639+rathlinus@users.noreply.github.com> Date: Sat, 31 Oct 2026 15:22:15 +0100 Subject: [PATCH] feat: show the colour mode as set by the organisation when its policy locks it --- .../settings/AppearanceSettings.tsx | 5 ++++- .../__tests__/org-policy-settings.test.ts | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 src/components/settings/__tests__/org-policy-settings.test.ts diff --git a/src/components/settings/AppearanceSettings.tsx b/src/components/settings/AppearanceSettings.tsx index ed48a426..c08e9a82 100644 --- a/src/components/settings/AppearanceSettings.tsx +++ b/src/components/settings/AppearanceSettings.tsx @@ -7,6 +7,7 @@ import { useSettingsStore, type ThemeMode, type Density } from '../../stores/set import { useLocaleStore } from '../../stores/locale-store'; import { setPendingSettingsTab } from '../../navigation/pending-settings-tab'; import { densityPreviewConfig } from './density-preview'; +import { useSettingLocked } from '../../stores/policy-store'; type Theme = ThemeMode; @@ -81,6 +82,8 @@ export function AppearanceSettings() { const theme = useSettingsStore((s) => s.theme); const t = useLocaleStore((s) => s.t); const setTheme = useSettingsStore((s) => s.setTheme); + // The organisation's theme policy can pin the colour mode (#1280). + const themeLocked = useSettingLocked('theme'); const density = useSettingsStore((s) => s.density); const setDensity = useSettingsStore((s) => s.setDensity); const showToolbarLabels = useSettingsStore((s) => s.showToolbarLabels); @@ -99,7 +102,7 @@ export function AppearanceSettings() { title={t('settings.appearance.title', "Appearance")} description={t('settings.appearance.description_mobile', 'Customize how the app looks')} > - + setTheme(v as Theme)} diff --git a/src/components/settings/__tests__/org-policy-settings.test.ts b/src/components/settings/__tests__/org-policy-settings.test.ts new file mode 100644 index 00000000..353c9e79 --- /dev/null +++ b/src/components/settings/__tests__/org-policy-settings.test.ts @@ -0,0 +1,19 @@ +import { describe, expect, it } from 'vitest'; +import fs from 'node:fs'; +import path from 'node:path'; + +// Where the organisation policy reaches the settings pages. No React Native +// renderer in the test env, so this checks the wiring (as +// src/components/__tests__/org-policy-wiring.test.ts does); what the policy +// does to the settings is tested in org-policy.test.ts and policy-store.test.ts. + +const read = (rel: string) => fs.readFileSync(path.resolve(__dirname, '..', '..', '..', '..', rel), 'utf8'); +const settings = (name: string) => read(`src/components/settings/${name}.tsx`); + +describe('organisation policy on the settings pages', () => { + it('shows the colour mode as set by the organisation when its theme policy locks it', () => { + const page = settings('AppearanceSettings'); + expect(page).toContain("const themeLocked = useSettingLocked('theme');"); + expect(page).toMatch(/label=\{t\('settings\.appearance\.theme\.label', "Theme"\)\}[^>]*locked=\{themeLocked\}>/); + }); +});