Commit Graph
37 Commits
Author SHA1 Message Date
Sérgio Saquetim 0c4f285618 DEV: Replace deprecated Ember's array uniq and uniqBy (#35227)
This commit replaces several instances of `.uniq`, `.uniqBy`, and related
array deduplication methods with a new utility function
`uniqueItemsFromArray`. This change ensures proper deduplication logic
across the codebase while addressing the deprecation issues.

**Main Changes:**

* Created new utility function `uniqueItemsFromArray`: Located in a new
file, `array-tools.js`, this function provides a reusable and
configurable alternative for deduplication.
* Replaced old methods: Updated multiple files to use the new utility
function instead of deprecated or custom implementations for
deduplication.
* Replaced manual deduplication: Replace uses of `[...new Set(array)]`
to standardize the deduplication logic across the codebase.
* Added unit tests: Introduced thorough test coverage
(`array-tools-test.js`) to validate functionality and edge cases for the
utility function.
* Updated deprecation workflow: Added logging for deprecated uniq and
uniqBy methods to the `deprecation-workflow.js`.

This change is primarily focused on code quality improvements, ensuring
future-proof deduplication, and maintaining alignment with deprecation
guidelines.
2025-10-13 16:47:36 -03:00
Jarek Radosz 2914e7712a DEV: Remove unused service injections (#34750) 2025-10-08 13:31:41 +02:00
Jarek RadoszandLoïc Guitaut 71834c898f DEV: Update rubocop-discourse to 3.13 and autofix issues (#35073)
Co-authored-by: Loïc Guitaut <loic@discourse.org>
2025-10-06 16:11:01 +02:00
Jarek RadoszandLoïc Guitaut a54e3208cb DEV: Hand-pick Rails/WhereNot autofixes (#35117)
We can't enable `Rails/WhereNot` lint/autofix, because it would break
code that uses mini_sql instead of AR (which rubocop, and tbh also we,
can't easily differentiate)

Those are safe because they either:
* are executed in AR model scope definitions
* are clearly chained starting from a AR model
* are less-clearly chained, but still can be traced to a AR model/scope

---------

Co-authored-by: Loïc Guitaut <loic@discourse.org>
2025-10-03 13:29:22 +02:00
Jarek RadoszandLoïc Guitaut e372355fd0 DEV: Clean up scope resolution operators in plugins (#34979)
Co-authored-by: Loïc Guitaut <loic@discourse.org>
2025-09-30 14:36:34 +02:00
Martin BrennanandJarek Radosz cc0e2fe00b DEV: Add basic system spec for discourse-reaction on post (#35029)
Covers default reactions,
`discourse_reactions_experimental_allow_any_emoji`,
`discourse_reactions_enabled_reactions`, and interaction with the
`emoji_deny_list` setting from core.

---------

Co-authored-by: Jarek Radosz <jradosz@gmail.com>
2025-09-30 10:29:34 +10:00
Sérgio SaquetimandJarek Radosz ad3a2df0a4 DEV: Replace Ember's deprecated mapBy with standard .map (#34963)
Replaces usages of `mapBy` across the codebase with JavaScript's native
`.map`. This resolves deprecation warnings related to Ember's array
extensions and ensures compatibility with future Ember versions.

---------

Co-authored-by: Jarek Radosz <jradosz@gmail.com>
2025-09-26 12:59:35 -03:00
Jarek Radosz 08a741b817 DEV: Fix PostDestroyer deprecations in specs (#34986)
…and remove a stray `puts` in a spec
2025-09-26 09:53:17 +08:00
Jarek Radosz 2773ee4963 DEV: Fix random typos (#34987)
September 2025 edition
2025-09-26 09:52:28 +08:00
Jarek Radosz 2c84945853 DEV: Normalize route and namespace setup in plugins (#34962) 2025-09-25 12:35:29 +02:00
David Taylor 6081bc2249 DEV: Standardize Ember route, controller and template naming (#34417)
For historical reasons, Discourse has a customized Ember resolver. This
had a much more fuzzy implementation of 'normalize' and 'findTemplate'
functions. This leniency meant that our file naming hasn't always
matched Ember conventions.

Standardizing our naming will make things easier to understand for
developers, and will make adoption of newer ecosystem tooling easier
(e.g. route-based bundle splitting in Embroider/vite)

This commit adds deprecations to the resolver when this leniency is
used, and uses a fully bespoke codemod to rename all of the affected
routes/controllers/templates in the Discourse core repository.
Backwards-compatibility is maintained for anyone looking up the old
names in the resolver.
2025-09-25 11:27:45 +01:00
Sérgio Saquetim 5b031945f7 DEV: Replace the use of Ember's .findBy for native methods on arrays (#34557)
Use the native array `.find` instead of Ember's `.findBy` which was deprecated.
2025-09-24 15:32:13 -03:00
Discourse Translator Bot e0b849beac Update translations (#34839) 2025-09-24 14:48:18 +02:00
Jarek Radosz 52e872961a DEV: Clean up requires (#34946)
1. remove unnecessary `.rb` filename suffixes from `require_relative`
calls
2. replace `require File.expand_path(File.dirname(__FILE__) + …` with
`require_relative`
3. remove `./` prefixes from `require_relative` calls
2025-09-24 12:00:22 +02:00
Discourse Translator Bot ccf379900d Update translations (#34804) 2025-09-15 10:47:22 +02:00
Discourse Translator Bot 5a8f5e8f07 Update translations (#34658) 2025-09-01 10:54:32 +02:00
Discourse Translator Bot 7f07453157 Update translations (#34633) 2025-08-29 17:24:43 +02:00
Discourse Translator Bot caf794c7ff Update translations (#34586) 2025-08-28 12:15:51 +02:00
Discourse Translator Bot fbdb1e2070 Update translations (#34537) 2025-08-26 16:12:30 +02:00
Sérgio Saquetim 95a95a492b DEV: Deprecate Site.mobileView/desktopView during initialization (#34122)
This commit introduces deprecation warnings for accessing Site.mobileView or
Site.desktopView during application initialization to prevent
layout-related errors and improve code reliability.

The changes include:

* Added deprecation warnings for Site.mobileView and Site.desktopView
access during the initialization phase.
* Updated multiple plugins and components to avoid these deprecated
calls during startup.
* Refactored initialization logic across discourse-ai, discourse-chat,
discourse-calendar, discourse-reactions, discourse-assign,
discourse-subscriptions, and discourse-user-notes plugins
* Improved error prevention by discouraging early access to
view-dependent properties before the application is fully initialized
* Enhanced code maintainability by establishing clearer boundaries
between initialization and runtime phases

This deprecation helps prevent subtle bugs that can occur when
components try to determine the view type before the application context
is properly established, leading to more robust plugin initialization
patterns.
2025-08-25 16:49:52 -03:00
fokx f002aa4022 FEATURE: Allow choosing custom emoji in reaction (#34312)
This PR allows user to choose any emoji in reaction, like the old retort plugin.

* Add a `discourse_reactions_experimental_allow_any_emoji` option, if enabled, will add a button of EmojiPicker in the ReactionsPicker
* When the EmojiPicker is shown, will prevent ReactionsPicker from collapse when clicking at outside(necessary on mobile device) / moving mouse outside of ReactionsPicker
* This is considered a disabled by default experimental feature for now, admins can enable
at their own discretion, as there is not currently a way to limit which reactions can be used here
2025-08-25 18:14:36 +10:00
Discourse Translator BotandGerhard Schlager ab0b0573a1 Update translations (#34413)
Co-authored-by: Gerhard Schlager <gerhard.schlager@discourse.org>
2025-08-19 16:23:59 +02:00
Discourse Translator Bot 74066bffa2 Update translations (#34116) 2025-08-19 12:14:51 +02:00
Jordan Vidrine e8cda50573 DEV: Simple refactor of button markup (#34256) 2025-08-12 13:00:32 -05:00
Sérgio Saquetim 4013d1ffb8 DEV: Improve user handling and access in post components (#34013)
This pull request improves how user properties are managed and accessed
in post-related components and models. Notable improvements include:

- The `Post` model now provides a cached `user` property, ensuring a
consistent and up-to-date user object using relevant post fields,
instead of relying on `user` being set directly or via the `PostStream`.
- Components such as `PostAvatar` and `PostMetaDataPosterName` now
consistently reference the `user` property, improving reliability and
reducing the risk of missing or inconsistent user data.
- User context is more accurately passed to value transformers and
plugin outlets, ensuring that avatar and name rendering logic always
receives the correct user information.
- The `GroupPostSerializer` now includes the `user_id` attribute,
improving API consistency.
- Test cases have been updated to work with the new user property
approach, removing direct creation of user objects on posts and instead
relying on post fields.
- The `discourse-reactions` plugin was updated to align with the new
user property logic, ensuring reaction-related user data is accessed
consistently.

Overall, these changes improve data integrity, reduce the risk of
rendering errors due to user data inconsistencies, and streamline how
user information is passed through Discourse post-related features.
2025-08-06 17:00:34 -03:00
Régis Hanol ced043be3c FIX: 'destination_url' cookie handling (#33072)
Since the introduction of dedicated login and signup pages (as opposed
to modals), we've been seeing reports of issues where visitors aren't
redirected back to the "page" they were at when they initiated the
_authentication_ process.

Since we have a bazillion of ways a user might authenticate
(credentials, social logins, SSO, passkeys, discourse connect, etc...),
it's really hard to know what a change will impact.

The goal of this PR is to "simplify" the way we handle this "redirection
back to origin" by leveraging the use of a single `destination_url`
cookie set on the client-side.

The changes remove scattered cookie-setting code and consolidate the redirection logic to ensure users are properly redirected back to their original page after authentication.

- Centralized destination URL cookie management in routes and authentication flows
- Removed manual cookie setting from various components in favor of automatic handling
- Updated test scenarios to properly test the new redirection behavior
2025-08-06 10:09:01 +02:00
Jarek Radosz ce6368ca98 DEV: Enable ember/no-classic-components (#33978)
…and apply lint-to-the-future
2025-07-30 14:54:24 +02:00
Jordan Vidrine 49a1667155 UX: Content border color (#33908) 2025-07-28 16:17:06 -05:00
Discourse Translator Bot fa87576fcf Update translations (#33892) 2025-07-28 18:38:22 +02:00
dependabot[bot]dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>Discourse CIJarek Radosz
e7d3c344d1 Build(deps-dev): Bump the lint group across 1 directory with 4 updates (#33881)
Bumps the lint group with 4 updates in the / directory:
[@discourse/lint-configs](https://github.com/discourse/lint-configs),
[ember-template-lint](https://github.com/ember-template-lint/ember-template-lint),
[eslint](https://github.com/eslint/eslint) and
[stylelint](https://github.com/stylelint/stylelint).


Updates `@discourse/lint-configs` from 2.22.0 to 2.28.0
- [Commits](https://github.com/discourse/lint-configs/commits)

Updates `ember-template-lint` from 7.7.0 to 7.9.1
- [Release
notes](https://github.com/ember-template-lint/ember-template-lint/releases)
-
[Changelog](https://github.com/ember-template-lint/ember-template-lint/blob/master/CHANGELOG.md)
-
[Commits](https://github.com/ember-template-lint/ember-template-lint/commits)

Updates `eslint` from 9.27.0 to 9.32.0
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v9.27.0...v9.32.0)

Updates `stylelint` from 16.19.1 to 16.22.0
- [Release notes](https://github.com/stylelint/stylelint/releases)
-
[Changelog](https://github.com/stylelint/stylelint/blob/main/CHANGELOG.md)
-
[Commits](https://github.com/stylelint/stylelint/compare/16.19.1...16.22.0)

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Discourse CI <ci@ci.invalid>
Co-authored-by: Jarek Radosz <jarek@cvx.dev>
2025-07-28 18:02:41 +02:00
Jarek Radosz 4d5b841b39 DEV: Clean up js: true from recently bundled plugin specs (#33873) 2025-07-27 12:59:00 +02:00
Jarek Radosz 21e9733f27 DEV: Fix various lint issues (#33811)
…mostly in recently bundled plugins.
2025-07-24 15:27:04 +02:00
Jarek Radosz 1cb3e2c070 DEV: Remove unnecessary rails_helper requires (#33812) 2025-07-24 13:50:04 +02:00
Discourse Translator Bot 0bad5c6104 Update translations (#33746) 2025-07-23 00:13:58 +02:00
Discourse Translator Bot 71a49efe3c Update translations (#33619) 2025-07-15 13:17:12 -04:00
Sérgio Saquetim 301f27caaa DEV: add shortcut fab!(:variable, :fabricator) to specs (#33577) 2025-07-11 11:16:34 -03:00
Jarek Radosz 620883cd13 DEV: Move discourse-reactions to core (#33538)
https://meta.discourse.org/t/373574

Internal `/t/-/156778`
2025-07-10 11:40:31 +01:00