Commit Graph

15088 Commits

Author SHA1 Message Date
David Taylor
eb2e3b510d
FEATURE: Introduce 'Subcategories with featured topics' view (#16083)
This categories view is designed for sites which make heavy use of subcategories, and use top-level categories mainly for grouping
2022-03-04 21:11:59 +00:00
Jarek Radosz
94ea1afc43
DEV: Allow @discourseComputed in native classes (#16097)
(also fixes `writeable` -> `writable` typo)
2022-03-04 17:04:40 +01:00
Joffrey JAFFEUX
dfc19c62f8
DEV: drops jquery for scroll-top mixin (#16099) 2022-03-04 12:45:23 +01:00
Osama Sayegh
8c71878ff5
UX: Add description to the 2FA page when adding new admins (#16098)
This PR adds an extra description to the 2FA page when granting a user admin access. It also introduces a general system for adding customized descriptions that can be used by future actions.

(Follow-up to dd6ec65061)
2022-03-04 06:43:06 +03:00
Rafael dos Santos Silva
967946378a
FIX: iOS do not have working push notifications yet (#15888)
Stop Discourse from prompting for push notification on latest iOS beta
where the navigators exposes a broken Push object.

We had some feature detection functions that where outside our
pre-initializer that it dedicated for this stuff. All feature detection
now lives on sniff-capabilities file.

Also removed some old browser detection from the push notifications
code, and simplified the function signature because of it.

Co-authored-by: Jarek Radosz <jradosz@gmail.com>
2022-03-03 16:19:46 -03:00
David Taylor
a7db0ce985
UX: Differentiate 'emails disabled' notice for 'yes' and 'non-staff' (#16096) 2022-03-03 15:49:20 +00:00
Kris
2d79275481
DEV: add class name to custom footer html (#16089) 2022-03-02 21:17:43 -05:00
Kris
fe4aeb22e2
DEV: remove wrap from discovery-list-container-top (#16090) 2022-03-02 21:17:28 -05:00
Jeff Wong
91cbd28fa4
FIX: calculate docking - include offset of main (#16079)
Include a calculation of offset in main - this allows docking
to be calculated (again) using global offsets, in case there is a
custom header outside of Discourse that pushes forum content down.
2022-03-02 17:36:24 -08:00
Alan Guo Xiang Tan
d52aa6a51b
DEV: Refactor model/post-stream to support any filter. (#16081)
The current implementation ties the filter query params tightly to the
`summary` attribute on the post stream model making it hard to support
other filters.
2022-03-03 08:50:47 +08:00
Dan Ungureanu
e3b4998efc
DEV: Remove notify user topic from share modal (#16085)
This feature was rarely used, could be used for spamming users and was
impossible to add a context to why the user was notified of a topic. A
simple private messages that includes the link and personalized message
can be used instead.
2022-03-03 09:27:45 +11:00
Krzysztof Kotlarek
ea3a58d051
FIX: indirectly muted categories for topic-tracking-state (#16067)
Topics belonging to indirectly muted categories should be excluded from topic-tracking-state report.
2022-03-02 15:02:09 +11:00
Mark VanLandingham
c33cf3c5e6
DEV: API to add keyboard shortcuts to help modal (#16075) 2022-03-01 14:37:26 -06:00
David Taylor
fd8388776e
DEV: Correctly detect plugin JS with .br.js extension (#16073) 2022-03-01 11:55:17 +00:00
David Taylor
bf6173509c
DEV: Ensure source-identifier works during theme qunit (#16072) 2022-03-01 11:14:23 +00:00
Martin Brennan
9e7e34fc24
FIX: Minor indentation fix for fullscreen code (#16071) 2022-03-01 09:20:49 +10:00
Martin Brennan
ff96d541e9
FEATURE: Add fullscreen button for code blocks (#16044)
This commit extends the original copy-codeblocks initializer,
renaming it to codeblock-buttons, and adding another button
to make the code block fullscreen in a modal window. The fullscreen
code is then run through highlight.js.

This commit also moves much of the code out of the initializer
and into a reusable CodeblockButtons class, so it can also be used
in the fullscreen code modal for the copy + paste button.

The fullscreen button will not be shown if there is no scroll overflow
in the code block, nor will it be shown on mobile. This commit also
changes the fullscreen table button to not show on mobile.

This will make long lines of code much easier to read and interact
with. This is gated behind the same `show_copy_button_on_codeblocks`
site setting.
2022-03-01 08:37:24 +10:00
Jarek Radosz
7c4be7f649
UX: Remove loading spinner from emoji picker (#16064)
Emoji picker doesn't load external data, so this didn't provide much value to users (and just delayed displaying the list by 50ms+)
2022-02-28 15:37:31 +01:00
Jarek Radosz
1a5c6f7632
FIX: Setting emoji filter from initial autocomplete (#16063)
…has regressed at some point
2022-02-28 15:01:26 +01:00
Vinoth Kannan
37b6fa7a1b
DEV: refactor JS files to not use self = this in code. (#15095)
We no longer use this pattern. Instead, we can use javascript arrow functions.
2022-02-28 16:57:32 +05:30
Joffrey JAFFEUX
ca7f0ce461
DEV: uses vanilla js to fetch csrf token instead of jquery (#16069) 2022-02-28 11:25:45 +01:00
Jarek Radosz
6f6406ea03
DEV: Fix random typos (#16066) 2022-02-28 10:20:58 +08:00
Martin Brennan
cfe4ff8d56
FIX: Make sure html_raw is hoisted in custom markdown cook function (#16050)
When returning the customRenderFn from within buildCustomMarkdownCookFunction
for custom markdown engines (such as the one used by the [chat] transcripts)
we were not hoisting/unhoisting the `html_raw` tokens created by the
transcript, which meant that opts.discourse.hoisted could end up in
a state where it was null, and which caused errors and general unpleasantness.

Instead, we can just call the `cook` function that is already exported
from discourse-markdown-it, that takes care of what we did previously
plus the hoisting.

There is a companion chat commit that adds tests for this, there are
no custom markdown engine usages in core to test with.
2022-02-28 07:54:55 +10:00
Jarek Radosz
d432e402a2
DEV: Update sinon (#16056) 2022-02-26 13:50:19 +01:00
Jarek Radosz
b05fddaa7c
DEV: Clean up the decorators file (#16058) 2022-02-26 02:33:25 +01:00
Krzysztof Kotlarek
3e5fb90ce6
FIX: new indirectly muted category (#16043)
When a new category is created and the parent category is muted or indirectly muted, the new category should be indirectly muted as well.
2022-02-25 13:08:22 +11:00
Jeff Wong
d1bdb6c65d
FEATURE: upload an avatar option for uploading avatars with selectable avatars (#15878)
* FEATURE: upload an avatar option for uploading avatars with selectable avatars

Allow staff or users at or above a trust level to upload avatars even when the site
has selectable avatars enabled.

Everyone can still pick from the list of avatars. The option to upload is shown
below the selectable avatar list.

refactored boolean site setting into an enum with the following values:

disabled: No selectable avatars enabled (default)
everyone: Show selectable avatars, and allow everyone to upload custom avatars
tl1: Show selectable avatars, but require tl1+ and staff to upload custom avatars
tl2: Show selectable avatars, but require tl2+ and staff to upload custom avatars
tl3: Show selectable avatars, but require tl3+ and staff to upload custom avatars
tl4: Show selectable avatars, but require tl4 and staff to upload custom avatars
staff: Show selectable avatars, but only allow staff to upload custom avatars
no_one: Show selectable avatars. No users can upload custom avatars

Co-authored-by: Régis Hanol <regis@hanol.fr>
2022-02-24 12:57:39 -08:00
Roman Rizzi
00bb5f3a9d
FIX: Use the category's text-only description in the category-chooser (#15735)
The category description is derived from a topic's cooked text and contains HTML elements. When we display it inside the category chooser in places like the composer, we don't want these elements to alter the component in any way.

Context: https://meta.discourse.org/t/some-html-tags-not-stripped-from-category-description/215017
2022-02-24 12:14:24 -03:00
Bianca Nenciu
e0b683f98e
FEATURE: Automatically select share URL (#16025)
The URL will be selected for easy copying immediately after the share
popup shows up.
2022-02-24 12:21:20 +11:00
Kris
582091a698
DEV: allow min_posts to be automatically passed (#16042) 2022-02-23 20:06:17 -05:00
Bianca Nenciu
82a9109ae3
FEATURE: Show topic visited state on search page (#15994)
The visited state used user's history instead of the data from the
server.
2022-02-23 21:24:26 +02:00
Jarek Radosz
44824bfa3d
DEV: Don't check this.element in @afterRender (#16033)
This would allow to use the decorator in tag-less components and in controllers.
2022-02-23 11:35:20 +01:00
Osama Sayegh
586d572e05
FIX: Don't advance draft sequence when editing topic title (#16002)
This commit handles the edge case where a draft is lost with no warnings if the user edits the title (or category/tags) of a topic while they're replying.to the same topic. Repro steps are as follows:

1. Start replying to a topic and type enough to get a draft saved.
2. Scroll up to the topic title and click the pencil icon next to the topic title, change the title, category and/or tags, and then save the changes.
3. Reload the page and you'll see that the draft is gone.

This happens because we only allow 1 draft per topic per user and when you edit the title of a topic that you're replying to, from the server perspective it'll look like as if you've submitted your reply so it will advance the draft sequence for the topic and delete the draft.

The fix in this commit makes `PostRevisor` skip advancing the draft sequence when a topic's title is edited using the pencil button next to the title.

Internal ticket: t60854.

Co-authored-by: Robin Ward <robin.ward@gmail.com>
2022-02-23 10:39:54 +03:00
Osama Sayegh
799e27d15d
FIX: Respect text direction inside quotes (#16004)
Meta topic: https://meta.discourse.org/t/rtl-direction-is-broken-in-quotes/217639?u=osama.

Posts in Discourse are by default always rendered in the same direction as the rest of site, for example if the site is RTL, a post in that site is always rendered RTL even if it's made of an LTR language entirely. However, this behavior can be changed by enabling the `support mixed text direction` site setting which makes our posts rendering engine consider each "paragraph" in the post and apply an appropriate direction (using the `dir` attribute) on it based on its content/language.

I put paragraph in quotes because technically we only loop through the immediate children of the HTML element that contains the post cooked HTML and do this direction check on them. Most of the time the immediate children are actually paragraphs, but not always. The direction of an element is determined by checking its `textContent` property against a regular expression that checks all characters are RTL characters and based on the regular expression result the `dir` attribute is set on the element.

This technique doesn't work so well on quotes because they may contain multiple paragraphs which may be in different languages/directions. For example: if a site's language is Arabic (RTL language) and the `support mixed text direction` setting is enabled, regular paragraphs outside quotes are rendered as expected with the right direction depending on the paragraph's language. However, paragraphs within a quote are all (incorrectly) rendered in a single direction, LTR or RTL, regardless of whether they're of different languages/directions or not.

The reason for this is that when we're determining the direction for the quote, it's considered as one element and the direction is set on the whole quote. But for complex quotes that contain mixed paragraphs, we need to be more surgical and apply direction on individual paragraphs/elements within the quote.

This commit adds special handling for quotes to ensure that:

* the quote top bar (the avatar plus the chevron and arrow) always match the site direction
* each immediate paragraph (`<p>` elements) under `<blockquote>` in the quote gets a direction based on its content.

For before/after screenshots, see PR #16004.
2022-02-23 10:26:45 +03:00
Martin Brennan
599a72768c
DEV: Add force_quote_link option to PrettyText (#16034)
This option will make it so the [quote] bbcode will always
include the HTML link to the quoted post, even if a topic_id
is not provided in the PrettyText#cook options. This is so
[quote] bbcode can be used in other places, like chat messages,
that always need the link and do not have an "off-topic" ID
to use.
2022-02-23 16:13:46 +10:00
David Taylor
3712c958fa
PERF: Only subscribe to /new when logged in (#16028)
The 'new' tab doesn't exist for anonymous users. Every 'new' topic also publishes a message on the `/latest` channel, so the blue banner at the top of the topic-list will still be functional
2022-02-22 19:35:59 +00:00
Ayke Halder
e4d10a1f5f
DEV: cleanup is-loading state of d-button component (#16012)
* DEV: remove duplicate code in button component template

* DEV: refactor is-loading state of d-button component

Before this change on initialisation `forceDisabled` is set `false` and then might change to `undefined` - depending on the use of the button component. This change ensures a boolean value for `forceDisabled`.

The added test works with and without the new change. The test is added as it represents the default use case for most buttons.
2022-02-22 12:40:47 -05:00
David Taylor
f6c852bf8e
PERF: Use a shared message for replies to tracked topics (#16022)
Previously we were publishing one messagebus message per user which was 'tracking' a topic. On large sites, this can easily be 1000+ messages. The important information in the message is common between all users, so we can manage with a single message on a shared channel, which will be much more efficient.

For user-specific values (notification_level and last_read_post_number), the JS app can infer values which are 'good enough'. Correct values will be loaded as soon as a topic-list containing the topic is visited.
2022-02-22 15:27:46 +00:00
Ayke Halder
e392fc56fa
DEV: refactor components to use discourse-computed decorator without reference to this (#16011)
Most computed properties are already implemented this way. These changes make the missing ones also use it.
2022-02-22 13:45:38 +01:00
Dan Ungureanu
685d186351
FIX: Show invite button if users can be invited (#16014)
This used to be shown regardless new users could be invited to the
forum.
2022-02-21 23:57:17 +02:00
Bianca Nenciu
90c3695ab0
FEATURE: Rename Reset Read bulk action to Defer (#15972)
It is enabled only if defer is enabled in user options too and if the
button shows up in the topic's footer.
2022-02-21 22:45:01 +02:00
Bianca Nenciu
ae1d2d957f
FEATURE: Replace share post popup with share modal (#15875)
This uniformizes the topic share modal and the post link popup. It also
introduces a new feature which can notify the user of a post.
2022-02-21 22:14:28 +02:00
Bianca Nenciu
953d36b788
FIX: Allow none category if default is none (#15995)
Even if the site setting's default value is none by default, it did not
allow admins to select it again after it was changed.
2022-02-21 18:15:55 +02:00
David Taylor
8e86d8a5dd
DEV: Enable the use of Glimmer components (#15999)
This will only work under Ember CLI, and a small hack is required to make the Resolver work in development mode. In future, when we move to a more recent version of the Ember Resolver, this hack will not be required.
2022-02-21 09:44:48 +00:00
David Taylor
87b98e2862
FIX: Ensure category/tag classes are added and removed correctly (#16003)
The use of a `/g` regex was causing some surprising, seemingly random, behavior. (https://stackoverflow.com/a/1520853/5913559)

There was also a known issue which would cause inconsistent class behavior when running the 'loading slider' theme component.

This commit takes the opportunity to refactor the component to remove the use of observers and remove the regex-based class parsing.
2022-02-21 09:42:39 +00:00
Kris
cd616900e5
FEATURE: allow moderators to bulk change ownership (#15997) 2022-02-18 14:28:27 -05:00
Vinoth Kannan
b9d943220d
UX: display post count badge even when user has only two posts. (#15990)
Previously, it only displayed the badge when a user has 3 or more posts.
2022-02-18 09:03:32 +05:30
Martin Brennan
6a5ef27eaa
DEV: Move text area surround code out of d-editor (#15950)
This commit moves _getMultilineContents and _applySurround into
TextareaTextManipulation, so other text area components using
that mixin can benefit from them (such as the chat composer).

It also creates a public function wrapper for many TextareaTextManipulation
functions that should not have underscore prefixes because they are
used outside the file. Will make follow-up PRs for each plugin/theme using
those functions then a final follow-up core PR to fix these up.
2022-02-18 08:56:37 +10:00
Vinoth Kannan
45c404a6c7
FIX: update can_see_members attribute after leaving a group. (#15982)
After leaving a group, it is trying to reload its member list. Previously, when the members_visibility_level attribute has a value of 2 or higher, it displayed an error popup since the can_see_members attribute was not updated.
2022-02-17 23:07:59 +05:30
Penar Musaraj
9249e98697
UX: Change styling of admin bulk invite button (#15981) 2022-02-17 17:10:08 +01:00
Osama Sayegh
dd6ec65061
FEATURE: Centralized 2FA page (#15377)
2FA support in Discourse was added and grown gradually over the years: we first
added support for TOTP for logins, then we implemented backup codes, and last
but not least, security keys. 2FA usage was initially limited to logging in,
but it has been expanded and we now require 2FA for risky actions such as
adding a new admin to the site.

As a result of this gradual growth of the 2FA system, technical debt has
accumulated to the point where it has become difficult to require 2FA for more
actions. We now have 5 different 2FA UI implementations and each one has to
support all 3 2FA methods (TOTP, backup codes, and security keys) which makes
it difficult to maintain a consistent UX for these different implementations.
Moreover, there is a lot of repeated logic in the server-side code behind these
5 UI implementations which hinders maintainability even more.

This commit is the first step towards repaying the technical debt: it builds a
system that centralizes as much as possible of the 2FA server-side logic and
UI. The 2 main components of this system are:

1. A dedicated page for 2FA with support for all 3 methods.
2. A reusable server-side class that centralizes the 2FA logic (the
`SecondFactor::AuthManager` class).

From a top-level view, the 2FA flow in this new system looks like this:

1. User initiates an action that requires 2FA;

2. Server is aware that 2FA is required for this action, so it redirects the
user to the 2FA page if the user has a 2FA method, otherwise the action is
performed.

3. User submits the 2FA form on the page;

4. Server validates the 2FA and if it's successful, the action is performed and
the user is redirected to the previous page.

A more technically-detailed explanation/documentation of the new system is
available as a comment at the top of the `lib/second_factor/auth_manager.rb`
file. Please note that the details are not set in stone and will likely change
in the future, so please don't use the system in your plugins yet.

Since this is a new system that needs to be tested, we've decided to migrate
only the 2FA for adding a new admin to the new system at this time (in this
commit). Our plan is to gradually migrate the remaining 2FA implementations to
the new system.

For screenshots of the 2FA page, see PR #15377 on GitHub.
2022-02-17 12:12:59 +03:00
Krzysztof Kotlarek
a7d43cf1ec
FEATURE: mute subcategory when parent category is muted (#15966)
When parent category or grandparent category is muted, then category should be muted as well.

Still, it can be overridden by setting individual subcategory notification level.

CategoryUser record is not created, mute for subcategories is purely virtual.
2022-02-17 00:42:02 +01:00
Dan Ungureanu
effbd6d3e4
FEATURE: Show error if invite to topic is invalid (#15959)
This can happen if the topic to which a user is invited is in a private
category and the user was not invited to one of the groups that can see
that specific category.

This used to be a warning and this commit makes it an error.
2022-02-16 18:35:02 +02:00
David Taylor
a170c8e708
DEV: Allow access to ember-computed-decorators under ember-cli (#15945)
This was deprecated in Discourse 2.4, but no end version was put on the deprecation. Many plugins/themes are still using it. This commit restores it under ember-cli so that it does not block the Ember CLI rollout, and can be removed in a future commit.
2022-02-16 11:16:28 +00:00
Bianca Nenciu
add4b74e08
FIX: Load short upload URLs only once (#15918)
Loading did not work when it was used for multiple posts. Only the
short URLs from the first post were loaded.
2022-02-16 08:57:20 +02:00
Martin Brennan
2d30dd439f
DEV: Add chat_quoted notification type (#15968)
This is needed for the notification sent when quoting
chat messages inside a post.
2022-02-16 15:22:08 +10:00
Kris
af73405958
UX: control whitespace on categories topic list (#15965) 2022-02-15 20:01:23 -05:00
Gerhard Schlager
c6265eec6b
UX: Use autocomplete="off" for date-picker (#15963) 2022-02-16 09:37:51 +11:00
Mark VanLandingham
2644813c99
FIX: Tag show - hide no topics footer until there are no topics (#15756) 2022-02-15 08:45:55 -06:00
David Taylor
ebb5c1ff4d
DEV: Prefix deprecation notices with plugin name (#15942)
To make this possible in development mode, the `sourceURL=` implementation needs to include something plugin-specific. This has no effect on production.

The asset version is bumped in order to trigger a re-compilation of plugin JS assets.
2022-02-14 20:13:52 +00:00
janzenisaac
ee050e5063
DEV: Make user card non-clickable for anon users: (#15938)
Make name / avatar non-clickable for anon users
2022-02-14 11:25:41 -06:00
Dan Ungureanu
efb584e32f
FEATURE: Use new topic-chooser for invite modal (#15884)
The old choose-topic component did not have the same style as the rest
of the create invite modal and was not very suitable to use in the modal
because it introduced the search results in modal's body.

The new topic-chooser is built using select-kit and provides a more
polished user experience.
2022-02-14 13:43:52 +02:00
David Taylor
a01b1dd648
PERF: Update ember-auto-import and webpack (#15919)
This makes a small improvement to 'cold cache' ember-cli build times, and a large improvement to 'warm cache' build times

The ember-auto-import update means that vendor is now split into multiple files for efficiency. These are named `chunk.*`, and should be included immediately after the `vendor.js` file. This commit also updates the rails app to render script tags for these chunks.

This change was previously merged, and caused memory-related errors on RAM-constrained machines. This was because Webpack 5 switches from multiple worker processes to a single multi-threaded process. This meant that it was hitting node's default heap size limit (~500mb on a 1GB RAM server). Discourse's standard install procedure recommends adding 2GB swap to 1GB-RAM machines, so we can afford to override's Node's default via the `--max-old-space-size` flag.
2022-02-14 11:21:39 +00:00
David Taylor
c4e34047a1 DEV: Prefix deprecation notices and api warnings with theme name/id 2022-02-14 10:11:19 +00:00
David Taylor
af24c10314 DEV: Improve theme error handling UX
- Update UI to improve contrast
- Make it clear that the message is only shown to administrators
- Add theme name and id to the console output
- Parse the error backtrace to identify the theme-id for post-decoration errors
- Improve console output to include the theme name / URL
- Add `?safe_mode=no_custom` to the admin panel link, so that it will work even if the theme is causing the site to break
2022-02-14 10:11:19 +00:00
Martin Brennan
4b4f2330da
DEV: Expand UploadMarkdown generation capabilities (#15930)
The chat quoting mechanism will need to be able to generate
markdown for all kinds of uploads. The UploadMarkdown class
was missing generation for video and audio uploads. This
commit adds that in, and also expands the server-side regex
recognition of FileHelper types to match those in uploads.js,
and adds a spec for UploadMarkdown
2022-02-14 15:48:27 +10:00
Alan Guo Xiang Tan
76aadc67bb
Revert "DEV: Prefix deprecation notices and api warnings with theme name/id" (#15902)
This reverts commit a4ff69bd99.

Follow-up to 8e5b945b0f
2022-02-11 11:37:12 +08:00
Alan Guo Xiang Tan
8e5b945b0f
Revert "DEV: Improve theme error handling UX" (#15900)
`PrettyText.cook` is breaking on some sites. Revert for now while we
investigate.

This reverts commit c81d369ab6.
2022-02-11 11:30:36 +08:00
Krzysztof Kotlarek
51a31f7835
FIX: subcategory filter limits results (#15655)
When the subcategory dropdown is searched, it should only display categories belonging to the same parent category.
2022-02-11 11:24:01 +11:00
Martin Brennan
e814f77eaa
DEV: Allow focusComposer to reply to existing topic (#15896)
Another use case for focusComposer() is if the user is
already inside a topic but another component (such as the
floating chat window) needs to open the composer. This
commit also fixes the appendText option to only prepend
2 new lines if there is text before the text to be appended.

Follow up 7850ee318f
2022-02-11 10:16:06 +10:00
David Taylor
a4ff69bd99 DEV: Prefix deprecation notices and api warnings with theme name/id 2022-02-10 22:56:11 +00:00
David Taylor
c81d369ab6 DEV: Improve theme error handling UX
- Update UI to improve contrast
- Make it clear that the message is only shown to administrators
- Add theme name and id to the console output
- Parse the error backtrace to identify the theme-id for post-decoration errors
- Improve console output to include the theme name / URL
- Add `?safe_mode=no_custom` to the admin panel link, so that it will work even if the theme is causing the site to break
2022-02-10 22:56:11 +00:00
Kris
35697c6076
Add classes to user stats, move likes received (#15892) 2022-02-10 16:18:55 -05:00
Bianca Nenciu
3170577ee1
FIX: Defer upload extension check for iOS (#15890)
accept HTML attribute is not fully supported on iOS yet and can contain
only MIME types. This changes the input to allow all files and the
extension check is performed later in JavaScript.
2022-02-10 21:48:22 +02:00
Krzysztof Kotlarek
9610aea189
FEATURE: cache last post number (#15772)
Instead of relaying on /timings request, we should cache last read post number. That should protect from having incorrect unread counter when going back to topic list.

This additional cache is very temporary as once /timings request is finished, serializer will have a correct result.

Simplified flow is:
1. Store in cache information about last seen post number before /timings request is sent
2. When getting back to topic list compare value of last seen post number returned by /latest request and information in cache. If cache number is higher, than use it instead of information returned by /latest. In addition delete cache item as there is high chance that `/timings` request already finished.
3. Optionally, delete cache when timings request is done and topic list was not yet visited.

Keeping cache reasonably small should not affect performance.
2022-02-10 13:09:28 +11:00
Krzysztof Kotlarek
d4be987cc8
FIX: topic tracking state for tags (#15623)
TopicTrackingState should correctly set filterCategory and filterTag for all different configurations.

When filterTag exists and new_topic message arrives, it ensures that filterTag is included in payload tags

If filterTag is part of payload tags, message that new topics are available is displayed and after click, new topics are included in the list.
2022-02-09 22:53:08 +01:00
Jarek Radosz
45572f9431
DEV: Deprecate assert.not() (#15595)
Use QUnit's standard `assert.notOk()` instead.
2022-02-09 18:49:05 +01:00
Vinoth Kannan
1f30bacb65
FIX: use prev_period data if prev30Days value is not available. (#15867)
Previously, reports of likes and flags doesn't include the 30 days trend icon and title.
2022-02-09 22:09:33 +05:30
Ayke Halder
5ff3a9c4bb
DEV: add native lazy loading for emojis (#15830) 2022-02-09 12:18:59 +01:00
Joffrey JAFFEUX
b3ecf00c98
DEV: adds initial support for custom blocks using code fencing (#15743)
Allows to write custom code blocks:

```
   ```mermaid height=200,foo=bar
   test
   ```
```

Which will then get converted to:

```
<pre data-code-wrap="mermaid" data-code-height="200" data-code-foo="bar">
  <code class="lang-nohighlight">
    test
  </code>
</pre>
```
2022-02-09 11:23:44 +01:00
Martin Brennan
c1ad9c3276
DEV: Make clipboardCopy util available for import (#15874)
We need this in other places, this commit moves clipboardCopy
to the utilities.js lib. Had to remove use of Promise as well because
lib/utilities cannot import it, otherwise it will cause a mini racer error.
2022-02-09 16:11:41 +10:00
Martin Brennan
7850ee318f
DEV: Add focusComposer to composer controller (#15872)
This commit adds a new helpful function to the composer controller
which can be used to focus the composer and insert text, regardless
of whether the consumer knows whether the composer is open or has
a draft. This is good for cases where an action needs to copy text
to the composer or open it with text after navigating to a URL.

The inspiration for this addition is the discourse-chat plugin,
which needs to be able to copy quoted markdown from the chat
and insert it into the composer, and unlike in the topic controller
we have no idea of the state of the composer from chat.
2022-02-09 15:25:03 +10:00
janzenisaac
8abc4a0fd6
Revert "DEV: Prioritize full name when setting active (#15820)" (#15869)
This reverts commit 5a93ce421d.
2022-02-08 13:25:19 -06:00
janzenisaac
5a93ce421d
DEV: Prioritize full name when setting active (#15820)
Prioritize full name in these places (when setting active):
See: https://meta.discourse.org/t/display-full-name-not-username-when-attributing-quote-or-reply/203533/6 for context

- Reply to post
- Composer reply to post
- Quoting
2022-02-08 08:37:20 -06:00
David Taylor
03b7d71827
DEV: Ensure that Discourse global is available for widget init (#15862)
Under ember-cli, we rely on the `ember-export-application-global` addon to make `window.Discourse` available. This happens in an initializer. Previously this inititalizer would run after `auto-load-modules`, and so any widget/helper modules would not be able to access it. This commit sets some `after` parameters on the `auto-load-modules` and `inject-objects` initializers to ensure that `export-application-global` is run first.
2022-02-08 10:45:36 +00:00
David Taylor
4cceb55621
Revert "PERF: Update ember-auto-import (#15814)" (#15854)
This reverts commit f4c6a61855 and a8325c9016

This update of ember-auto-import and webpack causes significantly higher memory use during rebuilds. This made ember-cli totally unusable on 1GB RAM / 2GB swap environments. We don't have a specific need for this upgrade right now, so reverting for now.
2022-02-07 22:41:07 +00:00
Penar Musaraj
e83d603bbc
DEV: Send message to DiscourseHub when dismissing (#15849) 2022-02-07 20:15:26 +01:00
David Taylor
cd460155aa
DEV: Add Ember-CLI backwards compatibility for Discourse.Site (#15847) 2022-02-07 18:39:34 +00:00
Penar Musaraj
45c00c72bd
FIX: Do not override mobile scroll on docked progress element (#15840) 2022-02-07 13:51:07 +01:00
Martin Brennan
357186ab7e
FIX: User option fields definition was being mutated on save (#15837)
In the commit d8bf2810ff we hoisted
the userOptionFields array to a module-level variable, but kept
the code inside save() the same. This causes an issue where if
save() is called twice on the same user with some array of user
option fields, the userOptionFields array is mutated, which means
the second save is likely not saving the fields intended.

This commit fixes the issue by not mutating the array. We cannot
change them into consts though, because we have an API to add more
items to the array.
2022-02-07 16:58:27 +10:00
Martin Brennan
0a738bd5bc
FEATURE: Allow sending group SMTP emails with from alias (#15687)
This commit allows group SMTP emails to be sent with a
different from email address that has been set up as an
alias in the email provider. Emails from the alias will
be grouped correctly using Message-IDs in the mail client,
and replies to the alias go into the correct group inbox.
2022-02-07 13:52:01 +10:00
Ayke Halder
81e175e6ba
FIX: allow native lazy loading attribute for quoted avatar image (#15834) 2022-02-07 09:28:26 +08:00
Alan Guo Xiang Tan
cc7a04afdc DEV: Improve test paths pattern for Ember CLI.
Ember tests follows a convention where test files have a postfix of
`-test.js`. This ensures that any files in the tests folder which
follows this pattern is included.
2022-02-07 09:22:15 +08:00
Andrei Prigorshnev
62029ec4eb
DEV: remove the includeMidFuture option on future-date-input (#15818)
This option was always on. Essentially, we set it only in two places and always use `|| true` with it.

Note that we're going to switch future-date-input-selector to another source of time shortcuts(https://github.com/discourse/discourse/blob/main/app/assets/javascripts/discourse/app/lib/time-shortcut.js) and also change its API to make it more customizable. Removing the includeMidFuture option is a part of that change.
2022-02-04 21:33:11 +04:00
Andrei Prigorshnev
778abb067f
FIX: Caret moves to a wrong position when uploading an image via toolbar (#15684)
When uploading an image, we change the uploading placeholder several times. Every time, we correct the position of the cursor after replacing. But we schedule repositioning of cursor to the afterRender queue in Ember Run Loop. As a result, sometimes we replace the placeholder several times but correct the cursor position only once at the end.

It just cannot work correctly with scheduling, we'll always be dealing with cumulative error. Removing scheduling fixes the problem.

Sadly, I cannot make the test work, I skipped it for now, going to give it another try later.
2022-02-04 18:26:48 +04:00
Penar Musaraj
d13117fa05
FEATURE: Select range in topic list with Shift + click (#15682) 2022-02-04 15:20:38 +01:00
Andrei Prigorshnev
c52e8ef8b6
DEV: dry up formatting of time options in time-shortcut-picker (#15810) 2022-02-04 17:18:21 +04:00
David Taylor
f4c6a61855
PERF: Update ember-auto-import (#15814)
This makes a small improvement to 'cold cache' ember-cli build times, and a large improvement to 'warm cache' build times

The ember-auto-import update means that vendor is now split into multiple files for efficiency. These are named `chunk.*`, and should be included immediately after the `vendor.js` file. This commit also updates the rails app to render script tags for these chunks
2022-02-04 11:00:51 +00:00
Martin Brennan
f3467ee673
FEATURE: Add requestCustomMarkdownCookFunction API (#15753)
This commit adds a requestCustomMarkdownCookFunction function
to the `helper` that is provided to custom markdown rules
via their `setup` function.

The way this works is that once the default markdown engine that
we use for cooking posts has been set up, we loop through all
of the callbacks registered by `requestCustomMarkdownCookFunction`
and call `_buildCustomMarkdownCookFunction`. This creates
a new markdown engine using many of the same settings as the
default one, but will allow for the following options to be
changed by the markdown rule requesting the custom function:

* featuresOverride - The markdown-it features to allow for the engine
* markdownItRules - The markdown-it rules to allow for the engine

After this engine is set up a render function which renders + sanitizes
the output is returned for use by the markdown rule.

The use case for this API is mainly for block BBCode markdown rules
which want to render their content with a limited subset of the
markdown features/rules. Our initial use case for this is chat message
quoting.

This commit also does some minor refactoring of discourse-markdown-it
to accommodate this new engine building.
2022-02-04 09:00:40 +10:00
Martin Brennan
9fc33d310b
FIX: Table pasting issues with uppy (#15787)
When changing to uppy for file uploads we forgot to add
these conditions to the paste event from 9c96511ec4

Basically, if you are pasting more than just a file (e.g. text,
html, rtf), then we should not handle the file and upload it, and
instead just paste in the text. This causes issues with spreadsheet
tools, that will copy the text representation and also an image
representation of cells to the user's clipboard.

This also moves the paste event for composer-upload-uppy to the
element found by the `editorClass` property, so it shares the paste
event with d-editor (via TextareaTextManipulation), which makes testing
this possible as the ember paste bindings are not picked up unless both
paste events are on the same element.
2022-02-04 08:45:55 +10:00
Keegan George
1485dab12e
FEATURE: Ability to re-order value lists (#15775)
Adds up and down buttons next to the inputs of value lists when there is more than 1 item present. This helps to re-order the items in the value lists if necessary.
2022-02-03 22:47:02 +01:00
janzenisaac
6e4af0e36f
DEV: update show social login logic (#15809)
Only display text if one or more social login options are enabled
2022-02-03 15:17:36 -06:00
Kris
b44950c3d9
DEV: new plugin outlet on user page (#15808) 2022-02-03 16:11:35 -05:00
Jordan Vidrine
5f322605c6
DEV: Add category-color variable (#15807) 2022-02-03 13:16:27 -06:00
janzenisaac
cffc2836cb
DEV: Don't allow users to immediately reinvite (#15722)
- Limit bulk re-invite to 1 time per day
- Move bulk invite by csv behind a site setting (hidden by default)
- Bump invite expiry from 30 -> 90 days

## Updates to rate_limiter
When limiting reinvites I found that **staff** are never limited in any way. So I updated the **rate_limiter** model to allow for a few things:
- add an optional param of `staff_limit`, which (when included and passed values, and the user passes `.staff?`) will override the default `max` & `secs` values and apply them to the user.
- in the case you **do** pass values to `staff_limit` but the user **does not** pass `staff?` the standard `max` & `secs` values will be applied to the user.

This should give us enough flexibility to 
1. continue to apply a strict rate limit to a standard user
2. but also apply a secondary (less strict) limit to staff
2022-02-03 13:07:40 -06:00
David Taylor
569fa8a135
DEV: Improve Ember module shims under Ember CLI (#15795) (#15806)
In our legacy environment, Ember RFC176 shims are included in `discourse-loader.js` which is part of the `vendor.js` bundle. This meant that the module shims were available as soon as the vendor.js asset was loaded.

Under Ember CLI, we were defining these shims in `discourse-boot.js`. This is loaded by the browser much later, and meant that the shims were not available to themes/plugins that call `require()` before Discourse has booted. This was causing errors under some circumstances.

This commit refactors the Ember CLI implementation so that the shims are included in the vendor.js bundle. This is done via an addon which leans on the ember-rfc176-data NPM package. This will ensure we have all the definitions, without the need for manual copy/paste.
2022-02-03 17:36:32 +00:00
David Taylor
c985f82174
Revert "PERF: Update ember-auto-import (#15695)" (#15805)
This reverts commit 76022132f7. This update introduced 'chunking' of vendored dependencies, which we don't support in the rails app.
2022-02-03 16:54:48 +00:00
David Taylor
ea37b30ab2
Revert "DEV: Improve Ember module shims under Ember CLI (#15795)" (#15803)
This reverts commit 7933278ef4. This isn't working in production, reverting pending investigations.
2022-02-03 16:13:33 +00:00
David Taylor
7933278ef4
DEV: Improve Ember module shims under Ember CLI (#15795)
In our legacy environment, Ember RFC176 shims are included in `discourse-loader.js` which is part of the `vendor.js` bundle. This meant that the module shims were available as soon as the vendor.js asset was loaded.

Under Ember CLI, we were defining these shims in `discourse-boot.js`. This is loaded by the browser much later, and meant that the shims were not available to themes/plugins that call `require()` before Discourse has booted. This was causing errors under some circumstances.

This commit refactors the Ember CLI implementation so that the shims are included in the vendor.js bundle. This is done via an addon which leans on the ember-rfc176-data NPM package. This will ensure we have all the definitions, without the need for manual copy/paste.
2022-02-03 12:57:57 +00:00
David Taylor
84c2c2f477
DEV: Refactor Site creation in tests (#15707)
Previously, `resetSite()` would immediately generate a new `Site` instance, and run all the initialization logic within the model. This included initializing Category objects.

This was problematic because `resetSite()` is called before any initializers have been run. That means that any modifications to the Site or Category classes would not have any effect on the already-initialized Site/Category instances.

This commit makes two main changes so so that the test environment is more production-like:

1. Update `resetSite` so that it simply stores the new data in the PreloadStore, and destroys the old Site instance. Initialization of a new site instance happens 'just in time' (normally during the `inject-discourse-objects` initializer)

2. Update the `helperContext` in tests to use getters. This avoids the need to look up `Site.current()` before initializers have run

It also makes a minor adjustment to one test which was relying on a side-effect of the previous behavior.

This should resolve the failing tests for discourse-category-expert under Ember-CLI: https://github.com/discourse/discourse-category-experts/pull/69
2022-02-03 10:02:47 +00:00
David Taylor
76022132f7
PERF: Update ember-auto-import (#15695)
This makes a small improvement to 'cold cache' ember-cli build times, and a large improvement to 'warm cache' build times
2022-02-03 10:01:59 +00:00
Penar Musaraj
7d5d2bf13e
A11Y: Use autocomplete=off more widely (#15780) 2022-02-03 16:16:49 +11:00
Natalie Tay
23a8341b28
FEATURE: Validate domain settings for blocked_onebox_domain only (#15754)
We want to prevent the user from adding ? or * minimally
when setting domains in sitesettings
2022-02-03 11:26:53 +08:00
Penar Musaraj
febe997bee
FIX: Regression in timezone name localizations (#15761)
This also switches to using the NPM package for better build stability. And adds a clearer label in the alert that is displayed to show your current timezone (when changing timezones).
2022-02-02 23:41:42 +01:00
Jordan Vidrine
c23ccd87f8
DEV: Add plugin outlet to topic-list-item.hbs (#15776) 2022-02-02 15:50:14 -06:00
Robin Ward
6f25f17360
DEV: Revisit skipped tests (#15769)
* Some are no longer flaky or easily fixed

* Some are out of date or test things we can't do accurately (scroll
  position) and are removed.

* Unwinds some uppy tests and makes sure all promises and runloops are
  resolved.

Everything has been run in legacy/ember cli multiple times to ensure no
obvious suite regressions.
2022-02-02 12:09:03 -05:00
Krzysztof Kotlarek
a1adc13125
FIX: aria label for popup-input-tip (#15724)
popup-input-tip is used for composer validation.
Aria label is essential to for accessibility.
Also, HTML tags have to be removed
2022-02-02 16:23:56 +11:00
Krzysztof Kotlarek
bb01563682
FIX: post mover validation color and message (#15688)
When the record is not saved, we should display a proper message.
One potential reason can be plugins for example discourse-calendar is specifying that only first post can contain event
2022-02-02 16:22:52 +11:00
tshenry
3da6f6b717
FEATURE: New plugin outlets for categories-boxes template (#15771)
Adds new category-box-before-each-box and category-box-after-each-box outlets to improve flexibility with customizations.
2022-02-01 19:53:02 -08:00
Jarek Radosz
6f8c91254e
FEATURE: Partial match aliases in emoji filter (#15613) 2022-02-01 22:36:48 +01:00
Jarek Radosz
7806857841
UX: Highlight "Users" link when on adminUser path (#15739) 2022-02-01 21:32:48 +01:00
Jarek Radosz
2e74f1dd28
DEV: Refactor clean-dom (#15609)
* Move it out of page-tracking initializer
* Don't use jQuery anymore
* Remove `activeElement` IE10 bug workaround
* Remove `$("html").data("hide-dropdown")` support; it dates back to the "initial" commit (68ad545f0f/app/assets/javascripts/discourse/routes/discourse_route.js.coffee (L26-L27)) and I don't think it was being used for years now
2022-02-01 19:29:53 +01:00
Joffrey JAFFEUX
c0e2a01d9f
PERF: attempts to resort to compute markdown in less cases (#15762) 2022-02-01 15:28:50 +01:00
Rafael dos Santos Silva
3f694e4ab5
FEATURE: Use native color-picker (#15748) 2022-02-01 11:18:13 -03:00
Andrei Prigorshnev
810391f474
FIX: some options on the topic timer modal weren't timezone aware (#15749)
These options weren't timezone aware:
- Two Weeks
- Six Months
2022-02-01 16:55:26 +04:00
Andrei Prigorshnev
cd2e7d5436
FEATURE: show the this weekend option on the bookmark modal (#15755) 2022-02-01 16:10:09 +04:00
Joffrey JAFFEUX
bb9015e811
DEV: uses innerHTML to decide if fast-edit is possible (#15760)
We don't need raw to decide if we can fast edit or not, we will fetch the raw later when we do the replacement, but this step can be done directly from innerHTML.
2022-02-01 11:58:04 +01:00
Joffrey JAFFEUX
c46b55dc3b
PERF: prevents any fast edit work if you can't edit (#15759) 2022-02-01 11:28:07 +01:00
Penar Musaraj
48cf5e2fbc
A11Y: Use autocomplete="off" for composer title (#15758) 2022-02-01 10:08:58 +01:00
Robin Ward
e3c5a40432
DEV: Clean up skipped tests (#15747)
Many of the tests work now that other, general fixes have been made.
I've deleted some that seem to have lost functionality.
2022-01-31 15:31:13 -05:00
Andrei Prigorshnev
18116433ee
FIX: show the Next Monday label instead of Monday on Sundays (#15745) 2022-01-31 15:15:20 +04:00
Penar Musaraj
30454b3f27
UX: try select-kit autocomplete Chrome fix (#15752) 2022-01-31 15:35:51 +11:00
Andrei Prigorshnev
5cce39278a
DEV: remove unused function in d-editor (#15680) 2022-01-28 17:12:58 +04:00
David Taylor
fe1e66ba9d
DEV: Add backwards-compat for SiteSettings/User globals in ember-cli (#15719) 2022-01-28 11:31:19 +00:00
Martin Brennan
0b8d0a14d7
DEV: Add markdown_additional_options to Site (#15738)
Sometimes plugins need to have additional data or options available
when rendering custom markdown features/rules that are not available
on the default opts.discourse object. These additional options should
be namespaced to the plugin adding them.

```
Site.markdown_additional_options["chat"] = { limited_pretty_text_markdown_rules: [] }
```

These are passed down to markdown rules on opts.discourse.additionalOptions.

The main motivation for adding this is the chat plugin, which currently stores
chat_pretty_text_features and chat_pretty_text_markdown_rules on
the Site object via additions to the serializer, and the Site object is
not accessible to import via markdown rules (either through
Site.current() or through container.lookup). So, to have this working
for both front + backend code, we need to attach these additional options
from the Site object onto the markdown options object.
2022-01-28 13:02:02 +10:00
Martin Brennan
68fe6903f7
DEV: Remove jQuery UI vendor dependencies (#15700)
We no longer use jQuery UI for anything since getting
rid of jQuery file uploader in 667a8a63b3,
so we can safely remove these now.
2022-01-28 11:21:59 +11:00
Robin Ward
5c694e62ba Update app/assets/javascripts/discourse/tests/setup-tests.js
Co-authored-by: Jarek Radosz <jradosz@gmail.com>
2022-01-27 16:37:48 -05:00
Robin Ward
3350657553 DEV: Clean up HTML state between tests
A bunch of tests were leaving leftovers in the DOM like class names,
custom styles and scroll positions. This ensures they are cleared
between tests.
2022-01-27 16:37:48 -05:00
Robin Ward
14d31417de Revert "Revert "DEV: Run Ember CLI tests in random order" (#15717)"
The worst of the flaky tests should be fixed now, so let's re-enable
this.
2022-01-27 12:22:20 -05:00
Alan Guo Xiang Tan
09ec0ce744 DEV: Fix typo in comment. 2022-01-27 14:58:11 +08:00
Robin Ward
a560f9d44b FIX: This was causing a flaky test in Ember CLI
The path should be `/topics/bulk` not `topics/bulk` (leading slash.)
2022-01-26 14:53:25 -05:00
David Taylor
2464839cbf
Revert "DEV: Run Ember CLI tests in random order" (#15717)
This reverts commit f43bba8d59.

Adding randomness has introduced a lot of flakiness in our ember-cli tests. We should fix those issues at the source. However, given the upcoming stable release, this randomness has been reverted so that the stable release includes a stable test suite. Having a stable test suite on stable will make backporting future commits much easier.
2022-01-26 15:30:03 +00:00
Dan Ungureanu
f5b94f152f
FIX: Allow staff to reset passwords by username (#15709)
When staff visits the user profile of another user, the `email` field
in the model is empty. In this case, staff cannot send the reset email
password because nothing is passed in the `login` field.

This commit changes the behavior for staff users to allow resetting
password by username instead.
2022-01-26 10:39:58 +02:00
Robin Ward
f43bba8d59 DEV: Run Ember CLI tests in random order
In browser this uses the `seed` config, in ember exam it adds `--random`
as a parameter.
2022-01-25 14:49:40 -05:00
Osama Sayegh
5dd8b827e8
DEV: Update fixture to fix tests (#15699)
Follow-up to a742952c8d.
2022-01-25 00:44:14 +03:00
Osama Sayegh
a742952c8d
FIX: Client should be able to route ID-less topic URLs (#15697)
The topic ID portion of the topic URL is optional in Discourse as long as the topic slug is unique across the site. If you navigate to a topic without the ID in the URL, Discourse will redirect you to the canonical version of the URL that includes the ID.

However, we have a now regression where the client app doesn't correctly handle ID-less topic URLs displays an error message when the user clicks on such URL. The regression was introduced b537d591b3 when we switched from `DiscourseURL.routeTo` to using Ember's router to perform the redirecting to the canonical version of the URL, but the problem is that the canonical version comes from the server and it contains the hostname which the Ember router doesn't understand because it expects a relative URL.

This PR fixes the problem by constructing a relative URL that contains the topic slug and ID and passing that to the Ember route.
2022-01-24 23:19:35 +03:00
Andrei Prigorshnev
cd68279f5c
DEV: use query() instead of queryAll() in tests (#15681) 2022-01-24 11:27:58 +11:00
Penar Musaraj
1f2226270e
FIX: Restore outlet in mobile views (#15683) 2022-01-23 18:41:01 +01:00
Robin Ward
78852e9754 FIX: Tests should never cloak posts
Depending on the load order of modules, the post cloaking code might
not be disabled properly in test mode, which results in flakey failures.
2022-01-21 14:32:26 -05:00
Bianca Nenciu
3bb1cd5c4d
FIX: Select topics instead of posts (#15674)
A code error caused post objects to be added to the selected array.
2022-01-21 19:52:09 +02:00
Dan Ungureanu
984089c94a
DEV: Add test for avatar-uploader (#15633)
Follow up to 64b089072a.
2022-01-21 19:51:24 +02:00
Dan Ungureanu
d0f4f408af
DEV: Simplify emoji-uploader tests (#15672)
Removes one layer of indirection in the tests. `emoji-uploader`'s
`uploadDone` can call the test handler directly without going through
an additional action method.
2022-01-21 19:51:04 +02:00
Robin Ward
d28808e866 FIX: The service observer was using this incorrectly
It was pointing at nothing due to context.
2022-01-20 16:51:36 -05:00
Régis Hanol
a582c49601
FIX: possible ReDOS in markdown newline rule (#15646)
Backport ffc49ab46b
2022-01-20 22:32:01 +01:00
Robin Ward
224f0a2655 DEV: This ensures that teardowns are executed if initializers are run
It does this by creating a new initializer that runs every time the app
is booted to track the current test. Then after each test, we see if the
app needs to be torn down.
2022-01-20 16:23:54 -05:00
Robin Ward
2dc0f36e07 DEV: A bunch of tests (like controller) weren't cleaning up
This creates a helper function with all the cleanup tasks we need to do
after tests, then makes sure to call it after tests that previously
weren't.

This fixes a lot of flakey tests.
2022-01-20 11:58:58 -05:00
Joffrey JAFFEUX
2426e3510d
FIX: correctly access last poster username (#15661)
Testing this is kinda complicated ATM (especially mobile template with hbr) , this is a component we should definitely aim to test very extensively when we move away from hbr templates.
2022-01-20 17:27:14 +01:00
Kris
1d02b9728d
A11Y: tag should be "role" not "aria-role" (#15653) 2022-01-20 09:58:32 -05:00
Kris
6a48106ed4
A11Y: do not use duplicate IDs (#15654) 2022-01-20 08:58:08 -05:00
Dan Ungureanu
5b7bddf966
FIX: Prefer email when resetting password (#15650)
The UI used to request a password reset by username when the user was
logged in. This did not work when hide_email_already_taken site setting
was enabled, which disables the lookup-by-username functionality.

This commit also introduces a check to ensure that the parameter is an
email when hide_email_already_taken is enabled as the single allowed
type is email (no usernames are allowed).
2022-01-20 10:04:45 +02:00
Bianca Nenciu
4951900bbc
FEATURE: Store dismissed state of topic nav popups (#15570)
The dismissed state will be stored between sessions if popupId
attribute is present.
2022-01-19 16:20:05 +02:00
Natalie Tay
3050fe893b
DEV: Quick fix to flaky test (#15644)
We know that the real problem has got to do with cloaking (/t/10298), but while we find out precisely why, here's a quick fix.

Similar to #15627
2022-01-19 11:23:35 +08:00
David Taylor
2d67315c32
FIX: Disable service worker proxying in chrome 97-97.0.4692 (#15638)
https://bugs.chromium.org/p/chromium/issues/detail?id=1286367
2022-01-18 19:41:25 +00:00
Mark VanLandingham
fcc80137ce
DEV: Add chat_group_mention notification type (#15616) 2022-01-18 08:26:27 -06:00
Roman Rizzi
5ee31cbf7d
FIX: Mark invites flash messages as HTML safe. (#15539)
* FIX: Mark invites flash messages as HTML safe.
This change should be safe as all user inputs included in the errors are sanitized before sending it back to the client.

Context: https://meta.discourse.org/t/html-tags-are-explicit-after-latest-update/214220

* If somebody adds a new error message that includes user input and doesn't sanitize it, using html-safe suddenly becomes unsafe again. As an extra layer of protection, we make the client sanitize the error message received from the backend.

* Escape user input instead of sanitizing
2022-01-18 09:38:31 -03:00
David Taylor
7329b766cb
FIX: Ensure floating quote button is not positioned under sidebar (#15634)
If themes/plugins introduce a sidebar on the left of the screen, the quote button would sometimes be positioned underneath. This commit ensures that the positioning logic keeps the floating buttons within the width of `.topic-area`
2022-01-18 12:05:36 +00:00
David Taylor
b725b7f1fa
FIX: Quick-quote on Safari (#15631)
Some safari-specific logic was inadvertently removed during the refactoring in b2d45c59. This commit restores it. The logic requires some state, so the getRangeBoundaryRect helper has to be moved back into the Component class. The functional change in this commit is the three lines enclosed by `if (this.capabilities.isSafari) {`.
2022-01-18 11:44:58 +00:00
Dan Ungureanu
eb4ad958c1
FIX: Ensure method exists before calling (#15632)
`_perFileData` is not always defined and uploads failed when it is not.
2022-01-18 13:44:02 +02:00
David Taylor
235de5dd90
FIX: Add /session/sso service-worker workaround for chrome 97 (#15630)
Followup to 2278c7f82d. Depending on the site's SSO implementation, this route is also used as part of a redirect sequence and needs to be able to set cookies.

Chrome bug reference: https://bugs.chromium.org/p/chromium/issues/detail?id=1286367
2022-01-18 11:27:01 +00:00
Natalie Tay
f2902d3830
FIX: Attempt to fix flaky test by using a shorter topic (#15627)
As part of /t/10298, try to remove the first flaky test in the list.

One finding is that the /t/280 topic has a very long post stream, so that may have caused some delay when rendering the topic. One way is to wait for the first expected element to load, but that doesn't scale well given how many waits we will need to add. So I chose to render a shorter topic instead.
2022-01-18 19:22:49 +08:00
David Taylor
ff5a6edb71 DEV: Update plugin JS loading in Ember CLI testem environment
Previously we were adding `/assets/discourse/tests/core_plugin_tests.js` to the test html all the time. This works in development mode, but fails silently when using testem via the `ember test` CLI, because there is no proxy running.

This commit makes a few changes to fix this, and make it more useful:

- Only renders the plugin `<script>` when in development mode, or when `LOAD_PLUGINS=1` (matching core's behavior)
- Only loads plugin translations based on the same logic
- When running via testem, and the above conditions are met, testem is configured to proxy `core_plugin_tests.js` through to a rails server. (port based on the `UNICORN_PORT` env variable)
- Adds a descriptive error if the plugin `<script>` fails to load. This can happen if the rails server hasn't been started
- Updates the logic for testem browsers. Ember CLI always launches testem in "CI" mode, and we don't really want 3 browsers opening by default. Our CI explicitly specifies the 3 browsers at runtime
2022-01-18 10:16:29 +00:00
David Taylor
b2d45c592a
UX: Apply new quote-button spacing behavior to all mobile devices (#15608)
This expands cbf99f48 to apply to all mobile devices. It removes the old mobile positioning logic entirely, refactors the new system a little for robustness and readability, and removes some JQuery.

On Andoid, we also need to avoid the start selection handle. Therefore the logic for locating selection boundaries is abstracted into a function for easier re-use.
2022-01-18 10:13:49 +00:00
Natalie Tay
2bf3f6d549
DEV: Remove duplicate key in fixture (#15625) 2022-01-18 16:42:53 +08:00
Alan Guo Xiang Tan
0aacd63436 FIX: Autocomplete incorrectly replacing text if used mid sentence.
* Adds test to document the behavior we were seeing.
2022-01-18 14:25:39 +08:00
Andrei Prigorshnev
59d78dcfcc
DEV: Restore tests for inserting images as separate paragraphs (#15601) 2022-01-17 17:30:38 +04:00
Joffrey JAFFEUX
307742e3aa
FIX: correctly uses the name helper for selected content (#15610) 2022-01-17 12:18:43 +01:00
Joffrey JAFFEUX
655f28ca5e
UX: center emoji picker when limited space (#15607)
Previously the picker would attempt to avoid positioning itself hover textarea and could in limited width screen end up being out of screen.

This behavior would be even more probable on full screen mode where the textarea takes a lot of space.
2022-01-17 12:11:04 +01:00
Jarek Radosz
f2be253b7c
DEV: Fix a computed override in tests (#15596)
Re-lands #11190
2022-01-17 08:58:37 +01:00
Jarek Radosz
f0abad6998
DEV: Use a real image to fix a net::err in tests (#15597) 2022-01-17 08:57:52 +01:00
Robin Ward
e1fb020a63
DEV: Improve stability of Tests (#15591)
* The current evaluation of uppy promises is causing the entire suite to fail
if there's an exception. Instead of using `done` we use the simpler
pattern of returning the promise from the test to force Qunit to wait
until it's completed.

* In some browser conditions `/last.json` will be requested depending on the
particular scroll / performance. This causes the tests not to fail if
that is the case.

* Keyboard shortcuts were not being fully cleared between runs,
  resulting in tests failures.
2022-01-17 08:57:05 +01:00
Martin Brennan
bc8cb38081
DEV: Skip failing flaky tests for now (#15605)
At Sam's request, these are causing a lot of build
problems right now.
2022-01-17 15:43:38 +10:00
Martin Brennan
35343e7f91
FIX: Improve emoji upload UI (#15603)
This commit adds a hover effect for drag and drop in
the admin emoji uploader. It also changes the "Add New
Emoji" button to open the file selector; previously it
was useless because it was disabled unless a name was
entered (which is not even a requirement for the emoji)
and also it didn't actually do anything on click even
if it wasn't disabled.

Now we have a way of adding files without having to drag
and drop them, which is nice.

Also in this PR, there was no indication before that the upload was
complete apart from the button becoming enabled again.
This commit adds the highlight class to the emoji list
and removes it once the highlight fade animation is done,
like we do for new posts.
2022-01-17 11:48:49 +10:00
David Taylor
5099c574d3
UX: Animate the movement of the quote button on selection change (#15590) 2022-01-17 12:05:05 +11:00
David Taylor
cbf99f48d8
FIX: Ensure floating quote button is distanced from iOS selection (#15588)
Tapping within ~50px of the selection end handle on iOS doesn't trigger a click event. This commit ensures that our quote buttons are always at least 50px away from the end handle. It will try 4 positions in order of preference:

1. The original position
2. 50px to the left of the handle
3. 50px to the right of the handle
4. 50px below the handle, centered on the handle
2022-01-17 12:03:43 +11:00
Martin Brennan
b06c5dde94
FIX: Emoji group not actually saving (#15602)
Follow up to 48f70dcd5f. The group
_appeared_ to be saved in the UI until a refresh when it became
clear that the group wasn't actually sent to the DB. This is because
of the way the per-file data was being set with a computed property.
This commit fixes the computed property by changing it to a regular
function and also makes sure the name resetting after the first upload
in multiple uploads works too.
2022-01-17 10:29:06 +10:00
Rafael dos Santos Silva
8cfd791e0f
FEATURE: Add missing emojis (#15582)
* FEATURE: Add missing emojis

* More missing emojis
2022-01-14 17:51:13 -03:00
Joffrey JAFFEUX
a9d69b0e88
DEV: fix tests (#15587)
These tests have been constantly failing locally for me on /qunit. Also it feels better to just rely on native component behavior.
2022-01-14 16:59:26 +01:00
Joffrey JAFFEUX
c758e2cdd1
UX: flat-btn should also respond to Enter (#15584) 2022-01-14 15:51:31 +01:00
Martin Brennan
48f70dcd5f
FIX: Selected group cleared between emoji uploads (#15581)
When uploading multiple emoji in Admin/Customize/Emojis
with an emoji Group selected, the group was cleared between
each file uploaded, making bulk uploading of emojis a chore
if anything but the default group was needed.

This commit fixes the issue, introduces tests for emoji-uploader,
and also adds `add-files` appEvents for uppy-upload mixin, same
as the composer-upload-uppy mixin, for interop with tests and so
we don't have to rely on a file upload element's change event.
2022-01-14 13:25:51 +10:00
Penar Musaraj
87dd69937f
DEV: Add after-topic-progress plugin outlet (#15572) 2022-01-13 21:32:05 -05:00
Martin Brennan
bd5fd93e81
DEV: Fix missing test paths for Ember CLI (#15578)
Since 6272edd121 some tests were
not loading for Ember CLI, this commit adds the missing paths so
all the tests load.
2022-01-14 11:53:52 +10:00
Robin Ward
6272edd121 DEV: Support for running theme test with Ember CLI (third attempt)
The second attempt fixed issues with smoke test.

This one makes sure minification only happens in production mode.
2022-01-13 16:02:07 -05:00
Joffrey JAFFEUX
25722e0b08
DEV: using Enter on a focused button should trigger action (#15564) 2022-01-13 14:24:52 +01:00
Martin Brennan
107239a442
Revert "DEV: Support for running theme test with Ember CLI (second attempt)" (#15559)
This reverts commit 2c7906999a.

The changes break some things in local development (putting JS files
into minified files, not allowing debugger, and others)
2022-01-13 10:05:35 +10:00
Rafael dos Santos Silva
2278c7f82d
FIX: Bypass service worker on the SSO path (#15558)
This is a workaround a behavior change in Chromium v97.
The following text was sent to the blink-dev mailing list:

> This change broke a SingleSignOn login on the FOSS software Discourse. We have a flow like:
>
> 1. User visits forum.siteA.com, click login
> 2. Gets redirected to idp.siteB.com
> 3. Fills login details
> 4. Gets redirected to forum.siteA.com/session/sso_login?parameters
> 5. Gets redirected to forum.siteA.com/homepage
>
> On step 4, the response includes a `set-cookie` header, with proper `HttpOnly; SameSite=Lax; Secure `and set. But if there is an active service worker, the login will fail as that cookie will be rejected by Chromium due to SameSite rules now.
>
> t=2971 [st=258]        COOKIE_INCLUSION_STATUS
>                        --> domain = "forum.siteA.com"
>                        --> name = "_t"
>                        --> operation = "store"
>                        --> path = "/"
>                        --> status = "EXCLUDE_SAMESITE_LAX, DO_NOT_WARN"
>
> The service worker is a vanilla WorkboxJS service worker that intercepts all GETs with the "Network First" strategy.
>
> Disabling the service worker or using Firefox results in a successful login. There is no warning in either DevTools network tab nor the console that the cookie was rejected.
>
> Chrome 96: login works
> Chrome 97: login does not work
> Chrome 98: login does not work
>
> Is this expected behavior? Even if the request `GET forum.siteA.com` was initiated because of a redirect from a different domain, is it expected that Chrome will silently drop same site cookies from forum.siteA.com?
2022-01-12 20:01:53 -03:00
Arpit Jalan
c593727497
FIX: navigate to topic/PM regardless of Shift key press (#15551)
Currently when pressing Shift key and hitting Reply button the user
stays on the post they are on and does not get navigated to newly
created topic/PM/reply. This is fine for replies but creates confusion
when composing a new topic/PM.

This commits makes it such that pressing Shift key and Reply button
(or ctrl-shift-enter / cmd-shift-enter) works only for replies and not
for new topic/PM. The user will always be navigated to new topic/PM.
2022-01-13 08:13:33 +11:00
Robin Ward
2c7906999a DEV: Support for running theme test with Ember CLI (second attempt)
This PR includes support for running theme tests in legacy ember
production envrionments.
2022-01-12 15:43:29 -05:00
David Taylor
6750c682ac DEV: Add integration test for refreshing discovery-topics views
This test would have detected the regression which was fixed in f94c01b233
2022-01-12 12:18:37 +00:00
David Taylor
78c6fc6e43 DEV: Use Ember router to determine currentURL
This means that our DiscourseURL logic will work consistently in tests, where `window.location` doesn't get updated.

To make it work properly, our `replaceState` implementation needed to be updated so that it writes the new URL to Ember's router, rather than bypassing the router and going straight to the `location` API.

A couple of tests needed updating following this fix:
- the composer-test was asserting that the new reply should be missing from the DOM... when really it **should** be in the DOM, and this fix to the test environment makes it so
- the topic-test was making a fake topic fixture based on the data from a topic with a different id. This was causing the topic route to get confused, and 'fix' the currentURL. This commit updates it to use a fixture with consistent data.

This commit also removes the feature detection of `window.history`. It's feature-detected within `discourse-location`. Plus, we don't support any browsers without it.
2022-01-12 12:18:37 +00:00
Natalie Tay
dd3ed27930
DEV: Allow utility class domFromString to take in strings with multiple top level elements (#15548)
Previously only `<div>one top element</div>` was allowed because we use `firstChild` instead of `children`.
We also want `<div>one</div><div>two</div>` to work with this method.
2022-01-12 19:49:24 +08:00
David Taylor
252bb87ab3
Revert "DEV: Support for running theme test with Ember CLI" (#15547)
This reverts commit ea84a82f77.

This is causing problems with `/theme-qunit` on legacy, non-ember-cli production sites. Reverting while we work on a fix
2022-01-11 23:38:59 +00:00
Kris
1d0e5ae4c8
DEV: add invite-page class (#15546) 2022-01-11 17:05:13 -05:00
Robin Ward
ea84a82f77 DEV: Support for running theme test with Ember CLI
This is quite complex as it means that in production we have to build
Ember CLI test files and allow them to be used by our Rails application.

There is a fair bit of glue we can remove in the future once we move to
Ember CLI completely.
2022-01-11 15:42:13 -05:00
David Taylor
8eb61de1cd
FIX: Handling of /p/### URLs within Ember (#15536) 2022-01-11 13:10:46 +00:00
David Taylor
b537d591b3
FIX: allow slug-less topic URLs to work within the same topic (#15508)
- Update the TOPIC_URL_REGEXP in `lib/url` so that `navigatedToPost` doesn't attempt to handle slug-less URLs. Slugs must contain at least one non-numeric character, so we can use that fact to make the regex more specific. We want slug-less URLs to be routed as a normal Ember transition, so that `topic-by-slug-or-id` can catch them and re-write the URL to include the slug.

- Update the `topic-by-slug-or-id` afterModel to ensure that the Ember router is used to handle the redirect, rather than DiscourseURL. This guarantees that it will function as a redirect (DiscourseURL.routeTo sometimes bypasses the router). This solves the history problem which was worked-around in 27211ee7bb.

- Update routes/topic to recover from aborted transitions gracefully. This means that following an aborted transition, the browser URL continues to be updated with post numbers as the user scrolls down the page.
2022-01-11 10:37:37 +00:00
Bianca Nenciu
5d35c38db2
FEATURE: Search screened IP address in blocks (#15461)
An admin could search for all screened ip addresses in a block by
using wildcards. 192.168.* returned all IPs in range 192.168.0.0/16.
This feature allows admins to search for a single IP address in all
screened IP blocks. 192.168.0.1 returns all IP blocks that match it,
for example 192.168.0.0/16.

* FEATURE: Remove roll up button for screened IPs

* FIX: Match more specific screened IP address first
2022-01-11 09:16:51 +02:00
Bianca Nenciu
5a8b8f6f1e
FEATURE: Show warning if user won't be mentioned (#15339)
The new warnings cover more cases and more accurate. Most of the
warnings will be visible only to staff members because otherwise they
would leak information about user's preferences.
2022-01-11 09:16:20 +02:00
Alan Guo Xiang Tan
2ee9a09c8c DEV: Fix failing test. 2022-01-11 11:45:22 +08:00
Alan Guo Xiang Tan
c2afc3915b FEATURE: Customizable rules and plugins for PrettyText.markdown.
This commit extends the options which can be passed to
`PrettyText.markdown` so that which Markdown-it rules and Discourse
Markdown plugins to be used when rendering a text can be customizable.
Currently, this extension is mainly used by plugins.
2022-01-11 10:39:40 +08:00
Jarek Radosz
2dcad9772f FIX: Don't display duplicated emoji in picker 2022-01-11 10:37:02 +08:00
Krzysztof Kotlarek
22249806a8 FEATURE: decorate username in email-group-user-chooser-row
We are allowing plugins to decorate username selector:

1f1aa6a0d8/app/assets/javascripts/discourse/app/lib/plugin-api.js (L1154)

1472e47aae/app/assets/javascripts/discourse/app/templates/user-selector-autocomplete.hbr (L9)

The same decoration can be beneficial for email-group-user-chooser-row. An example use case is to show the icon that a user is on holiday when assigning a user to post/topic.
2022-01-11 09:49:27 +08:00
Jarek Radosz
933f6780ee
FIX: Update recent emoji list when selecting from it (#15514)
…after you re-open the modal or select another emoji.

Reason:
Even the most used emoji would be knocked off the list after a while, if you use any emoji outside the recent. Consider the sequence:

, 😃,  (from recent), 😀,  (from recent), 😛,  (from recent), 😎,  (from recent), and so on

With the previous logic, the check mark emoji would leave the list, even though it used constantly and (and the time of removal) would the the second most recent used emoji.

---

It doesn't update the list when you use the recent list so that you can click an emoji repeatedly and it doesn't shift from under your mouse cursor.
2022-01-11 00:00:47 +01:00
Rafael dos Santos Silva
06bba76719
DEV: Update emojis constants (#15506)
Follow up to d1cfabd so the new emojis are usable by the app
2022-01-10 14:53:52 -03:00
David Taylor
ef37186be3
DEV: Allow click-interceptor in tests and add navigation test (#15499)
The app's wrapper element ID is different in tests. `app.rootElement` allows us to consistently obtain the selector in the initializer, so it works correctly regardless of the app's configuration.
2022-01-10 15:45:44 +00:00
Andrei Prigorshnev
c4646264c1
DEV: Restore facked timers in the after-each hook (#15522) 2022-01-10 19:30:50 +04:00
David Taylor
b3aeedd653
DEV: Correct method name in theme-errors-handler pre-initializer (#15501) 2022-01-10 10:51:40 +00:00
David Taylor
df7cda40b7
DEV: Skip timers when loading topic route in tests (#15500)
The test environment will wait for all timers to settle before continuing. These timers were causing all tests involving `/t/*` routes to spend 500ms doing nothing.

Fun fact: we load the topic route 214 times during the core test suite. That means that this commit saves a total of around 107s across the whole suite. On my machine, that's a 30% improvement in runtime.
2022-01-10 10:51:18 +00:00
David Taylor
3513835722
DEV: Improve and document __container__ workaround in tests (#15498)
Modern Ember only sets up a container when the ApplicationInstance is booted. We have legacy code which relies on having access to a container before boot (e.g. during pre-initializers).

In production we run with the default `autoboot` flag, which triggers Ember's internal `_globalsMode` flag, which sets up an ApplicationInstance immediately when an Application is initialized (via the `_buildDeprecatedInstance` method).

In tests, we worked around the problem by creating a fresh container, and placing a reference to it under `Discourse.__container__`.

HOWEVER, Ember was still creating a Container instance for each ApplicationInstance to use internally, and make available to EmberObjects via injection. The `Discourse.__container__` instance we created was barely used at all.

Having two different Container instances in play could cause some weird issues. For example, I noticed the problem because the `appEvents` instance held by DiscourseURL was different to the `appEvents` instance held by all the Ember components in our app. This meant that events triggered by DiscourseURL were not picked up by components in test mode.

This commit makes the hack more robust by ensuring that Ember re-uses the Container instance which we created pre-boot. This means we only have one Container instance in play, and makes `appEvents` work reliably across all parts of the app. It also adds detailed comments describing the hack, to help future travelers.

Hopefully in future we can remove this hack entirely, but it will require significant refactoring to our initialization process in Core and Plugins.

The mapping-router and map-routes initializer are updated to avoid the need for `container.lookup` during teardown. This isn't allowed under modern Ember, but was previously working for us because the pre-initializer was using the 'fake' container which was not ember-managed.
2022-01-10 10:34:08 +00:00
Penar Musaraj
c908fa2f5b
FIX: Regression in topic list kbd navigation (#15513) 2022-01-09 17:22:41 -05:00
Jarek Radosz
71cf6839ab
DEV: Add count to missing translation strings (#15509)
…for easier debugging of i18n issues.
2022-01-09 23:10:32 +01:00
Ayke Halder
c0d702f01f
DEV: migrate audio cloak-prevention to decorateCookedElement (#15502)
Migrate deprecated decorateCooked to decorateCookedElement for audio cloak-prevention.

This might give a minimal performance boost: running audio cloak-prevention for 20 (non-audio) posts takes 1 ms and not 15 ms.

Co-authored-by: Jarek Radosz <jradosz@gmail.com>
2022-01-09 01:57:49 +01:00
Dan Ungureanu
c0d72ec3d6
FIX: Append /all to URL if default list is 'none' (#15460)
It was impossible to select the 'all' filter for categories that have
the default list filter set to 'no subcategories'. This happens because
'/all' was not appended to the URL and in the absence of any list filter
('all' or 'none'), the default list filter ('none') was automatically
selected.
2022-01-08 13:58:42 +02:00
Penar Musaraj
1ed2520589
DEV: Fewer jQuery calls in offset calculation (#15465) 2022-01-07 16:02:03 -05:00
David Taylor
f94c01b233
FIX: Refresh logic in discovery topic lists (#15489)
Before 6e0e6014, the flow looked something like:

1. `discovery/topics` controller (which extends `discovery` controller) `afterRefresh()` calls `.send("loadingComplete")`
2. Bubbles to [`discovery` route](554ff07786/app/assets/javascripts/discourse/app/routes/discovery.js (L58))
3. Discovery route calls `controllerFor('discovery').loadingComplete()`. `loading` is set false, and the spinner disappears

Now that `discovery/topics` defines `loadingComplete` as an action, the `discovery/topics` controller runs its own `loadingComplete` handler logic in step 1, and the action does not bubble any further.

This commit adds action overrides in `discovery/topics`, so that the new actions only apply to the main `discovery` controller. The need for this does suggest some more radical refactoring is required, but these are very critical routes, and we are very close to a major release.
2022-01-07 17:22:49 +00:00
Alan Guo Xiang Tan
bdc868246f DEV: Removing unused lines of code.
The code had no effect on how the markdown-it is being configured.
2022-01-07 09:06:16 +08:00
David Taylor
c1f74cd92a
DEV: Update default tagName and connectorTagName for plugin outlets (#13685)
This commit should be a no-op for all existing core outlets. Outlets which are introduced by themes/plugins may see a change in behavior, and should follow the steps below if they want to maintain their previous behavior.

`tagName="" connectorTagName=""` is almost always the correct choice for plugin outlets. 40eba8cd introduced a `noTags=true` shortcut which achieved this, and left a comment saying it should be the future default. This commit does exactly that. To avoid any breaking changes for plugins, all existing plugin outlets have been reviewed and adjusted by following this logic:

1) If `noTags=true`, remove the `noTags` parameter, and do not complete any further steps
2) If `tagName` is not specified, set `tagName="span"` (the previous default)
3) If `connectorTagName` is not specified, set `selectorTagName="div"` (the previous default)
4) If `tagName=""`, remove it
5) If `connectorTagName=""`, remove it

The updates were accomplished with the help of a ruby script:

```ruby
def removeAttr(tag, attribute)
  tag = tag.sub /\s#{attribute}="?\w*"? /, " "
  tag = tag.sub /\s#{attribute}="?\w*"?}}/, "}}"
  tag = tag.sub /^\s*#{attribute}="?\w*"?\n/, ""
  tag
end

files = Dir.glob("app/assets/javascripts/**/*.hbs")

puts "Checking #{files.count} files..."
files.each do |f|
  content = File.read(f)

  count = 0
  edits = 0
  content.gsub!(/{{\s*plugin-outlet.*?}}/m) do |match|
    count += 1

    result = match

    noTags = result.include?("noTags=true")
    tagName = result[/tagName="(\w*)"/, 1]
    connectorTagName = result[/connectorTagName="(\w*)"/, 1]

    if noTags
      result = removeAttr(result, "noTags")
    else
      if connectorTagName == ""
        result = removeAttr(result, "connectorTagName")
      elsif connectorTagName.nil?
        result = result.sub(/name="[\w-]+"/) { |m| "#{m} connectorTagName=\"div\"" }
      end

      if tagName == ""
        result = removeAttr(result, "tagName")
      elsif tagName.nil?
        result = result.sub(/name="[\w-]+"/) { |m| "#{m} tagName=\"span\"" }
      end
    end

    edits += 1 if match != result

    result
  end

  puts "#{count} outlets, #{edits} edited -> #{f}"

  File.write(f, content)
end
```
2022-01-06 20:38:17 +00:00
David Taylor
2bcb5360b6
DEV: Modernise navigation-bar plugin-outlet (#15478)
This workaround was introduced before we had the ability to render components with no wrapper element. Now we can pass `tagName=""` to `plugin-outlet`.
2022-01-06 19:15:29 +00:00
Andrei Prigorshnev
9006c07373
FEATURE: Make the draft error exclamation in composer red (#15475) 2022-01-06 19:28:18 +04:00
Arpit Jalan
cfcdedb709
FIX: new-topic feature was broken when 'Default List Filter' was set to 'no subcategories' (#15476)
https://meta.discourse.org/t/directly-linking-to-new-topic-not-working-when-default-list-filter-no-sub-categories/197447
2022-01-06 20:48:08 +05:30
Meghna
cc4c7a05e6
UX: better invite accept form (#15472) 2022-01-06 16:31:32 +05:30
Jarek Radosz
5b6acea56e DEV: Remove obsolete topic-progress code 2022-01-06 09:04:30 +08:00
Alan Guo Xiang Tan
85e124bae1 DEV: Remove redundant lines of code.
Engines are enabled by default so there is no need to specify Discourse
specific engines in the object.
2022-01-06 09:02:52 +08:00
David Taylor
e6ab8f5b71
DEV: Re-use main app registry for raw HBS view lookups (#15456)
da6edc1 introduced the `lookupView` method, which initialized a fresh resolver, and used it to directly look up raw-views (with no caching). This worked well, but was not a clean solution. It required initializing an entirely new resolver, and did not have any caching.

This commit updates the `helperContext` to include access to the registry, and uses it to perform raw-view lookups. As well as re-using the registry, this also means we're making use of the resolver's built-in cache.

I haven't been able to measure any noticeable performance impact from this change, but there is certainly less work being done, so it may be beneficial on older devices.

Co-authored-by: Ayke Halder <rr-it@users.noreply.github.com>
2022-01-05 22:22:13 +00:00
Robin Ward
6e0e6014d1 FIX: When loading more topics, showFooter was not updated properly 2022-01-05 15:12:40 -05:00
Penar Musaraj
e04069cf0d
FIX: Jittery topic progress on some window sizes (#15462) 2022-01-05 14:09:25 -05:00
Andrei Prigorshnev
692ba188bf
DEV: migrate routes to the new @action pattern (#15435)
After this fix we have only two routes that use the old "actions:" pattern:
- route:application
- route:discourse

I'll migrate them soon.
2022-01-05 16:08:06 +04:00
Krzysztof Kotlarek
719d052ead FIX: smaller pencil icon for edit tags
Pencil icon should be same size as in edit topic title
2022-01-05 10:25:39 +08:00
Penar Musaraj
a717c307ce
FIX: Small adjustments to topic progress position on desktop (#15447) 2022-01-04 18:28:26 -05:00
David Taylor
1f1aa6a0d8
FEATURE: Catch decorateCooked errors from themes/plugins (#15450)
If a theme/plugin raises an error while decorating post content, the decorator will be skipped, and the error reported on the console. Additionally, administrators will be shown a red warning at the top of the screen.

This commit refactors and re-uses some of the logic from the theme-initializer-error-reporting logic. In future, new error reports can be added by doing something like:

```
document.dispatchEvent(
  new CustomEvent("discourse-error", {
    detail: { messageKey: "some.translation.key", error },
  })
);
```
2022-01-04 21:59:52 +00:00
David Taylor
6c5522db77
DEV: Remove JQuery from app.js (#15449) 2022-01-04 19:56:27 +00:00
Penar Musaraj
be599513e3
FEATURE: use raster image and autofill in 2FA input (#15429)
- switches to a raster image QR code so it can be long-pressed (or right
clicked) and added to iCloud keychain
- adds `autocomplete="one-time-code"` to the 2FA input for better
discoverability
2022-01-04 15:31:46 +11:00
Martin Brennan
ed83d7573e
FIX: Tone down admin dashboard critical problem messaging (#15442)
Keep the title the same as it used to be and only
show the exclamation icon on the critical problems in
the list.
2022-01-04 13:00:58 +10:00
Martin Brennan
20fe5eceb8
FEATURE: Scheduled group email credential problem check (#15396)
This commit adds a check that runs regularly as per
2d68e5d942 which tests the
credentials of groups with SMTP or IMAP enabled. If any issues
are found with those credentials a high priority problem is added to the
admin dashboard.

This commit also formats the admin dashboard differently if
there are high priority problems, bringing them to the top of
the list and highlighting them.

The problem will be cleared if the issue is fixed before the next
problem check, or if the group's settings are updated with a valid
credential.
2022-01-04 10:14:33 +10:00
Osama Sayegh
61bb0df3f6
FEATURE: Allow topic pin toggle when header is docked (#15438)
Meta topic: https://meta.discourse.org/t/cant-pin-unpin-topic-from-the-title/213444?u=osama.

I know there is an inconsistency between the category of the linked topic (#bug) and the title prefix of this PR, but I really couldn't find anything in the code base that suggested this ever worked before, so I'm categorizing this PR as a feature.
2022-01-03 15:21:06 +03:00
David Taylor
7fdb2944b9
DEV: Allow ember server --environment production to be used (#15431)
Running in production mode is useful when doing performance-sensitive work.

- Set the `exportApplicationGlobal` flag, so we get the `Discourse` global in production mode. It defaults to only adding the global in development mode. Note that, when generating ember-cli assets via rails, we set this in `ApplicationHelper#discourse_config_environment`.

- Disable SRI - Ember CLI adds this to index.html when in production mode. We don't use SRI in production, so disable here to match.

- Refactor the `AssetRev` logic in `ember-cli-build.js`, so that our custom bundle hashes are find/replaced into index.html. Without this change, our custom bundles (e.g. `start-discourse.js`) remain without their hash in `index.html`, and do not function.

  I have confirmed that the only diff in the `/dist` out following this change is to the `index.html` file. All other filenames and contents remain identical.
2021-12-31 12:26:23 +00:00
Joe
20de49c872 check for code-blocks before loading highlight-js 2021-12-30 12:44:22 -05:00
Joe
c5c216563e remove deprecated jQuery workaround 2021-12-30 12:44:22 -05:00
Penar Musaraj
05eaedc810
DEV: revert linting workaround for emoji picker keydown action (#15424) 2021-12-30 12:39:21 -05:00
Penar Musaraj
879e35195a
DEV: Small refactor to header offset (#15421)
Centralizes calculations in a helper under the site header component.

This also reverts a small CSS change to the composer: since ac79c5ef,
the composer height was not including the grippie, which means that the
composer height was off by 11 pixels, and the topic progress widget was
sometimes being displayed cut off by 11 pixels.
2021-12-29 11:03:21 -05:00
Penar Musaraj
108c8302fb
FEATURE: Automatic admin editor dark mode (#15419) 2021-12-29 11:02:37 -05:00