Commit Graph

3688 Commits

Author SHA1 Message Date
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
Régis Hanol
fd1220af69
FIX: chat bookmarks in drawer mode (#29757)
When using chat in drawer mode, after you've clicked on a chat bookmark in the user menu, clicking any other chat bookmark would "do nothing".

In 8b18fd1556 we added an optimization to prevent the same route from being reloaded, but it ended up breaking the bookmarks.

This commit reverts the changed made the above commit and adds a system specs that ensure we can click two chat bookmarks in the user menu when using chat in drawer mode.

Internal ref - t/134362
2024-11-14 17:20:11 +01:00
David Battersby
8dc772f2a8
UX: prevent shrinking unread badge for long DM channel names (#29756)
Fixes a small UX issue where the unread badge gets squashed in long DM channel names.
2024-11-14 15:27:14 +04:00
David Battersby
5ce4af1aa6
FEATURE: add mention count to threads (#29739)
Previously we only counted mentions that were made within channels, however for threads this was never implemented.

This change adds a mention count to the ThreadUnreadsQuery, which is used for channel thread lists and the user thread list. We are also expanding channel mentions count to include mentions within threads.

The goal is to have a more consistent urgent badge across chat, in places such as channel lists and the chat header.
2024-11-14 14:10:12 +04:00
Régis Hanol
fea82d04ec
DEV: fix chat:*:populate rake tasks (#29740) 2024-11-13 18:11:25 +01:00
Régis Hanol
b4156107df
DEV: restore AutoJoinChannelBatch job as a no-op to clear queue (#29743)
The job was removed in 6dfe2fbe16 as part of a performance-related refactor.

The issue was that job was already enqueued in sidekiq and now that the file has been deleted, it's generating a lot of `uninitialized constant Jobs::Chat::AutoJoinChannelBatch` errors.

Restoring this file will help clear the sidekiq queue. We'll remove the job in a few months.

Internal ref - t/141563
2024-11-13 18:10:03 +01:00
Joffrey JAFFEUX
352777a074
DEV: adds a page object for automation page (#29732)
This page object also attempts to make the update automation more resilient as we are seeing flakey specs on this codepath. The solution for now is to ensure we have the sequence: click button/button is loading/ button has finished loading.

---------

Co-authored-by: Alan Guo Xiang Tan <gxtan1990@gmail.com>
2024-11-13 11:49:38 +09:00
Jan Cernik
234133bd3b
UX: Split hide_profile_and_presence user option (#29632)
It splits the hide_profile_and_presence user option and the default_hide_profile_and_presence site setting for more granular control. It keeps the option to hide the profile under /u/username/preferences/interface and adds the presence toggle in the quick user menu.

Co-authored-by: Régis Hanol <regis@hanol.fr>
2024-11-12 22:22:58 -03:00
Loïc Guitaut
d637bd6519
DEV: Don’t replace Rails logger in specs (#29721)
Instead of replacing the Rails logger in specs, we can instead use
`#broadcast_to` which has been introduced in Rails 7.
2024-11-13 08:47:39 +08:00
Discourse Translator Bot
d7503a6153
Update translations (#29715) 2024-11-12 14:54:38 +01:00
David Taylor
fb2a688b29
DEV: Bump eslint, lint-configs, and move to flat config (#29661) 2024-11-12 12:33:17 +00:00
Régis Hanol
6dfe2fbe16
PERF: auto join & leave chat channels (#29193)
Chat channels that are linked to a category can be set to automatically join users.

This is handled by subscribing to the following events

- group_destroyed
- user_seen
- user_confirmed_email
- user_added_to_group
- user_removed_from_group
- category_updated
- site_setting_changed (for `chat_allowed_groups`)

As well as a

- hourly background job (`AutoJoinUsers`)
- `CreateCategoryChannel` service
- `UpdateChannel` service

There was however two issues with the current implementation

1. We were triggering a lot of background jobs, mostly because it was decided to batch to auto join/leave into groups of 1000 users, adding a lot of stress to the system
2. We had one "class" (a service or a background job) per "event" and all of them had slightly different ways to select users to join/leave, making it hard to keep everything in sync

This PR "simply" adds two new servicesL `AutoJoinChannels` and `AutoLeaveChannels` that takes care, in an efficient way, of all the cases when users might automatically join a leave a chat channel.

Every other changes come from the fact that we're now always calling either one of those services, depending on the event that happened.

In the making of these classes, a few bugs were encountered and fixed, notably

- A user is only ever able to access chat channels if and only if they're part of a group listed in the `chat_allowed_group` site setting
- A category that has no associated "category groups" is only accessible to staff members (and not "Everyone")
- A silenced user should not be able to automatically join channels
- We should not attempt to automatically join users to deleted chat channels
- There is no need to automatically join users to chat channels that have already more than `max_chat_auto_joined_users` users

Internal - t/135259 & t/70607

* DEV: add specs for auto join/leave channels services

* DEV: less hacky specs

* DEV: no instance variables in specs
2024-11-12 15:00:59 +11:00
Jarek Radosz
e68905510d
DEV: Use the new hasHtml/includesHtml from qunit-dom (#29680) 2024-11-11 13:06:12 +01:00
Jarek Radosz
2272b1340b
DEV: Use qunit-dom instead of raw href/title comparisons (#29678) 2024-11-11 11:44:54 +01:00
Joffrey JAFFEUX
c4de8565ec
FIX: flakey due to 0 width/height images (#29700)
https://github.com/mainmatter/qunit-dom/blob/master/API.md#isvisible will return true if offsetWidth or offsetHeight are zero which could happen in this case as the test could run before the image has loaded. By forcing a minimum height in the test we ensure it will be consistent.
2024-11-11 17:23:19 +09:00
Jarek Radosz
78ed0bb711
DEV: Use selectors instead of query() where possible (#29677) 2024-11-10 13:53:12 +01:00
Jarek Radosz
16a9663557
DEV: Use qunit-dom's isDisabled/isEnabled (#29675) 2024-11-10 02:24:58 +01:00
Jarek Radosz
d67a6002eb
DEV: Replace count with qunit-dom (#29674) 2024-11-10 02:06:03 +01:00
Jarek Radosz
f9e58938ce
DEV: Update visible/invisible uses to qunit-dom (#29672) 2024-11-10 01:41:50 +01:00
Jarek Radosz
de6d575d40
DEV: Convert all uses of exists to qunit-dom (#29667) 2024-11-10 01:30:33 +01:00
Joffrey JAFFEUX
b24c8a41ac
FIX: remove header-icons from styleguide (#29670)
Recent changes in header makes it complicated to show multiple standalone headers with different state.
2024-11-09 21:58:48 +09:00
Joffrey JAFFEUX
0669830a5b
FIX: broken post in styleguide (#29669)
The base `transformedPost` in dummy-data was missing the topic object.
2024-11-09 21:46:56 +09:00
Jarek Radosz
c1916f7984
DEV: Convert assert.true(exists()) to qunit-dom (#29638) 2024-11-08 20:27:32 +01:00