Commit Graph

12504 Commits

Author SHA1 Message Date
Mark VanLandingham 4da7904ffd
REVERT: "DEV: Convert admin API keys to conform to UI guidelines"
This reverts commit d9ddc25808.

I noticed that Webhook admin UI is now inaccessible through the subheader
2025-01-08 11:03:40 -06:00
David Taylor 498481e5be
DEV: Introduce 'dev tools' toolbar and plugin-outlet debugger (#30624)
This commit introduces a new 'dev tools' feature for core, theme and plugin developers. This is enabled by default in development environments, and can be enabled in production by running `enableDevTools()` in the browser console. 

When enabled, it will load a separate dev-tools JS/CSS bundle, and show a new toolbar on the left of the page. Dev Tools will remain enabled until the 'x' button is clicked, or `disableDevTools()` is run in the console.

The toolbar currently has three buttons:

- "Toggle safe mode" provides an easy way to toggle all themes/plugins on/off

- "Toggle verbose localization" is a toggle for our existing locale debugging feature

- "Debug plugin outlets" is inspired by the popular 'plugin outlet locations' theme component. It hooks into core's plugin outlet system, and renders a button into every single outlet. Those buttons have a tooltip which shows more information about the outlet, including all of the outletArg values. To inspect the value further, buttons allow the values to be saved to globals and logged to the console.

All of this is implemented under `/static`, and is only async-import()-d when the dev tools are enabled. Therefore, we can continue to add more tools, with zero performance cost to ordinary users of Discourse.
2025-01-08 15:26:18 +00:00
Jordan Vidrine 9779cc9d5e
UX: Conditionally render permalinks filter (#30633) 2025-01-08 06:18:01 -06:00
David Taylor 6330e6ceae
DEV: Set glimmer-topic-list to 'auto' by default (#30582)
This will cause the glimmer topic-list to be enabled for sites with compatible customizations. Incompatible customizations will print a deprecation message to the console, along with a link to more information.

Also cleans up a handful of specs/behaviour which were revealed by switching the default.

More details at https://meta.discourse.org/t/343404
2025-01-08 12:00:56 +00:00
Joffrey JAFFEUX 6740a340ca
DEV: unifies emoji picker (#28277)
The chat emoji picker is renamed emoji-picker, and the old emoji-picker is removed.

This commit doesn't attempt to fully rework a new emoji-picker but instead tries to migrate everything to one picker (the chat one) and add small changes.

Other notable changes:
- all the favorite emojis code has been mixed into one service which is able to store one state per context, favorites emojis will be stored for all topics, and for each chat channel. Meaning that if you always use a specific emoji in a channel, it will only show as favorite emoji in this channel.
- a lot of static code has been removed which should improve initial load perf of discourse. Initially this code was around to improve the performance of the emoji picker rendering.
- the emojis are now stored, once the full list has been loaded, if you close and reopen the picker it won't have to load them again.

List of components:

- `<EmojiPicker />` will render a button which will open a dropdown
- `<EmojiPickerContent />` represents the content of the dropdown alone, it's useful when you want to render a picker from an action which is not the default picker button
- `<EmojiPickerDetached />` just a simple wrapper over `<EmojiPickerContent />` to make it easier to use it with `this.menu.show(...)`

---------

Co-authored-by: Renato Atilio <renatoat@gmail.com>
2025-01-08 11:41:36 +01:00
Ted Johansson d9ddc25808
DEV: Convert admin API keys to conform to UI guidelines (#30096)
This PR updates the admin API keys page to follow the Admin UI Guidelines. In addition it modernizes all the JavaScript involved in this admin area.
2025-01-08 18:11:38 +08:00
Sam 9cf78ba195
FEATURE: show silence reason when viewing silenced users (#30635)
This adds the Silence Reason column to silenced user lists.

This feature helps combat large spam attacks cause you can quickly see
why a user was silenced and then bulk act on all the silenced users
2025-01-08 16:04:19 +11:00
Osama Sayegh 4f9359d056
FIX: Name field should appear in the signup form for login-required sites (#30634)
Meta topic: https://meta.discourse.org/t/full-name-at-sign-up-went-missing/345662/17?u=osama

The preloaded `site` object for anons on login-required sites is a stripped down version of the full object with just a specific set of attributes and doesn't use the site serializer. This results in the `full_name_required_for_signup` and `full_name_visible_in_signup` attributes not making it to the client app when a login-required site is accessed by an anon, causing the name field in the signup form to not be rendered, even when it's required.

This commit includes those attributes in the stripped down version of the `site` object that's used for anons on login-required sites.
2025-01-08 03:49:34 +03:00
Martin Brennan c1a46995a7
FIX: Wizard improvements post-merge part 1 (#30612)
* FIX: Wizard improvements post-merge part 1

Followup 3135f472e2

Fixes the following:

* On mobile, the Styling step was very narrow
* When clicking Next on the Styling step after previously
  selecting Hot, we got an error

Also makes the following UX improvements for the preview:

* Use different topic titles for Latest and Hot
* Also make Hot view and reply numbers higher

This helps differentiate the two previews.

* DEV: Review fixes
2025-01-07 17:01:05 +10:00
Krzysztof Kotlarek 51a444ab53
FIX: consistent delete button for admin panel (#30592)
Move the delete button to more options to follow guide https://meta.discourse.org/t/creating-consistent-admin-interfaces/326780#p-1605522-h-5d-table-26
2025-01-07 14:05:45 +11:00
Natalie Tay 0f0b3a21e6
FIX: Allow attachments to be opened in a new tab instead of downloading them (#30535)
Back then in 31e31ef, we added the Content-Disposition headers so that SVGs get downloaded instead of get run in the browser. Inadvertently, this also causes other attachments like pdfs and videos to be downloaded instead of heeding the "Open in new tab" option that users choose in the browser.

When the header is removed, the default value is "inline", this allows the browser to perform as requested. This also applies to other file types like pdfs, allowing users to "Open in new tab" and view them in the browser instead of always downloading them.

Existing tests (#10205) already do check that SVGs remain downloaded. Some existing tests written for PDFs have been modified to cater for SVGs instead, when there was a bug in defining the filenames per #10108
2025-01-07 10:32:32 +08:00
Martin Brennan 725e146dca
FIX: Calculate experiment_enabled on server for "What's new?" (#30599)
Experimental "What's new?" feature feed items previously calculated
a boolean for experimentEnabled on the client based on the siteSettings
service, and this would control the initial state of the experiment
toggle.

However this requires the person who creates the site setting for the
experiment to remember to set it to `client: true`. This commit removes
that manual step by calculating whether the experiment is enabled
server-side, where we have access to all the site settings.
2025-01-07 11:27:24 +10:00
Martin Brennan bcc34420bb
UX: Remove version from "What's new?" items (#30596)
This version number is a technical detail that controls
what items show up on certain sites, most admins don't
need this level of detail. Remove it here, maybe we can
add it back in some hidden way later if needed.
2025-01-07 10:06:10 +10:00
Martin Brennan 9c7b0ddb2f
UX: Update email and security sidebar link copy (#30563)
* UX: Update email and security sidebar link copy

Followup b3fa335c7d

Changes these sidebar links to better reflect
what these pages contain:

* (Email) Server setup → Server setup & logs
* (Security) Staff action logs → Logs & screening

* DEV: Test fix
2025-01-07 09:59:31 +10:00
Krzysztof Kotlarek 407fa69778
UX: admins embedding page follows admin ux guideline (#30122)
Conversion of /admin/customize/embedding page to follow admin UX guidelines.
2025-01-06 13:01:08 +11:00
Jarek Radosz 8be29694ec
DEV: Clean up topics_controller_spec (#30553) 2025-01-05 01:09:23 +01:00
Osama Sayegh e2129dc07c
FIX: Allow signups when full names are disabled (#30551)
Follow-up to 3187606d34

When the `enable_names` setting is false and the `full_name_requirement` setting is set to `required_at_signup`, the name field in the signup form should effectively be not required (and hidden). However, that is not actually the case at the moment because the `name-validation.js` mixin only checks for the `full_name_requirement` setting when determining whether the name field should block a new signup.

This commit fixes the issue by making the `full_name_required_for_signup` and `full_name_visible_in_signup` site attributes check for the `enable_names` setting themselves. This spares any consumers of these properties from having to remember to include a check for the `enable_names` setting.
2025-01-04 15:13:44 +03:00
Jarek Radosz 5ce33991f4
DEV: Fix flaky deprecated setting specs (#30550)
…and remove obsolete (and already-disabled) TL-migration related specs
2025-01-04 12:55:22 +01:00
Jarek Radosz a33e9bc2f9
DEV: Remove deprecated `search_tokenize_chinese_japanese_korean` setting (#30549)
It was supposed to be removed ~3 years ago (there was [a migration](b4f0a8748d/db/migrate/20220126052157_change_segment_cjk_site_setting.rb) already)
2025-01-03 23:21:18 +01:00
Jan Cernik 1c893d1725
FIX: Show error message when password is too common (#30507) 2025-01-03 09:23:14 -03:00
Jarek Radosz 145c7e46e1
DEV: Remove invalid parsing options (#30545)
HTML5 parser doesn't have those options
2025-01-03 13:17:49 +01:00
Natalie Tay 91f7ae2741
DEV: Allow export user archive (job) to be requested and sent to an admin (#30543)
It is not possible for an admin to generate a suspended user's archive now, disallowing SAR (subject access requests) under the GDPR.

This commit expands the export_user_archive job to allow specifying a requesting_user_id which will send the archive to an admin. When not specified, this defaults to the user itself.
2025-01-03 14:27:10 +08:00
Martin Brennan 6b36b0b68d
FIX: Reports did not respect user locale (#30524)
Our bulk report endpoint uses `hijack`, which does not
use the current user's locale via the `with_resolved_locale`
method in `ApplicationController`. This is happening because
we are doing `around_action` to set the locale, then calling
the code in the block inside the action directly when we use
`hijack`.

We can fix this by capturing `I18n.locale` when starting the
hijack then using `I18n.with_locale` when evaluating the
block inside `hijack`, this way the translations will always
use the correct locale based on the current user.
2025-01-02 13:05:53 +10:00
Martin Brennan 9a12eb5c3c
FIX: Wizard branding step null logo (#30523)
Followup 3135f472e2

Fixes an issue where the wizard branding step would
error if SiteSetting.logo was null, this did not come
up during testing because in our testing discourse-logo-sketch-small.png
is used for the logo settings.
2025-01-02 10:44:31 +10:00
Martin Brennan 3135f472e2
FEATURE: Improve wizard quality and rearrange steps (#30055)
This commit contains various quality improvements to
our site setup wizard, along with some rearrangement of
steps to improve the admin setup experience and encourage
admins to customize the site early to avoid "all sites look the
same" sentiment.

#### Step rearrangement

* “Your site is ready” from 3 → 4
* “Logos” from 4 → 5
* “Look and feel” from 5 → 3

#### Font selector improvements

Changes the wizard font selector dropdown to show
a preview of all fonts with a CSS class so you don't
have to choose the font to get a preview.

Also makes the fonts appear in alphabetical order.

#### Preview improvements

Placeholder text changed from lorem ipsum to actual topic titles,
category names, and post content. This makes it feel more "real".

Fixes "undefined" categories. Added a date to the topic timeline.

Fixes button rectangles and other UI elements not changing in
size when the font changed, leading to cut off text which looked super
messy. Also fixed some font color issues.

Fixed table header alignment for Latest topic list.

#### Homepage style selector improvements

Limited the big list of homepage styles to Latest, Hot, Categories with latest topics,
and Category boxes based on research into the most common options.

#### Preview header

Changed the preview header to move the hamburger to the left
and add a chat icon

#### And more!

Changed the background of the wizard to use our branded blob style.
2025-01-02 09:28:23 +10:00
Martin Brennan 5711bf6f27
DEV: Move admin config pages out of /customize/ sub-route (#30511)
The customize routes add CSS classes that make these admin
config pages look different from the ones under /admin/config.
We want all config routes to be under /admin/config as well.

This commit moves the emoji, user fields, and permalinks pages
out of customize and into config, updating all references and
adding more rails routes as needed.

Also renames admin emojis route to emoji, emoji is singular and plural.
2025-01-02 09:13:11 +10:00
Régis Hanol d523c37057
FIX: correctly extract body and/or reply from exchange emails (#30512)
When receiving emails sent with Exchange, we look for some markers to identify the body of the mail and the reply (aka. previous email).

For some reasons, those markers aren't 100% reliable and sometimes, only one of them is present.

The commit 20ba54d536 introduced the bug because the `HTML_EXTRACTERS` regex for exchange looks for either `messageBodySection` or `messageReplySection` but we were only using the `reply` section. So if an email had only the `body` section, it would not be correctly extracted.

This commit handle the cases where either one of them is missing and use the other one as the actual "reply". When both are present, it correctly elides the "reply" section.
2024-12-31 15:29:36 +01:00
zogstrip 4d889f2ef8 FEATURE: add support for One-Click unsubscribe (RFC 8058)
We were missing the "List-Unsubscribe-Post" header in emails we sent to allow Yahoo / GMail and others to automagically show a link to unsubscribe.

Internal ref - t/144713
2024-12-31 15:28:59 +01:00
Sam 9b9babdd72
FEATURE: allow disabling of anti spam profile hiding feature (#30508)
The profile hiding feature is particularly problematic on sites that are
private (invite only or must approve users) so it is unconditionally disabled.

Also certain sites may prefer to disable the anti spam feature, they can
opt out using `hide_new_user_profiles`


Co-authored-by: Martin Brennan <martin@discourse.org>
2024-12-31 15:04:53 +11:00
Gary Pendergast 86637403c7
UX: Add Sentence Casing for Setting Names (#30479) 2024-12-31 09:55:53 +11:00
Osama Sayegh 3187606d34
FEATURE: Add option to hide full name input at signup (#30471)
This commit replaces the `full_name_required` setting with a new `full_name_requirement` setting to allow more flexibility with the name field in the signup form. The new setting has 2 options, "Required at signup" and "Optional at signup", which are equivalent to the true/false possibilities of the old setting, and a third option "Hidden at signup" that hides the name field from the signup form, making it effectively optional too.

New sites will have the "Hidden at signup" option as the default option, and existing site will continue to use the option that maps to their current configuration.

Internal topic: t/136746.
2024-12-30 22:26:20 +03:00
Angus McLeod ce7a14104b
Add user api key client rate limit settings (#30402) 2024-12-30 11:10:48 -05:00
Gary Pendergast 92793c5b73
DEV: Ensure all site settings have a keyword entry (#30485) 2024-12-30 12:22:55 +11:00
Alan Guo Xiang Tan cad56e2a21
DEV: Support a `perform_when_readonly` option for `Jobs::Scheduled` (#30478)
This is useful for scheduled jobs that should be performed even when
`Discourse.readonly_mode?` is `true`.
2024-12-27 09:42:40 +08:00
Mark VanLandingham df1fc5bca8
FIX: Consistently notify lowest post number if post_moved notification generation (#30448)
We currently query the posts table without an order when notifying users of moved posts. Generally the query will return the lowest post number post (b/c ID correlates with post_number in most cases) but not always. This adds an order to the post query in notify_moved_posts job.

Also I removed some if statement nesting with early returns / guard clauses.
2024-12-23 09:53:43 -06:00
Osama Sayegh e2cd1da26d
FIX: All admins should be allowed to see deleted PM posts regardless of their mod status (#30206)
Admins and moderators can see a user's deleted posts via the `/u/:username/deleted-posts` route. Admins can always see any post on the site, but that's not always the case for moderators, e.g., they can't see all PMs. So, this route accounts for that and excludes posts that a moderator wouldn't be allowed to see if they were not deleted.

However, there's currently a problem with that logic where admins who also have moderation privileges, are treated the same way as moderators and prevented from seeing posts that pure moderators can't see. This commit fixes that problem and only applies the permission checks to moderators who don't have admin privileges.

Internal topic: t/143107.
2024-12-23 12:48:03 +03:00
Alan Guo Xiang Tan 859d61003e
DEV: API to register custom request rate limiting conditions (#30239)
This commit adds the `add_request_rate_limiter` plugin API which allows plugins to add custom rate limiters on top of the default rate limiters which requests by a user's id or the request's IP address.

Example to add a rate limiter that rate limits all requests from Googlebot under the same rate limit bucket:

```
add_request_rate_limiter(
  identifier: :country,
  key: ->(request) { "country/#{DiscourseIpInfo.get(request.ip)[:country]}" },
  activate_when: ->(request) { DiscourseIpInfo.get(request.ip)[:country].present? },
)
```
2024-12-23 09:57:18 +08:00
Sam 3fd3a76422
FIX: we introduced a Jobs::UserEmail which broke consistency checks (#30409)
Fix ensures all classes are rooted and there is a spec that will catch
failures next time
2024-12-22 21:33:47 +11:00
Régis Hanol 268d4d4fb9
FIX: more... should not show when there are no visible links (#30405)
When lurking on a Discourse as anonymous, if the sidebar is enabled, and a section contains only secondary links that are not visible to anonymous users, we should not display the "more..." button.

Otherwise it feels broken because clicking on it does nothing, since there are no "visible" links to be shown.

Internal ref t/144716
2024-12-21 01:06:46 +01:00
marstall 3e8e861103
DEV: return full name in /notifications.json (#30335)
* wip: return full name in /notifications.json

* DEV: test for full name

* DEV: add test for enable_names=true

* DEV: add notification6, cleanup

* DEV: fix tests
2024-12-20 11:43:13 -05:00
Keegan George 380910aedd
DEV: Cleanup todos from codebase (#30394)
This PR involves cleaning up the codebase from my (@keegangeorge's) todos. 

In particular:
- Remove Form Template related todos (these are no longer in the roadmap)
- Remove old left-over AI summarization related code after moving to AI (https://github.com/discourse/discourse-ai/pull/658)
- Update one form template related spec
2024-12-19 18:22:33 -08:00
Sam c315e26485
FIX: handle more thread pool edge cases (#30392)
* Split `shutdown` into two separate methods for better control:
  - `shutdown` - signals threads to stop accepting new work
  - `wait_for_termination` - waits for threads to finish (with optional timeout)

* Add tracking of busy threads via `@busy_threads` Set
* Make idle_time parameter optional with 30-second default
* Improve thread spawning logic:
  - Spawn initial thread immediately when work is posted
  - Spawn additional threads when all threads are busy and work is queued
* Fix race condition in work distribution
* Add busy thread count to stats output
* Add test coverage for zero min_threads configuration

This commit makes the ThreadPool more reliable, easier to use, and adds 
better visibility into its internal state.

---------

Co-authored-by: Alan Guo Xiang Tan <gxtan1990@gmail.com>
2024-12-20 11:50:00 +11:00
Martin Brennan b3fa335c7d
UX: Admin sidebar link changes (#30365)
Make all links in the admin sidebar follow https://meta.discourse.org/t/formatting-text-in-discourse-documentation-and-uis/324637

Remove the following links, and add keywords to their root links.
Email logs section is removed entirely.

* Email Settings > Preview Summary
* Email Logs > Sent
* Email Logs > Skipped
* Email Logs > Bounced
* Email Logs > Received
* Email Logs > Rejected
* Security > Error Logs
* Security > Screened Emails
* Security > Screened IPs
* Security > Screened URLs
* Security > Search Logs
* Advanced > Webhooks
2024-12-20 09:58:42 +10:00
Sam efa50a4da2
FEATURE: ThreadPool implementation (#30364)
This commit introduces a new ThreadPool class that provides efficient worker
thread management for background tasks. Key features include:

- Dynamic scaling from min to max threads based on workload
- Proper database connection management in multisite setup
- Graceful shutdown with task completion
- Robust error handling and logging
- FIFO task processing with a managed queue
- Configurable idle timeout for worker threads

The implementation is thoroughly tested, including stress tests, error
scenarios, and multisite compatibility.
2024-12-20 07:37:12 +11:00
Penar Musaraj 6873962572
DEV: Fix flakey spec (#30382) 2024-12-19 14:19:34 -05:00
David Taylor d2979997e9
DEV: Introduce new 'glimmer topic list mode' site setting (#30375)
This replaces the previous group-based site setting
2024-12-19 17:38:35 +00:00
Keegan George d886c55f63
DEV: Reusable post-list component (#30312)
This update adds a  _new_ `<PostList />` component, along with it's child components (`<PostListItem/>` and `<PostListItemDetails />`). This new generic component can be used to show a list of posts.

It can be used like so:
```js
/**
 * A component that renders a list of posts
 *
 * @component PostList
 *
 * @args {Array<Object>} posts - The array of post objects to display
 * @args {Function} fetchMorePosts - A function that fetches more posts. Must return a Promise that resolves to an array of new posts.
 * @args {String} emptyText (optional) - Custom text to display when there are no posts
 * @args {String|Array} additionalItemClasses (optional) - Additional classes to add to each post list item
 * @args {String} titleAriaLabel (optional) - Custom Aria label for the post title
 * 
*/
```
```hbs
<PostList
    @posts={{this.posts}}
    @fetchMorePosts={{this.loadMorePosts}}
    @emptyText={{i18n "custom_identifier.empty"}}
    @additionalItemClasses="custom-class"
 />
```
2024-12-19 09:20:25 -08:00
Blake Erickson 17bdffc900 SECURITY: When enabled only allow Discourse Connect logins
If Discourse Connect is enabled no other methods for account creation or
authentication should be allowed.
2024-12-19 13:13:23 -03:00
Krzysztof Kotlarek 95564a3df2 SECURITY: Moderators cannot see user emails.
Unless `moderators_view_emails` SiteSetting is enabled, moderators should not be able to discover users’ emails.
2024-12-19 13:13:18 -03:00
Martin Brennan 553784f919
DEV: Delete AdminPageHeader and AdminPageSubheader components (#30337)
No longer needed because of https://github.com/discourse/discourse/pull/30146
and there are plugin PRs to remove other traces of it
2024-12-19 12:47:14 +10:00