Commit Graph

3563 Commits

Author SHA1 Message Date
Natalie Tay
5b51ed3856
DEV: Promote historic post_deploy migrations (#28128)
This commit promotes all post_deploy migrations which existed in Discourse v3.2.0 (timestamp <= 20240112043325)
2024-07-30 01:14:03 +08:00
Discourse Translator Bot
f5fc49f5db
Update translations (#28115)
* Update translations

* DEV: Spec failed because of translation update

---------

Co-authored-by: Gerhard Schlager <gerhard.schlager@discourse.org>
2024-07-29 15:16:40 +02:00
David McClure
880da52bb6
DEV: improve copy for instant-runoff polls (#28104) 2024-07-27 22:08:41 -04:00
Jarek Radosz
f14cf4f8a9
DEV: Fix random typos (#28103)
July 2024 edition
2024-07-26 23:13:12 +02:00
David Battersby
6f2f34f786
DEV: fix chat message grace edit period flaky (#28095)
The message grace edit window (10 seconds) was too short after freezing time, possibly causing the test to fail occasionally if the record is not updated within 5 seconds.
2024-07-26 18:16:17 +04:00
Jarek Radosz
038e5deb2a
DEV: Clean up imports (#28060)
* `@ember/owner` instead of `@ember/application`
* `discourse-i18n` instead of `I18n`
* `{ service } from "@ember/service"` instead of `inject as service`
2024-07-25 15:09:06 +02:00
Joffrey JAFFEUX
7a7cc815be
DEV: removes legacy modal code (#28047) 2024-07-24 18:07:17 +02:00
Joffrey JAFFEUX
0fbce0aa85
DEV: adds a way to set a title/description to a radio (#28049)
Usage:

```
<Form as |form|>
  <form.Field @name="foo" @title="Foo" as |field|>
    <field.RadioGroup as |RadioGroup|>
      <RadioGroup.Radio @value="one" as |radio|>
        <radio.Title>One title</radio.Title>
        <radio.Description>One description</radio.Description>
      </RadioGroup.Radio>
    </field.RadioGroup>
  </form.Field>
</Form>
```
2024-07-24 14:25:34 +02:00
chapoi
5b693c61af
UX: change sidebar background to secondary (#28043) 2024-07-23 15:56:21 +02:00
Discourse Translator Bot
5b5d5b4b4a
Update translations (#28041) 2024-07-23 15:23:42 +02:00
Joffrey JAFFEUX
8b18fd1556
FIX: do not reload identical route in drawer (#27992)
This is a performance optimisation to prevent the same route to keep reloading the same endpoint.

No tests as it's not changing behavior and is also quite complex to test efficiently.
2024-07-19 22:27:32 +02:00
Natalie Tay
278ae6e5fd
DEV: Try until success for clipboard copies (#27986) 2024-07-19 19:44:10 +08:00
David Taylor
94d4b187ef
UX: Show error when checkbox change fails (#27968)
e.g. due to a permissions/network issue
2024-07-18 13:22:10 +01:00
Joffrey JAFFEUX
1aa24f83bb
DEV: form-kit improvements (#27966)
- correctly support @title on fields
- correctly support @subtitle on fields
- improves error message when a field name is incorrect in assertions
2024-07-18 10:30:18 +02:00
Martin Brennan
48d13cb231
UX: Use a dropdown for SSL mode for group SMTP (#27932)
Our old group SMTP SSL option was a checkbox,
but this was not ideal because there are actually
3 different ways SSL can be used when sending
SMTP:

* None
* SSL/TLS
* STARTTLS

We got around this before with specific overrides
for Gmail, but it's not flexible enough and now people
want to use other providers. It's best to be clear,
though it is a technical detail. We provide a way
to test the SMTP settings before saving them so there
should be little chance of messing this up.

This commit also converts GroupEmailSettings to a glimmer
component.
2024-07-18 10:33:14 +10:00
Discourse Translator Bot
6dd09b0868
Update translations (#27936)
* Update translations

* DEV: Spec failed after recent translation changes

---------

Co-authored-by: Gerhard Schlager <gerhard.schlager@discourse.org>
2024-07-17 15:49:33 +02:00
Kris
c17fab873d
UX: remove whitespace from rendered localdate (#27952) 2024-07-17 09:48:28 -04:00
chapoi
2ca06ba236
DEV: form-kit
This PR introduces FormKit, a component-based form library designed to simplify form creation and management. This library provides a single `Form` component, various field components, controls, validation mechanisms, and customization options. Additionally, it includes helpers to facilitate testing and writing specifications for forms.

1. **Form Component**:
   - The main component that encapsulates form logic and structure.
   - Yields various utilities like `Field`, `Submit`, `Alert`, etc.

   **Example Usage**:
   ```gjs
   import Form from "discourse/form";

   <template>
     <Form as |form|>
       <form.Field
         @name="username"
         @title="Username"
         @validation="required"
         as |field|
       >
         <field.Input />
       </form.Field>

       <form.Field @name="age" @title="Age" as |field|>
         <field.Input @type="number" />
       </form.Field>

       <form.Submit />
     </Form>
   </template>
   ```

2. **Validation**:
   - Built-in validation rules such as `required`, `number`, `length`, and `url`.
   - Custom validation callbacks for more complex validation logic.

   **Example Usage**:
   ```javascript
   validateUsername(name, value, data, { addError }) {
     if (data.bar / 2 === value) {
       addError(name, "That's not how maths work.");
     }
   }
   ```

   ```hbs
   <form.Field @name="username" @validate={{this.validateUsername}} />
   ```

3. **Customization**:
   - Plugin outlets for extending form functionality.
   - Styling capabilities through propagated attributes.
   - Custom controls with properties provided by `form` and `field`.

   **Example Usage**:
   ```hbs
   <Form class="my-form" as |form|>
     <form.Field class="my-field" as |field|>
       <MyCustomControl id={{field.id}} @onChange={{field.set}} />
     </form.Field>
   </Form>
   ```

4. **Helpers for Testing**:
   - Test assertions for form and field validation.

   **Example usage**:
   ```javascript
   assert.form().hasErrors("the form shows errors");
   assert.form().field("foo").hasValue("bar", "user has set the value");
   ```

   - Helper for interacting with he form

   **Example usage**:
   ```javascript
   await formKit().field("foo").fillIn("bar");
   ```

5. **Page Object for System Specs**:
   - Page objects for interacting with forms in system specs.
   - Methods for submitting forms, checking alerts, and interacting with fields.

   **Example Usage**:
   ```ruby
   form = PageObjects::Components::FormKit.new(".my-form")
   form.submit
   expect(form).to have_an_alert("message")
   ```

   **Field Interactions**:
   ```ruby
   field = form.field("foo")
   expect(field).to have_value("bar")
   field.fill_in("bar")
   ```


6. **Collections handling**:
   - A specific component to handle array of objects

   **Example Usage**:
   ```gjs
    <Form @data={{hash foo=(array (hash bar=1) (hash bar=2))}} as |form|>
      <form.Collection @name="foo" as |collection|>
        <collection.Field @name="bar" @title="Bar" as |field|>
          <field.Input />
        </collection.Field>
      </form.Collection>
    </Form>
   ```
2024-07-17 11:59:35 +02:00
Robert
bae492efee
FEATURE: Add Ranked Choice Voting
using Instant Run-off Voting algorithm to Poll Plugin (Part 2 add Ranked Choice)

---------

Co-authored-by: Joffrey JAFFEUX <j.jaffeux@gmail.com>
Co-authored-by: Jarek Radosz <jradosz@gmail.com>
2024-07-17 11:49:14 +02:00
Joffrey JAFFEUX
c74fa300e7
FEATURE: allows browse page in chat drawer (#27919)
This commit ensures the browse page can be loaded in the drawer and doesn’t force full page mode.

Other notable changes of this commit:
- be consistent about wrapping each full page route with "c-routes.--route-name" and each drawer container with "c-drawer-routes.--route-name"
- move browse channels into its own component, it was before in the template of the channels browse
2024-07-16 12:34:37 +02:00
Régis Hanol
6ebd0c5aec
DEV: skip flaky spec in CI (#27918) 2024-07-15 12:00:43 +02:00
Natalie Tay
9bed472a77
DEV: Temporarily skip failing test on CI (#27915) 2024-07-15 15:23:01 +08:00
Kelv
98cbfd598c
DEV: add deprecation ids for base-url, fa-icon and chat service (#27911) 2024-07-15 14:29:17 +08:00
David Battersby
f75dd1b43a
FIX: update order of chat message service steps (#27889)
A change made in #27875 added a new step to the create message service, however the step should have been placed before saving the message.
2024-07-12 11:56:07 +04:00
David Battersby
4a365bc4a2
FEATURE: prevent chat emails for messages created via SDK (#27875)
This change allows us to distinguish between regular user generated chat messages and those created via the Chat SDK.

A new created_by_sdk boolean column is added to the Chat Messages table. When this value is true, we will not include the message in the user summary email that is sent to users.
2024-07-12 10:57:14 +04:00
Joffrey JAFFEUX
897518e874
FIX: ensures chat panel can't have an invalid width (#27876)
Prior to this fix the following sequence would cause an overflow:

- open a thread
- expand thread panel to maximum width
- close panel
- reduce window width
- open thread again
- 💥

The fix is now ensuring that we never use or set a width which would cause the main panel + side panel to be larger than the chat container. We also removed the service as it was overkill for this case and it's easier to have all the implementation at one place.

This commit also uses JS animation api to set the width of the panel.

<!-- NOTE: All pull requests should have tests (rspec in Ruby, qunit in JavaScript). If your code does not include test coverage, please include an explanation of why it was omitted. -->
2024-07-11 20:27:30 +02:00
Joffrey JAFFEUX
6547f78ff8
DEV: migrates reviewable-created-by to gjs (#27862) 2024-07-11 11:54:35 +02:00
Robert
d8d3d2184a
FIX: Poll: Show gear button only when there is more than one dropdown item (#27775)
During migration of Poll plugin from widget basis to glimmer, some functionality was inadvertently dropped:

- A single button should appear instead of the dropdown menu when there is only one valid "poll admin" action
- No button should appear when there are no valid "poll admin" actions for current user

This PR restores the original behaviour and adds test coverage (that didn't exist prior to migration, partly why it wasn't caught earlier)

relates to #27204

related meta topic:  https://meta.discourse.org/t/what-is-the-gear-button-under-the-poll-for/315477/2
2024-07-11 11:19:04 +08:00
Kris
c780e764d0
A11Y: usercard resizing for high zoom levels (#27846) 2024-07-10 14:51:56 -04:00
Régis Hanol
d2873d9775
DEV: wait a bit for chat message to persist (#27830)
Internal ref t/132745
2024-07-10 16:11:50 +02:00
Discourse Translator Bot
dd67375de7
Update translations (#27790) 2024-07-09 23:12:03 +02:00
Joffrey JAFFEUX
c080ac0094
FIX: show too long message error on client (#27794)
Prior to this fix we would show the message after a round trip to the server. If you had a too long message error, at this point your input would be empty and we would show an error in chat. It's important to have this server side safety net, but we can have a better UX by showing an error on the frontend before sending the message, that way you can correct your message before sending it and not lose it.
2024-07-09 18:34:35 +02:00
Kris
4ee64ad168
UX: fix card positioning, allow shrink-to-fit (#27774) 2024-07-08 17:30:43 -04:00
Jarek Radosz
619f132f57
DEV: Check for poll element presence (#27765)
Fixes a flaky test. `afterUpdate` from chart.js is not integrated with the runloop and component lifecycle, as a result we have no guarantee on when it will happen. The easiest change we can do for now is ensuring we actually have the DOM we expect to have, and if not, we exit early.


Co-authored-by: Joffrey JAFFEUX <j.jaffeux@gmail.com>
Co-authored-by: merefield <merefield@gmail.com>
2024-07-08 13:58:35 +02:00
Alan Guo Xiang Tan
f9a5d149e1
DEV: Skip flaky polls acceptance test (#27757)
Example of flakiness: https://github.com/discourse/discourse/actions/runs/9831645793/job/27139325323
2024-07-08 09:11:38 +08:00
ScottMastro
21b62f7894
FIX: typo in poll "closed" (#27748)
Reference to string poll.results.close.title should be "closed" instead of "close"
2024-07-08 08:42:31 +08:00
Robert
f86a95d282
FIX: Allow safe html in poll options (#27741) 2024-07-07 15:08:00 +02:00
Robert
4f87f0d7ef
FIX: Poll: option text wrapping bevahiour styling improvement (#27738) 2024-07-05 15:27:40 +02:00
Régis Hanol
9db1620842
DEV: skip flaky system chat spec (#27737) 2024-07-05 15:27:07 +02:00
Robert
8b963986b3
FIX: Poll: critical display issue when results are only shown upon vote (#27732) 2024-07-05 10:55:14 +02:00
Alan Guo Xiang Tan
906da0f3d1
DEV: Skip flaky poll QUnit acceptance tests (#27728)
The skipped tests have become flaky after
e3b6be15b8, skip those tests for now while
we sort things out.
2024-07-05 10:59:51 +08:00
Robert
a30a861546
FIX: Poll: do not attempt to show voter list on private polls (#27714)
* FIX: avoid attempting to enrich results with undefined voters
2024-07-04 18:20:37 +02:00
chapoi
2db35149fd
UX: Chat mobile menu styling update (#27598) 2024-07-04 18:02:30 +02:00
Robert
e3b6be15b8
FEATURE: Add Instant Run-off Voting to Poll Plugin (Part 1: migrate existing plugin to Glimmer only) (#27204)
The "migration to Glimmer" has been broken out here from #27155 to make the review process less onerous and reduce change risk: 

* DEV: migrates most of the widget code to Glimmer in prep for IRV additions
* NB This already incorporates significant amounts of review and feedback from the prior PR.
* NB because there was significant additional feedback relating to older Poll code that I've improved with feedback, there are some additional changes here that are general improvements to the plugin and not specific to IRV nor Glimmer!
* There should be no trace of IRV code here.

Once this is finalised and merged we can continue to progress with #27155.
2024-07-04 13:34:48 +02:00
Loïc Guitaut
8d249457e8 DEV: Upgrade Rails to version 7.1
---------

Co-authored-by: Jarek Radosz <jradosz@gmail.com>
2024-07-04 10:58:21 +02:00
锦心
f3130bc6d9
FIX: Inline footnotes doesn’t work in the table at fullscreen (#27686)
* FIX: Inline footnotes doesn’t work in the table at fullscreen

meta topic: https://meta.discourse.org/t/inline-footnotes-doesnt-work-in-the-table-at-fullscreen/313445
2024-07-03 18:52:36 +08:00
Krzysztof Kotlarek
c3fadc7330
FEATURE: created edit and delete flags (#27484)
Allow admins to create edit and delete flags.
2024-07-03 08:45:37 +10:00
Keegan George
ea58140032
DEV: Remove summarization code (#27373) 2024-07-02 08:51:47 -07:00
Discourse Translator Bot
052550c6e0
Update translations (#27680) 2024-07-02 16:42:56 +02:00
Kris
9e8d8d37fa
UX: fix height of lazy youtube embeds (#27671) 2024-07-01 17:27:11 -04:00
Jan Cernik
6599b85a75
DEV: Block accidental serialization of entire AR models (#27668) 2024-07-01 17:08:48 -03:00
David Battersby
bee7312f46
FIX: show group based notifications in chat summary email (#27641)
Follow up to #27631 to account for group mentions in channels.

We only want to show mentions for groups that are currently mentionable and those that the current user belongs to.
2024-07-01 12:47:38 +04:00
Martin Brennan
ffc99253fa
DEV: Resolve TODO comments for martin-brennan
I am changing many of these to notes or resolving them as is,
most of these I have not actively worked on in years so someone
else can work on them when we get to these areas again.
2024-07-01 15:32:30 +10:00
Jan Cernik
e161086630
FIX: User controls buttons order for admins (#27646) 2024-06-28 18:32:25 -03:00
Discourse Translator Bot
423f92490c Update translations 2024-06-28 16:10:06 +02:00
David Battersby
580bad3c02
FIX: only show relevent chat channel mentions in summary email (#27631)
Chat summary email should only contain mentions that are relevant to the current user.
2024-06-27 15:53:40 +04:00
Loïc Guitaut
f58b844f45
Revert "DEV: Upgrade Rails to version 7.1" (#27625)
This reverts commit ce00f83173.
2024-06-26 18:55:05 +02:00
Joffrey JAFFEUX
01e36cbb47
FIX: correctly show validation errors in automation (#27622)
A previous refactor has prevented errors to show correctly. The guilt of the issue is that we were not calling the error variable correctly in the templates.

This commit also adds a spec for this case, and removes the need for `I18n.backend.store_translations` in specs so we don't have to write too much boilerplate each time we write a spec.
2024-06-26 14:09:26 +02:00
Discourse Translator Bot
7d4ff77a14
Update translations (#27604) 2024-06-25 15:40:08 +02:00
Ted Johansson
d63f1826fe
FEATURE: User fields required for existing users - Part 2 (#27172)
We want to allow admins to make new required fields apply to existing users. In order for this to work we need to have a way to make those users fill up the fields on their next page load. This is very similar to how adding a 2FA requirement post-fact works. Users will be redirected to a page where they can fill up the remaining required fields, and until they do that they won't be able to do anything else.
2024-06-25 19:32:18 +08:00
Jan Cernik
a07ddf4ec0
UX: Show chat and message buttons on your own profile (#27600) 2024-06-25 07:52:17 -03:00
pangbo13
c8e65fa673 fix linting 2024-06-25 12:17:22 +02:00
pangbo13
98f7430480 fix: allow staff and direct message enabled groups to create personal chats 2024-06-25 12:17:22 +02:00
chapoi
9f40ac0918
UX: revert chat footer changes partially (#27591) 2024-06-24 17:46:54 +02:00
Kris
e5c0cfcd27
UX: remove default use of quaternary color, update nav pill styles (#27502) 2024-06-24 09:54:34 -04:00
Régis Hanol
3927b27f34 FIX: allow quote-less details BBCode
In 53b3d2f0dc we introduced a stricter BBCode Tag parser. It prevents having "values" with spaces when they're not surrounded by a valid pair of quotes.

The `[details=` BBCode Tag is popular enough that it's worth adding a special case for it (especially since it doesn't support other parameters).

This also adds the Finnish pair of quotes.

Context - https://meta.discourse.org/t/details-accepts-only-one-word-as-summary/313019
2024-06-24 14:16:36 +02:00
Loïc Guitaut
ce00f83173 DEV: Upgrade Rails to version 7.1
---------

Co-authored-by: Jarek Radosz <jradosz@gmail.com>
2024-06-24 11:16:14 +02:00
Jarek Radosz
8d4c9523ee
DEV: Convert some tests to qunit-dom (#27577)
(and fix two test bugs)
2024-06-23 22:34:15 +02:00
Kris
f38bb5e3e4
UX: fix chat drawer z-index (#27568) 2024-06-21 10:09:05 -04:00
Loïc Guitaut
160011793a Revert "DEV: Upgrade Rails to version 7.1 (#27539)"
This reverts commit ca4af53be8.
2024-06-21 11:20:40 +02:00
Loïc Guitaut
ca4af53be8 DEV: Upgrade Rails to version 7.1 (#27539)
* DEV: Upgrade Rails to 7.1

* FIX: Remove references to `Rails.logger.chained`

`Rails.logger.chained` was provided by Logster before Rails 7.1
introduced their broadcast logger. Now all the loggers are added to
`Rails.logger.broadcasts`.

Some code in our initializers was still using `chained` instead of
`broadcasts`.

* DEV: Make parameters optional to all FakeLogger methods

* FIX: Set `override_level` on Logster loggers (#27519)

A followup to f595d599dd

* FIX: Don’t duplicate Rack response

---------

Co-authored-by: Jarek Radosz <jradosz@gmail.com>
2024-06-21 09:44:06 +02:00
chapoi
c1f477c1b6
UX: Remove or replace button transitions with variable (#27527) 2024-06-20 19:51:20 +02:00
Loïc Guitaut
982c005979 Revert "DEV: Upgrade Rails to version 7.1 (#27539)"
This reverts commit 2301dddcff.
2024-06-20 11:43:35 +02:00
Loïc Guitaut
2301dddcff
DEV: Upgrade Rails to version 7.1 (#27539)
* DEV: Upgrade Rails to 7.1

* FIX: Remove references to `Rails.logger.chained`

`Rails.logger.chained` was provided by Logster before Rails 7.1
introduced their broadcast logger. Now all the loggers are added to
`Rails.logger.broadcasts`.

Some code in our initializers was still using `chained` instead of
`broadcasts`.

* DEV: Make parameters optional to all FakeLogger methods

* FIX: Set `override_level` on Logster loggers (#27519)

A followup to f595d599dd

* FIX: Don’t duplicate Rack response

---------

Co-authored-by: Jarek Radosz <jradosz@gmail.com>
2024-06-20 10:33:01 +02:00
Jarek Radosz
5cb84f8dcf
DEV: Revert rails 7.1 upgrade (#27522)
* Revert "FIX: Set `override_level` on Logster loggers (#27519)"

This reverts commit c1b0488c54.

* Revert "DEV: Make parameters optional to all FakeLogger methods"

This reverts commit 3318dad7b4.

* Revert "FIX: Remove references to `Rails.logger.chained`"

This reverts commit f595d599dd.

* Revert "DEV: Upgrade Rails to 7.1"

This reverts commit 081b00391e.
2024-06-18 23:48:30 +02:00
Loïc Guitaut
081b00391e DEV: Upgrade Rails to 7.1 2024-06-18 15:58:05 +02:00
Discourse Translator Bot
69c99a82dd
Update translations (#27511) 2024-06-18 15:39:31 +02:00
Jarek Radosz
1defb9449b
UX: Move user-cards above composer (#27491)
There is currently only one scenario when both the composer and a user card would be present at the same time:

if you have the composer open and then you click on something outside it that triggers a card. Which implies intent to see the card (unobstructed by the composer 😉)

The reverse doesn't happen because opening the composer would close an existing user card.

In theory there's also displaying a user card by clicking on a mention in composer's preview but that functionality is currently broken (and this PR is a prerequisite 😉)

---

I changed `.user-card, .group-card` to `.fk-d-menu[data-identifier="card"]` because that regressed when we moved user cards to float-kit – they are nested inside `.fk-d-menu` so its `z-index` is now important (effectively the cards had `z-index: z("dropdown")` instead of `z("usercard")`)
2024-06-18 15:12:41 +02:00
Régis Hanol
53b3d2f0dc FIX: BBCode tag parser
Wasn't quite handling the cases where a closing bracket `]` was used in the value of one of the attributes.

```markdown
[chat quote=user channel="[broken]"]
```

Would not be correctly parsed because we would _greedily_ use the first `]` as the end of the tag even though it might be a valid character when inside proper quotes.

c39a4de139/app/assets/javascripts/discourse-markdown-it/src/features/bbcode-block.js (L62)

Re-wrote the `parseBBCodeTag` to properly handle the following cases

- A closing tag (aka `[/name]`) which are easy since they don't have any attributes
- An old `[quote=...]` format we used that doesn't uses quotes but still has various attributes of the form `key:value`
- All three valid BBCode opening tag formats we support
  - `[name]` without any attributes
  - `[name=foo]` with a default value
  - `[name foo=bar]` with some attributes

Ended up having to fix/rewrite the few bbcode rules that were using the `parseBBCodeTag` function, namely `d-wrap` and `discourse-local-dates`.

While working on this, I think I also found a way to get rid the of shims we had in place so that plugins could use the `parseBBCodeTag` function.

Reference - https://meta.discourse.org/t/having-a-right-bracket-in-a-channel-name-breaks-all-quotes-from-that-channel/308439
2024-06-18 10:47:18 +02:00
Kris
3a31c47d37
UX: remove padding to fix mobile thread date pinning (#27470) 2024-06-14 13:50:27 -04:00
Jarek Radosz
fe00796027
DEV: Minor refactor of chat models (#27467)
* remove default prop values where they're being set in constructor
* replace some `||` operators in constructors with `??` so the fallback boolean values are actually used
2024-06-13 17:07:31 +02:00
David Battersby
3b653a918e
FEATURE: show my threads from muted chat channels (#27468)
We should show threads from muted channels in the My Threads area so that users can easily access their followed threads.
2024-06-13 18:39:35 +04:00
Jarek Radosz
a8567d409d
DEV: Clean up chat-message-reaction (#27465)
* remove an unused service injection (and sort the rest)
* remove unused prop
* inline an arg check
* remove an unnecessary `?.` operator
* sort element attributes
2024-06-13 15:12:56 +02:00
Jarek Radosz
5361c3704d
FIX: Don't modify FloatKitInstances arrays unless needed (#27462) 2024-06-13 12:44:38 +02:00
David Battersby
47540fb4e0
FEATURE: chat drawer navigation improvement (#27419)
This change replaces the chat drawer tabs with new drawer routes for channels, direct messages and threads.

The main objective is to improve navigation within drawer, now that we have separation of chat sections in drawer.
2024-06-13 13:17:12 +04:00
Jarek Radosz
9f681ad65e
FIX: Check for textarea presence (#27457)
This mirrors `ChatThreadComposer.blur`

Co-authored-by: Leonardo Mosquera <ldmosquera@gmail.com>
2024-06-12 23:37:19 +02:00
Discourse Translator Bot
74e7bed7d5
Update translations (#27417) 2024-06-11 17:20:39 +02:00
Kris
ebc23b348f
UX: restrict mobile tooltip width to prevent horizontal overflow (#27420) 2024-06-11 10:37:42 -04:00
David Battersby
fb11ab5895
FIX: new chat from url flaky fix (#27414)
The order of chat direct message groups can sometimes place usernames in an unexpected order, this change tests multiple combinations of usernames and accepts them no matter what order they are in.
2024-06-11 14:13:08 +04:00
Kris
dfad95058d
UX: allow cooked local-dates to wrap (#27404) 2024-06-10 17:22:30 -04:00
Régis Hanol
5d33ea1f6e FIX: correctly load channels in chat webhooks
In 4e7a75a7ec, we moved to a single admin plugin page and added a few fields to the "plugin serializer" but we already had a proper route with the correct serializers to properly load channels.

This fixes it by removing the "add_to_serializer" calls and changed the calls to "/admin/plugins/chat.json" to the proper "/admin/plugins/chat/hooks.json" route.

Meta - https://meta.discourse.org/t/names-are-missing-from-list-when-creating-new-chat-channel-webhooks/308481
2024-06-10 17:30:38 +02:00
Jan Cernik
1a42249bd8
UX: Show message and chat buttons on hidden profiles (#27326) 2024-06-10 10:38:22 -03:00
chapoi
b6c2430bf6
UX: make chat drawer settingspage full height (#27385) 2024-06-10 15:25:28 +02:00
Régis Hanol
71391cd40d PERF: fix performance of chat email notifications
When chat is enabled, there's a scheduled job that runs every 5 minutes to check whether we need to send a "chat summary" email to users with unread chat messages or mentions.

On Discourse with a large number of users, the query used wasn't optimal and sometimes taking minutes. Which isn't good when the query is called every 5 minutes 😬

This PR reworks the query in `Chat::Mailer.send_unread_mentions_summary`.

Instead of starting from the `users` table, it starts from the `user_chat_channel_memberships` table which is the main piece tying everything together.

The new query is mostly similar to the previous one, with some bug fixes (like ensuring the user has `allow_private_messages` enabled for direct messages) and is also slightly simpler since it doesn't keep track of the `memberships_with_unread_messages` anymore. That part has been moved to the `user_notifications.chat_summary` email method.

The `UserEmailExtension` has been deleted since that was using to N+1 update the `user_chat_channel_memberships.last_unread_mention_when_emailed_it`(quite a mouthful 😛) but that's now done directly in the `user_notifications.chat_summary` email method.

The "plat de résistance" of that PR - the `user_notifications.chat_summary` method has been re-worked for improved performances 🚀

Instead of doing everything in one query, it does 4 tiny ones.

- One to retrieve the list of unread mentions (@something) in "category" channels
- One to retrieve the list of unread messages in "direct message" channels (aka. 1-1 and group discussions)
- One to load all the chat messages for each "category" channels from the last unread mention
- One to load all the chat messages for each "direct message" channels from the last unread message

All the specs for both `Chat::Mailer` and `UserNotification.chat_summary` have been rewriten for easier comprehension and faster execution (mostly by not using chat services which makes the specs go 10x slower...)

Internal ref - t/129848
2024-06-10 14:25:06 +02:00
Alan Guo Xiang Tan
8f55cd85ad
DEV: Clean up state to prevent flaky tests (#27397)
When adding custom translations for tests using `I18n.backend.store_translations`,
we need to remove the custom translations at the end of each test to
prevent the custom translations from leaking to other tests.
2024-06-10 08:41:03 +08:00
David Battersby
9e6dc4c5c8
DEV: prevent duplication of chat drawer routes (#27381)
This change prevents explicitly declaring each route that should be intercepted for chat drawer mode.

In theory all chat drawer routes should be intercepted from the main chat routes file and therefore we would only need to add new drawer routes directly within chat-drawer-router.js.
2024-06-07 10:47:01 +04:00
David Battersby
891fb17f60
FEATURE: load chat channel settings within drawer (#27346)
This change allows chat drawer users to edit channel settings and members without leaving drawer mode. If a channel is open within chat drawer and the user clicks the Channel name, it will load channel settings within the drawer.
2024-06-06 14:01:09 +04:00
Discourse Translator Bot
a5c06f0b2c
Update translations (#27321) 2024-06-04 21:44:04 +02:00
Jan Cernik
625c715856
FIX: Lazy TikTok embeds height in chat (#27306) 2024-06-03 11:20:47 -03:00
David Battersby
4e80c9eb13
FIX: chat direct message group user limit is off by 1 (#27014)
This change allows the correct number of members to be added when creating a group direct message, based on the site setting chat_max_direct_message_users.

Previously we counted the current user within the max user limit and therefore the count was off by 1.
2024-06-03 12:11:49 +04:00
Kris
62b1b69e82
UX: constrain width of chat transcripts in posts (#27288) 2024-05-31 16:26:46 -04:00
Discourse Translator Bot
81fe4ed248
Update translations (#27274) 2024-05-31 12:27:26 +02:00
Jan Cernik
28fe3c339e
FIX: Allow triggering Discobot when bookmarking the entire topic (#27255) 2024-05-30 09:58:51 -03:00
Joffrey JAFFEUX
5aefda1dee
FIX: allows listing messages of any thread (#27259)
Before this fix we could only list messages of a thread if it was part of a `threading_enabled` channel or if the thread was set to `force`.

Due to our design of also using a thread id when this is just a chain of replies so we can switch from threading enabled to disabled at any time, we will allow `Chat:: ListChannelThreadMessages` to list the messages of any thread, the only important requirements are:
- having a thread id
- being able to access this thread

To allow this, this commit simply removes the check on `threading_enabled` or `force`.
2024-05-30 10:20:40 +02:00
Sérgio Saquetim
d0ac6c33c6
DEV: Prevent possible Ember rendering error on Chat::DeleteChannel modal (#27248)
Under some circumstances, the TextField component could trigger a `Assertion Failed: You attempted to update attrs on ..., but it had already been used previously in the same computation...` error, causing the Ember app to crash.
2024-05-29 15:40:29 -03:00
Jarek Radosz
b1b218aa99
DEV: Convert choose-topic to glimmer (#27229) 2024-05-29 17:19:52 +02:00
chapoi
eb8549e527
UX: Chat footer unread indicator (#27244)
A few follup changes after changing to the chat footer split for drawer:
* Fixing a bug that stretched the unread indicator on mobile
* Minor style changes in hover/focus behaviour for chat drawer
* Repositioning of unread indicator so it has more space at the top of the footer
* Using the `c-unread-indicator` mixin
2024-05-29 17:16:03 +02:00
Régis Hanol
94cf1c4786 FIX: quoting a spoiler
Was "removing" (rather not re-applying) the `[spoiler]` BBCode because we were testing the **whole** class of the `span`/`div` was `spoiled` but we added another class and thus broke this functionnality.

In order to fix this issue, the test to determine whether a `span`/`div` is a spoiler, now uses a regular expression to check whether the `class` **contains** the word `spoiled`.

Reference - https://meta.discourse.org/t/quoting-spoiler-text-doesnt-include-spoiler-tags-in-the-quote/170145
2024-05-28 19:24:52 +02:00
chapoi
d0427919f1
UX: add illustrations for empty chat list + split into tabs on drawer (#26910)
Adds a placeholder image + CTA in chat, for empty channel and DM lists.

On desktop with drawer mode, we split chat into tabs (like mobile).

---------

Co-authored-by: Joffrey JAFFEUX <j.jaffeux@gmail.com>
Co-authored-by: David Battersby <info@davidbattersby.com>
Co-authored-by: Régis Hanol <regis@hanol.fr>
2024-05-28 17:00:04 +04:00
Krzysztof Kotlarek
39902c148f
FIX: move ServiceRunner from Chat to Core (#27219)
In this PR service objects were moved to Core https://github.com/discourse/discourse/pull/26506

However, ServiceRunner should be moved as well. Mostly for CI to run effortlessly without loading plugins.
2024-05-28 13:55:46 +10:00
Krzysztof Kotlarek
556ff0a7b8
DEV: remove obsolete needs_review score type (#27200)
Chat messages are following normal post flags. This newly registered score type is not used anymore.
2024-05-28 13:03:58 +10:00
chapoi
6a21143d83
UX: add text-overflow for channel members list (#27208) 2024-05-27 21:28:54 +02:00
Loïc Guitaut
2a28cda15c DEV: Update to lastest rubocop-discourse 2024-05-27 18:06:14 +02:00
Discourse Translator Bot
9d8044a2ee
FEATURE: Add Uyghur language (#27183)
Co-authored-by: Gerhard Schlager <gerhard.schlager@discourse.org>
2024-05-27 09:58:18 +02:00
Ted Johansson
cb592ae4ac
DEV: Remove deprecated User#saw_notification_id method (#27175) 2024-05-27 11:10:46 +08:00
Joffrey JAFFEUX
0260415664
FIX: correctly handle notifications for channels (#27178)
Prior to this fix we had too logic to detect if a user is active or not:

- idle codepath on the frontend
- online user ids on the backend

The frontend solution is not very reliable, and both solution are just trying to be too smart. Making a lot of people questioning why they receive a notification sometimes and sometimes not. This commit removes all this logic and replaces it with a much more simpler logic:

- you can't receive notifications for channel you are actually watching
- we won't play a sound more than once every 3seconds
2024-05-24 19:59:24 +02:00
Joffrey JAFFEUX
14b8894ddb
FIX: missing appEvents param for onNotification (#27180)
The `onNotification` signature is:

```
onNotification(data, siteSettings, user, appEvents)
```

And we were not passing `appEvents`.

Also explicitly inject `currentUser` in `chat-notification-manager` service.
2024-05-24 18:39:54 +02:00
Joffrey JAFFEUX
5134e74e91
UX: also plays notification sounds in group channels (#27176)
Prior to this fix we were limiting this to 1:1 channels.
2024-05-24 17:48:07 +02:00
Ted Johansson
69205cb1e5
DEV: Catch missing translations during test runs (#26258)
This configuration makes it so that a missing translation will raise an error during test execution. Better discover there than after deploy.
2024-05-24 22:15:53 +08:00
Joffrey JAFFEUX
d5066336ec
UX: reduces idle time to 0 on chat (#27158)
We consider that you should always receive a notification sound when someone speaks directly with you in chat.

This commit also refactors the way we play audio in chat to make it simpler and throttle it to 3 seconds.

We also added a safeguard to ensure we won't play sounds for old messages, this case can happen when message bus is catching up the backlog (eg: in an inactive tab for example).
2024-05-24 11:18:11 +02:00
David Battersby
c39a4de139
FIX: load existing chat dm channel via url (#26998)
When users click a link that points to an existing group chat, we should reopen that chat instead of creating a new group chat so users can more easily continue ongoing conversations.
2024-05-24 12:12:49 +04:00
Joffrey JAFFEUX
b3802e12f0
FIX: correct in_thread? message logic (#27151)
A message is in a thread if:
- it has a thread_id
- it is in threading_enabled channel OR the associated thread is marked as `force`
2024-05-23 11:08:55 +02:00
Krzysztof Kotlarek
cfbbfd177c
DEV: move post flags into database (#27125)
This is preparation for a feature that will allow admins to define their custom flags. Current behaviour should stay untouched.
2024-05-23 12:19:07 +10:00
Joffrey JAFFEUX
22237e4407
FIX: set active thread on correct channel (#27141)
activeChannel is something we should use less and less as it could not exist, in this case we have the channel right here in the function so there's no reason to reach for `this.chat.activeChannel`.
2024-05-22 23:38:12 +02:00
Joffrey JAFFEUX
485427b578
FIX: correctly handles near-message-with-thread route in drawer (#27115)
Prior to this fix we wouldn't intercept it, and we also wouldn't handle it, which in result would cause us to handle as a full page interaction and open the full page chat even if you were in drawer mode.
2024-05-22 21:03:40 +02:00
Régis Hanol
0012d9626f FIX: chat activity indicator wasn't working for threads
When a user had the chat option "Show activity indicator in header" set to "all new messages", and they would get a reply to a thread they're part of, the chat icon in the header would not show the unread bubble indicator.

In order to fix this, the `ChatHeaderIconUnreadIndicator` component will now `showUnreadIndicator` whenever there is either one unread public channel or there are unread threads.

I only added a system spec for this very specific path because I don't want to slow down the whole suite to test for all the various combination of the `chat_header_indicator_preference` values.

Internal ref - t/128874
2024-05-22 17:42:59 +02:00
Régis Hanol
d4af30f26d FIX: elided content in email should always have an href
Not 100% sure why the changes in `PrettyText.format_for_email` raised this issue, but we were missing adding a link to the Discourse instance whenever we are replacing the elided part of a post with a link to either the post or the Discourse instance in the email.

Also reformated the specs using better variable names (sometimes a variable named `md` would contain some html) and used the `match_html` helper for all the tests.
2024-05-22 15:38:18 +02:00
Jan Cernik
9889547475
FEATURE: Allow to bulk delete chat messages (#26586) 2024-05-22 08:57:00 -03:00
Joffrey JAFFEUX
e5d040ef61
UX: removes blinking indicator while streaming message (#27131)
Given this is currently buggy and  we have the cancel button Im not sure this is actually necessary. I feel like it's adding a lot of noise of low value.

For now at least, it's better without it.
2024-05-22 13:48:44 +02:00
Joffrey JAFFEUX
52125d849f
FIX: correctly check for disabled notifications, tab and is idle (#27127)
This commit reuses the existing codepath in desktop-notifications and make it available to use to chat.

primaryTab was too hard to test if not impossible in this service test, however isIdle and disabled notifications are correctly tested.
2024-05-22 10:08:05 +02:00
Jan Cernik
915982955b
DEV: Fix flaky spec when creating a chat message from params (#27099) 2024-05-21 17:39:17 -03:00
Joffrey JAFFEUX
bc0ef9f7ee
FIX: play audio sound on message in non group DMs (#27112)
Prior to this change, only mentions would get a notification and a sound. This change will not create a notification for this case, but will play a sound. This is still respecting notification settings, not playing the sound when you are viewing the channel or not following it.

---------

Co-authored-by: Régis Hanol <regis@hanol.fr>
2024-05-21 21:51:22 +02:00
Discourse Translator Bot
db3db06caf
Update translations (#27104) 2024-05-21 17:40:50 +02:00
Jarek Radosz
87769a83c4
DEV: Implement glimmer topic-list (#26743)
(experimental)

The initial implementation of glimmer topic-list and related components. Does not include new APIs and isn't compatible with existing customization. That's gonna come in future PRs.

Enabled by adding groups to `experimental_glimmer_topic_list_groups` setting.
2024-05-21 14:36:15 +02:00
Krzysztof Kotlarek
40d65dddf8
Revert "DEV: move post flags into database (#26951)" (#27102)
This reverts commit 7aff9806eb.
2024-05-21 16:21:07 +10:00
Krzysztof Kotlarek
7aff9806eb
DEV: move post flags into database (#26951)
This is preparation for a feature that will allow admins to define their custom flags. Current behaviour should stay untouched.
2024-05-21 13:15:32 +10:00
Joffrey JAFFEUX
7a0c4c5296
FIX: improves chat audio notification reliability (#27089)
Debouncing the audio was causing the audio to be lost sometimes, somewhat randomly. It's not supposed to be necessary.

The commit also refactors the code to async/await.
2024-05-20 20:48:30 +02:00
Joffrey JAFFEUX
9302187ca4
FIX: ensures topic info is dynamic with scroll (#27082)
Prior to this fix we were using `topic.current_post_number` which is coming from the server side and represents the initial topic scroll position when initially rendered to the end user. However, this value is not dynamic and is not updated when the user scrolls, `topic.currentPost` is the dynamic equivalent.

No test as there are very low chances a test like this one based on scroll position, will be reliable over time.
2024-05-20 11:20:37 +02:00
Régis Hanol
aa1b874f1a
FIX: My Thread's last reply excerpt on mobile (#27072)
... wasn't properly escaped so it would should html entities (like `&#39;` instead of the apostrophe `'`).

I checked all the other places we show an excerpt and this was the only one that was missing the call to `htmlSafe` -> `replaceEmoji`.

Internal ref - t/128877
2024-05-18 14:07:49 +02:00
Régis Hanol
6060e4618c
FIX: customize chat dropdown labels (#27067)
The translations of the labels of some of the chat preferences dropdowns were not customizable via the "site texts" feature.

This was because they were declared outside of a Controller class and were thus not taking into account the customization through "site texts".

Internal ref - t/128859
2024-05-17 18:56:08 +02:00
David Battersby
34c4acd32f
DEV: update thread title prompt migration (#27052)
Add migration to handle batch processing of user options 

Co-authored-by: Osama Sayegh <asooomaasoooma90@gmail.com>
2024-05-17 00:53:19 +04:00
Régis Hanol
02469d5795
FIX: chat replies are not always in a thread (#27023)
When you reply to a chat message, we [always create a thread][1]. But when the channel we're in doesn't have threading enabled, the reply is _technically_ not a thread.

This changes the `in_thread?` method to check for both the presence of a `thread_id` and to ensure that the channel has `threading_enabled`.

Internal ref - t/128103/3

[1]: e6e3eaf472/plugins/chat/app/services/chat/create_message.rb (L110-L115)
2024-05-16 16:10:23 +02:00
Jan Cernik
0258e985d8
DEV: Remove legacy styles for LazyYT (#27047) 2024-05-16 09:53:59 -03:00
Sam
e90e6e8f86
FIX: thread safety for active automation tracking (#27044) 2024-05-16 13:34:24 +10:00
Jarek Radosz
24c55d6797
FIX: Sidebar mode switching on subfolder (#27026) 2024-05-15 10:12:15 +02:00
Régis Hanol
906f48694c FIX: deep linking to a message in a thread
Whenever you get a bookmark notification, a mention notification, or click on a bookmark on a message in a long thread, we should ensure we always highlight and show the proper message.

Before this fix, we would correctly load the thread, but would always start at the bottom.

Internal ref. t/128103
2024-05-15 09:42:12 +02:00
Discourse Translator Bot
104ca5c325
Update translations (#27017) 2024-05-14 16:19:44 +02:00
chapoi
49602905d3
UX: add missing class for oneboxing youtube video (#27005) 2024-05-13 22:53:03 +02:00
Martin Brennan
10b2715cb3
DEV: Use site setting mandatory_values for chat allowed groups (#26994)
For both `chat_allowed_groups` and `chat_message_flag_allowed_groups`,
this commit removes the `is_staff?` guardian check, and instead
adds both `moderators` and `admins` auto groups as `mandatory_values`
to those settings, as part of an ongoing effort to do this for
group-based setting values.
2024-05-13 14:38:26 +10:00
Jarek Radosz
fcd2293226
DEV: Convert the entire sidebar to gjs (#26978) 2024-05-12 19:43:51 +02:00
Osama Sayegh
3be4924b99
DEV: Move array type custom fields to JSON type in automation (#26939)
The automation plugin has 4 custom field types that are array typed. However, array typed custom fields are deprecated and should be migrated to JSON type.

This commit does a couple of things:

1. Migrate all four custom fields to JSON
2. Fix a couple of small bugs that have been discovered while migrating the custom fields to JSON (see the comments on this commit's PR for details https://github.com/discourse/discourse/pull/26939)
2024-05-10 18:47:12 +03:00
Osama Sayegh
9ebf7c9c37
FIX: Preveint recurring automations from running before start_date (#26963)
Some combinations of start_date and frequency/interval values can cause a recurring automation rule to either trigger before its start_date or never trigger. Example repros:

- Configure a recurring automation with hourly recurrence and a start_date several days ahead. What this will do is make the automation start running hourly immediately even though the start_date is several days ahead.

-  Configure a recurring automation with a weekly recurrence and a start_date several weeks ahead. This will result in the automation never triggering even after the start_date.

These 2 scenarios share the same cause which is that the automation plugin doesn't use the start_date as the date for the first run and instead uses the frequency/interval values from the current time to calculate the first run date.

This PR fixes this bug by adding an explicit check for start_date and using it as the first run's date if it's ahead of the current time.
2024-05-10 11:45:23 +10:00
Joffrey JAFFEUX
72aed56daf
DEV: bots are always allowed to chat (#26948)
Bots should be allowed to chat regardless of their groups, just like staff. It makes configuring bots to work in chat much easier.
2024-05-09 12:05:31 +02:00
David Battersby
4404b6808c
UX: expand threads list tap area on mobile (#26818)
This change adds a wrapper link around the thread list details on mobile to make the click area larger.

We also update child div elements to span to ensure valid html, since the link is an inline element and divs are block level.

---------

Co-authored-by: chapoi <101828855+chapoi@users.noreply.github.com>
2024-05-09 12:45:02 +04:00
Jarek Radosz
e579cfc08f
DEV: Avoid using the old action helper (#26935) 2024-05-08 20:26:48 +02:00
Joffrey JAFFEUX
c8faf3e427
FIX: ensures chat notifications links work with subfolder (#26938)
We were missing two `getURL` calls.

The test is now written for subfolder but it's good enough. If it's working for subfolder, it's working for non subfolders, the opposite being false.
2024-05-08 14:47:15 +02:00
Joffrey JAFFEUX
fe16633a0c
DEV: allows for multiple menus/tooltips (#26823)
menus and tooltips are now appended to their own portals. The service are the only responsible for managing the instances, prior to this commit, services could manage one instance, but the DMenu and DTooltip components could also take over which could cause unexpected states.

This change also allows nested menus/tooltips.

Other notable changes:

- few months ago core copied the CloseOnClickOutside modifier of float-kit without removing the float-kit one, this commit now only use the core one.
- the close function is now trully async
- the close function accepts an instance or an identifier as parameter
2024-05-07 23:48:44 +02:00
Régis Hanol
12cba2ce24 PERF: bail out of expensive post validations
Whenever a post already failed "lightweight" validations, we skip all the expensive validations (that cooks the post or run SQL queries) so that we reply as soon as possible.

Also skip validating polls when there's no "[/poll]" in the raw.

Internal ref - t/115890
2024-05-07 18:56:16 +02:00
Joffrey JAFFEUX
278eb0a1a5
FIX: improvements to chat message streaming (#26892)
- prevents re-rendering avatars while updating messages quickly in the thread preview indicator
- ensures the cancel button is shown when you are admin OR when the streamed message is a reply to the current user
2024-05-07 15:38:24 +02:00
Discourse Translator Bot
42297b2ec3
Update translations (#26903) 2024-05-07 09:31:46 -04:00
Joffrey JAFFEUX
26c8eab1f3
FIX: allows bots to create/update/stream messages (#26900)
Prior to this commit, only system users had this pass.

Another significant change of the PR, is to make membership of a channel the angular stone of the permission check to create/update/stop streaming a message. The idea being, if you are a member of a channel already we don't need to check if you can join it AGAIN.

We also have `Chat::AutoRemove::HandleCategoryUpdated` which will deal with permissions change so it's simpler and less prone to error to consider the membership as the only source of truth.
2024-05-07 15:17:42 +02:00
Joffrey JAFFEUX
2347ff7074
FIX: only show discourse-ai CTA to admins (#26895) 2024-05-07 00:43:30 +02:00
Osama Sayegh
2f2355b0ad
DEV: Convert some files to autoloading and various improvements (#26860) 2024-05-06 23:12:55 +03:00
chapoi
8bbcd409e3
UX: hide user count in original message link (#26890) 2024-05-06 22:02:15 +02:00
Jarek Radosz
79870d3a1e
DEV: Fix random typos (#26881) 2024-05-06 20:52:48 +02:00
Joffrey JAFFEUX
f72f63660a
FIX: an existing member of a channel is allowed to join (#26884)
There's no point checking if a user can join a channel if they are already part of it. This case was frequent when using `enforce_membership: true` for custom bots for example.
2024-05-06 17:14:20 +02:00
Joffrey JAFFEUX
00d88766b2
FIX: correctly pass topic/posts context (#26882)
This case had not been tested end to end as `Discourse.track_events` was not working when wrapping `send_message`. Because of this lack of end to end test, a regression has been created when renaming the expected context properties. This commit fixes the regression and write a slightly convulted, but effective end to end test.
2024-05-06 15:33:00 +02:00
Régis Hanol
6c6a56139e FIX: nested polls
Polls should work when "nested" inside a quote or a details block.

Internal ref - t/89085
2024-05-03 19:46:13 +02:00
Joffrey JAFFEUX
671e6066bf
DEV: adds first_messages/last_messages to thread SDK (#26861)
This commit introduces several enhancements to the ChatSDK module, aiming to improve the functionality and usability of chat thread interactions. Here's what has been changed and added:

1. **New Method: `first_messages`:**
   - Added a method to retrieve the first set of messages from a specified chat thread.
   - This method is particularly useful for fetching initial messages when entering a chat thread.
   - Parameters include `thread_id`, `guardian`, and an optional `page_size` which defaults to 10.
   - Usage example added to demonstrate fetching the first 15 messages from a thread.

2. **New Method: `last_messages`:**
   - Added a method to retrieve the last set of messages from a specified chat thread.
   - This method supports reverse pagination, where the user may want to see the most recent messages first.
   - Similar to `first_messages`, it accepts `thread_id`, `guardian`, and an optional `page_size` parameter, defaulting to 10.
   - Usage example provided to illustrate fetching the last 20 messages from a thread.
2024-05-03 17:30:39 +02:00
David Taylor
f28742e597
DEV: Update chat scheduled job loading to match skeleton (#26853)
Followup to e949684fc5, ref https://github.com/discourse/discourse-plugin-skeleton/pull/47
2024-05-02 19:20:00 +01:00
David Taylor
e949684fc5
DEV: Eager load chat's scheduled jobs in development mode (#26852) 2024-05-02 18:26:30 +01:00
Joffrey JAFFEUX
dda4bb0f7c
DEV: allows to disable strip_whitespaces in messages (#26848)
The TextCleaner step has been moved from chat message’s validation to create_message/update_message services. It allows us to easily tweak part of its behavior depending on the needs.

For example we will now disable strip_whitespaces by default when streaming messages as we want to keep newlines and spaces at the end of the message.
2024-05-02 11:59:18 +02:00
David Battersby
c1f6ec5f62
FIX: add excerpt fallback for chat message replies (#26834) 2024-05-01 16:39:47 +02:00
Osama Sayegh
8ed684312f
FIX: Prevent race condition in recurring automations (#26828)
Recurring automations are triggered by a scheduled job that runs every minute and checks for due automations, runs them and then marks as them as completed (by deleting the `PendingAutomation` record). However, the job is currently subject to a race condition where a recurring automation can be executed more than once at its due date if it takes more than a minute to finish.

This commit adds a mutex around the code that triggers the recurring automation so that no concurrent executions can happen for a single automation.

Meta topic: https://meta.discourse.org/t/daily-summary-9pm-utc/291850/119?u=osama.
2024-05-01 09:01:58 +03:00
Discourse Translator Bot
d1f008a2fc
Update translations (#26821) 2024-04-30 21:57:28 +02:00
Joffrey JAFFEUX
038236fcca
FIX: prevents long URL to overflow thread title (#26827) 2024-04-30 21:44:35 +02:00
Osama Sayegh
0e44072b2b
FIX: Prevent infinite loop of automations triggering each other (#26814)
It's currently possible to setup multiple automation rules that trigger each other resulting in an infinite loop. To prevent that, this commit adds a global "circuit breaker" that prevents all automations from triggering while an automation rule is executing.

Internal topic: t/124365.
2024-04-30 20:13:29 +03:00
Jarek Radosz
3930064fd1
DEV: Convert various components to gjs (#26782)
Those were all low hanging fruits - all were already glimmer components, so this was mostly merging js and hbs files and adding imports.

(occasionally also adds/fixes class names)
2024-04-30 16:44:49 +02:00
Joffrey JAFFEUX
271ca2c968
FIX: correctly check the user id of the original message (#26805)
Followup: write a test for this
2024-04-29 13:34:49 +02:00
David Battersby
0c8f531909
FEATURE: encourage users to set chat thread titles (#26617)
This change encourages users to title their threads to make it easier for other users to join in on conversations that matter to them.

The creator of the chat thread will receive a toast notification prompting them to add a thread title when on mobile and the thread has at least 5 sent replies.
2024-04-29 17:20:01 +08:00
Joffrey JAFFEUX
c1c823144b
FIX: correctly rename scroller everywhere (#26783) 2024-04-29 08:45:37 +02:00
Jarek Radosz
cf11e556cb
DEV: Update htmlSafe imports (#26776) 2024-04-27 12:01:58 +02:00
Joffrey JAFFEUX
fb40f50865
FIX: ensures last read is updated on new message (#26772) 2024-04-26 18:27:39 +02:00
Joffrey JAFFEUX
e7f0aa52fa
FIX: ensures we don't exit without pending automations (#26771)
This case is not supposed to happen but it seems safer to ensure this case will recreate pending automations.
2024-04-26 14:05:27 +02:00
Joffrey JAFFEUX
351d212e8a
FIX: do not increment reply count manually (#26769)
That could cause flakeyness in specs depending in which timing message bus would arrive and it's not necessary as it should be updated with `handleThreadOriginalMessageUpdate`.
2024-04-26 12:32:06 +02:00
David Battersby
dad6912566
DEV: add toast progress bar to styleguide (#26767) 2024-04-26 16:49:58 +08:00
David Battersby
09f2a42f5f
FIX: build chat message excerpt for thread preview (#26765)
Follow up to #26712 to account for older threads that don't have a persisted excerpt, as this was previously generated on every page load.

This change allows us to build the excerpt on the fly when none exists, fixing the issue of missing message excerpts for thread previews (within channel) and thread lists (on mobile/desktop).
2024-04-26 14:29:35 +08:00
Régis Hanol
989d6f921a UX: loading spinner when clicking an item
This fixes the UX when clicking a checklist item to toggle its state.
2024-04-25 18:45:38 +02:00
Joffrey JAFFEUX
0f2067b363
DEV: drop ignored columns (#26755)
chat_channels - last_message_sent_at
2024-04-25 16:35:23 +02:00
David Battersby
c62d3610c6
PERF: Reduce overhead from chat message excerpt (#26712)
This change moves the chat message excerpt into a new database column (string) on the chat_messages table.

As part of this change, we will now set the excerpt within the `Chat::CreateMessage` service, and update it within the `Chat::UpdateMessage` service.
2024-04-25 14:29:00 +02:00
Joffrey JAFFEUX
52e8d57293
FEATURE: implements last read message for threads (#26702)
This commit will now allow us to track read position in a thread and returns to this position when you open the thread.

Note this commit is also extracting the following components to make it possible:
- `<ChatMessagesScroller />`
- `<ChatMessagesContainer />`

The `UpdateUserThreadLastRead` has been updated to allow this.

Various refactorings have also been done to the code and specs to improve the support of last read.
2024-04-25 10:47:54 +02:00
Joffrey JAFFEUX
2bab1df461
FIX: ensures we close modal on reaction (#26745)
It's important to close the modal or we will just remove it from screen without calling callbacks, which will cause the body to be locked on iOS.

It's hard to test this behavior, as it only happens on iOS and the modal will disappear anyways, it's only a matter of ensuring it's closed correctly.
2024-04-24 19:06:11 +02:00
Discourse Translator Bot
dde1132a28
Update translations (#26713) 2024-04-23 16:22:27 +02:00
Joffrey JAFFEUX
a564274ba2
FIX: messages are already reversed (#26692)
This is reverting part of 08ff0bac29 to only have the call on exit channel. This was causing incorrect unread update. I will refactor this in another commit.
2024-04-20 12:33:09 +02:00
Joffrey JAFFEUX
08ff0bac29
FIX: ensures last read is updated on exit (#26691) 2024-04-20 10:50:32 +02:00
Joffrey JAFFEUX
bf715c8235
FIX: resets pending automations only if necessary (#26685)
Prior to this fix, any change to an automation would reset `pending_automations`, now we only do it if any value related to recurrence (start_date, interval, frequency, execute_at...) has been changed.

It means that any trigger creating `pending_automations` now needs to manage them in the `on_update` callback.
2024-04-19 14:23:57 +02:00
David Taylor
e9e3456f18 DEV: Rename modifier import to avoid overwriting template keyword 2024-04-19 10:06:08 +01:00
Kris
60d3a79d40
UX: update to variable text color for variable background (#26676) 2024-04-18 14:12:16 -04:00
David Taylor
5c2ac4fe88
DEV: Allow RenderGlimmer to be used inside post-cooked-glued widgets (#26675)
In this case, the top-level widget being glued must have a `_postCookedWidget` attribute.
2024-04-18 15:39:29 +01:00
Jarek Radosz
27d9b53bac
FEATURE: Allow dismissing tooltips by clicking their button (#26668)
Also: fixes typos, updates tests, and moves the tooltip element into document.body
2024-04-18 13:16:55 +02:00