fix(settings): expose UI rendering fields without requiring SETTINGS_READ (#1293)

The Clear Plate button (and 4 other features on the Printers page) read
  their state from /settings, which requires SETTINGS_READ. Granting that
  permission also adds the Settings nav item and leaks SMTP/LDAP/MQTT
  credentials — exactly what users were trying to avoid by giving an
  operator only printers:clear_plate.

  New /settings/ui-preferences endpoint returns a curated, opt-in subset
  of non-sensitive fields. Matches the existing /default-sidebar-order
  precedent. PrintersPage switched to the new endpoint; admin pages still
  use /settings for full access.
This commit is contained in:
maziggy
2026-05-12 16:30:28 +02:00
parent 5fea138f5d
commit 8a6fcf5cbd
8 changed files with 205 additions and 6 deletions
+18
View File
@@ -3990,6 +3990,24 @@ export const api = {
// Settings
getSettings: () => request<AppSettings>('/settings/'),
getDefaultSidebarOrder: () => request<{ default_sidebar_order: string }>('/settings/default-sidebar-order'),
// Public subset of settings for UI rendering — no settings:read required.
// Used by pages whose users may not have SETTINGS_READ (e.g. operators with
// only printers:clear_plate). Keep in sync with _UI_PREFERENCE_FIELDS in
// backend/app/api/routes/settings.py.
getUiPreferences: () =>
request<{
require_plate_clear?: boolean;
check_printer_firmware?: boolean;
camera_view_mode?: 'window' | 'embedded';
time_format?: 'system' | '12h' | '24h';
date_format?: string;
drying_presets?: string;
ams_humidity_good?: number;
ams_humidity_fair?: number;
ams_temp_good?: number;
ams_temp_fair?: number;
bed_cooled_threshold?: number;
}>('/settings/ui-preferences'),
updateSettings: (data: AppSettingsUpdate) =>
request<AppSettings>('/settings/', {
method: 'PUT',