Commit Graph

12533 Commits

Author SHA1 Message Date
Krzysztof Kotlarek ff815384b1
FIX: Expand the hidden post menu when one option is available. (#30831)
When only one option is available for the action menu, it should be
automatically expanded for the glimmer component.

This is the default behaviour for the old post menu:
https://github.com/discourse/discourse/blob/main/app/assets/javascripts/discourse/app/widgets/post-menu.js#L624
2025-01-17 11:30:16 +11:00
Krzysztof Kotlarek 029bd6feda
FEATURE: setting allowing tl0/anonymous flag illegal content (#30785)
The new site setting `allow_anonymous_and_tl0_to_flag_illegal` allows
tl0 users to flag illegal content. In addition, anonymous users are
instructed on how to flag illegal content by sending emails.

Also `email_address_to_report_illegal_content` setting is added. If not
provided, then the site contact email is used.
2025-01-17 08:57:44 +11:00
Ted Johansson 4682919744
DEV: Add base admin page page object (#30814)
This PR introduces a base page object for admin pages. Since we're standardizing using components, this makes writing tests easier by abstracting away details about selectors.
2025-01-16 12:52:41 +08:00
Ted Johansson 59a2a70806
DEV: Move admin page objects to /pages directory (#30812)
A handful of the page objects for admin pages were placed directly under /page_objects rather than under /page_objects/pages with the others. This PR simply moves them.
2025-01-16 11:18:36 +08:00
Ted Johansson 5c0b7c4d70
Admin webhooks UI guidelines (#30764)
This change converts the admin webhooks UI to the new UI guidelines and modernizes the JS.
2025-01-16 10:22:18 +08:00
Martin Brennan 35507d4090
FIX: Process tag synonyms when approving reviewable queued post (#30810)
Followup 72c4709a5a

Previously we made a fix to allow skip validations when tagging
a topic via TopicCreator. However, this flow also skips a lot of
the more in-depth work on tags we do when creating a topic, like
processing tag synonyms. When approving reviewable queued posts,
we skip validations, so this would cause an issue where a topic
was approved and the tag synonyms weren't applied.

This commit changes the logic so we attempt the more complete
`DiscourseTagging.tag_topic_by_names` call first and if this fails
and skip validations is on, then we do
`DiscourseTagging.add_or_create_tags_by_name`.
This at least gives a chance for the full workflow to work first.
2025-01-16 11:01:45 +10:00
Natalie Tay cfac49fb10
FIX: Include original filename in s3 uploads even if not attachment (#30789)
Related: https://github.com/discourse/discourse/pull/30535

In the PR above, the [content-disposition
header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition)
was removed for all non-svg files due to the "attachment" keyword added
to them, causing files to be downloaded instead of opening in a new tab
when requested. When removing that, it also removed the filename
attribute attached to s3 uploads.

After some testing, it turns out that `filename` is also respected when
next to `inline`, despite it not being obvious [in
docs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition#syntax).
This commit adds inline+filename so that users can still download files
and have filenames be respected instead of using the s3 hash.
```http
<!-- mdn docs -->
Content-Disposition: inline
Content-Disposition: attachment
Content-Disposition: attachment; filename="file name.jpg"
Content-Disposition: attachment; filename*=UTF-8''file%20name.jpg
<!-- this actually works too -->
Content-Disposition: inline; filename="file name.jpg"
```
2025-01-15 18:08:18 +08:00
Alan Guo Xiang Tan 1a70d118a8
FIX: `S3Inventory#backfill_etags_and_list_missing` need to unescape key (#30787)
The `key` provided in the S3 inventory file will esacpe any special
characters in the filename of the key so we need to unescape. Otherwise,
uploads with extensions that conatins special characters will fail to
match records which we insert into the temporary table based off the
s3 inventory file.
2025-01-15 14:52:49 +08:00
Gary Pendergast 5da6a06ce3
UX: Use DPageHeader on the Emails page (#30781)
There are a few changes here to make the Emails admin page more consistent with the rest of the admin UI.

- The header and navigation menu have been updated.
- The sidebar now stays highlighted when visiting the email admin sub-pages.
- Moved the Template editor from /admin/customize/email_templates to /admin/email/templates, so it fit as a sub-page.
- Removed the link to the Template editor from the Customize section of the old top menu, since it's accessible from the Emails section, instead.
2025-01-15 15:36:16 +11:00
Mark VanLandingham a89086f799
DEV: Add per_page as public param for TopicQuery (#30716)
This change allows controllers that construct TopicQuery parameters, to pass per_page into the TopicQuery constructor as an option. I can't see why this shouldn't be a public param, so long as we properly validate the value!

Internal discussion at t/145686.
2025-01-14 09:19:19 -06:00
Ted Johansson 6b4aa1221c
DEV: Add problem check informing about admin layout deprecation (#30685)
We want to avoid surprises when we make the new admin sidebar baseline, so in addition to announcements, we're also adding a problem check that informs you if you don't have it enabled for any group yet.
2025-01-14 13:22:59 +08:00
Martin Brennan e9fb4131ea
FIX: Add Type column to Flag Status CSV export (#30756)
This Type column is a special ":post" column on the
Flag Status report, so it did not show by default in
the CSV export of that report. This adds it so the
type of flag e.g. illegal, off topic, innapropriate
is shown in the CSV output.
2025-01-14 13:31:55 +10:00
Gary Pendergast 8c86676fcf
DEV: Revert the addition of keywords for all site settings. (#30755)
This is a revert of 92793c5b73.

Following on from discussions after the previous commit, it became evident that it was only a small step towards solving the larger problem of finding site settings in a reliable fashion across multiple languages.

This is going to take more thought and discussion, and since the changes  introduced in the previous commit are effectively non functional without additional work, I'm going to revert it for now.
2025-01-14 13:34:04 +11:00
David Taylor 0ed4b09527
DEV: Move `discourse-common/(utils|lib)` to `discourse/lib` (#30733)
`discourse-common` was created in the past to share logic between the
'wizard' app and the main 'discourse' app. Since then, the wizard has
been consolidated into the main app, so the separation of
`discourse-common` is no longer useful.

This commit moves `discourse-common/(lib|utils)/*` into
`discourse/lib/*`, adds shims for the imports, and updates existing
uses in core.
2025-01-13 13:02:49 +00:00
Jarek Radosz b28fafd372
DEV: Fix job serialization warnings (#30735)
(…and remove extraneous `stringify_keys` - enqueue already does
`deep_stringify_keys`)

The warning in question:

```
Deprecation notice: Jobs::RunProblemCheck was enqueued with argument values which do not cleanly serialize to/from JSON. This means that the job will be run with slightly different values than the ones supplied to `enqueue`. Argument values should be strings, booleans, numbers, or nil (or arrays/hashes of those value types). (deprecated since Discourse 2.9) (removal in Discourse 3.0)
```
2025-01-13 13:35:40 +01:00
Régis Hanol d7aa13328d
FIX: strip unsubscribe links in incoming emails (#30695)
When we send an email notification to a user, we always include a link
that will allow them unsubscribe to these emails.

If the user reply to the email notification, the link to unsubscribe
might still be present in the final post (often in the elided part).

Since those links do not require authentication to unsubscribe a user
(this is a feature, not a bug), we would like to avoid showing them to
other users on Discourse.

(If such an email is forwarded elsewhere, then it's totally out of our
control.)

This commmit ensures we always strip those unsubscribe links from any
incoming email to avoid making it easier to unsubscribe another user.

Since the format we use for those links might be similar to the ones
used by other applications, the regular expression used to match those
links uses the absolute URL of the Discourse (aka.
`Discourse.base_url`).
2025-01-13 11:33:46 +01:00
Régis Hanol 03119312b5
FIX: ensure GroupChooser works with localized group names (#30593)
The "Tag Groups Form" component was using group names to handle
permissions. This works just fine when the default locale is "English"
but breaks as soon as it's changed to a different locale.

The fix is to use the group id's for handling the permissions instead of
the group name.

Reported in https://meta.discourse.org/t/221849
2025-01-13 11:29:04 +01:00
David Battersby 47c8197ea1
FEATURE: add drafts dropdown menu (#30277)
This change adds a new dropdown trigger next to the "New Topic" button.
When clicked a menu will display a list of topic/post drafts that can be
clicked to resume the draft within the composer.

The "New Topic" button will no longer change text to show "Open Draft"
when a draft topic exists, it will still attempt to load the existing
draft if one exists (this will change later when we support multiple
drafts in a separate PR).

The "My Posts" link in desktop sidebar will now be "My Drafts" and only
appear when the current user has existing drafts.
2025-01-13 13:33:57 +04:00
Martin Brennan 7c96d7587e
FIX: Allow admins to use reserved usernames (#30262)
It is possible for admins to rename users like `system`
to some other username, but if they try to change it back
they cannot, since `system` is a reserved username.

This commit allows admins to change any user's username
to a reserved username _as long as that username is not
already in use_.
2025-01-13 17:30:36 +10:00
Krzysztof Kotlarek 89ba034422
DEV: Improve distributed cache multisite specs (#30662)
Distributed cache when namespace is false is not multisite safe as
values are shared between sites. Distributed cache with namespace option
(default) is multisite safe.

Improved specs to cover both cases.
2025-01-13 17:03:56 +11:00
Ted Johansson b1bae9b785
FIX: Add back missing API key 'peek' step (#30683)
In #30096 we converted the API keys UI to follow the new admin UI guidelines.

During this conversion, the step where you get a chance to copy the API key after creating, was lost due to a rebase mistake.

This re-introduces it.
2025-01-10 10:21:22 +08:00
Angus McLeod 427ea5301b
Apply the same url normalisation to embed_urls inserted in the PostCreator (#30641) 2025-01-09 14:59:08 -05:00
Gary Pendergast ec30b6f6c6
FIX: Inline oneboxes should obey the locale. (#30664)
Following on from f369db5ae9, we need to apply a similar fix to inline oneboxes, since they use a different code path to retrieve the onebox provider data.

This change ensures the Accept-Language header is sent by inline onebox requests, too.
2025-01-09 17:22:22 +11:00
Gary Pendergast f53c734ba6
FEATURE: Add a onebox_locale site setting. (#30655)
Following on from f369db5ae9, this change adds the ability to choose a custom locale to send to onebox providers.

If this setting is left blank, it will fall back to using default_locale.
2025-01-09 14:11:37 +11:00
Ted Johansson 590b3e11fb
DEV: Convert admin API keys to conform to UI guidelines (#30660)
Re-opening of #30096. It was reverted because it was missing a sidebar link to Webhooks in the admin panel.
2025-01-09 10:57:40 +08:00
Krzysztof Kotlarek 9bf31add6a
FIX: do not memoize score types (#30657)
Score types are dynamic because of custom flags. Therefore we cannot memorize them on class level as it is not multisite safe.
2025-01-09 13:20:59 +11:00
Sérgio Saquetim e5d6ca0451
DEV: Fix triple click selection in WebKit derived browsers (#30628)
On WebKit-based browsers, triple clicking on the last paragraph of a post won't stop at the end of the paragraph, leaking the selection into the following nodes until it finds a non-empty node.

This commit introduces a workaround to fix this behavior.
2025-01-08 19:14:15 -03:00
Gary Pendergast f369db5ae9
FIX: Ensure Onebox requests ask for the correct language. (#30637)
Onebox embeds currently default to accepting any language response from the destination, which can have some surprising behaviour. For example the `curl` equivalent of what Onebox does:

```
% curl -si -H "Accept-Language: *" 'https://developer.android.com/studio' | grep location:
location: /studio?hl=hi
```

This PR uses the value of `SiteSetting.default_locale` to populate the `Accept-Language` header, falling back to English if that isn't available, then finally accepting whatever language the destination makes available.
2025-01-09 09:08:27 +11:00
Blake Erickson 6811296b24
DEV: Make silence_reason and can_be_deleted optional (#30647)
In the api docs note that `silence_reason` and `can_be_deleted` are
optional responses for the admin user api response.

Follow up to: 9cf78ba195

> TODO @blake / @sam - this is not passing cause "silence_reason" is a conditional attribute
> (also can_be_deleted is) - we need to figure out how to not include it in the schema - it is not included
> in the admin response by design
2025-01-08 12:43:39 -07:00
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