2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-03-03 23:54:20 +08:00
discourse/app/controllers/admin
Régis Hanol 5f6e69f64f
UX: Display interpolation keys as interactive pills in admin editors (#37254)
When editing site texts or email templates, admins need to know which
interpolation keys are available and whether they're being used
correctly.
Previously there was no UI for this.

Show interpolation keys as clickable pill buttons below the editor:
- Unused keys are dimmed — clicking inserts %{key} at the last cursor
position
- Used keys are highlighted green to confirm they're present in the text
- Invalid keys (typos or unknown keys) appear in red as non-clickable
pills

Implementation:
- New `<AdminInterpolationKeys>` template-only component renders the
pills
- New `interpolationKeysWithStatus()` utility in admin/lib centralizes
the
logic for computing key statuses (used/unused/invalid) across both
editors
- Controllers track textarea focus and cursor position via private
fields
  (no @Tracked — these are only read imperatively on pill click)
- Uses document.execCommand("insertText") for native undo/redo support
- Fix duplicate keys in backend by using Array#| (set union) instead of
Array#+

<img width="1662" height="1355" alt="2026-02-26 @ 17 09 32"
src="https://github.com/user-attachments/assets/05497832-4e17-4eb2-b4c1-e9e0e036304a"
/>

<img width="1662" height="1355" alt="2026-02-26 @ 17 09 19"
src="https://github.com/user-attachments/assets/f13271ad-511e-4fa1-9bec-eb6fbc7a66d8"
/>


Ref - t/172375
2026-02-27 21:21:26 +01:00
..
config DEV: exclude hidden settings when auto updating logos (#38124) 2026-02-27 11:00:23 -08:00
admin_controller.rb DEV: Drop WithServiceHelper 2024-09-05 09:58:20 +02:00
admin_notices_controller.rb DEV: Update rubocop-discourse to 3.13 and autofix issues (#35073) 2025-10-06 16:11:01 +02:00
api_controller.rb DEV: Update rubocop-discourse to 3.13 and autofix issues (#35073) 2025-10-06 16:11:01 +02:00
backups_controller.rb DEV: Update rubocop-discourse to 3.13 and autofix issues (#35073) 2025-10-06 16:11:01 +02:00
badges_controller.rb FIX: ensures admin can't set system property on badges (#37820) 2026-02-16 12:33:32 +01:00
color_schemes_controller.rb FEATURE: Allow editing theme-owned palettes (#34722) 2025-10-06 09:02:39 +03:00
dashboard_controller.rb FEATURE: Upcoming changes part 1 (#34617) 2025-10-30 10:46:14 +10:00
email_controller.rb FIX: disable smtp_should_reject code 2025-11-25 10:34:35 -05:00
email_logs_controller.rb DEV: Update rubocop-discourse to 3.13 and autofix issues (#35073) 2025-10-06 16:11:01 +02:00
email_styles_controller.rb
email_templates_controller.rb FEATURE: Add background job and ability to delete posts from suspend user modal (#36813) 2026-01-07 10:25:01 -06:00
embeddable_hosts_controller.rb DEV: Expand top_tags, topic.tags, etc, to return an array of tag objects instead of tag names (#36678) 2026-02-02 10:03:02 +08:00
embedding_controller.rb UX: admins embedding page follows admin ux guideline (#30122) 2025-01-06 13:01:08 +11:00
emoji_controller.rb DEV: Move admin config pages out of /customize/ sub-route (#30511) 2025-01-02 09:13:11 +10:00
form_templates_controller.rb DEV: Rename experimental_ upcoming change settings (#37589) 2026-02-10 10:34:37 +10:00
groups_controller.rb FIX: Logging hole in group user histories and convert group create to service (#37054) 2026-02-06 13:34:58 +10:00
impersonate_controller.rb FIX: Stop impersonation session not working with group-based upcoming change (#37655) 2026-02-10 16:24:31 +10:00
permalinks_controller.rb FIX: Permalink.create didn't work as expected anymore (#29895) 2024-11-22 21:11:26 +01:00
plugins_controller.rb FIX: Don't allow access to plugin page if plugin is not visible (#26431) 2024-04-02 16:26:15 +03:00
reports_controller.rb FIX: bulk action missing report_type format validation (#37787) 2026-02-13 09:08:48 +01:00
robots_txt_controller.rb FIX: Log changes to robots.txt by admins (#37901) 2026-02-18 14:20:21 -05:00
screened_emails_controller.rb SECURITY: Moderators cannot see user emails. 2024-12-19 13:13:18 -03:00
screened_ip_addresses_controller.rb DEV: minor api cleanup, unhandled args (#37795) 2026-02-13 17:44:10 +11:00
screened_urls_controller.rb
search_controller.rb FEATURE: Add admin-only reports and centralize report visibility logic 2026-01-28 17:11:14 +00:00
search_logs_controller.rb
section_controller.rb DEV: Add a skeleton for section landing page & items (#28477) 2024-10-02 12:19:38 +10:00
site_settings_controller.rb FEATURE: onboarding banner for admins (#37583) 2026-02-10 14:53:44 -03:00
site_texts_controller.rb UX: Display interpolation keys as interactive pills in admin editors (#37254) 2026-02-27 21:21:26 +01:00
staff_action_logs_controller.rb DEV: Add comparison budget to ONPDiff (#38063) 2026-02-25 14:25:03 -05:00
staff_controller.rb DEV: Drop WithServiceHelper 2024-09-05 09:58:20 +02:00
themes_controller.rb FIX: Eager load base_scheme color_scheme_colors in themes controller (#37550) 2026-02-05 13:17:56 +03:00
unknown_reviewables_controller.rb FEATURE: Gracefully handle unhandled reviewables (#31118) 2025-02-05 14:38:45 +11:00
user_fields_controller.rb FEATURE: Allow hiding user fields on signup form (#34672) 2025-09-15 10:42:07 +08:00
users_controller.rb FEATURE: Add background job and ability to delete posts from suspend user modal (#36813) 2026-01-07 10:25:01 -06:00
versions_controller.rb
watched_words_controller.rb DEV: Refactor watched words to use tracked properties and filtered model (#36010) 2025-11-13 19:56:52 -03:00
web_hooks_controller.rb FIX: Allow selecting tags when creating or editing webhooks (#37942) 2026-02-20 23:00:50 +08:00