Commit Graph

2506 Commits

Author SHA1 Message Date
Joffrey JAFFEUX 81a16a105e
DEV: makes <Chat::Admin::ExportMessage /> use glimmer (#22498) 2023-07-10 09:35:54 +02:00
Natalie Tay 64dec1368c
DEV: Cleanup an old spec (#22503)
Introduced in #22297, now clear to remove since we don't have a habit of keeping migration specs.
2023-07-10 11:34:17 +08:00
Guhyoun Nam b70bd4366b
FEATURE: Separated 'trusted users can edit others' setting for trust level 3 & 4 (#21493) 2023-07-07 10:48:14 -05:00
Joffrey JAFFEUX 2dfeb5f0c2
FIX: typo in property name (#22489)
Sadly this function is one of the very hard to test codepaths of the app. We could in the future attempt to extract the content of the function to unit-test it.
2023-07-07 12:48:21 +02:00
Martin Brennan 3ea8203719
FIX: Track thread in UI when user sends first message (#22462)
When a user sends their first message in a thread we
automatically track the thread in the backend, but we
don't reflect this in the UI until the user re-opens
the thread. This commit fixes that by showing the new
tracking level in the UI.
2023-07-07 13:09:06 +10:00
Joffrey JAFFEUX f0d82de5d9
DEV: fix flakeyness with drawer specs (#22476)
Chat drawer was using the `DiscourseURL` hook `afterRouteComplete`. This hook suffer from a very poor implementation which makes it very unreliable:

```javascript
if (typeof opts.afterRouteComplete === "function") {
  schedule("afterRender", opts.afterRouteComplete);
}
```

This commit attempts to return the promise from `handleURL` to directly use it and have a very reliable after transition hook.
2023-07-07 00:46:04 +02:00
Joffrey JAFFEUX d41fa579c8
DEV: more resilient auto remove spec (#22472)
We have no guarantees on the last record here, it's easier and more stable to check all created records.
2023-07-06 21:44:53 +02:00
Joffrey JAFFEUX c0808b2537
FIX: correctly makes dm creator to follow channel (#22470)
In previous changes we prevented creating a channel to also make users follow the channel. We were forcing recipients to follow the channel on message sent but this was not including the creator of the message itself.

This commit fixes it and also write an end-to-end system spec to cover these cases. The message creator service is currently being rewritten and should correctly test and ensure this logic is present.

This commit also makes changes on the frontend to instantly follow a DM when you open it, this change prevents a green dot to appear for a split second when you send a message in a channel you were previously not following. Only recipients will see the green dot.
2023-07-06 21:42:19 +02:00
Jarek Radosz dc46acb851
DEV: Remove `OK` pretender helper (#22438)
We already have the `response` helper (which additionally sets the `Content-Type` header)

(also: all-caps name suggested a constant, not a function)
2023-07-06 20:39:23 +02:00
Isaac Janzen b8cf50798b
DEV: Skip flaky visit-channel system tests (#22469)
Consistently seeing failures on 
- visit-channel
- navigation

specs
2023-07-06 13:17:37 -05:00
Joffrey JAFFEUX 250e3d881d
FIX: removes discourse-teams-sidebar support (#22465)
This plugin is now archived we don't need to carry this code anymore.
2023-07-06 15:40:24 +02:00
Joffrey JAFFEUX 30e4b898f5
FIX: limits legacy sidebar height (#22466)
Prior to this fix the sidebar was taking unlimited height.
2023-07-06 15:40:20 +02:00
Mark VanLandingham 3171fd1a0a
DEV: Introduce Chat Notices with publishing method (#22369) 2023-07-06 08:26:25 -05:00
Loïc Guitaut 5134b28d83 FIX: Add missing chat translations
Some error messages when creating a new chat message were not defined.
2023-07-06 11:35:02 +02:00
Martin Brennan f69748e325
FIX: Mark threads read when threading enabled for a channel (#22458)
Since we create threads in the background regardless of whether
threading is enabled for a channel, we get the unexpected behaviour
of everyone having a lot of unread threads when threading is enabled
for the channel.

To counteract this, when the admin enables threads for a channel
we can just run a high priority background job to mark all threads
as read in the channel for all users, so they are essentially
starting from a clean slate.
2023-07-06 16:24:56 +10:00
Martin Brennan 9b14bf82dc
FIX: Show replies count on thread indicator regardless of participants (#22459)
Followup to 802fb3b194

We should not hide the replies count if there is only 1 participant
for a thread, because this makes it look like the last reply is the
only reply.
2023-07-06 14:31:18 +10:00
Martin Brennan 1cd512a03a
DEV: Normalize key modifier checks for keyboard shortcuts (#22451)
This introduces a PLATFORM_KEY_MODIFIER const that
can be used both client and server side, to determine
whether we should be using the Meta or Ctrl key based
on whether the user is on Windows/Linux or Mac.
2023-07-06 13:34:24 +10:00
Alan Guo Xiang Tan 4c810703c1
FIX: Avoid transitioning when a chat thread component is destroyed (#22457)
Why this change?

Before this commit, there is a chance that we will transition the user
to a different route if the chat thread component has been destroyed
prior to the request for fetching messasges in a chat thread returning.

This commit makes it such that we simply ignore the request if the chat
thread component has been destroyed.

We believe this is the cause of the flaky system tests in plugins/chat/spec/system/navigation_spec.rb
which we've been seeing on CI.
2023-07-06 10:53:28 +08:00
Alan Guo Xiang Tan ff38bccb80
DEV: Fix number of chars for chat message content in fabricator (#22454)
Why this change?

`Faker::Lorem.paragraph` generates a differrent length of string
every time. When a string happens to be long, it can change the UI
across system test runs making it harder to reason about our system
tests across multiple runs since the state is never really consistent.

We will just generate a paragraph with a fixed length going forward so
that the UI remains consistent. This should make certain tests which
relies on the UI being in a certain state to become less flaky.
2023-07-06 10:34:57 +08:00
Alan Guo Xiang Tan cb9ae1eb1f
DEV: Fix flaky chat drawer system test (#22452)
Why this change?

This change ensures that we scroll to the top of the message when
hovering over a message to ensure that the message actions container
that appears on hover is not hidden in the chat drawer when the content
of the chat message is long.
2023-07-06 09:03:42 +08:00
Alan Guo Xiang Tan 9a65c78d87
DEV: Avoid waiting full capybara default wait time (#22449)
Why this change?

`not_to be_open` ends up calling `has_css?` on a selector that will
never appear so it ends up waiting the full default wait time.
2023-07-06 08:16:58 +08:00
Martin Brennan 37a8036b2d
FIX: Better handling of deleted thread original messages (#22402)
This commit includes several fixes and improvements to thread
original message handling:

1. When a thread's original message is deleted, the thread no longer
   counts as unread for a user
2. When a thread original message is deleted and the user is looking
   at the thread list, it will be removed from the list
3. When a thread original message is restored and the user is looking
   at the thread list, it will be added back to the list if it was
   previously loaded
2023-07-06 09:47:34 +10:00
Joffrey JAFFEUX 478c4b1a74
DEV: prevents message actions to hide drawer's header (#22448)
In specific conditions (generally a small drawer, with a long message) it is possible to have the message’s actions menu to be displayed hover the drawer's header.

This is particularly hard to fix correctly using popper due to our positioning which is slightly at the limit of the container.

The proposed fix targets mostly the specs by ensuring the messages actions will be hidden before attempting to click any header's button.
2023-07-06 07:33:39 +08:00
Alan Guo Xiang Tan 772334a346
DEV: Add more helpful assertions for flaky system tests in CI (#22432)
Why this change?

In CI, we know we're clicking a link to a chat channel's threads list.
However, the threads list is not loaded and we want to add more
assertions here to try and figure out why. By asserting for the current
URL, we will at least know that the transition to the URL is successful.
2023-07-06 07:08:59 +08:00
Joffrey JAFFEUX 972e0f74ff
FIX: more consistent composer focus and replying indicator (#22443) 2023-07-05 22:24:53 +02:00
Joffrey JAFFEUX 2ce9364c08
FIX: do not filter on category name (#22442) 2023-07-05 21:12:39 +02:00
Joffrey JAFFEUX cfdf5b9518
FIX: correctly show unread and presence (#22441)
- Presence needs to be explicitly set on the component now
- We were not checking and testing correctly the presence of the unread indicator in the menu
2023-07-05 21:01:23 +02:00
Kris 4cec091f1a
REFACTOR: improve poll info layout (#22353) 2023-07-05 12:20:18 -04:00
Joffrey JAFFEUX d75d64bf16
FEATURE: new jump to channel menu (#22383)
This commit replaces two existing screens:
- draft
- channel selection modal

Main features compared to existing solutions
- features are now combined, meaning you can for example create multi users DM
- it will show users with chat disabled
- it shows unread state
- hopefully a better look/feel
- lots of small details and fixes...

Other noticeable fixes
- starting a DM with a user, even from the user card and clicking <kbd>Chat</kbd> will not show a green dot for the target user (or even the channel) until a message is actually sent
- it should almost never do a full page reload anymore

---------

Co-authored-by: Martin Brennan <mjrbrennan@gmail.com>
Co-authored-by: Jordan Vidrine <30537603+jordanvidrine@users.noreply.github.com>
Co-authored-by: chapoi <101828855+chapoi@users.noreply.github.com>
Co-authored-by: Mark VanLandingham <markvanlan@gmail.com>
2023-07-05 18:18:27 +02:00
Alan Guo Xiang Tan 1e26a521c2
FIX: Error when loading a channel with threading enabled but no threads (#22434)
Without this fix, the following error is raised:

```
ActiveRecord::StatementInvalid:
  PG::SyntaxError: ERROR:  syntax error at or near ")"
  LINE 4:   WHERE thread_id IN ()
```
2023-07-05 14:33:49 +08:00
Alan Guo Xiang Tan 14517785b2
DEV: Fix flaky system test when expanding chat message actions on mobile (#22428)
Why this change?

Chat system tests that opens the message actions on mobile have been
flaky on our CI. Those system test usually fails when the message
actions do not show up as expected causing subsequent actions to fail.

In the case of the `Reply to message - channel - mobile when the message has an existing thread replies to the existing thread`
system test, failure screenshot shows that we ended up navigating to the
thread instead of opening the message actions button. To understand why
this happens, we first need to understand that by default Capybara clicks
on the centre of an element. Also, we need to note that the HTML structure of
a chat message is like so:

```
<div class="chat-message-container">
  <div class="chat-message">
    <div class="chat-message-avatar" />
    <div class="chat-message-content" />
    <div class="chat-message-thread-indicator" />
  </div>
</div>
```

Since `PageObjects::Pages::ChatChannel#expand_message_actions_mobile`
attempts to click on the `.chat-message-contaier`, there is a
possibility that the center of that element is the
`.chat-message-thread-indicator` element which would explain why we
navigated to the thread list instead of opening up the message actions.
This is possible because the content of the original chat message as
well as the message excerpt in the thread is randomly generated where the
length of the message and how the text wraps on mobile can affect the
height of the `.chat-message-content` element as thus its position in
the `.chat-message-container` element. In most cases, the middle of the
`.chat-message-container` happens to be the `.chat-message-content`
which is why this test "flakes" sometimes.

What is the solution?

Instead of clicking on the `.chat-message-container`, we be more
specific and click on the `.chat-message-content` element instead.
2023-07-05 10:39:04 +08:00
Martin Brennan e9e3f147f0
DEV: Unhide chat experimental threads site setting (#22426)
This is in preparation for the V1 thread announcement,
where we will begin to allow site admins to enable this
themselves.
2023-07-05 11:20:31 +10:00
Discourse Translator Bot 9ee1972a2c
Update translations (#22412) 2023-07-04 18:14:46 +02:00
David Taylor 773e198cb3
DEV: Convert poll modals to new component-based API (#22164) 2023-07-04 15:25:34 +01:00
chapoi ee1dbd46c6
UX: Thread indicator small fixes (#22389)
* UX: make timestamp font size smaller

* UX: participants use copy instead of avatar

* FIX: Move thread participant count into i18n

---------

Co-authored-by: Martin Brennan <martin@discourse.org>
2023-07-04 10:32:09 +02:00
Martin Brennan 56aef3c082
DEV: Fix or remove flaky chat specs (#22406)
* DEV: Fix flaky thread nav spec

When we transitioned from the chat thread panel under some conditions
the request for the thread would come back and realise the component
was destroyed, which was trying to do a transition to the channel
itself.

Now we check for the previous route here too and transition to the
correct route.

* DEV: Fix chat transcript spec relying on animation

The on-animation-end modifier is not reliable in system specs
because it fires instantly (we have disabled capybara animations)
so the showCopySuccess boolean can be mutated back to false straight
away.

Better to have a separate boolean tracked with a data-attr that we
can reliably inspect in the system spec.
2023-07-04 16:23:04 +10:00
Alan Guo Xiang Tan 454a4af0bf
DEV: Ensure browser network conditions is reset in system tests (#22404)
Why this change?

By ensuring the reset happens in an `ensure` code block, we ensure that
the code will always be run even if code fails or an error is raised.
This helps to prevent leaking custom network condition states and
improves the stability of our system tests.
2023-07-04 13:22:58 +08:00
Isaac Janzen 2910b76138
DEV: Skip all chat user status tests (#22398) 2023-07-03 16:42:47 -05:00
Isaac Janzen 45ed84354b
DEV: Skip remaining flaky mention status tests (#22397) 2023-07-03 16:20:19 -05:00
Isaac Janzen f596de2143
DEV: Skip flaky chat deleted message mention status flake (#22396) 2023-07-03 16:00:09 -05:00
Isaac Janzen debe47cc0b
DEV: Skip flaky chat mention status test (#22395) 2023-07-03 15:54:03 -05:00
Jan Cernik 585a2e4e77
FEATURE: Use rich user status tooltip everywhere (#21125)
- Inline mentions on posts
- Inline mentions on chat messages
- The user autocomplete for the composer
- The user autocomplete for chat
- The chat section of the sidebar
2023-07-03 11:09:41 -03:00
Jan Cernik 5034eda386
FIX: Allow to use `%h%m%s` for youtube `t` param (#22299) 2023-07-03 10:39:37 -03:00
David Taylor b3a23bd9d6
DEV: Introduce new component-based DModal API (#21304)
Ember 4.x will be removing the 'named outlet' feature, which were previously relying on to render modal 'controllers' and their associated templates. This commit updates the modal.show API to accept a component class, and also introduces a declarative API which can be used by including the <DModal component directly in your template.

For more information on the API design, and conversion instructions from the current API, see these Meta topics:

DModal API: https://meta.discourse.org/t/268304
Conversion: https://meta.discourse.org/t/268057
2023-07-03 10:51:27 +01:00
Martin Brennan f6072ba804
DEV: Move user count update for channels to ensure_consistency! (#22321)
This fixes a longstanding TODO to move the contents of the
UpdateUserCountsForChannels job to the ensure_consistency!
method of Chat::Channel, which runs every 15 mins as part of
periodical updates.

This commit also addresses the performance issue of the original,
where we would fetch all channels and do an individual query to
get the count and update the count of each one. Now we do it all
in one query, and only publish the changed channels to the UI.
2023-07-03 11:41:51 +10:00
Martin Brennan 821cf201f5
FIX: ActiveModel::Types :array load error in production (#22377)
Followup to 3f1024de76

The ActiveModel::Types.register(:array) call for chat was
called too late in the Zeitwerk load order in production,
causing this error:

> `lookup': Unknown type :array (ArgumentError)
> raise ArgumentError, "Unknown type #{symbol.inspect}"
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

We need to load the type and register it manually before the rest
of the chat files are loaded via the engine and Zeitwerk.
2023-07-03 11:30:09 +10:00
Martin Brennan 3f1024de76
DEV: Refactor DM channel creation into new service pattern (#22144)
This will be used when we move the channel creation for DMs
to happen when we first send a message in a DM channel to avoid
a double-request. For now we can just have a new API endpoint
for creating this that the existing frontend code can use,
that uses the new service pattern.

This also uses the new policy pattern for services where the policy
can be defined in a class so a more dynamic reason for the policy
failing can be sent to the controller.

Co-authored-by: Loïc Guitaut <loic@discourse.org>
2023-07-03 10:18:37 +10:00
Martin Brennan 58a3cdc6ae
DEV: Try fix flaky chat navigation spec (#22356)
Followup to e57070af92,
try to check for href of link first before clicking.
2023-06-30 09:08:29 +08:00
Alan Guo Xiang Tan e57070af92
DEV: Skip a flaky system test (#22354)
This has been flagged by our internal system as well and has been
failing on CI. Skip this for now to improve the stability of our system
test runs while we figure out why it is flaky.
2023-06-30 07:35:44 +08:00
Joffrey JAFFEUX ea0b8ca38c
FEATURE: allows to enable/disable threading in UI (#22307)
Enabling/Disabling threading has been possible through command line until now. This commit introduces two new UIs:

- When creating a channel, it will be available once the category has been selected
- On the settings page of a channel for admins
2023-06-29 07:19:12 +02:00