Commit Graph

50023 Commits

Author SHA1 Message Date
Isaac Janzen
37e4c050c5
DEV: Cleanup glimmer search menu tests (#22170) 2023-06-17 08:31:11 -05:00
Joffrey JAFFEUX
7e1d015657
DEV: more reliable thread level spec (#22173)
Rely on frontend state instead of checking backend state.
2023-06-17 14:28:22 +02:00
Isaac Janzen
afa6c0a9a4
DEV: Escape html and emojis in search menu topic result type titles (#22166)
# Before
<img width="419" alt="Screenshot 2023-06-16 at 3 23 49 PM" src="https://github.com/discourse/discourse/assets/50783505/557e0657-afc8-4608-b025-d9896fd9a8c9">

# After
<img width="433" alt="Screenshot 2023-06-16 at 3 21 41 PM" src="https://github.com/discourse/discourse/assets/50783505/1df71b3b-479b-4163-8a7c-5bb434102a55">
2023-06-16 15:56:41 -05:00
Juan David Martínez Cubillos
93e5272223
FIX: Incompatibility between default_composer_category and default_subcategory_on_read_only_category (#22165) 2023-06-16 15:56:25 -05:00
David Taylor
e061166a05
FIX: Restore behavior of window.Discourse (#22167)
The work in fa509224f0 updated our initializer patterns to match modern Ember. This caused the initializer from the (deprecated) ember-export-application-global addon to change its behavior from exporting the ApplicationInstance to exporting the Application. This affects customizations which were using some long-deprecated APIs we had attached to the ApplicationInstance.

This commit removes the deprecated addon, restores the previous ApplicationInstance behavior which we've come to depend on, and adds a test for the expected behavior. It also bumps the `dropFrom` version to make it clear that we do not intend to remove these APIs during this release cycle.
2023-06-16 21:54:15 +01:00
Mark VanLandingham
987d5b9fce
DEV: Add plugin modifier to expand group mentions in post_alerter (#22163) 2023-06-16 14:48:07 -05:00
David Taylor
4b9d50c98a DEV: Update poll components and controllers to native class syntax
Conversion performed using the ember-native-class-codemod
2023-06-16 18:16:31 +01:00
David Taylor
aebe6625d2 DEV: Modernize poll JS directory structure and colocate components 2023-06-16 18:16:31 +01:00
Kris
e8f91a0a4c
UX: remove short topic timeline transition (#22161) 2023-06-16 12:21:04 -04:00
Canapin
84bbf0fdd7
UX: fix avatar selector overflow (#22159) 2023-06-16 16:36:13 +01:00
Jarek Radosz
9984accfa5
DEV: Remove renderTemplate from 2fa preferences, email preferences, and new-category (#22156) 2023-06-16 16:50:45 +02:00
Jarek Radosz
37030ed348
DEV: Convert d-navigation-item to glimmer (#22155) 2023-06-16 16:36:50 +02:00
David Taylor
f8ea5b1136
DEV: Update TranslateAccelerator missing translation string (#22158)
Upstream added a capital 'T' to the 'Translation missing' message in https://github.com/ruby-i18n/i18n/commit/c5c6e753f3. This caused our translate accelerator patch to diverge, and the change in case affected a number of our specs. This commit updates the translate accelerator to match the upstream casing, and introduces a spec to detect future divergence.
2023-06-16 15:28:03 +01:00
Kris
ffcac7bf5a
UX: consistent button hover transitions (#22157) 2023-06-16 10:25:58 -04:00
Isaac Janzen
a2b038ffe7
DEV: Upgrade search-menu to glimmer (#20482)
# Top level view
This PR is the first version of converting the search menu and its logic from (deprecated) widgets to glimmer components. The changes are hidden behind a group based feature flag. This will give us the ability to test the new implementation in a production setting before fully committing to the new search menu.

# What has changed
The majority of the logic from the widget implementation has been updated to fit within the context of a glimmer component, but it has not fundamentally changed. Instead of having a single widget - [search-menu.js](https://github.com/discourse/discourse/blob/main/app/assets/javascripts/discourse/app/widgets/search-menu.js) - that built the bulk of the search menu logic, we split the logic into (20+) bite size components. This greatly increases the readability and makes extending a component in the search menu much more straightforward.

That being said, certain pieces needed to be rewritten from scratch as they did not translate from widget -> glimmer, or there was a general code upgraded needed. There are a few of these changes worth noting:

### Search Service
**Search Term** -> In the widget implementation we had a overly complex way of managing the current search term. We tracked the search term across multiple different states (`term`, `opts.term`, `searchData.term`) causing headaches. This PR introduces a single source of truth: 
```js
this.search.activeGlobalSearchTerm
```
This tracked value is available anywhere the `search` service is injected. In the case the search term should be needs to be updated you can call 
```js
this.search.activeGlobalSearchTerm = "foo"
```
 
**event listeners** -> In the widget implementation we defined event listeners **only** on the search input to handle things such as 
- keyboard navigation / shortcuts
- closing the search menu
- performing a search with "enter"

Having this in one place caused a lot of bloat in our logic as we had to handle multiple different cases in one location. Do _x_ if it is this element, but do _y_ if it is another. This PR updates the event listeners to be attached to individual components, allowing for a more fine tuned set of actions per element. To not duplicate logic across multiple components, we have condensed shared logic to actions on the search service to be reused. For example - `this.search.handleArrowUpOrDown` - to handle keyboard navigation.

### Search Context
We have unique logic based on the current search context (topic / tag / category / user / etc). This context is set within a models route file. We have updated the search service with a tracked value `searchContext` that can be utilized and updated from any component where the search service is injected.

```js
# before
this.searchService.set("searchContext", user.searchContext);

# after
this.searchService.searchContext = user.searchContext;
```

# Views
<img width="434" alt="Screenshot 2023-06-15 at 11 01 01 AM" src="https://github.com/discourse/discourse/assets/50783505/ef57e8e6-4e7b-4ba0-a770-8f2ed6310569">

<img width="418" alt="Screenshot 2023-06-15 at 11 04 11 AM" src="https://github.com/discourse/discourse/assets/50783505/2c1e0b38-d12c-4339-a1d5-04f0c1932b08">

<img width="413" alt="Screenshot 2023-06-15 at 11 04 34 AM" src="https://github.com/discourse/discourse/assets/50783505/b871d164-88cb-405e-9b78-d326a6f63686">

<img width="419" alt="Screenshot 2023-06-15 at 11 07 51 AM" src="https://github.com/discourse/discourse/assets/50783505/c7309a19-f541-47f4-94ef-10fa65658d8c">

<img width="424" alt="Screenshot 2023-06-15 at 11 04 48 AM" src="https://github.com/discourse/discourse/assets/50783505/f3dba06e-b029-431c-b3d0-36727b9e6dce">

<img width="415" alt="Screenshot 2023-06-15 at 11 08 57 AM" src="https://github.com/discourse/discourse/assets/50783505/ad4e7250-040c-4d06-bf06-99652f4c7b7c">
2023-06-16 09:24:07 -05:00
David Taylor
251d6f0627
DEV: Introduce Zeitwerk reloading check in CI (#22151)
This should help us to catch the most catastrophic cases where plugins fail to auto-reload in development mode.
2023-06-16 14:33:14 +01:00
David Taylor
6e143c6157
DEV: Namespace chat_header_indicator UserOption enum (#22152)
Previously this was defining methods like `UserOption#never?`, `UserOption#all_new?`, `UserOption#dm_and_mentions?`. Now they will be prefixed like `UserOption#chat_header_indicator_never?`
2023-06-16 13:14:53 +01:00
Joffrey JAFFEUX
7db6d27292
FIX: correctly sets and uses has-reply class (#22153)
The layout was broken for messages replying to another message in non threaded channels.

This commit also refactors the chat-message-test to use fabricators.
2023-06-16 14:04:11 +02:00
David Taylor
54cae1299e
DEV: Do not attempt to overwrite UserOption enums during autoloading (#22150)
Unfortunately, Discourse's `UserOption` model is not currently autoloaded. That means that modifying it via a `reloadable_patch` will try to apply the changes repeatedly. Normally this doesn't matter since the changes are idempotent. However, introducing ActiveRecord enums is not idempotent - they raise an error if the same enum already exists on the model. This commit adds a check to avoid hitting this 'duplicate definition' error.

Reproduced

```
rails runner 'Rails.application.reloader.reload!'
```
2023-06-16 12:29:32 +01:00
Joffrey JAFFEUX
ab286cc6e1
FIX: css class was incorrect (#22149)
This was preventing to have the correct active background on the chat message while hovering the action's menu.
2023-06-16 12:33:13 +02:00
Joffrey JAFFEUX
7dafd275ac
FIX: various mobile chat improvements (#22132)
- FIX: improves reactions and thread indicator touch event on mobile
These "buttons" are located inside a scroll list which makes them very specific. The general idea is to ensure these events are passive and are not bubbling to the parent.
- DEV: moves state on top level message node
- FIX: ensures popover arrow has the correct border
- FIX: makes a message expanded by default
- FIX applies the same ios scroll fix on thread and channel
- UI: better active/hover state for thread indicator
- UI: attempts to follow more closely our BEM naming scheme
- FIX: reduces bottom padding on message with thread indicator and user info hidden
- UI: add padding for first message in thread
- FIX: prevents actions backdrop to open thread
- UI: makes thread indicator resizable
2023-06-16 11:36:43 +02:00
Ted Johansson
517c9e7782
DEV: Remove deprecated 'desc' parameter from group members endpoint (#22147) 2023-06-16 16:42:00 +08:00
Alan Guo Xiang Tan
d60c90aef1
DEV: Change have_section_link match to use exact text match. (#22148)
Today I learnt that `has_link?("text of link")` by default does an
includes instead of looking for a link with the exact text. This is not
the behaviour I want so I'm changing
`PageObjects::Components::Sidebar.has_section_link?` to use the
`exact_text` option instead.
2023-06-16 16:36:34 +08:00
Martin Brennan
3802d0de9d
DEV: Further refine development reload for plugin files (#22141)
Followup f3afc8bf85 to better
exclude all spec files including PageObject files.
2023-06-16 16:15:15 +08:00
Ted Johansson
d548231475
DEV: Remove old deprecation warnings where constants already removed (#22140)
We renamed these constants 3 years ago. This PR just removes the old deprecation notices.
2023-06-16 11:26:26 +08:00
Martin Brennan
9174716737
DEV: Remove Discourse.redis.delete_prefixed (#22103)
This method is a huge footgun in production, since it calls
the Redis KEYS command. From the Redis documentation at
https://redis.io/commands/keys/:

> Warning: consider KEYS as a command that should only be used in
production environments with extreme care. It may ruin performance when
it is executed against large databases. This command is intended for
debugging and special operations, such as changing your keyspace layout.
Don't use KEYS in your regular application code.

Since we were only using `delete_prefixed` in specs (now that we
removed the usage in production in 24ec06ff85)
we can remove this and instead rely on `use_redis_snapshotting` on the
particular tests that need this kind of clearing functionality.
2023-06-16 12:44:35 +10:00
Sérgio Saquetim
e89c70643b
DEV: Add attributes identifying the setting on the user chat settings (#22139) 2023-06-15 23:32:17 -03:00
Martin Brennan
d6374fdc53
FEATURE: Allow users to manually track threads without replying (#22100)
This commit adds a tracking dropdown to each individual thread, similar to topics,
that allows the user to change the notification level for a thread manually. Previously
the user had to reply to a thread to track it and see unread indicators.

Since the user can now manually track threads, the thread index has also been changed
to only show threads that the user is a member of, rather than threads that they had sent
messages in.

Unread indicators also respect the notification level -- Normal level thread tracking
will not show unread indicators in the UI when new messages are sent in the thread.
2023-06-16 12:08:26 +10:00
Alan Guo Xiang Tan
783bce4b2c
DEV: Don't render header on invites page (#22138)
What this change?

Previous solution relied on CSS to hide the header which is first
wasteful since we're still rendering the header and second makes it
untestable. If we don't want the header to show, we should avoid
rendering it in the first place.
2023-06-16 09:42:00 +08:00
Alan Guo Xiang Tan
9fad71809c
UX: Improve defaults shown for categories and tags section in sidebar (#22062)
Why is this change required?

When a site is newly setup and a user has just been created, the
categories and tags sections are hidden from the user. This happens
because the admin has not configured the `default_navigation_menu_categories` or
`default_navigation_menu_tags` site settings. When the categories and tags
sections are hidden from the user, the sidebar looks extremely bare and
does not create a good experience.

What is being change?

In this commit, we're changing the logic such that the site's top
categories and tags are displayed if the user does not have any
categories/tags configured in each respective section. The only
regression introduced in this change is that the categories and tags
section can no longer be hidden as a result. However, we have plans to
address this in the future by allowing sidebar sections to be configured
to be hidden by each individual user.
2023-06-16 09:06:01 +08:00
Joffrey JAFFEUX
7352ba1fe8
FIX: direct message channels can be flagged (#22134)
The events leading to this mistake are unclear but we decided few months ago to make direct messages NOT flaggable and even wrote a spec for this, when we actually support flagging of direct messages.

This commit ensures it will show for direct messages channels and inverses the existing spec.
2023-06-16 11:04:59 +10:00
dependabot[bot]
d53e306681
Build(deps-dev): Bump ember-cli-app-version in /app/assets/javascripts (#22136)
Bumps [ember-cli-app-version](https://github.com/ember-cli/ember-cli-app-version) from 6.0.0 to 6.0.1.
- [Release notes](https://github.com/ember-cli/ember-cli-app-version/releases)
- [Changelog](https://github.com/ember-cli/ember-cli-app-version/blob/master/CHANGELOG.md)
- [Commits](https://github.com/ember-cli/ember-cli-app-version/compare/v6.0.0...v6.0.1)

---
updated-dependencies:
- dependency-name: ember-cli-app-version
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-06-16 01:38:49 +02:00
dependabot[bot]
3995b87667
Build(deps-dev): Bump ember-cli-dependency-checker (#22137)
Bumps [ember-cli-dependency-checker](https://github.com/quaertym/ember-cli-dependency-checker) from 3.3.1 to 3.3.2.
- [Release notes](https://github.com/quaertym/ember-cli-dependency-checker/releases)
- [Commits](https://github.com/quaertym/ember-cli-dependency-checker/commits)

---
updated-dependencies:
- dependency-name: ember-cli-dependency-checker
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-06-16 01:38:34 +02:00
dependabot[bot]
4b35653854
Build(deps): Bump sass-embedded from 1.63.3 to 1.63.4 (#22135)
Bumps [sass-embedded](https://github.com/ntkme/sass-embedded-host-ruby) from 1.63.3 to 1.63.4.
- [Commits](https://github.com/ntkme/sass-embedded-host-ruby/compare/v1.63.3...v1.63.4)

---
updated-dependencies:
- dependency-name: sass-embedded
  dependency-type: indirect
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-06-16 01:38:10 +02:00
dependabot[bot]
a5c69ee56a
Build(deps): Bump @ember/test-helpers in /app/assets/javascripts (#22133)
Bumps [@ember/test-helpers](https://github.com/emberjs/ember-test-helpers) from 2.9.3 to 2.9.4.
- [Release notes](https://github.com/emberjs/ember-test-helpers/releases)
- [Changelog](https://github.com/emberjs/ember-test-helpers/blob/v2.9.4/CHANGELOG.md)
- [Commits](https://github.com/emberjs/ember-test-helpers/compare/v2.9.3...v2.9.4)

---
updated-dependencies:
- dependency-name: "@ember/test-helpers"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-06-15 20:27:08 +02:00
Godfrey Chan
0fa92529ed
DEV: enable plain functions as helpers in Ember (#22023)
* Enable "plain function as helpers" polyfill

This feature landed in Ember 4.5+, but this polyfill would allow
it to work on 3.25+

References

RFC: https://github.com/emberjs/rfcs/pull/756
Update: https://github.com/emberjs/rfcs/pull/788
Guides: https://github.com/ember-learn/guides-source/pull/1924

* Convert truth-helpers to use plain functions

Mainly to test that the polyfill is working, but it's a good
refactor anyway.
2023-06-15 19:57:41 +02:00
Kris
7958f57174
UX: softer dropdown and menu panel shadows (#22114) 2023-06-15 10:52:51 -04:00
Sérgio Saquetim
4b22e67c8b
DEV: Added modifier to change mentions extracted from cooked text (#21654)
Added a new modifier hook to allow plugins to modify the @mentions
extracted from a cooked text.

Use case: Some plugins may change how the mentions are cooked to prevent
them from being confused with user or group mentions and display the user
card.

This modifier hook allows the plugin to filter the mentions detected or add new ways
to add mentions into cooked text.
2023-06-15 10:52:52 -03:00
dependabot[bot]
5bd09edc2d
Build(deps): Bump webpack in /app/assets/javascripts (#22121)
Bumps [webpack](https://github.com/webpack/webpack) from 5.86.0 to 5.87.0.
- [Release notes](https://github.com/webpack/webpack/releases)
- [Commits](https://github.com/webpack/webpack/compare/v5.86.0...v5.87.0)

---
updated-dependencies:
- dependency-name: webpack
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-06-15 15:40:08 +02:00
Meghna
7da307669f
UX: stack group inbox label horizontally (#22130) 2023-06-15 18:35:36 +05:30
Godfrey Chan
fa509224f0
DEV: Migrate discourse core to Ember initializers (#22095)
https://meta.discourse.org/t/updating-our-initializer-naming-patterns/241919

For historical reasons, Discourse has different initializers conventions than standard Ember:

```
| Ember                 | Discourse          |                        |
| initializers          | pre-initializers   | runs once per app load |
| instance-initializers | (api-)initializers | runs once per app boot |
```

In addition, the arguments to the initialize function is different – Ember initializers get either the `Application` or `ApplicationInstance` as the only argument, but the "Discourse style" gets an extra container argument preceding that.

This is confusing, but it also causes problems with Ember addons, which expects the standard naming and argument conventions:

1. Typically, V1 addons will define their (app, instance) initializers in the `addon/(instance-)initializers/*`, which appears as `ember-some-addon-package-name/(instance-)initializers/*` in the require registry.

2. Just having those modules defined isn't supposed to do anything, so typically they also re-export them in `app/(instance-)initializers/*`, which gets merged into `discourse/(instance-)initializers/*` in the require registry.

3. The `ember-cli-load-initializers` package supplies a function called `loadInitializers`, which typically gets called in `app.js` to load the initializers according to the conventions above. Since we don't follow the same conventions, we can't use this function and instead have custom code in `app.js`, loosely based on official version but attempts to account for the different conventions.

The custom code that loads initializers is written with Discourse core and plug-ins/themes in mind, but does not take into account the fact that addons can also bring initializers, which causes the following problems:

* It does not check for the `discourse/` module prefix, so initializers in the `addon/` folders (point 1 above) get picked up as well. This means the initializer code is probably registered twice (once from the `addon/` folder, once from the `app/` re-export). This either causes a dev mode assertion (if they have the same name) or causes the code to run twice (if they have different names somehow).

* In modern Ember blueprints, it is customary to omit the `"name"` of the initializer since `ember-cli-load-initializers` can infer it from the module name. Our custom code does not do this and causes a dev mode assertion instead.

* It runs what then addon intends to be application initializers as instance initializers due to the naming difference. There is at least one known case of this where the `ember-export-application-global` application initialize is currently incorrectly registered as an instance initializer. (It happens to not use the `/addon` folder convention and explicitly names the initializer, so it does not trigger the previous error scenarios.)

* It runs the initializers with the wrong arguments. If all the addon initializer does is lookup stuff from the container, it happens to work, otherwise... ???

* It does not check for the `/instance-initializers/` module path so any instance initializers introduced by addons are silently ignored.

These issues were discovered when trying to install an addon that brings an application initializer in #22023.

To resolve these issues, this commit:

* Migrates Discourse core to use the standard Ember conventions – both in the naming and the arguments of the initialize function

* Updates the custom code for loading initializers:
  * For Discourse core, it essentially does the same thing as `ember-cli-load-initializers`
  * For plugins and themes, it preserves the existing Discourse conventions and semantics (to be revisited at a later time)

This ensures that going forward, Ember addons will function correctly.
2023-06-15 14:17:43 +02:00
Joffrey JAFFEUX
79a260a6bb
FIX: allows selection of messages in threads (#22119)
This commit fixes the selection of message in threads and also applies various refactorings
- improves specs and especially page objects/components
- makes the channel/thread panes responsible of the state
- adds an animationend modifier
- continues to follow the logic of "state" should be displayed as data attributes on component by having a new `data-selected` attribute on chat messages
2023-06-15 11:27:31 +02:00
Martin Brennan
f3afc8bf85
DEV: Do not auto reload on plugin spec file changes (#22127)
There is no need to reload the rails server if plugin spec
files change, since they are not autoloaded but they are also
not loaded into the app.
2023-06-15 16:34:30 +10:00
Martin Brennan
c819c96c31
FIX: Minor thread indicator issue (#22128)
* Set a line height for the last reply excerpt so the height
  does not jump when including an emoji
2023-06-15 16:05:06 +10:00
Sérgio Saquetim
c10e3ac57b
DEV: Export dropdown in widgets/header to be used by plugins/TCs (#22126) 2023-06-15 01:05:47 -03:00
Alan Guo Xiang Tan
1bbb41a901
UX: Hide sidebar on invites page (#22125)
This hides the sidebar to make the signup experience less confusing.

Co-authored-by: Ella E <ella.estigoy@gmail.com>
2023-06-15 12:01:04 +08:00
Natalie Tay
fcaefc9f2f
FIX: De-duplicate poll vote on user merge (#22107)
When merging users, polls may error out if the source and target users have both voted on the same poll before. 😢 

There is no constraint on the `poll_votes` table either to support this. Ideally a composite primary key can be used `(poll_id, user_id)`, but alas there is no support yet, which is probably why it wasn't created in the first place.

This fix ensures that merging is successful by only keeping the target poll votes if duplicates exist.

This fix also runs a migration on older poll votes where failed merges would have caused a single user to have voted twice on a single poll. e.g. this weird edge case
2023-06-15 11:18:51 +08:00
Joseph
ec31eb4c7b
DEV: Fix broken link (#22112)
"SMTP and SEND API Settings" link under Mailjet.
2023-06-15 09:53:49 +08:00
Krzysztof Kotlarek
959c50001d
FIX: rename everything link to topics (#22076)
Rename everything link in community sidebar section to topics, which is
a bit more descriptive.
2023-06-15 11:36:38 +10:00
Martin Brennan
f75ac9da30
FEATURE: Thread indicator improvements and participants (#21909)
This commit adds the initial part of thread indicator improvements:

* Show the reply count, last reply date and excerpt,
and the participants of the thread's avatars and
count of additional participants
* Add a participants component for the thread that
can be reused for the list
* Add a query class to get the thread participants
* Live update the thread indicator more consistently
with the last reply and participant details
image image

In subsequent PRs we will cache the participants since
they do not change often, and improve the thread list
further with participants.

This commit also adds a showPresence boolean (default
true) to ChatUserAvatar, since we don't want to show the
online indicator for thread participants.

---------

Co-authored-by: chapoi <charlie@discourse.org>
2023-06-15 10:49:27 +10:00