Commit Graph

2684 Commits

Author SHA1 Message Date
Discourse Translator Bot 23222aa2d4
Update translations (#23099) 2023-08-15 21:24:57 +02:00
Roman Rizzi 5683c90917
FIX: TopicSummarization workaround for Postgres' discrete range types (#23105)
Our code assumed the content_range interval was inclusive, but they are open-ended due to Postgres' [discrete range types](https://www.postgresql.org/docs/current/rangetypes.html#RANGETYPES-DISCRETE), meaning [1,2] will be represented as [1,3).

It also fixes some flaky tests due to test data not being correctly setup and the registry not being resetted after each test.
2023-08-15 14:16:06 -03:00
Joffrey JAFFEUX 2d782c7b00
FIX: correctly deletes webhook_events with webhook (#23097)
Each time a message is created through a webhook, we create we webhook_event associated to this webhook.

When destroying a webhook, we were not destroying the webhook_events which was causing orphans records and more importantly errors in the app expecting to find and associated webhook.
2023-08-15 15:36:00 +02:00
Martin Brennan fb36af7799
DEV: Move calendar date + time picker from local dates into core component (#23023)
This commit moves the calendar date and time picker shown in
the local dates modal into a core component that can be reused
in other places. Also add system specs to make sure there isn't
any breakages with this feature, and a section to the styleguide.
2023-08-11 13:05:44 +10:00
Joffrey JAFFEUX 7358856ae7
FIX: chat styleguide modal import (#23062) 2023-08-10 15:55:28 +02:00
Jarek Radosz bc26e6c4b2
DEV: Migrate insert-hyperlink to the new modal api (#23051) 2023-08-10 12:09:26 +02:00
chapoi cd5a9a2775
UX: add transition (#23034) 2023-08-10 10:28:59 +02:00
Martin Brennan 2ecc8291e8
DEV: Remove unnecessary chat hashtag/mention transform JS (#23054)
Not sure when we added this but it is no longer necessary,
hashtags are cooked appropriately when sending chat messages
and the mention transform was not used anywhere.
2023-08-10 09:31:41 +02:00
Joffrey JAFFEUX 930b917295
DEV: fixes flakey spec from auto-join-channel-batch (#23044)
The specs were relying a lot on mock and stubs. I suspect that under certain circumstances it didn't play well with fabricators and we ended up with the stub of another spec causing this kind of error:

```
  1) Chat::AutoJoinChannelBatch.call when arguments are valid when channel is found when more than one membership is created publishes an event
     Failure/Error: subject(:result) { described_class.call(params) }

     Mocha::ExpectationError:
       unexpected invocation: Chat::Publisher.publish_new_channel(#<Chat::CategoryChannel:0x39b840>, #<User::ActiveRecord_Relation:0x39b868>)
       unsatisfied expectations:
       - expected exactly once, invoked never: Chat::Publisher.publish_new_channel(#<Chat::CategoryChannel:0x39b890>, [#<User:0x39b8b8>, #<User:0x39b8e0>])
       satisfied expectations:
       - allowed any number of times, invoked once: Chat::Action::CreateMembershipsForAutoJoin.call(has_entries({:channel => #<Chat::CategoryChannel:0x39b890>, :contract => instance_of(Chat::AutoJoinChannelBatch::Contract)}))
       - allowed any number of times, invoked never: Chat::ChannelMembershipManager.new(#<Chat::CategoryChannel:0x39b890>)
       - allowed any number of times, invoked never: #<Mock:0x39b930>.recalculate_user_count(any_parameters)
     # ./plugins/chat/app/services/chat/auto_join_channel_batch.rb:65:in `publish_new_channel'
     # ./plugins/chat/app/services/service/base.rb:118:in `instance_exec'
     # ./plugins/chat/app/services/service/base.rb:118:in `call'
     # ./plugins/chat/app/services/service/base.rb:368:in `block in run!'
     # ./plugins/chat/app/services/service/base.rb:368:in `each'
     # ./plugins/chat/app/services/service/base.rb:368:in `run!'
     # ./plugins/chat/app/services/service/base.rb:361:in `run'
     # ./plugins/chat/app/services/service/base.rb:229:in `call'
     # ./plugins/chat/spec/services/chat/auto_join_channel_batch_spec.rb:50:in `block (3 levels) in <main>'
     # ./plugins/chat/spec/services/chat/auto_join_channel_batch_spec.rb:110:in `block (6 levels) in <main>'
     # ./spec/rails_helper.rb:412:in `block (2 levels) in <top (required)>'
```

The spec is now simplified and shouldn't have this issue anymore.
2023-08-09 22:37:28 +02:00
Joffrey JAFFEUX df7dab9dce
FIX: ensures generic onebox has width/height for thumbnail (#23040)
Prior to this fix we would output an image with no width/height which would then bypass a large part of `CookedProcessorMixin` and have no aspect ratio. As a result, an image with no size would cause layout shift.

It also removes a fix for oneboxes in chat messages due to this case.
2023-08-09 20:31:11 +02:00
chapoi a846226e92
UX: micro animations chat input (#23030) 2023-08-09 12:58:36 +02:00
Joffrey JAFFEUX 3a3346c95a
FIX: correctly applies aria-expanded/aria-controls (#23029) 2023-08-09 11:51:28 +02:00
Joffrey JAFFEUX 5de86ad7ed
FIX: removes useless model reload (#23016)
I suspect it was moreover possibly related to a flaky spec:

```
  1) Chat::AutoJoinChannelBatch.call when arguments are valid when channel is found when more than one membership is created publishes an event
     Failure/Error: subject(:result) { described_class.call(params) }

     Mocha::ExpectationError:
       unexpected invocation: Chat::Publisher.publish_new_channel(#<Chat::CategoryChannel:0x401f28>, #<User::ActiveRecord_Relation:0x401f50>)
       unsatisfied expectations:
       - expected exactly once, invoked never: Chat::Publisher.publish_new_channel(#<Chat::CategoryChannel:0x401f78>, [#<User:0x401fa0>, #<User:0x401fc8>])
       satisfied expectations:
       - allowed any number of times, invoked once: Chat::Action::CreateMembershipsForAutoJoin.call(has_entries({:channel => #<Chat::CategoryChannel:0x401f78>, :contract => instance_of(Chat::AutoJoinChannelBatch::Contract)}))
       - allowed any number of times, invoked never: Chat::ChannelMembershipManager.new(#<Chat::CategoryChannel:0x401f78>)
       - allowed any number of times, invoked never: #<Mock:0x402018>.recalculate_user_count(any_parameters)
     # ./plugins/chat/app/services/chat/auto_join_channel_batch.rb:65:in `publish_new_channel'
     # ./plugins/chat/app/services/service/base.rb:118:in `instance_exec'
     # ./plugins/chat/app/services/service/base.rb:118:in `call'
     # ./plugins/chat/app/services/service/base.rb:368:in `block in run!'
     # ./plugins/chat/app/services/service/base.rb:368:in `each'
     # ./plugins/chat/app/services/service/base.rb:368:in `run!'
     # ./plugins/chat/app/services/service/base.rb:361:in `run'
     # ./plugins/chat/app/services/service/base.rb:229:in `call'
     # ./plugins/chat/spec/services/chat/auto_join_channel_batch_spec.rb:50:in `block (3 levels) in <main>'
     # ./plugins/chat/spec/services/chat/auto_join_channel_batch_spec.rb:110:in `block (6 levels) in <main>'
     # ./spec/rails_helper.rb:393:in `block (2 levels) in <top (required)>'
```
2023-08-08 22:44:30 +02:00
Discourse Translator Bot 5b6493ff4b
Update translations (#23013) 2023-08-08 15:42:28 +02:00
Jan Cernik b7953b2562
FIX: Don't create a reviewable when sending PM to user in chat (#22914)
The change is mainly to improve the consistency between flagging a chat message and flagging a post. This, in particular skips creating a reviewable when sending a PM to the user using the option "Send @user a message" from the flag menu.

Context: https://meta.discourse.org/t/send-message-to-user-flags-create-review-item-in-chat/272362
2023-08-08 13:18:34 +02:00
David Taylor edb276b9a9
DEV: Raise exception when capybara finder times out (#22686)
If a selenium finder takes the full wait duration to resolve, that means it has been written inefficiently. Most likely a matcher has been negated incorrectly.

This commit introduces a patch which will raise an error in this situation so that we can catch the issues while developing specs.

This commit also fixes chat's visit_thread helper. It was spinning on `has_css?(".chat-skeleton")` for the full selenium wait duration, and then returns false. That's because the thread is often already fully loaded before `has_css?` is even called. It's now updated to only look for the final expected state.
2023-08-08 10:16:09 +01:00
Martin Brennan 09223e5ae7
DEV: Remove enable_experimental_hashtag_autocomplete logic (#22820)
This commit removes any logic in the app and in specs around
enable_experimental_hashtag_autocomplete and deletes some
old category hashtag code that is no longer necessary.

It also adds a `slug_ref` category instance method, which
will generate a reference like `parent:child` for a category,
with an optional depth, which hashtags use. Also refactors
PostRevisor which was using CategoryHashtagDataSource directly
which is a no-no.

Deletes the old hashtag markdown rule as well.
2023-08-08 11:18:55 +10:00
Joffrey JAFFEUX c996b7fe4b
FIX: prevents readonly mode to crash channel_messages#index (#22987)
Prior to this fix `context.membership&.update!(last_viewed_at: Time.zone.now)` would generate an update statement from a GET request which is not permitted by default when in readonly mode.

The usual fix in this case is to check for readonly or rescue an error, however, this common pattern of updating "last seen" or similar can be better handled in a `Schedule::Defer` block, which won't raise the `ActiveRecord::ReadOnlyError` when in readonly and will also prevent the controller to wait for this operation.
2023-08-07 16:34:22 +02:00
Martin Brennan 3e44f04ff5
DEV: Unskip chat delete message spec (#22951)
Skipped in https://github.com/discourse/discourse/pull/22862 but
it seems like that may have been a sidebar error, unskipping to
see if it's ok now
2023-08-07 11:04:10 +10:00
David Taylor b7e642d99d
DEV: Introduce decorator-position lint rule (#22937) 2023-08-04 12:26:06 +01:00
Jarek Radosz 38d3208027
FIX: Poll breakdown regressions (#22955)
Some related to the modal api change, some due to chart.js updates
2023-08-03 16:58:52 +02:00
David Taylor 45ae9d9bab
UX: Introduce toggle-switch UI for plugins (#22910)
This commit makes some visual tweaks to the admin panel plugin list, and introduces functional 'toggle switches' for admins to enable/disable plugins more easily.

Co-authored-by: Jordan Vidrine <jordan@jordanvidrine.com>
2023-08-03 15:19:33 +01:00
Jarek Radosz 2b04301c19
FIX: Make poll breakdown modal closable again (#22952)
Regressed in https://github.com/discourse/discourse/pull/22164
2023-08-03 10:33:49 +02:00
Jarek Radosz f9b4cfe67e
DEV: Use async/await in checklist (#22943) 2023-08-02 23:24:20 +02:00
Jarek Radosz 7405aae85a
DEV: Remove checklist syntax migrator (#22942)
Added in https://github.com/discourse/discourse-checklist/pull/23

Those who wanted to convert most likely did in the last three years :]
2023-08-02 22:31:56 +02:00
Jarek Radosz c5c786b4ac
DEV: Fix array-related linting issues in templates (#22935)
and remove more linting exemptions
2023-08-02 19:43:37 +02:00
Jarek Radosz 09502cf627
DEV: Reduce the number of IntersectionObservers (#22933)
…by adding the `chat/track-message` modifier only to the last thread rather than all of them

(plus: don't use Ember's `lastObject`)
2023-08-02 15:24:30 +02:00
David Taylor 17d5e3ec23
DEV: Update composer service to inherit from Service, not Controller (#22929)
This was forgotten during the work in 22991bba44

This revealed two differences we were depending on: the merged `actions` hash (re-implemented on the service), and a couple of calls to `composer.send` (now removed)
2023-08-02 12:44:18 +01:00
Jarek Radosz 407ff39fdf
FIX: Poll builder UI issues (#22931)
1. recent css regression related to modal upgrade
2. autofocus and on-enter regressions
3. array related linting issue (reliance on Ember's firstObject/lastObject)
2023-08-02 12:55:25 +02:00
David Taylor 2d4be458a5
FEATURE: Bundle discourse-checklist plugin into core (#22927)
Formerly https://github.com/discourse/discourse-checklist
2023-08-02 10:17:24 +01:00
Martin Brennan d32e90a8d3
DEV: Remove unused chat translations (#22925)
Both placeholder_start_conversation and
placeholder_start_conversation_users are no
longer used.
2023-08-02 17:15:49 +10:00
Discourse Translator Bot d5f4b8e02c
Update translations (#22904) 2023-08-01 16:05:44 +02:00
Martin Brennan 6286e790b2
DEV: Remove unread_private_messages and deprecation (#22893)
This was added all the way back in 2020 in b79ea986ac,
enough time has passed, we can delete this now.
2023-08-01 14:44:39 +10:00
Gerhard Schlager 76649550c2 Fix typo in `not_enough_dice`
From https://www.collinsdictionary.com/dictionary/english/dice:
> In old-fashioned English, 'dice' was used only as a plural form, and the singular was die, but now 'dice' is used as both the singular and the plural form.
2023-07-31 13:28:42 +02:00
Martin Brennan f79f43ddf9
FIX: Chat translation minor issues (#22869) 2023-07-31 11:44:32 +10:00
Joffrey JAFFEUX 1d2cb3abdc
DEV: skip flakey spec in deleted messages (#22862) 2023-07-28 20:37:41 +02:00
Joffrey JAFFEUX 891aabde19
FIX: when using arrow to bottom fetch from newest (#22860)
We were attempting to fetch from last read but this is actually complicated to get right when you have a lot unread, as we might still have more to load after this but the last unread id is still the same and would make the user end up in a loop.
2023-07-28 19:31:28 +02:00
Andrei Prigorshnev 7c67360d4a
DEV: a better way of picking of the earliest date (#22858)
See https://github.com/discourse/discourse/pull/22854#discussion_r1277542736.
2023-07-28 20:17:04 +04:00
Andrei Prigorshnev cd45f33430
FEATURE: Remove restrictions from the chat messages export (#22854)
Now, when we took care of performance in fbe0e4c and ad05924 
there is no need anymore to restrict the export to
- 6 months
- 10000 rows
2023-07-28 17:04:57 +04:00
Alan Guo Xiang Tan bfc3132bb2
SECURITY: Impose a upper bound on limit params in various controllers
What is the problem here?

In multiple controllers, we are accepting a `limit` params but do not
impose any upper bound on the values being accepted. Without an upper
bound, we may be allowing arbituary users from generating DB queries
which may end up exhausing the resources on the server.

What is the fix here?

A new `fetch_limit_from_params` helper method is introduced in
`ApplicationController` that can be used by controller actions to safely
get the limit from the params as a default limit and maximum limit has
to be set. When an invalid limit params is encountered, the server will
respond with the 400 response code.
2023-07-28 12:53:46 +01:00
Martin Brennan 3c8cc0c73e
DEV: Remove chat TODO (#22846)
This is unnecessary, I already fixed this problem
2023-07-28 09:10:14 +08:00
Andrei Prigorshnev ad05924bdf
DEV: Do one query per month when exporting chat messages (#22746)
We did some testing and saw that making one query per month is 
cheaper than querying all chat messages at ones. Note that even 
though the export job will be performing one query per month, 
the exported messages will be streamed into a single CSV file, so 
nothing changes from the user's point of view.
2023-07-27 21:56:32 +04:00
chapoi 7b3f9dc86b
UX: different way of centering chat notice to accommodate longer texts (#22779)
* UX: different way of centering chat notice to accommodate longer

* linting

* UX: keep close button in top right corner
2023-07-27 15:53:43 +02:00
Jan Cernik 807390bb93
DEV: Remove experimental setting row for chat threads (#22730) 2023-07-27 15:29:28 +02:00
Joffrey JAFFEUX 0aa524821e
DEV: skip flaky spec (#22825)
An attempt to make this spec more stable has been made in f76a9aab22 which doesn’t seem to workout: https://github.com/discourse/discourse/actions/runs/5679336462/job/15391318065#step:31:1128
2023-07-27 15:12:22 +02:00
chapoi d10fd697b4
UX: responsive oneboxing with images in chat (#22824)
* UX: fix narrow oneboxing with images in chat

* UX: more responsive oneboxing

* UX: onebox-avatar limits

* ony flex non onebox-avatars
2023-07-27 13:57:30 +02:00
Loïc Guitaut 1377186d38 DEV: Refactor chat channel fetching
This is extracted from #22390.

This patch introduces a scope to avoid duplication and a new method,
`Chat::Channel.find_by_id_or_slug` to allow finding a channel either by
its id or by its slug (or its category slug).
2023-07-27 11:55:17 +02:00
Joffrey JAFFEUX 05aa55e172
DEV: moves logic from job to a service (#22691)
`Jobs::AutoJoinChannelBatch` was holding a lot of logic which should be in a service. Moreover, this refactoring is the opportunity to address a bug which could cause a duplicate key error.

From now when trying to insert a new membership it won't fail if a membership is already present.

Example error:

```
Job exception: ERROR:  duplicate key value violates unique constraint "user_chat_channel_unique_memberships"
DETAIL:  Key (user_id, chat_channel_id)=(1, 2) already exists.

Backtrace
rack-mini-profiler-3.1.0/lib/patches/db/pg.rb:110:in `exec'
rack-mini-profiler-3.1.0/lib/patches/db/pg.rb:110:in `async_exec'
(eval):29:in `async_exec'
mini_sql-1.4.0/lib/mini_sql/postgres/connection.rb:209:in `run'
mini_sql-1.4.0/lib/mini_sql/active_record_postgres/connection.rb:38:in `block in run'
mini_sql-1.4.0/lib/mini_sql/active_record_postgres/connection.rb:34:in `block in with_lock'
activesupport-7.0.5.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
activesupport-7.0.5.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
activesupport-7.0.5.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
activesupport-7.0.5.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
mini_sql-1.4.0/lib/mini_sql/active_record_postgres/connection.rb:34:in `with_lock'
mini_sql-1.4.0/lib/mini_sql/active_record_postgres/connection.rb:38:in `run'
mini_sql-1.4.0/lib/mini_sql/postgres/connection.rb:64:in `query_single'
/var/www/discourse/plugins/chat/app/jobs/regular/chat/auto_join_channel_batch.rb:38:in `execute'
```

Note this commit is also using main branch of `shoulda-matchers` as the gem has not been released yet.

Co-authored-by: Loïc Guitaut <5648+Flink@users.noreply.github.com>
2023-07-27 10:25:41 +02:00
Joffrey JAFFEUX 2d567cee26
FEATURE: thread pagination (#22624)
Prior to this commit we were loading a large number of thread messages without any pagination. This commit attempts to fix this and also improves the following points:

- code sharing between channels and threads:
Attempts to reuse/share the code use in channels for threads. To make it possible part of this code has been extracted in dedicated helpers or has been improved to reduce the duplication needed.

Examples of extracted helpers:
- `stackingContextFix`: the ios hack for rendering bug when momentum scrolling is interrupted
- `scrollListToMessage`, `scrollListToTop`, `scrollListToBottom`:  a series of helper to correctly scroll to a specific position in the list of messages

- better general performance of listing messages:
One of the main changes which has been made is to remove the computation of visible message during scroll, it will only happen when needed (update last read for example). This constant recomputation of `message.visible` on intersection observer event while scrolling was consuming a lot of CPU time.
2023-07-27 09:57:03 +02:00
Jarek Radosz 92d2ea008e
DEV: Fix no-negated-condition linting issues (#22808) 2023-07-26 19:53:37 +02:00
Penar Musaraj f2048eeb4c
UX: Minor change to compact tag chooser (#22796)
Followup to f5e8e73.

This switches the placeholder label to the existing string "optional
tags" and only shows it if there are no items picked.

Co-authored-by: Jarek Radosz <jradosz@gmail.com>
2023-07-26 11:43:46 -04:00
Jan Cernik a2eb2b0490
DEV: Remove experimental site setting for chat threads (#22720)
We are removing the experimental site setting. Admins can now decide on a per channel basis to enable/disable threading. It's disabled by default.
2023-07-26 12:46:23 +02:00
Jarek Radosz d06431ba9b
DEV: Fix random typos (#22804)
A fresh batch of stashed changes :P
2023-07-26 12:45:35 +02:00
Jan Cernik c43271eb9b
FIX: Chat emoji picker focus offset (#22795) 2023-07-26 12:18:10 +02:00
Joffrey JAFFEUX 5346e7f693
FIX: attempt to fix multi sessions reaction spec (#22797)
I was only able to get one failure out of 100 tries, this failure didn't get me more info. My best guess  ATM is  that sometimes, the first session was still loading while receiving the reaction and created some unexpected situation.

The commit attempts to start the "check" session before the session making the reaction hoping that will be enough to prevent this case, if this is the issue.
2023-07-26 11:58:35 +02:00
Loïc Guitaut 25138db433 DEV: Promote historic post_deploy migrations
This commit promotes all post_deploy migrations which existed in
Discourse v3.0.0 (timestamp <= 20221212234948)
2023-07-26 10:36:37 +02:00
Discourse Translator Bot ad9ad55870
Update translations (#22664) 2023-07-25 17:57:48 +02:00
Penar Musaraj f5e8e737ad
UX: Compact option for multi-selects (#22239)
Adds an alternative to the default multi select item, better suited for quickly adding/removing tags.
2023-07-25 11:00:02 -04:00
David Battersby f7353e7bfa
FIX: Prevent lightbox from loading onebox embed icons in chat uploads (#22776)
Sharing a link in chat will create a onebox embed with a source that includes a site icon and title.

This change prevents loading the site icon into lightbox.
2023-07-25 15:56:26 +08:00
Roman Rizzi 3389b3eeb0
FIX: Use base 10 when gettings allowed group IDs from settings. (#22761)
Same as discourse/discourse-ai#113
2023-07-24 12:05:04 -03:00
chapoi 5a36abd073
UX: category hashtag colors order fix (#22758)
* UX: revert gradient of category hashtag colours

* tests
2023-07-24 14:36:56 +02:00
Loïc Guitaut 5d2ec6461d DEV: Refactor a little chat uploads
This is extracted from #22390.

This patch simplifies a little how we handle uploads in chat, relying on
ActiveRecord mechanisms instead of calling custom methods.

This also makes `Chat::Message#validate_message` a “real” AR validation,
meaning it will run automatically when `#valid?` is called.
2023-07-24 11:13:57 +02:00
David Taylor eb94ec16da
DEV: introduce Ember `<template>` tag support (.gjs) (#22719)
The gjs/gts formats are a new pattern for authoring Ember components. This commit introduces support for these patterns to our build pipeline for core/plugins, and converts a handful of components to use the new format. It also introduces relevant updates to our linting config, and to our sample vscode configuration.

Co-authored-by: Godfrey Chan <godfreykfc@gmail.com>
Co-authored-by: Krystan HuffMenne <kmenne+github@gmail.com>
2023-07-20 21:01:12 +01:00
Andrei Prigorshnev 3349ce2c79
DEV: extract channel. joined_by method (#21752)
This only moves code around and doesn't change any behavior. This does two things:

1. Extracts the `channel.joined_by?` methods
2. Uses term "members" instead of "participants" for chat members
2023-07-20 22:06:36 +04:00
Loïc Guitaut 050828d1de DEV: Allow chat services to have optional models
This is extracted from #22390.

This patch adds a new `optional` option to the `model` step. This
means if an optional model returns something blank (`nil` or an empty
collection) then the service won’t fail and will execute the next step.
However if a model is properly returned, the step will try to check if
it is valid or not (if it responds to `#invalid?`). If the model isn’t
valid, then the step will fail (so no change here).
2023-07-20 17:27:44 +02:00
Jarek Radosz 6c8dcdb30c
DEV: Consistently use html5 loofah (#22711)
Turns out making a html4 fragment and then operating on parts of it using html5 fragments is a bad idea. ;)
This seems to fix the issue with occasionally missing GH icons in oneboxes.
2023-07-20 12:01:45 +02:00
Andrei Prigorshnev d1760727cf
DEV: check if user can_chat inside the can_join_chat_channel guardian (#21812)
Someone who cannot chat is also not able to join chat channels, 
so we may not check all the time user.can_chat? && user.can_join_chat_channel? 
and just call user.can_join_chat_channel? instead.
2023-07-19 21:55:00 +04:00
Isaac Janzen 1561e51a13
DEV: Revert "DEV: Update `replaceWith` on Route (#22645)" (#22693)
This reverts commit 33db93c9b2.
2023-07-19 10:47:31 -05:00
Martin Brennan a6956af902
FIX: Show mention count for channel list on mobile (#22682)
Followup to 07c3782e51

The above incorrectly removed the channel unread count in
the mobile/drawer channel list when the user has mentions
(meaning the unreads are urgent). This commit adds it
back and refactors system specs a little.
2023-07-19 16:24:01 +10:00
Krzysztof Kotlarek 20ec7ac174
FEATURE: new API to add panels to sidebar (#22534)
Define new concept of panels in sidebar. Panels are wrappers around sidebar sections. In the future, it allows creating full focus mode by switching between panels.

A new API method called addSidebarPanel was added. Default main panel is already registered and by default all API sections are mounted to main.
2023-07-19 11:31:45 +10:00
Alan Guo Xiang Tan 7cee80d699
DEV: Use the main default session for main test assertions (#22677)
Why this change?

The test being changed in question has been flaky on our CI. However, we
are unable to view the screenshot of why it failed because
ActionDispatch will only take a screenshot of the default session upon
failure. At the same time, taking screenshot of all sessions
automatically upon failure is not possible via the official Capybara or
Rails APIs at the moment. Therefore, we're changing this system test to
avoid using two custom session and instead have the main assertion use
the default session such that any failures will provide us with a
screenshot.
2023-07-19 08:21:31 +08:00
Martin Brennan 6efae69c61
FIX: Doubled up or not tracked threads in thread list (#22631)
This commit fixes two issues with the thread list:

1. All threads were being shown regardless of whether the user had
   a membership in the thread. This was happening because the list
   and the channel share the same thread store, so if the channel
   had OMs with threads we would load them and they showed in the list.
2. Threads created by the user from a staged thread would double up.
   This is because the _cache in the channel threadsManager would use
   the staged thread ID even after we'd replaced the object's ID with
   the actual thread from the DB. The answer to this is to remove and
   re-add the thread to the local cache with the actual ID.
2023-07-19 10:09:22 +10:00
Isaac Janzen 33db93c9b2
DEV: Update `replaceWith` on Route (#22645)
Per https://deprecations.emberjs.com/v3.x/#toc_routing-transition-methods

We are upgrading all `this.replaceWith` calls on routes to directly call the router service (`this.router.replaceWith`)
2023-07-18 15:05:53 -05:00
Isaac Janzen 011ba5b9f6
DEV: Update `transitionTo` on Route (#22644)
Per https://deprecations.emberjs.com/v3.x/#toc_routing-transition-methods

We are upgrading all `this.transitionTo` calls on routes to directly call the router service (`this.router.transitionTo`)
2023-07-18 14:52:55 -05:00
Jan Cernik d258bda2fe
FIX: Update `last_read_message_id` when moving chat messages (#22643) 2023-07-18 12:46:54 -03:00
Martin Brennan f76a9aab22
DEV: Fix and re-enable chat flakys (#22653)
* DEV: Fix and re-enable chat flakys

The early return in JS was added to prevent an error
from channel being null, and it's better to use known
users for the message fabrications in the specs.

* DEV: Use travel_to in drawer spec for thread tracking

Sometimes in the system test the datetime that is last
viewed for the channel for the user and the datetime for
the last message created_at is only microseconds of difference,
and we do not provide that level of fidelity in the MessageBus
serializer, so unreadThreadsCountSinceLastViewed is not
accurate.

Better to just utilize travel_to and move forward 1 minute in
time before sending the new message to easily differentiate.
2023-07-18 15:45:52 +10:00
Martin Brennan 1cb2043edc
FIX: Chat errors for thread subscriptions (#22657)
When we have subscriptions for new messages in a channel,
we also have special handling for messages in a thread. For
cases like DM channels where threads are made in the background
but not used in the UI, this is causing JS errors because we
are trying to fetch the thread but it returns 404.

We only want to do things with messages in threads if the
channel actually has threading enabled.
2023-07-18 13:02:27 +10:00
Martin Brennan b583872eed
DEV: Introduce enabled? API to hashtag data sources (#22632)
We need a nice way to only return some hashtag data
sources based on various site settings. This commit
adds an enabled? method that every hashtag data source
must implement. If this returns false the data source
will not be used at all for hashtag lookups or search.
2023-07-18 09:39:01 +10:00
Alan Guo Xiang Tan beb91e1707
DEV: Skip two flaky system tests (#22651)
Why this change?

These tests have shown to be flaky and are being skipped for now while
we look into it.
2023-07-18 07:26:12 +08:00
Joffrey JAFFEUX a982b6765f
FIX: allows to resize panels on tablets (#22640)
On tablets like iPad where we allow channel and thread to be on the same screen, it was not possible to resize the panels due to code being thought for mouse events. This commit should now correctly allow for this.

The "resizer" has also been made larger to simplify touching.

No test as it's hard to test on iPad and dragging events are also complex.
2023-07-17 15:11:51 +02:00
Joffrey JAFFEUX fe8d9b6b4e
FIX: allows to focus thread's composer on ipad (#22639)
On iOS we have a hack to prevent the viewport to move when focusing an input, however this code was targeting the textarea node through a global selector which is working fine on iOS as we only show one composer at a time but was failing on iPad as we show both channel and thread on the same screen. As a result `document.querySelector(".chat-composer__input")` was always targeting the first textarea on the screen which was the channel's composer, making it impossible to focus the thread's one.
2023-07-17 14:38:29 +02:00
chapoi e4deba0075
UX: size down unread indicators fror drawer/mobile (#22636) 2023-07-17 12:54:00 +02:00
Joffrey JAFFEUX c042978778
DEV: fix flaky spec temporarily (#22633)
We have a fix coming tomorrow.
2023-07-17 09:45:31 +02:00
Martin Brennan 07c3782e51
FEATURE: Show unread in sidebar for unread channel threads (#22342)
This commit makes it so that when the user has unread threads
for a channel we show a blue dot in the sidebar (or channel index
for mobile/drawer).

This blue dot is slightly different from the channel unread messages:

1. It will only show if the new thread messages were created since
   the user last viewed the channel
2. It will be cleared when the user views the channel, but the threads
   are still considered unread because we want the user to click into
   the thread list to view them

This necessitates a change to the current user serializer to also
include the unread thread overview, which is all unread threads
across all channels and their last reply date + time.
2023-07-17 13:00:49 +10:00
Alan Guo Xiang Tan d916ff56b5
DEV: Use the main default session for main test assertion (#22627)
Why this change?

The test being changed in question has been flaky on our CI. However, we
are unable to view the screenshot of why it failed because
ActionDispatch will only take a screenshot of the default session upon
failure. At the same time, taking screenshot of all sessions
automatically upon failure is not possible via the official Capybara or
Rails APIs at the moment. Therefore, we're changing this system test to
avoid using two custom session and instead have the main assertion use
the default session such that any failures will provide us with a
screenshot.
2023-07-17 08:58:09 +08:00
Martin Brennan 6459922993
DEV: Move Bookmark modal/component to use d-modal (#22532)
c.f. https://meta.discourse.org/t/converting-modals-from-legacy-controllers-to-new-dmodal-component-api/268057

This also converts the Bookmark component to a Glimmer
component.
2023-07-17 10:14:17 +10:00
Jan Cernik 402ac39fa2
FIX: Close modal after moving message to channel (#22601) 2023-07-14 12:22:18 +02:00
Joffrey JAFFEUX 6e95c1af3f
FIX: incorrect selector in system specs (#22615)
This could lead to flakey specs, and was invalid anyways.
2023-07-14 11:01:35 +02:00
Joffrey JAFFEUX ef21450be7
FIX: redirects to browse after removing last followed (#22563)
Prior to this change you might end up in a loop where removing a channel would redirect you to this channel and as we auto-follow opened direct message channels, you could never unfollow this last direct message channel.
2023-07-14 08:26:18 +02:00
Martin Brennan 10d155ea41
DEV: Further improve thread list query and add spec (#22610)
Followup to d7ef7b9c03,
this adds a spec to test the case where old threads are
still unread for the user and should show at the top regardless
of pagination, and fixes some issues/makes some slight refactors.
2023-07-14 16:08:35 +10:00
Martin Brennan 72bbc2fa8a
FIX: created_at datetime format inconsistencies in chat (#22611)
This commit attempts to fix an issue where we are ending
up with bad created_at date formats for last messages, which
is breaking the DM sort order and sometimes causing DM channels
to fall off the list, or show "Invalid date" on mobile.

I have not been able to consistently reproduce these issues
locally, however the serialzier for the channels index uses
MultiJSON.dump() and the Chat::Publisher uses .to_json, both of
which format created_at differently for messages.

The former is `2023-07-05T06:53:25.977Z` (iso8601).

The latter is `2023-07-14 03:59:22 UTC` (.to_s default).

Since we are doing comparison and sorting of these dates on the UI
we need consistent formatting for the JS Date parsers (and moment)
to deal with.

If the issue still occurs after this we can investigate further.
2023-07-14 16:05:01 +10:00
Joffrey JAFFEUX d7ef7b9c03
FIX: simplify channel threads lookup for pagination (#22596)
The previous query with subqueries was complicated to make right with pagination, this new query should be working correctly and is passing tests.
2023-07-13 16:44:22 +02:00
Joffrey JAFFEUX d7b7ca82f5
FIX: show only context menu on img long press (#22589)
Prior to this commit a long press on the image of a chat message would trigger both the actions menu and the contextual menu. This commit ensures we only show the contextual menu in this case.

No test as it's a quite complex behavior to reproduce (would need android for example).
2023-07-13 13:31:53 +02:00
Joffrey JAFFEUX ab6c638da2
FIX: prevent default event on touchend reaction (#22588)
This was causing this event to cause other touch events down the road. For example click a reaction above the composer when the message action was opened could cause the composer to gain focus after the reaction was made.
2023-07-13 11:33:51 +02:00
Joffrey JAFFEUX 720063fcfb
FIX: s/--border-radius-large)/--d-border-radius-large (#22587) 2023-07-13 10:17:29 +02:00
Joffrey JAFFEUX 32e32f43b5
FIX: prevents user to restore message deleted by staff (#22571)
It could only occur on message created by the user itself and deleted while the user was looking at the channel.

It more generally fix the trash service which was not correctly setting the author of the delete.
2023-07-13 10:16:15 +02:00
Joffrey JAFFEUX c996e5502f
FEATURE: enable_public_channels site setting (#22565)
`SiteSetting.enable_public_channels` allows site admin to decide if public channels are available at all. There's no distinction between admins or not as we expect admins to create private category channels if they want to limit usage.
2023-07-13 10:00:25 +02:00
Joe 82c03127df
FEATURE: New Discourse Lightbox using Glimmer (#19798)
Introduces new lightbox as a step to migrate away from Magnific Popup.

Please see https://meta.discourse.org/t/migrating-away-from-magnific-popup/251505 for more details

Co-authored-by: Nat <natalie.tay@discourse.org>
Co-authored-by: David Battersby <info@davidbattersby.com>
2023-07-13 15:06:17 +08:00
Alan Guo Xiang Tan f933c9fcd9
DEV: Rename method PageObjects::Pages::Chat (#22583)
`has_right_header_href?` is a little verbose and `has_header_href?` has
the same meaning.
2023-07-13 13:00:49 +08:00
Martin Brennan cdfa2b4aa2
DEV: Fix reply to spec (#22581)
Not sure how this was even working previously, since it's trying
to press the reply button on a thread original message, which doesn't
work, you need to click the indicator to open the thread.
2023-07-13 12:24:44 +10:00