Commit Graph

3710 Commits

Author SHA1 Message Date
Loïc Guitaut
cf2b4d9934 DEV: Apply new Rubocop linting on services 2024-12-02 17:31:36 +01:00
David Taylor
a52b83333e
DEV: Correctly lint bundled plugins admin directory (#29999) 2024-12-02 16:31:21 +00:00
Jarek Radosz
b3423c40b0
DEV: Fix random typos (#30023)
(late) Nov 2024 edition
2024-12-02 07:34:05 +08:00
Jarek Radosz
6e4baaf092
DEV: Use qunit-dom's hasValue wherever possible (#30018) 2024-12-01 20:37:24 +01:00
Jarek Radosz
efa2589204
DEV: Finish qunit-dom hasText migration (#30017) 2024-12-01 14:00:48 +01:00
Jarek Radosz
1396aef99f
DEV: Make the logIn helper replace current-user service (#30010) 2024-11-30 17:23:51 +01:00
Jarek Radosz
dfb74d90c3
DEV: Extensively use qunit-dom's hasText (#30012) 2024-11-30 16:44:51 +01:00
Joffrey JAFFEUX
35be2a9879
FIX: word break long continuous thread titles (#30007) 2024-11-30 01:07:39 +01:00
Joffrey JAFFEUX
c42248670d
FIX: increase chat thread title limit (#30006)
This will ensure AI generated titles don't appear as out of range in the UI and also allow users to set longer titles. The limit in DB was already 100 so it's just a simple frontend change.
2024-11-30 00:42:20 +01:00
Joffrey JAFFEUX
877b03c7ae
FIX: do not show as clickable the thread header (#30005)
When the current user can't modify the thread title we shouldn't show it as a clickable area.
2024-11-30 00:32:58 +01:00
Joffrey JAFFEUX
b546c31b7f
UI: simplify chat thread title (#29998)
We were using a complex logic to make it change size based on scroll position but this was imperfect and not visually pleasing. Also the title had been made a button which was causing the ellipsis to not work correctly, and I would prefer to not mix page knowledge (thread) with title component so I made this click logic directly in the chat-thread component.

---------

Co-authored-by: Jordan Vidrine <jordan@jordanvidrine.com>
2024-11-29 22:39:18 +01:00
Jarek Radosz
52b7280ad4
DEV: Remove a use of discourseModule (#29996) 2024-11-29 18:16:21 +01:00
David Battersby
3cde55b76f
FIX: show urgent badge for mentions in DM threads (#29821)
When thread tracking level is Normal in a DM channel, we should still show notification badges to the mentioned user.
2024-11-29 12:52:55 +04:00
Régis Hanol
8f8d88afac
PERF: Optimize query for finding users with unread chat messages (#29964)
Using CTEs and DISTINCT ON to:
- Pre-filter active users with correct preferences
- Get only first unread message per channel
- Eliminate redundant joins and message scanning

This reduces the query execution time by limiting message scanning and joins to only relevant users and messages.

Internal ref t/142836 & t/139517
2024-11-28 15:28:37 +01:00
Joffrey JAFFEUX
5a3afa0505
UI: hides channel with visible panel on narrow screen (#29541)
This commit will hide the channel when the side panel is present and the width of the viewport is less than 1000px. This is especially useful when you want to focus reading a thread on a small screen.

This change only impacts desktops.
2024-11-28 11:58:36 +01:00
Jarek Radosz
ef7518d4ad
DEV: Fix no-loose-assertions lint (#29965)
and enable some of qunit lints
2024-11-28 11:22:27 +01:00
Gabriel Grubba
43414abf83
FIX: TopicTagsChanged trigger not working with multiple tags (#29961)
* FIX: `TopicTagsChanged` trigger not working with multiple tags

The check for when had multiple tags was being exclusive, you had to have all tags to trigger the automation, now it's inclusive, you can trigger the automation if you have any of the tags.

* DEV: add specs for when having multiple categories

* DEV: changed to use unions and intersections for tags

added more tests to check for multiple tags
2024-11-27 14:16:29 -03:00
Joffrey JAFFEUX
b4406861ae
FIX: simplify desktop notifications behavior (#29957)
Historically the behavior of this file has been complexified to attempt to answer this use case:

A user has two tabs open, tab 1 is on a topic, tab 2 is on a chat channel. If your active tab is tab 1 and someones sends you a mention in chat. We will show a desktop notification, but in which tab the channel should open if you click it? The changes made years ago said: in tab 2.

I think this is complexifying too much this codepath and is also confusing. You might wonder why this discourse notification you clicked opened in some of your 50 tabs in the background when you had a discourse tab active currently in front of you.

Moreover, a recent change has made the notification to only happen on desktop, but all the subscription stuff was happening regardless of mobile or desktop.
2024-11-27 17:33:31 +01:00
Jarek Radosz
5db0eba0a8
DEV: Autofix (w/ manual follow up) various qunit lints (#29950) 2024-11-27 13:02:55 +01:00
Loïc Guitaut
d6bec460a8 DEV: Upgrade Rails to version 7.2 2024-11-27 10:48:47 +01:00
chapoi
cdf8eb8055
UX: update minwidth to chat sidepanel + better title word-break fn (#29954) 2024-11-27 06:04:04 +01:00
Discourse Translator Bot
b9f183e2c3
Update translations (#29934) 2024-11-26 23:14:56 +01:00
Joffrey JAFFEUX
a692e87b72
DEV: lint poll test (#29937)
Co-authored-by: David Taylor <david@taylorhq.com>
2024-11-26 16:22:33 +01:00
Joffrey JAFFEUX
7333a00ddb
DEV: ensures poll-test is correctly linted (#29936)
Broken in a535798659
2024-11-26 14:18:30 +01:00
Robert
a535798659
FIX: Poll: ensure it is not possible to vote with all abstentions in Ranked Choice (#29601)
Make sure Cast Vote button is disabled when all abstain and remove any historic data that fails new zero rank vote validation
2024-11-26 20:16:22 +08:00
chapoi
3a11e70b3d
UX: chat drawer hover effect width calc fix (#29910) 2024-11-26 03:25:12 +01:00
Isaac Janzen
6aae60a212
FIX: Tooltip styleguide triggers not rendering options (#29926)
Tooltips have different triggers / untriggers by device type (mobile / desktop) and this PR provides the correct options in the styleguide based on device type. 

# Before
<img width="787" alt="Screenshot 2024-11-25 at 3 31 56 PM" src="https://github.com/user-attachments/assets/f18f3003-e887-42c5-8f42-24af87cadf56">

# After
<img width="800" alt="Screenshot 2024-11-25 at 3 30 48 PM" src="https://github.com/user-attachments/assets/6113eff3-7b1f-4782-aea3-c8bee5e9842a">
2024-11-25 16:00:52 -06:00
Joffrey JAFFEUX
0c68b14534
FIX: correctly link to settings in full page (#29913)
There's already a test for this behavior and the CI is currently broken because of it.
2024-11-25 08:21:41 +01:00
Joffrey JAFFEUX
66409fa8b4
UX: improved collapsed drawer state/interactions (#29850)
- Clicking the channel title of a collapsed drawer will only open the drawer, and not open settings
- Remove the back button when the drawer is collapsed
- Uses same icon for toggling on chat that composer
- add max-width to minimised drawer + add hover effect
---------

Co-authored-by: chapoi <101828855+chapoi@users.noreply.github.com>
2024-11-25 03:39:03 +01:00
Loïc Guitaut
f87333c4e0 DEV: Refactor DiscourseAutomation::DestroyAutomation a bit
Small followup to 932bd6b.
2024-11-22 16:05:31 +01:00
Régis Hanol
d71016522e
FIX: hide chat button in user card (#29887)
when the user isn't able to receive DMs (either because they've disabled it or because they're suspended for example).

Internal ref - t/142198
2024-11-22 09:05:58 +01:00
Tobias Eigen
5bf5d13356
UX: Corrected text for notification titles (#29860)
Improves notification title text from:

Chat quoted -> Quoted in chat
Chat watched thread -> Watched chat thread
2024-11-22 09:37:41 +04:00
Jarek Radosz
2589545623
DEV: Detect hbr topic list customizations (#29793) 2024-11-21 16:00:49 +01:00
Gary Pendergast
f1bf63f89c
FIX: Tweak the unread channel shortcut key behaviour (#29874) 2024-11-21 11:41:02 +11:00
Blake Erickson
1841e72571
DEV: Make sure chat migration is in plugin directory (#29867)
This migration is for chat so it needs to live in the chat plugin
directory.

Follow up to: 23a7f00524
2024-11-20 14:50:15 -07:00
Gary Pendergast
f06a5635b3
FIX: Improve the reliability of the unread channel keyboard shortcuts (#29814)
Additionally, a bunch of related flaky tests were unflakified.
2024-11-21 08:24:26 +11:00
Blake Erickson
23a7f00524
DEV: Re-apply chat index migration (#29859)
Commit c2a733a95a was applied to an
existing migration that possibly had already run. Due to this some
discourse instances might not have the correct index.

This change removes the original migration and creates a new one so that
it will actually be applied.

This is the missing index that some sites might not have:
```
Missing Index | CREATE INDEX
index_chat_messages_on_chat_channel_id_and_id ON public.chat_messages
USING btree (chat_channel_id, id) WHERE (deleted_at IS NOT NULL)
```
2024-11-20 12:59:07 -07:00
David Taylor
6f7c581a80
DEV: Bump @discourse/lint-configs and autofix (#29847)
In particular, this applies:

- new `discourse/no-implicit-this` template-lint rule
- `init`/`willDestroy` ordering enforcement
- `lines-between-class-members`
2024-11-20 14:15:04 +00:00
David Taylor
5563e9dc03
DEV: Revert ember-template-lint CI command change (#29845)
Partial revert of a10dcffb73, pending https://github.com/ember-template-lint/ember-template-lint/pull/3095

Also corrects a linting failure which snuck in while CI was broken
2024-11-20 11:10:16 +00:00
Joffrey JAFFEUX
2fb811a335
FIX: serializes interaction for direct messages (#29844)
Prior to this fix it would cause an error as we need to pass the user to get the title of the channel.

This commit also adds a test for message interaction serializer.
2024-11-20 11:26:12 +01:00
Régis Hanol
7cf28fec7b
PERF: optimize chat user membership cleanup when removing a single user (#29833)
This optimizes a hot path when users are being removed from one or more groups since we use the `on(:user_removed_from_group)` event to call the `Chat::AutoLeaveChannels` with a `user_id` parameter. In such case, we don't need to clear the membership of all users, just that one user.

DEBUG: Also added a "-- event = <event>" comment on top of the SQL queries used by the "AutoLeaveChannels" so they show up in the logs and hopefully facilitate any performance issues that might arise in the future.
2024-11-20 09:21:02 +01:00
Joffrey JAFFEUX
eb41a07afb
DEV: supports blocks in chat message sdk (#29839)
Blocks have been added in 582de0ffe3 but were not yet supported in the SDK.
2024-11-20 08:06:48 +01:00
Discourse Translator Bot
abfd065ff0
Update translations (#29835) 2024-11-20 00:21:25 +01:00
David Taylor
32665cf9dd
DEV: Consolidate i18n import paths (#29804)
Enables our new eslint rules which enforce consistent i18n imports. For more info, see 0d58b40cd7
2024-11-19 20:45:18 +00:00
Jarek Radosz
187b7d74fb
DEV: Fix linting (#29826) 2024-11-19 21:43:44 +01:00
Penar Musaraj
7776773a11
FIX: Simplify max-height calculation for chat composer (#29822)
In some rare cases, this was causing the input to be invisible. The
change here means the input will have a smaller max height, but since
here we are limiting this to 25% of the viewport height, it should be
more than fine.

It's also not necessary to include the `chat-header-offset`, it ends up
being only a few pixels' difference (since, again, it is divided by 4).
2024-11-19 12:18:05 -05:00
Joffrey JAFFEUX
582de0ffe3
DEV: adds blocks support to chat messages (#29782)
Blocks allow BOTS to augment the capacities of a chat message. At the moment only one block is available: `actions`, accepting only one type of element: `button`.

<img width="708" alt="Screenshot 2024-11-15 at 19 14 02" src="https://github.com/user-attachments/assets/63f32a29-05b1-4f32-9edd-8d8e1007d705">

# Usage

```ruby
Chat::CreateMessage.call(
  params: {
    message: "Welcome!",
    chat_channel_id: 2,
    blocks: [
      {
         type: "actions",
         elements: [
           { value: "foo", type: "button", text: { text: "How can I install themes?", type: "plain_text" } }
         ]
      }
    ]
  },
  guardian: Discourse.system_user.guardian
)
```

# Documentation

## Blocks

### Actions

Holds interactive elements: button.

#### Fields

| Field | Type | Description | Required? |
|--------|--------|--------|--------|
| type | string | For an actions block, type is always `actions` | Yes |
| elements | array | An array of interactive elements, maximum 10 elements | Yes |
| block_id | string | An unique identifier for the block, will be generated if not specified. It has to be unique per message | No |

#### Example

```json
{
  "type": "actions",
  "block_id": "actions_1",
  "elements": [...]
}
```

## Elements

### Button

#### Fields

| Field | Type | Description | Required? |
|--------|--------|--------|--------|
| type | string | For a button, type is always `button` | Yes |
| text | object | A text object holding the type and text. Max 75 characters | Yes |
| value | string | The value returned after the interaction has been validated. Maximum length is 2000 characters | No |
| style | string | Can be `primary` ,  `success` or `danger` | No |
| action_id | string | An unique identifier for the action, will be generated if not specified. It has to be unique per message | No |

#### Example

```json
{
  "type": "actions",
  "block_id": "actions_1",
  "elements": [
    {
      "type": "button",
      "text": {
          "type": "plain_text",
          "text": "Ok"
      },
      "value": "ok",
      "action_id": "button_1"
    }
  ]
}
```

## Interactions

When a user interactions with a button the following flow will happen:

- We send an interaction request to the server
- Server checks if the user can make this interaction
- If the user can make this interaction, the server will:

  * `DiscourseEvent.trigger(:chat_message_interaction, interaction)`
  * return a JSON document
  
  ```json
  {
    "interaction": {
        "user": {
            "id": 1,
            "username": "j.jaffeux"
        },
        "channel": {
            "id": 1,
            "title": "Staff"
        },
        "message": {
            "id": 1,
            "text": "test",
            "user_id": -1
        },
        "action": {
            "text": {
                "text": "How to install themes?",
                "type": "plain_text"
            },
            "type": "button",
            "value": "click_me_123",
            "action_id": "bf4f30b9-de99-4959-b3f5-632a6a1add04"
        }
    }
  }
  ```
  * Fire a `appEvents.trigger("chat:message_interaction", interaction)`
2024-11-19 07:07:58 +01:00
Gary Pendergast
69d9868c7f
FEATURE: Add keyboard shortcuts for jumping to unread channels (#29734) 2024-11-18 11:18:58 +11:00
Jarek Radosz
01a1dc43cb
DEV: Skip flaky styleguide system specs (#29773) 2024-11-15 00:13:22 +01:00
Sérgio Saquetim
91ce470fce
FIX: Styleguide errors and add smoke test for component pages (#29747) 2024-11-14 15:07:05 -03:00