Commit Graph

10637 Commits

Author SHA1 Message Date
ba7311d807 DEV: remove fa remapping logic (#32478)
Follow up to https://github.com/discourse/discourse/pull/31866, we are
removing the FA name mappings from the codebase. Timeline is mentioned
in Meta topic
https://meta.discourse.org/t/were-upgrading-our-icons-to-font-awesome-6/325349:

> Start May 2025 - removal of old icon names mapping and error level
logging

We'll be merging this in on the 2nd May.

---------

Co-authored-by: Ted Johansson <ted@discourse.org>
2025-05-02 10:20:21 +08:00
4d0a817f40 DEV: Compile 'common' CSS into own assets (#31416)
Previously we were compiling core and theme CSS into two targets:
Desktop and Mobile. The majority of both files was the 'common' css.
This commit splits those common styles into their own targets so that
there is less duplication. This should improve compilation times + cache
reuse, as well as opening the door for experiments with
media-query-based mobile-modes.

The only functional change is that we can no longer use `@extend` to
copy 'common' rules in core to mobile/desktop. This is probably for the
best. Duplication and/or mixins are a more native-css pattern for this.

Plugins already have a common / mobile / desktop pattern, so are
unchanged by this commit.
2025-05-01 10:44:49 +01:00
edbd5e08f9 DEV: Refactor StartReply & StopReply services a bit
- Move some data transforming into contracts.
- Add some missing specs.
- Use the `try` step.
- Improve the `model` step a bit by allowing to catch any exception,
  and not only `ArgumentError`. We already had the mechanism to inspect
  which exception was caught.
2025-04-30 11:50:22 +02:00
e7450cc6da DEV: Migrate from sprockets to propshaft for assets (#32475)
We are no longer using any of the transpilation/bundling features of
Sprockets. We only use it to serve assets in development, and then
collect & fingerprint them in production. This commit switches us to use
the more modern "Propshaft" gem for that functionality.

Propshaft is much simpler than Sprockets. Instead of taking a
combination of paths + "precompile" list, Propshaft simply assumes all
files in the configured directory are required in production. Previously
we had some base paths configured quite high in the directory structure,
and then only precompiled selected assets within the directory. That's
no longer possible, so this commit refactors those places (mostly
plugin-related) to use dedicated directories under
`app/assets/generated/`.

Another difference is that Propshaft applies asset digests in
development as well as production. This is great for caching & dev/prod
consistency, but does mean some small changes were required in tests.

We previously had some freedom-patches applied to Sprockets. Some of
those had to be ported across to Propshaft. We now have three patches:

1. Skip adding digest hashes to webpack-generated chunks (which are
already digested, and referred to from other js files)

2. Avoid raising errors for missing assets in test mode. We don't always
compile assets before running basic RSpec tests.

3. Maintain relative paths for sourcemap URLs, so that files don't need
to be recompiled depending on their CDN path

Significant refactors are made to the `assets.rake` and `s3.rake` tasks,
which rely on implementation details of Sprockets/Propshaft.
2025-04-30 08:59:32 +01:00
cde16697cd Bump version to v3.5.0.beta4-dev 2025-04-29 12:26:54 +08:00
bb5d5b9f83 Bump version to v3.5.0.beta3 2025-04-29 12:26:54 +08:00
63037fb7ad FIX: allow tags to be restricted to admin only (#32493)
Allow creating a tag group with tags that are visible to everyone but
can be used by admin only.
2025-04-29 09:09:57 +05:30
c89245beff FIX: Production asset compilation following c62a4a47 (#32491)
The bypass_sprockets_uglify was removed in that commit
2025-04-28 15:04:56 +01:00
c62a4a4759 PERF: Compile main locale bundles just-in-time (#32335)
Previously all locale bundles would be built & compressed during
assets:precompile. For most sites, only one of these languages was
actually used, so this is fairly wasteful.

This commit moves the main locale bundle into the
ExtraLocalesController, which has recently undergone many improvements
to make it more efficient. This allows locale files to be bundled "just
in time" when they're first accessed.

Now that brotli level=6 is enabled for these assets in our nginx config,
this change should have no impact on the locale bundle size.
2025-04-28 10:31:27 +01:00
84c8f51c54 DEV: Account for relative url root in Stylesheet::Manager cache keys (#32487)
This is mainly used for the test environment where
`Discourse.current_hostname` and `GlobalSetting.relative_url_root` can
be stubbed.

### Reviewer notes

We don't really need a test here since this doesn't really affect the
production environment.
2025-04-28 15:50:01 +08:00
3146142c2e DEV: Create topic and post localization resources (#32440)
This commit adds

- `topic_localization` containing its topic, a locale, title, and
fancy_title
- `post_localization` containing its post, a locale, raw, cooked, the
associated post's version
- and also APIs to add them

Reviewer note: We may ask ourselves "why create separate models instead
of one that is generic?" but the different localizable models may be
vastly different. For example in posts we only have raw that we need to
translate, and topics we have only title, but for categories we have
name and description. Then, we may ask ourselves "why not create a
polymorphic one that takes in model and column name?" and then we end up
with the same thing as what we have currently which is custom fields
(which is a mess in itself). Also, when replacing the untranslated
content to the translated one, we may find it easier to just `join` +
`coalesce` on the dedicated table - it would be a much simpler query
than polymorphism.
2025-04-28 12:16:14 +08:00
fbc2cfb618 DEV: Refactor moment.js loading (#32337)
- Load moment and moment-timezone-with-data via webpack import instead
of including copies in every locale file

- Fetch static files from node_modules instead of `vendor/`

This cuts the size of locale-specific JS files in half, since they no
longer include moment itself.
2025-04-26 13:52:07 +01:00
2dfafe3fd2 DEV: Report runtime duration of each parallel test process (#32457)
This information is generally useful to know and it simple for us to
instrument.
2025-04-25 15:23:53 +08:00
588caa60b9 UX: Add missing discourse-table SVG icon (#32447)
Meta:
https://meta.discourse.org/t/icon-missing-in-admin-panel-after-updating-discourse-today/363295

The `discourse-table` icon usage was introduced in
464726d973.
However, the SVG doesn't exist in core, but instead in the [AI
plugin](https://github.com/discourse/discourse-ai/blob/main/svg-icons/icons-sprite.svg?short_path=9d0511c).

The PR adds this SVG icon to the core.
2025-04-24 13:45:24 -04:00
25938208ff FIX: recalculate respects default invitee trust level (#32393)
Currently, trust level is calculated with this formula:
`[granted_trust_level, previous_trust_level,
SiteSetting.default_trust_level].max`

When a user is invited, SiteSetting.default_invitee_trust_level should
be respected in that calculation.
2025-04-23 09:49:44 +08:00
0252712008 DEV: Add --exclude-pattern to bin/turbo_rspec (#32390)
This commit adds a new `--exclude-pattern` CLI option which supports
excluding files using unix style pattern matching.

This is to simplify a couple of situations:

1. Running `bin/turbo_rspec plugin/spec` but we want to exclude all
   tests in the `plugin/spec/system` folder.

   Example: `bin/turbo_rspec --exclude-pattern="*spec/system*"
plugin/spec`

2. Running `bin/turbo_rspec plugin/*/spec/system` but we want to exclude
   tests for a particular plugin.

   Example: `bin/turbo_rspec --exclude-pattern="plugins/chat/*"
plugin/*/spec/system`
2025-04-22 11:34:48 +08:00
72f9714ddc FEATURE: Implement tag group selection in dropdown and multi-select for topic creation and preview when using Form Templates (#32108)
Adds support for a tag-chooser in form templates. It supports single tag
and multi tags. The source of the displayed tags has to be a tag_group
name.

---------

Co-authored-by: Joffrey JAFFEUX <j.jaffeux@gmail.com>
2025-04-17 08:38:03 -05:00
918aa0fbec DEV: Add :sidekiq_job_error DiscourseEvent (#32307)
This commit adds a `:sidekiq_job_error` event which is
triggered when an error is encountered while running a Sidekiq job. The
intent of this change is to complement the `:sidekq_job_ran` event which
can be used with the `:sidekiq_job_error` event to calculate the error
rate for each job.
2025-04-17 15:41:58 +08:00
a69a304f11 FEATURE: allow edit custom flags (#32344)
Allow admins to edit user custom flags. Because changing
name/description will update name/description for old reviewables,
warning has to be displayed.

Still, system flags can never be edited or deleted (only disabled).
2025-04-17 12:31:52 +08:00
3d689bbbc2 DEV: Raise exception for deprecations in core stylesheets (#31894) 2025-04-16 16:36:41 +01:00
f3d3c61754 PERF: Reuse existing core JS build where possible (#32311)
Building the Discourse JS app is very resource-intensive. This commit
introduces an `assemble_ember_build` script which will check the
existing content of the `dist/` directory and re-use the core build if
possible. Plugins will always be rebuilt.

For now, this functionality is only useful for multi-stage (i.e.
non-standard) Discourse deployments. But in future, this script may be
extended to pull the contents of the `dist/` directory from a remote
location.
2025-04-15 16:18:22 +01:00
fc6aaa3e49 DEV: Wizard step tweaks (#32304)
This makes two tweaks to the setup wizard:

1. Move the branding (site logo) step to after styling (look & feel).
2. Remove the corporate (your organization) step.
2025-04-15 13:53:01 +08:00
d1ce861a6b DEV: Add usage example for anon cache cookie registration (#32283)
Adding an example for the plugin api `register_anonymous_cache_key`.
2025-04-14 21:03:05 +08:00
f0057c7353 DEV: Drop legacy topic-list and raw-handlebars compilation system (#32081) 2025-04-14 10:42:40 +01:00
d416b64af0 FIX: Move CORE_SVG_SPRITES constant to a method (#32261)
Changing the `CORE_SVG_SPRITES` constant to a method enables us to
detect SVG files that are written to the vendor directory during plugin
initialization (as done by the [FontAwesome pro
plugin](79a8d39fb4/plugin.rb (L31)))
which happens after all the ruby classes/files are read and loaded into
memory.

Internal topic: t/151476.
2025-04-11 06:25:04 +03:00
Sam
da088a24c3 FEATURE: allow searching for whispers and bots (#32252)
Add new advanced search filters for post types

- `in:bot` or `in:bots`: Filters for posts made by bot users (user_id <
0)
- `in:human` or `in:humans`: Filters for posts made by human users
(user_id >= 0)
- `in:whisper` or `in:whispers`: Filters for whisper posts (respects
permissions)
- `in:regular`: Filters for regular posts only
2025-04-10 16:21:46 +10:00
5e9a1a64c7 DEV: Fix the error message from the deprecated icon handler
The string was written as a JS one (using ``), but in Ruby this syntax
tries to execute the string as a command on the host system.
2025-04-09 12:18:14 +02:00
ad0966afa9 FEATURE: Introduce new components listing page (#32164)
Follow-up to https://github.com/discourse/discourse/pull/31887

This commit introduces a new design for the components listing page, which
is not linked from anywhere in the UI at the moment, but it can be
accessed by heading to the `/admin/config/customize/components` path
directly. We'll make this new design available from the sidebar and
remove the old page once we've tested and validated the new design
internally.

Internal topic: t/146007.

---------

Co-authored-by: Ella <ella.estigoy@gmail.com>
2025-04-08 17:58:29 +03:00
ec0b6affd7 DEV: Add Site admin admin config page (#32196)
This PR adds a dedicated admin config page for Site admin related site settings.
2025-04-08 09:52:42 +08:00
5f0b186061 DEV: Add User defaults admin config page (#32195)
This PR adds a dedicated admin config page for User defaults related site settings.
2025-04-08 09:21:54 +08:00
928f9175f0 FEATURE: fonts section for branding page (#32031)
New configure fonts section was added. Because now we have two sections
completed (logos and fonts), new /branding page was introduced and old
/logo and /font pages was removed.

When text size is changed, modal is displayed to ask if preferences of
existing users should be retrospectively updated.



https://github.com/user-attachments/assets/f6b0c92a-117f-4064-bd76-30fa05acc6d3

---------

Co-authored-by: Ella <ella.estigoy@gmail.com>
Co-authored-by: Alan Guo Xiang Tan <gxtan1990@gmail.com>
2025-04-07 10:28:42 +08:00
ae2bc240af PERF: Set JOBS=1 for low-memory build environments (#32171)
Recent testing has shown that this config requires significantly less
memory for a successful build, which should improve the situation for
people running Discourse on low-memory servers.

Co-authored-by: Alan Guo Xiang Tan <gxtan1990@gmail.com>
2025-04-04 13:48:19 +01:00
0f0a59d7ff DEV: Move admin only constants into admin bundle (#32141)
Minor optimization so that we don't load extra data for non-admin users.
2025-04-03 14:28:36 +08:00
116a72504b UX: rename Twitter login button to X (#32123)
Before:

<img width="234" alt="Screenshot 2025-04-02 at 1 15 25 PM"
src="https://github.com/user-attachments/assets/1f852543-38d7-45d3-96d3-df6a8a7e3623"
/>

After:

<img width="184" alt="Screenshot 2025-04-02 at 1 20 41 PM"
src="https://github.com/user-attachments/assets/6bf9428f-2152-45a1-8215-ae006ce4f356"
/>
2025-04-02 15:35:59 +05:30
Sam
c0cf898c10 FEATURE: when rich-editor is enabled use Jetbrains Mono as code font (#32122)
This change forces consistency around code font in Discourse once the
new
rich-editor is enabled

- This means all code blocks in Discourse will render with this font
- Additionally the markdown mode composer will render with this font

Additionally we make 3 small adjustments:

1. We disable ligatures which conflict with typographer
2. We add support for custom ligature settings
3. We adjust down font size, cause 14px ends up matching visually with a
16px non monospace font, this change is already in place previously on
posts

Example:


![image](https://github.com/user-attachments/assets/eca0b544-f3a4-4172-b2af-b39a3c0208e7)
2025-04-02 16:36:52 +11:00
2a26555a7a DEV: Allow specifying a condition when preloading topics for topic list (#32101)
Currently when using `register_topic_preloader_associations`, we are
not able to specify a condition that is evaluated at runtime.

This commit allows specifying a condition and also keeps backward
compatibility.

```
   register_topic_preloader_associations(:linked_topic) { true }
   register_topic_preloader_associations({
     first_post: [uploads]
   })
```
2025-04-01 16:50:16 +08:00
b37591632d FIX: Update tag topic counts when bulk removing tags (#32095)
When bulk removing tags, the tag topic count isn't updated. You have to wait for the daily "ensure consistency" job to run for it to update properly. This is causing downstream problems, like the inability to use the "remove unused tags" feature.

The counter updating is handled on destroy by the join table model TopicTag. But we are calling #delete_all to perform the bulk tag removal, which bypasses callbacks.

This changes from #delete_all to #destroy_all, which invokes callbacks and updates the counters.
2025-04-01 11:46:07 +08:00
b8dcabc2ac DEV: Add env var to silence SASS deprecation warnings (#32074)
SASS deprecation warnings are quite noisy, especially when
running specs, here is an example:

```
Deprecation Warning [mixed-decls]: Sass's behavior for declarations that appear after nested
rules will be changing to match the behavior specified by CSS in an upcoming
version. To keep the existing behavior, move the declaration above the nested
rule. To opt into the new behavior, wrap the declaration in `& {}`.

More info: https://sass-lang.com/d/mixed-decls

    ╷
52  │ ┌     @media screen and (max-width: 1048px) {
53  │ │       right: 0;
54  │ │     }
    │ └─── nested rule
... │
56  │       background: var(--secondary);
    │       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ declaration
    ╵
    theme-entrypoint/desktop.scss 56:5         @import
    /home/mb/repos/discourse/desktop.scss 3:9  root stylesheet
Deprecation Warning [mixed-decls]: Sass's behavior for declarations that appear after nested
rules will be changing to match the behavior specified by CSS in an upcoming
version. To keep the existing behavior, move the declaration above the nested
rule. To opt into the new behavior, wrap the declaration in `& {}`.
```

This commit adds an env var (`QUIET_SASS_DEPRECATIONS`) to control
turning them off.
2025-04-01 13:11:33 +10:00
1c1d687283 DEV: show no icon if icon name is missing and log at error level (#31866)
On 1st April 2025, we start showing no icons if the icon name used is a
deprecated one and therefore no longer part of the svg set.

We'll continue showing the messages with the correct icon name to aid
correction of these names.

Console logging will now be done at an error level for such icons.

We retain the behaviour of raising an error for such icons in plugins
from svg_sprite.rb in test environments, but removed this from
icon-library.js as it's harder to test the actual expected behaviour of
returning the original icon now that it's not part of the deprecation
workflow. (sinon.stub doesn't work well here for `isTesting` - the
alternative would be to override the environment.js module with
`proxyquire`) In any case, once we remove the mapping logic, we won't be
raising errors in test environment either for this scenario.
2025-04-01 10:54:48 +08:00
377a6554b9 FIX: create UserHistory only when setting changed (#32075)
Do not create UserHistory when new value is same as the old one. It is
even more important now, when we have bulk save option.
2025-04-01 09:56:33 +08:00
b21c3e86f7 Revert "DEV: Allow specifying a condition when preloading topics for … (#32092)
…topic list (#32079)"

This reverts commit 70887351d7962947184e8351fea5745ee2b3a974.

This was causing errors:

```
NoMethodError (undefined method `call' for nil)
app/models/topic_list.rb:144:in `block in load_topics'
app/models/topic_list.rb:141:in `each'
app/models/topic_list.rb:141:in `load_topics'
app/models/topic_list.rb:75:in `topics'
app/serializers/suggested_topics_mixin.rb:15:in `include_suggested_topics?'
```
2025-04-01 09:37:47 +11:00
119295f687 DEV: Preserve ids/classes in emails (#32084)
These aren't technically needed in the output, since we inline all
styles. However, there's no harm in including them, and having them
visible will improve the developer experience when restyling emails.
2025-03-31 20:58:45 +01:00
70887351d7 DEV: Allow specifying a condition when preloading topics for topic list (#32079)
Currently when using `register_topic_preloader_associations`, we are not
able to specify a condition that is evaluated at runtime.

This commit allows specifying a condition and also keeps backward
compatibility.

```
   register_topic_preloader_associations({
     association: :linked_topic, condition: ->(topic) { topic.custom_field.present? }
   })
```
2025-03-31 21:32:05 +08:00
b4cdc39e51 FEATURE: Allow rejected user details to be scrubbed (#31987)
When a site has the `must_approve_users` setting enabled, new user data is stored on the Reviewable model, including username, email, and any other data that is entered during signup. If the user is rejected, that data is retained, without a clear path to deleting it.

In order to allow data that could be PII to be removed, without breaking Discourse's audit and logging trails, this change scrubs the PII from the relevant `ReviewableUser` and `UserHistory` objects, replacing that data with who scrubbed it, and why.
2025-03-31 12:40:35 +11:00
3f353a726b FIX: Prioritize !important CSS in emails (#32061)
7d587937 introduced css property deduplication in emails to workaround
bugs in some email clients. However, this didn't account for
admin-supplied customizations which were overriding core rules using
`!important`. This commit ensures that the deduplicator will always
prioritise `!important` rules, just like a browser.
2025-03-28 16:24:03 +00:00
387dc8c255 DEV: Drop 'cache_onebox_response_body' feature (#32035)
This is a hidden site setting which has never been publicized, and is
not recommended for use. If we decide to add a feature like this in
future as a visible site setting, it would need many more safeguards to
prevent misuse.
2025-03-28 10:55:29 +00:00
b40cbfcb76 DEV: Move backfill into SiteSetting::Update service (#32037)
Some site settings support backfilling if the user specified it. This works fine for singular site settings sent to the SiteSettingsController#update endpoint, but with bulk save we need to support this for a list of settings as well.

This change alters the params format for SiteSetting::Update.

It also moves the backfill logic into the service.
2025-03-28 12:01:56 +08:00
f1a67ecb37 DEV: Improvements to plugin API docs (#31988)
Follow-up to af03873d37decf8dba4278fc38bfcde7747a79f4
2025-03-28 09:59:25 +08:00
29cbbd6b31 DEV: Fix Lint/ShadowingOuterLocalVariable (#32036)
unblocks a rubocop update
2025-03-27 13:50:24 +01:00
042c480049 FIX: Do not @import .css assets for plugins (#32014)
b1924c35 switched our compiler to use `@import` internally for scss
entrypoints. This logic also applied to `.css` files, but unfortunately
sass doesn't do anything with `@import` of CSS files, so they'll be left
intact all the way to the browser. Continue using the old concatenation
approach for them in the compiler.

Followup to b1924c352487ab2c85ae50af45c5b3e098589014
2025-03-26 11:01:24 +00:00