12880 Commits

Author SHA1 Message Date
Alan Guo Xiang Tan
2ec0bf32da
DEV: Fix broken request/qunit_controller_spec.rb (#32376)
This test file fails locally if `tmp/theme-transpiler.js` does not
exists.
Since the test file stubs the production env, we have to ensure that
`DiscourseJsProcessor::Transpiler.build_production_theme_transpiler` is
run first to mirror the production environment where the theme
transpiler file is built as part of assets precompilation.

### Review notes:

Example failure:
https://github.com/discourse/discourse/actions/runs/14529161497/job/40766003075

To repro locally, run the following steps: 

1. In your Discourse directory, run `rm -rf tmp`
2. `rspec spec/requests/qunit_controller_spec.rb`
2025-04-21 13:46:25 +08:00
David Battersby
e47b0996ed
FIX: enable drafts dropdown on private categories (#32370)
Reinstates the draft dropdown on private category pages.
2025-04-18 17:38:35 +04:00
Martin Brennan
6c4e9dfbc8
DEV: Try fix composer rich text transcript spec (#32364)
This is to try fix this error by sending the keys
on the element itself:

```
Failure/Error: page.send_keys([PLATFORM_KEY_MODIFIER, "v"])

Selenium::WebDriver::Error::StaleElementReferenceError:
  stale element reference: stale element not found in the current frame
    (Session info: chrome=135.0.7049.84); For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#stale-element-reference-exception
```
2025-04-18 15:52:35 +10:00
Renato Atilio
9b5ada304f
UX: avoid auto-linking clash with code marks on rich editor (#32365)
Avoid auto-linking URLs within code marks

Avoid auto-linking URLs when there's a `` ` `` just before the matched
URL, assuming the user is about to type a closing `` ` `` to create a
code mark instead.
2025-04-18 01:11:59 -03:00
Mark VanLandingham
1c8646b48e
DEV: Refactor forcing admin sidebar logic in hamburger nav mode (#32257)
This PR allows for other code to force the sidebar, but making the
language not admin-specific. There is a general problem to solve of "how
can I force the sidebar to appear, while keeping the hamburger menu in
the header as-is". This problem is solved for admin interface, but the
variable naming made it seem like the logic was directly tied to the
admin UI.

It is easy with this change, to have another sidebar manager force the
sidebar to be open for a route. Technically it was easy before, but it
would look like you were doing awful hacks.

---------

Co-authored-by: Isaac Janzen <isaac.janzen@discourse.org>
2025-04-17 22:36:38 -05:00
Renato Atilio
2b4521d0b3
FIX: pasting img on rich editor could be double-processed (#32356)
Without the `useCapture` as `true` on this `ComposerUpload`'s
`addEventListener`, if the clipboard contained both a Files array and a
`text/html` item, the paste event would be captured by ProseMirror
before being captured by the `ComposerUpload` setup and its
`preventDefault` call.
2025-04-18 00:20:44 -03:00
Renato Atilio
4c26679b2d
DEV: fix form template flaky (#32360) 2025-04-17 19:54:38 -03:00
Renato Atilio
cd805d0d8f
DEV: Revert "FIX: Flaky test for FormTemplatesController (#32351)" (#32359)
This reverts commit 4cd7ca677f69a18ab680c4b0ecac4a0d583d533b.
2025-04-17 18:39:26 -03:00
Juan David Martínez Cubillos
4cd7ca677f
FIX: Flaky test for FormTemplatesController (#32351) 2025-04-17 10:23:58 -05:00
Juan David Martínez Cubillos
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
Alan Guo Xiang Tan
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
Krzysztof Kotlarek
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
Alan Guo Xiang Tan
f6eb2e083c
DEV: Resolve flaky test due to regexp match (#32343)
The test being fixed in this commit was flaking with the following
error:

```
Capybara::Ambiguous:
  Ambiguous match, found 2 elements matching visible css ".stream-topic-title .title a[href*='/2']"
```

The regexp match on the `href` attribute has the potential to match
multiple elements if both urls contain the `/#{topic.id}` substring. For
example, both `/t/-/2/2` and `/t/-/1/2` will satisfy the regexp.
2025-04-17 09:32:22 +08:00
Chris Alberti
b724181bdf
DEV: Update verbiage around remove password modal, swap button for a link (#32338)
Simplified the language around remove password to be more clear, swapped out the button for a link.
2025-04-16 14:37:54 -05:00
Gary Pendergast
9b351614ea
FIX: Set X-Robots-Tag header to prevent indexing of /safe-mode (#32329)
This change adds the `X-Robots-Tag` header to the `/safe-mode` response, discouraging search engines from including the page in their index.
2025-04-16 16:51:32 +10:00
Martin Brennan
8ccb66a44a
FEATURE: Release admin search for all sites (#32327)
This commit removes the experimental setting controlling
admin search and releases it for all admins. This search
can be triggered with Ctrl+/ or Cmd+/

For more information see
https://meta.discourse.org/t/introducing-comprehensive-admin-search/360157
2025-04-16 16:26:53 +10:00
Juan David Martínez Cubillos
c7d400eda2
FEATURE: Implement Form Template Preview (#32111)
![imagen](https://github.com/user-attachments/assets/db5cf334-6e92-40b6-b93a-5cfa12882e8f)
2025-04-15 23:52:02 -05:00
Gabriel Grubba
09747898d1
FIX: Fix meta data content modifier state leak (#32316)
It was using `<<` that caused the SiteSetting to get modified

Updated the spec to use the same pattern as other modifiers and used
`next` to return the correct value of the modifer
2025-04-15 14:32:35 -03:00
David Taylor
3af7410264
DEV: Skip meta_data_content specs (#32315)
State seems to be leaking into other specs. Minimal repro:

```
bin/rspec --order defined spec/helpers/application_helper_spec.rb:783 spec/lib/wizard/wizard_builder_spec.rb:38
```

```
Failures:

  1) Wizard::Builder introduction should not prefill default site setting values
     Failure/Error: expect(description_field.value).to eq("")

       expected: ""
            got: " - modified by plugin"
```
2025-04-15 17:02:17 +01:00
Chris Alberti
375a36e2ef
Don't require password to create users with previous authentication (#32201)
Don't require password to create users with previous authentication in
the session, regardless of email/email verification during user creation

Before my changes we were calling `user.password_required!` in
`UserAuthenticator.authenticated?` based on whether authentication
session data contained a matching email address and email verified
externally. I believe `authenticated?` is intended for our own email
validation during the activation process, but shouldn't be a gate for
password requirement.

Even when we were setting `user.password_required`, then during user
creation we were creating random passwords to get around the blank
password restriction when creating accounts with external auth.

After my change we can remove the random password creation because we no
longer require a password when the session has previous authentication
info at all.

Looks like this extra password requirement may have been introduced as a
side effect during a previous refactor of `UserController` here:
51eff92170
Before that change, password requirement was simply based on whether
session[:authentication] existed, but after that change it was based on
the email/email_valid fields as well.
2025-04-15 10:35:49 -05:00
Natalie Tay
02c5dd439b
DEV: Add a post_owner_changed event (#32312)
This allows plugins to hook onto this event when post owner changes.
2025-04-15 22:26:44 +08:00
Osama Sayegh
351a295846
DEV: Fix failing test after a rename (#32314) 2025-04-15 17:05:06 +03:00
Osama Sayegh
0b8df4b833
UX: Use 'unused' instead of 'active' for components (#32284)
This commits changes the language for components that aren't used on any themes to be "used/unused" instead of "active/inactive" throughout the new components listing page.
2025-04-15 16:12:20 +03:00
Osama Sayegh
5e8778ecf7
UX: Use core description of popular components when there's no description (#32286)
When an installed component doesn't have a description in its locale
files, we should fallback to the description that core has for the
component if it's one of the popular components that core features.
2025-04-15 16:07:22 +03:00
Osama Sayegh
71b31604b5
PERF: Implement infinite scrolling for new components page (#32291)
On sites with many components, serializing and rendering all components
in one-go on a page can take quite a bit of time. The new components
listing page that was introduced in
https://github.com/discourse/discourse/pull/32164 currently loads all
components in one-go, so this commit implements infinite-scrolling
pagination for the page to address this performance issue for sites with
many components.
2025-04-15 16:05:10 +03:00
Osama Sayegh
996a3493fe
PERF: Prevent N+1 queries when loading theme/component descriptions (#32305)
Theme/component description is fetched via the `locale_fields` and
`theme_translation_overrides` associations on the `Theme` model. We're
currently not preloading these associations when serializing
themes/components, which causes an N+1 performance issue when accessing
the themes/components listing pages.
2025-04-15 16:02:41 +03:00
Natalie Tay
4510d1ad46
DEV: Update site spec for unregistering modifiers (#32310)
Adding some changes to site.rb, and seeing this error:

```
     Failure/Error: raise "Clearing modifiers during a plugin spec run will affect all future specs. Use unregister_modifier instead."
```

This is a standalone PR to update the usage here so that my future PR
won't be affected.
2025-04-15 20:07:48 +08:00
Ted Johansson
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
Martin Brennan
735bef9ea0
UX: Remove Ctrl+F search shortcut (#32281)
This commit removes the Ctrl+F search shortcut, which hijacks the
browser search shortcut in Discourse. We are doing this because there
has been many years of complaints around this behaviour, and now that
we have the new header search it has become even more annoying.

We originally added this because we lazy load posts in a topic, and it
might not have been immediately clear to users that they are not
searching
all the posts in the topic when pressing Ctrl+F. However, that was 10+
years
ago, most people are very familiar with lazy loading now, it doesn't
make sense
to keep this additional hijack for this one topic use case.

Search is still accessible by pressing the `/` shortcut.
2025-04-15 15:14:54 +10:00
Krzysztof Kotlarek
077649fafd
FIX: bugs with refresh page after save fonts (#32282)
It takes a moment to sync site settings. Therefore, it is better to pass
new values to `refreshPage` function.

Also, it was not working for some fonts like `JetBrains Mono`.
SiteSetting key is `jet_brains_mono` but font family value should be
`JetBrains Mono`.
2025-04-15 12:02:28 +08:00
Renato Atilio
d8d341ebf6
FIX: remove newline from rich editor's pasted img title/alt (#32295)
New lines on `alt`/`title` embedded media are not allowed, causing an
invalid serialized Markdown which is not supposed to contain new lines
for these attributes.

This PR removes them during HTML parsing – we are not creating this new
line scenario otherwise.
2025-04-14 19:24:21 -03:00
Gabriel Grubba
12f05181c7
FIX: Add helpers for title and content for application.html.erb and crawler.html.erb (#32290)
Previously, there was only those helpers in `crawler.html.erb` as we
added it in https://github.com/discourse/discourse/pull/32259

However, to keep it consistent, we need to add it in
`application.html.erb` as well.
2025-04-14 16:34:23 -03:00
Renato Atilio
29ca0ae0b1
FEATURE: add footnote (plugin) rich editor extension (#31719)
Continues the work done on
https://github.com/discourse/discourse/pull/30815.

Adds a `footnote` node, parser, `^[inline]` input rule, toolbar button
item, and serializer.

Also adds a NodeView with an internal ProseMirror editor to edit the
footnote content.
2025-04-14 14:25:36 -03:00
Renato Atilio
a0a5b2889f
DEV: replace rich editor input rules regex lookbehind (#31909)
Refactors the rich editor input rules matches that rely on a lookbehind,
it breaks on iOS <= 16.3.
2025-04-14 14:25:17 -03:00
David Taylor
f0057c7353
DEV: Drop legacy topic-list and raw-handlebars compilation system (#32081) 2025-04-14 10:42:40 +01:00
Krzysztof Kotlarek
ee035582e2
FIX: Rename branding to logo and fonts (#32264)
Change branding page into logo and fonts.

In addition, icon for email setting and email appearance were changed.
2025-04-14 10:49:47 +08:00
Yuriy Kurant
8b5da219d8
UX: header search mobile support (#31711)
## Requirements

Initially defined in
https://meta.discourse.org/t/software-engineer-frontend-ember-js-yuriy-kurant/353612/14?u=yaran.

1. On mobile devices and tablets, users can open the search input field
by tapping the search icon
2. When opened, the search input takes over the entire header area:
    - Users can tap the sliders icon to navigate to the advanced search page
(/search)
    - Users can tap Cancel to close search input
3. After submitting a search, results area will take over the entire
screen:
    - Users can tap the X icon to clear the search term from the input field
    - Users can tap Cancel to close search results area and return to their
previous page (i.e. search area overlays content)

## Implementation

1. When opened, the search input takes over the entire header area:
    - changed panel width from `90vw` to `100vw`
    - on initial render (when search input is empty), search panel hovers over the header section only (doesn't cover main content below)
    - quick tip and recent searches lists are not displayed on mobile view
2. Tap on the sliders icon navigates to the advanced search page
(`/search`)
3. Tap on the **Cancel** button:
    - closes search menu
    - if the search term is present, it is cleared
4. Tap on the left-hand side **Search** icon triggers a topics search

## Dev notes

1. Added `// TODO` questioning `search` service `noResults` default value of `false`
2. Added animation on toggling header search panel (created `delayed-destroy` custom modifier)
3. Extracted in-context search filters into a standalone component `search-menu/active-filters`:
    - mobile: active filters below search input
    - desktop: active filters inside search input
3. Removed unnecessary top padding when search results are empty
4. Added `data-test-` attrs for Ember tests. Benefits:
    - semantically `data-test-` attrs indicate that these parts of the layout are covered with tests
    - decouples selector dependency on `id/class` names for testing purposes - eliminates risk of broken tests due to `id/class` name changes
2025-04-14 10:27:48 +08:00
Renato Atilio
198dc81375
FEATURE: Ctrl+M to toggle between rich/markdown editor (#32266) 2025-04-12 09:01:41 -03:00
Renato Atilio
bc070dcbe3
FIX: avoid double base path on push notification (#32228)
Our service worker concatenates `baseUrl` with `url` coming from the
payload:


e8f4433872/app/views/static/service-worker.js.erb (L96)

This PRs strips the base path before sending `url` to the push
notification to avoid having a URL with the base path duplicated,
causing a 404.
2025-04-12 08:16:53 +10:00
Gabriel Grubba
c484d2fd88
FEATURE: add override for crawler title and description tags (#32259)
In https://github.com/discourse/discourse/pull/32159 we overrode the
`og:` and `twitter:` title and description but for some crawlers, we
need to override the `title` and `description` meta tag as well.
2025-04-11 09:38:11 -03:00
David Taylor
36f364fe11
FIX: Ensure discovery queryParams do not persist invisibly (#32178)
Sharing a controller seems to make query params behave more weirdly than
normal. This change lets Ember create a separate controller instance for
each route, even though they will still share the same class.
2025-04-11 09:44:32 +01:00
Gary Pendergast
05e0491902
FIX: Ensure uploaded watched word CSVs are converted to utf-8. (#32263)
When a watched words CSV file is uploaded, we assume it's utf-8 encoded, but that's not always going to be the case. This change loads the CSV and converts it to utf-8 before processing it.
2025-04-11 16:12:45 +10:00
Gabriel Grubba
181606e0bd
FIX: Prioritize the author when replying to topic (#32244)
Added in https://github.com/discourse/discourse/pull/32086 this
prioritization did not accounted for when the user was replying to the
topic/OP.

Now when replying to the topic, the author will be prioritized in the
list.

All other cases are the same as before.

Added testing for all cases and changed `replyingToUser` to
`replyingToUserId` for clarity and consistency with API.

---------

Co-authored-by: Penar Musaraj <pmusaraj@gmail.com>
2025-04-10 09:02:32 -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
David Battersby
7de9f79f55
FIX: hide search field on invites page (#32236)
Prevents rendering the search field on the invites page.
2025-04-10 09:54:17 +04:00
Ted Johansson
db214a38a2
DEV: Add Content admin config page (#32194)
This PR adds a dedicated page for Content related site settings. It has four different site setting tabs.
2025-04-10 11:20:22 +08:00
Martin Brennan
db68fd7046
DEV: Skip prosemirror flaky (#32231)
Example of a failure is here

https://github.com/discourse/discourse/actions/runs/14345676579/job/40214833933
2025-04-10 12:54:11 +10:00
Krzysztof Kotlarek
14a42bdafe
FIX: incorrect flag message when en_GB language (#32191)
Currently, this is the order of i18n translate function:
1. Translation in required language;
2. Optional `defaultValue` provided;
3. Fallback to forum default language.

When admin set language as English GB, translation was not correctly
displayed as it went to step 2 and displayed `defaultValue` instead of
correct translation from default language.
2025-04-10 08:06:52 +08:00
Chris Alberti
3106c30f16
Added button to remove password from account (#32200)
Added button to remove password from account if user has a linked
external account or passkey

The button only displays if the user has at least one associated account
or a passkey set up. Uses the ConfirmSession dialog in addition to a
warning about deleting the password.

Users can still reset their password via the Reset Password button
(which will now display "Set Password" if they've removed it).

Also prevent user from removing their last remaining associated account
or passkey if they have no password set.

Replaces PR #31489 from my personal repo, with some fixes for conflicts
since then.
2025-04-09 09:32:51 -05:00
Renato Atilio
5836a9a664
UX: backspace rich editor keymap improvements (#32234) 2025-04-09 06:54:15 -03:00