discourse/app
David Taylor fb9948c79c
DEV: Make capabilities available outside of application instance (#22516)
Browser capabilities are inherently unconnected to the lifecycle of our app. Making them formally available outside of the service means that they can safely be used in non-app-linked functions without needing risky hacks like `helperContext()` or `discourse-common/lib/get-owner`.

One example of where the old hacks were problematic is the `translateModKey()` utility function. This is called in the root of the `discourse/components/modal/keyboard-shortcuts-help` es6 module. If anything (e.g. a theme/plugin) caused that es6 module to be `require()`d before the application was booted, a fatal error would occur.

Following this commit, `translateModKey()` can safely import and access `capabilities` without needing to worry about the app lifecycle.

The only potential downside to this approach is that the capabilities data now persists across tests. If any tests need to 'stub' capabilities, they will need to revert their changes at the end of the test (e.g. by using Sinon to stub a property).

This commit also updates some legacy references from `capabilities:main` to `service:capabilities`.
2023-07-12 09:38:25 +01:00
..
assets DEV: Make capabilities available outside of application instance (#22516) 2023-07-12 09:38:25 +01:00
controllers DEV: Remove deprecated target_usernames param from PostsController#create (#22561) 2023-07-12 11:31:24 +08:00
helpers SECURITY: Don't reuse CSP nonce between requests (#22544) 2023-07-11 15:24:36 -06:00
jobs FEATURE: Warn about outdated translation overrides in admin dashboard (#22384) 2023-07-10 10:06:40 +08:00
mailers FIX: don't add "Re:" prefix in email subject for first post of group PMs. (#22175) 2023-06-19 18:52:00 +05:30
models SECURITY: limit amount of links in custom sidebar section (#22543) 2023-07-11 15:25:01 -06:00
serializers DEV: Try fix category form template flaky (#22461) 2023-07-06 14:42:59 +10:00
services FIX: post alerter notification when topic directly watched (#22433) 2023-07-06 11:27:23 +10:00
views SECURITY: Don't reuse CSP nonce between requests (#22544) 2023-07-11 15:24:36 -06:00