Commit Graph

226 Commits

Author SHA1 Message Date
Martin Brennan
d3a1b09361
FEATURE: Chat header icon indicator preference (#20474)
This commit allows the user to set their preference vis-a-vis
the chat icon in the header of the page. There are three options:

- All New (default) - This maintains the existing behaviour where
  all new messages in the channel show a blue dot on the icon
- Direct Messages and Mentions - Only show the green dot on the
  icon when you are directly messaged or mentioned, the blue dot
  is never shown
- Never - Never show any dot on the chat icon, for those who
  want tractor-beam-laser-focus
2023-03-01 11:01:44 +10:00
Martin Brennan
74e7ee175b
FIX: Blank dialog when auto-join selected in channel creation modal (#20405)
Fixes issue introduced in 7ef482a292
where the correct warning message was not shown when enabling auto-join
for public categories when creating a channel. Adds more system specs
as well to avoid regressions.
2023-02-22 17:38:54 +10:00
Gerhard Schlager
7ef482a292
REFACTOR: Fix pluralized strings in chat plugin (#20357)
* FIX: Use pluralized string

* REFACTOR: Fix misuse of pluralized string

* REFACTOR: Fix misuse of pluralized string

* DEV: Remove linting of `one` key in MessageFormat string, it doesn't work

* REFACTOR: Fix misuse of pluralized string

This also ensures that the URL works on subfolder and shows the site setting link only for admins instead of staff. The string is quite complicated, so the best option was to switch to MessageFormat.

* REFACTOR: Fix misuse of pluralized string

* FIX: Use pluralized string

This also ensures that the URL works on subfolder and shows the site setting link only for admins instead of staff.

* REFACTOR: Correctly pluralize reaction tooltips in chat

This also ensures that maximum 5 usernames are shown and fixes the number of "others" which was off by 1 if the current user reacted on a message.

* REFACTOR: Use translatable string as comma separator

* DEV: Add comment to translation to clarify the meaning of `%{identifier}`

* REFACTOR: Use translatable comma separator and use explicit interpolation keys

* REFACTOR: Don't interpolate lowercase channel status

* REFACTOR: Fix misuse of pluralized string

* REFACTOR: Don't interpolate channel status

* REFACTOR: Use %{count} interpolation key

* REFACTOR: Fix misuse of pluralized string

* REFACTOR: Correctly pluralize DM chat channel titles
2023-02-20 10:31:02 +01:00
Joffrey JAFFEUX
eb0caed75a
FIX: ensures staged message are set with channel id (#20335) 2023-02-16 18:05:13 +01:00
Joffrey JAFFEUX
723a7e316b
DEV: adds spec for deleted message (#20317) 2023-02-15 22:05:16 +01:00
Joffrey JAFFEUX
61934afbb1
FIX: ensures chat-message is recomputed with model (#20312)
The message model is not yet using tracked properties and as a result we were not correctly recomputing on various cases.
2023-02-15 15:08:55 +01:00
Martin Brennan
4f509b045c
FIX: Regression with chat shift+select messages (#20305)
Followup to b94fa3b87a,
which broke the functionality to click on a message
checkbox, hold shift, then click another one, and have
the messages inbetween selected. Add system spec to
catch this.
2023-02-15 08:49:56 +01:00
Joffrey JAFFEUX
714e903e81
FIX: correctly open channel info (#20297)
A typo was preventing a click on channel title when in drawer mode to correctly open the channel info in full page.

This commit fixes the typo and adds a test.
2023-02-15 14:03:29 +10:00
Martin Brennan
07ab20131a
FEATURE: Chat side panel with threads initial skeleton (#20209)
This commit introduces the skeleton of the chat thread UI. The
structure of the components looks like this. Its done this way
so the side panel can be used for other things as well if we wish,
not just for threads:

```
.main-chat-outlet
   <ChatLivePane />
   <ChatSidePanel>
     <-- rendered with {{outlet}} -->
     <ChatThread />
   </ChatSidePanel>
```

Later on the `ChatThreadList` will be rendered here as well.
Now, when you go to a channel you can open a thread by clicking
on either the Open Thread message action button or by clicking on
the reply indicator. This will take you to a route like `chat/c/:slug/:channelId/t/:threadId`.
This works on mobile as well.

This commit includes basic serializers and routes for threads,
as well as a new `ChatThreadsManager` service in JS that caches
threads for a channel the same way the channel threads manager does.

The chat messages inside the thread are intentionally left out
until a later PR.

**NOTE: These changes are gated behind the site setting enable_experimental_chat_threaded_discussions
and the threading_enabled boolean on a ChatChannel**
2023-02-14 11:38:41 +10:00
Joffrey JAFFEUX
f4b56ea455
UX: orders public channels by slug instead of title (#20188)
Public channels were previously sorted by name, however, channels with a leading emoji in the name would always appear first in the list. By using slug we avoid this issue.
2023-02-07 10:36:28 +01:00
Roman Rizzi
85e1a4934b
REFACTOR: Move mention warnings logic into a separate service. (#19465)
First follow-up to the feature introduced in #19034. We don't want to pollute main components like `chat-live-pane`, so we'll use a service to track and manage the state needed to display before-send warnings while composing a chat message.

We also move from acceptance tests to system specs.
2023-02-03 15:38:30 -03:00
Joffrey JAFFEUX
d5024d96f1
FEATURE: resizeable chat drawer (#20160)
This commit implements a requested feature: resizing the chat drawer.

The user can now adjust the drawer size to their liking, and the new size will be stored in localstorage so that it persists across refreshes. In addition to this feature, a bug was fixed where the --composer-right margin was not being correctly computed. This bug could have resulted in incorrectly positioned drawer when the composer was expanded.

Note that it includes support for RTL.
2023-02-03 15:11:12 +01:00
Joffrey JAFFEUX
24f026c895
FIX: correctly filters input with pre-filled value (#20154)
Before this fix we would fill the input but that wouldn't trigger the actual filtering.
2023-02-02 23:49:36 +01:00
Jan Cernik
6325e641d8
FIX: Emoji autocomplete “more” button not working in chat (#20113)
* FIX: Emoji autocomplete “more” button not working

* Rely on setting an intial value on the filter input

This commit removes custom logic applied on initial filter and instead gives a param to use as value for the input, automatically triggering the existing filtering handler.

Other notes:
- Slightly changes the API to be able to set a filter and open the composer in one go
- Adds a very simple service spec
- Adds a system spec to fully validate the behavior

---------

Co-authored-by: Joffrey JAFFEUX <j.jaffeux@gmail.com>
2023-02-02 15:04:52 -03:00
Roman Rizzi
5c699e4384
DEV: Pass messageId as a dynamic segment instead of a query param (#20013)
* DEV: Rnemae channel path to just c

Also swap the channel id and channel slug params to be consistent with core.

* linting

* channel_path

* Drop slugify helper and channel route without slug

* Request slug and route models through the channel model if possible

* DEV: Pass messageId as a dynamic segment instead of a query param

* Ensure change is backwards-compatible

* drop query param from oneboxes

* Correctly extract channelId from routes

* Better route organization using siblings for regular and near-message

* Ensures sessions are unique even when using parallelism

* prevents didReceiveAttrs to clear input mid test

* we disable animations in capybara so sometimes the message was barely showing

* adds wait

* ensures finished loading

* is it causing more harm than good?

* this check is slowing things for no reason

* actually target the button

* more resilient select chat message

* apply similar fix to bookmark

* fix

---------

Co-authored-by: Joffrey JAFFEUX <j.jaffeux@gmail.com>
2023-02-01 12:39:23 -03:00
Martin Brennan
db5ad34508
FEATURE: Allow editing channel slug (#19948)
This commit introduces the ability to edit the channel
slug from the About tab for the chat channel when the user
is admin. Similar to the create channel modal functionality
introduced in 641e94f, if
the slug is left empty then we autogenerate a slug based
on the channel name, and if the user just changes the slug
manually we use that instead.

We do not do any link remapping or anything else of the
sort, when the category slug is changed that does not happen
either.
2023-01-30 13:18:34 +10:00
Roman Rizzi
d07b472b79
DEV: /channel -> /c chat route rename (#19782)
* DEV: Rnemae channel path to just c

Also swap the channel id and channel slug params to be consistent with core.

* linting

* channel_path

* params in wrong order

* Drop slugify helper and channel route without slug

* Request slug and route models through the channel model if possible

* Add client side redirection for backwards-compatibility

Co-authored-by: Joffrey JAFFEUX <j.jaffeux@gmail.com>
2023-01-27 09:58:12 -03:00
Jarek Radosz
17deb79fcb
DEV: Fix random typos (#19973) 2023-01-24 15:41:01 +01:00
Martin Brennan
0924f874bd
DEV: Use UploadReference instead of ChatUpload in chat (#19947)
We've had the UploadReference table for some time now in core,
but it was added after ChatUpload was and chat was just never
moved over to this new system.

This commit changes all chat code dealing with uploads to create/
update/delete/query UploadReference records instead of ChatUpload
records for consistency. At a later date we will drop the ChatUpload
table, but for now keeping it for data backup.

The migration + post migration are the same, we need both in case
any chat uploads are added/removed during deploy.
2023-01-24 13:28:21 +10:00
Martin Brennan
641e94fc3c
FEATURE: Allow changing slug on create channel (#19928)
This commit allows us to set the channel slug when creating new chat
channels. As well as this, it introduces a new `SlugsController` which can
generate a slug using `Slug.for` and a name string for input. We call this
after the user finishes typing the channel name (debounced) and fill in
the autogenerated slug in the background, and update the slug input
placeholder.

This autogenerated slug is used by default, but if the user writes anything
else in the input it will be used instead.
2023-01-23 14:48:33 +10:00
Martin Brennan
46adcfa5e9
FIX: Do not override channel name when category selected (#19920) 2023-01-19 09:35:59 +01:00
Martin Brennan
31f6811a93
FIX: Change wording from title -> name in channel about page (#19889)
We refer to the channel name rather than title elsewhere
(including the new channel modal), so we should be consistent.
Title is an internal abstraction, since DM channels cannot have
names (currently).

Also change the name field on channel edit to a input type="text"
rather than a textarea, since we don't want a huge input here.
2023-01-18 09:13:33 +10:00
Martin Brennan
9a6eefaafc
DEV: Fix chat sidebar system spec flaky (#19844)
The spec was flaky because it was dependent on order,
when usernames got high enough sequence numbers in them
we would get this error:

> expected to find text "bruce99, bruce100" in "bruce100, bruce99"

Also move selectors into page object and use them in the
spec instead.
2023-01-12 14:12:49 +10:00
Martin Brennan
387693e889
FIX: Improve error reporting and failure modes for channel archiving (#19791)
There was an issue with channel archiving, where at times the topic
creation could fail which left the archive in a bad state, as read-only
instead of archived. This commit does several things:

* Changes the ChatChannelArchiveService to validate the topic being
  created first and if it is not valid report the topic creation errors
  in the PM we send to the user
* Changes the UI message in the channel with the archive status to reflect
  that topic creation failed
* Validate the new topic when starting the archive process from the UI,
  and show the validation errors to the user straight away instead of
  creating the archive record and starting the process

This also fixes another issue in the discourse_dev config which was
failing because YAML parsing does not enable all classes by default now,
which was making the seeding rake task for chat fail.
2023-01-12 10:04:46 +10:00
David Taylor
055310cea4
DEV: Apply syntax_tree formatting to plugins/* 2023-01-07 11:11:37 +00:00
Martin Brennan
6977761593
DEV: Re-enable chat transcript nested system spec (#19758)
The problem here was that if your input has an Enter
listener (such as the chat message input) and the
`fill_in(with: str)` string has a `\n` at the end, this
is treated as an Enter keypress, so this `fill_in` was
submitting the chat message.
2023-01-06 09:04:38 +10:00
Martin Brennan
16b9165630
FIX: Bookmark auto delete preference usage and default value (#19707)
This commit fixes an issue where the chat message bookmarks
did not respect the user's `bookmark_auto_delete_preference`
which they select in their user preference page.

Also, it changes the default for that value to "keep bookmark and clear reminder"
rather than "never", which ends up leaving a lot of expired bookmark
reminders around which are a pain to clean up.
2023-01-05 08:43:58 +10:00
Martin Brennan
9e175a3613
DEV: Add chat system spec for multi-file upload (#19709)
Followup to 29638f0639
2023-01-04 15:26:52 +01:00
Alan Guo Xiang Tan
1e118a271a
DEV: Fix syntax error in spec file (#19702)
Follow-up to b4adb806e5
2023-01-04 05:51:21 +08:00
Joffrey JAFFEUX
b4adb806e5
DEV: slightly increase wait to avoid flakey tests (#19695) 2023-01-03 17:14:02 +01:00
Joffrey JAFFEUX
a5dac26769
DEV: attempts to move all Jobs.run_immediately! at top (#19688) 2023-01-03 11:32:27 +01:00
Martin Brennan
b57f9c73a4
DEV: Skip all chat specs with Jobs.run_immediately! (#19684)
These specs are causing issues around AR connection pools
and busy connections, try skipping them for now, e.g. see
https://github.com/discourse/discourse/actions/runs/3826965835/jobs/6511173680
and /t/82525
2023-01-03 16:02:15 +10:00
Joffrey JAFFEUX
b235799792
FIX: more stable system tests (#19678)
This commit is a series of fixes to improve stability of system tests following the use of threadsafe:

* Jobs.run_immediately in before block was causing issues
* During test a js error could be caused by an undefined this.details in chat-live-pane
* Apply the chat composer click trick everywhere when sending a message, it ensures we are not hiding anything with autocomplete
* There was another case not using send_message yet
2023-01-03 14:53:41 +10:00
Joffrey JAFFEUX
d8a19b2c9a
FIX: correctly uses request_uri to generate load_more_url (#19680)
Before this change we were generating an incorrect absolute URL: `https://chat/api/channels...`
2023-01-03 00:19:13 +01:00
Roman Rizzi
2f61d26e3d
PERF: Make chat mention notifications async. (#19666)
This PR removes the limit added to max_users_notified_per_group_mention during #19034 and improve the performance when expanding mentions for large channel or groups by removing some N+1 queries and making the whole process async.

* Fully async chat message notifications

* Remove mention setting limit and get rid of N+1 queries
2023-01-02 11:54:52 -03:00
Joffrey JAFFEUX
b8100ad1ae
DEV: enables threadsafe for system tests
It should fix flakeys we have due to using_session. This commit is also fixing tests which were failing constantly with treadsafe enabled.

A test has also bene skipped as the issue couldn't be found so far.

More info: https://github.com/teamcapybara/capybara#threadsafe-mode
2023-01-02 15:17:21 +01:00
Joffrey JAFFEUX
b97fff444e
FIX: ensures loading more doesn’t erase filter on browse (#19675) 2023-01-02 14:40:13 +01:00
Joffrey JAFFEUX
4ba4959a26
FIX: various fixes to channel archive status (#19649)
- improves UI by displaying channel status on it's own line
- ensures channel status is correctly updated right after the request on frontend
- adds status on info page
2022-12-29 11:45:40 +01:00
Joffrey JAFFEUX
df11457d56
FIX: correctly allows admin to visit a user chat's preferences page (#19619) 2022-12-23 21:18:09 +01:00
Joffrey JAFFEUX
03d32f26bb
FIX: correctly handles navigating to a message (#19614)
Recent changes surfaced the various issues with this codepath:
- we were not correctly reseting `messageLookup` leading to us trying to scroll to a non existing message in the view
- we were calling markAsRead which would scroll to the bottom, even if we had a target message
- we were not debouncing fetchMessages, which could cause multiple reload of the messages when loading it with a targetMessageId: first fetch from last read and then immediately fetch from targetMessageId
- other naming inconsistencies
- not handling drawer

This commit also adds tests for classic scenarios related to this use case.
2022-12-23 19:48:14 +01:00
Joffrey JAFFEUX
64dcd44c94
FIX: more reliable archive channel spec (#19605) 2022-12-23 10:25:51 +01:00
Martin Brennan
29638f0639
DEV: Add upload system specs for chat (#19604) 2022-12-23 08:41:10 +01:00
Joffrey JAFFEUX
f17aed973e
FIX: ensures recovering network doesn't create unread mentions (#19597) 2022-12-23 07:38:45 +01:00
Joffrey JAFFEUX
f1e808153c
FIX: flakey spec due to autocomplete (#19598)
The autocomplete could show and hide the invite link causing the test to fail. Clicking the composer input forces the autocomplete disappear.
2022-12-23 10:35:02 +10:00
Joffrey JAFFEUX
2c295f76fe
FIX: increment wait to prevent a specific flakey spec (#19599)
I could repro the same failure by doing: `page.driver.browser.network_conditions = { offline: false, latency: 3000, throughput: 0 }`

Wait shouldn't be needed as we wait for selector, but I couldn't find a better solution on this case for now.
2022-12-23 10:34:25 +10:00
Martin Brennan
85b14a0359
DEV: Move chat transcript tests into system specs (#19434)
We are all in on system specs, so this commit moves all the chat quoting acceptance tests (some of which have been skipped for a while) into system specs.
2022-12-23 10:04:41 +10:00
Martin Brennan
788bcb7736
DEV: Fix hashtag system spec flakys (#19574)
Honestly seems like it's being in some weird loop for
discourse/hashtag_autocomplete_spec.rb for this:

```ruby
  within topic_page.post_by_number(2) do
      cooked_hashtags = page.all(".hashtag-cooked", count: 2)

      expect(cooked_hashtags[0]["outerHTML"]).to eq(<<~HTML.chomp)
      <a class=\"hashtag-cooked\" href=\"#{category.url}\" data-type=\"category\" data-slug=\"cool-cat\"><svg class=\"fa d-icon d-icon-folder svg-icon svg-node\"><use href=\"#folder\"></use></svg><span>Cool Category</span></a>
      HTML
      expect(cooked_hashtags[1]["outerHTML"]).to eq(<<~HTML.chomp)
      <a class=\"hashtag-cooked\" href=\"#{tag.url}\" data-type=\"tag\" data-slug=\"cooltag\"><svg class=\"fa d-icon d-icon-tag svg-icon svg-node\"><use href=\"#tag\"></use></svg><span>cooltag</span></a>
      HTML
    end
```

I see this many times in the full logs with `SELENIUM_VERBOSE_DRIVER_LOGS=1`:

```
COMMAND FindElements {
   "using": "css selector",
   "value": "#post_2"
}

Followed by:

COMMAND FindChildElements {
   "id": "26dfe542-659b-46cc-ac8c-a6c2d9cbdf0a",
   "using": "css selector",
   "value": ".hashtag-cooked"
}
```

Over and over and over, there are 58 such occurrences. I am beginning to
think `within` is just poison that should be avoided.
2022-12-23 09:23:29 +10:00
Joffrey JAFFEUX
46b51ade83
DEV: more reliable send message helper (#19594) 2022-12-22 23:23:54 +01:00
David Taylor
b1b53da71d
DEV: Improve performance of system test sign_in helper (#19579)
Previously, calling `sign_in` would cause the browser to be redirected to `/`, and would cause the Ember app to boot. We would then call `visit()`, causing the app to boot for a second time.

This commit adds a `redirect=false` option to the `/session/username/become` route. This avoids the unnecessary boot of the app, and leads to significantly faster system spec run times.

In local testing, this takes the full system-spec suite for chat from ~6min to ~4min.
2022-12-22 16:03:27 +00:00
Joffrey JAFFEUX
daff62e3cb
FIX: re-enables using_session tests (#19564) 2022-12-22 14:40:36 +01:00
Joffrey JAFFEUX
48ac5d5db9
FIX: corrects a regression with last_read_message_id (#19553)
This commit also adds a system to correctly track this case.
2022-12-21 19:49:32 +01:00
Joffrey JAFFEUX
b4b14c4d95
FIX: allows an admin to access users preferences (#19559) 2022-12-21 17:52:53 +01:00
Joffrey JAFFEUX
2304761223
FIX: correctly sorts public channels (#19555) 2022-12-21 17:01:20 +01:00
Joffrey JAFFEUX
c15b4212b6
FIX: better chat-api error handling (#19550)
- chat-message is not using chat-api yet and the `jsonMode` shouldn't have been added
- correctly error on `getChannel` not found
- adds/correct relevant system tests
2022-12-21 16:11:35 +01:00
Joffrey JAFFEUX
d2e24f9569
DEV: start glimmer-ification and optimisations of chat plugin (#19531)
Note this is a very large PR, and some of it could have been splited, but keeping it one chunk made it to merge conflicts and to revert if necessary. Actual new code logic is also not that much, as most of the changes are removing js tests, adding system specs or moving things around.

To make it possible this commit is doing the following changes:

- converting (and adding new) existing js acceptances tests into system tests. This change was necessary to ensure as little regressions as possible while changing paradigm
- moving away from store. Using glimmer and tracked properties requires to have class objects everywhere and as a result works well with models. However store/adapters are suffering from many bugs and limitations. As a workaround the `chat-api` and `chat-channels-manager` are an answer to this problem by encapsulating backend calls and frontend storage logic; while still using js models.
- dropping `appEvents` as much as possible. Using tracked properties and a better local storage of channel models, allows to be much more reactive and doesn’t require arbitrary manual updates everywhere in the app.
- while working on replacing store, the existing work of a chat api (backend) has been continued to support more cases.
- removing code from the `chat` service to separate concerns, `chat-subscriptions-manager` and `chat-channels-manager`, being the largest examples of where the code has been rewritten/moved.

Future wok:
- improve behavior when closing/deleting a channel, it's already slightly buggy on live, it's rare enough that it's not a big issue, but should be improved
- improve page objects used in chat
- move more endpoints to the API
- finish temporarily skipped tests
- extract more code from the `chat` service
- use glimmer for `chat-messages`
- separate concerns in `chat-live-pane`
- eventually add js tests for `chat-api`, `chat-channels-manager` and `chat-subscriptions-manager`, they are indirectly heavy tested through system tests but it would be nice to at least test the public API

<!-- 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. -->
2022-12-21 13:21:02 +01:00
chapoi
8db1f1892d
UX: Hashtag autocomplete styling (#19426)
* UX: added fadeout + hashtag styling

UX: add full name to autocomplete

UX: autocomplete mentions styling

UX: emoji styling user status

UX: autocomplete emoji

* DEV: Move hashtag tag counts into new secondary_text prop

* FIX: Add is-online style to mention users via chat

UX: make is-online avatar styling globally available

* DEV: Fix specs

* DEV: Test fix

Co-authored-by: Martin Brennan <martin@discourse.org>
2022-12-19 12:31:45 +01:00
Martin Brennan
6b9c0ee554
DEV: Change HashtagAutocompleteService to use DiscoursePluginRegistry (#19491)
Follow up to a review in #18937, this commit changes the HashtagAutocompleteService to no longer use class variables to register hashtag data sources or types in context priority order. This is to address multisite concerns, where one site could e.g. have chat disabled and another might not. The filtered plugin registers I added will not be included if the plugin is disabled.
2022-12-19 13:46:17 +10:00
Blake Erickson
5c925f2db3
FEATURE: Chat and Sidebar are now on by default (#19406)
FEATURE: Chat and Sidebar are now on by default

- Set the sidebar site setting to be enabled by default
- Set the chat site setting to be enabled by default
- Updated existing specs that assumed the original default
- Use a migration to keep old defaults for existing sites
2022-12-13 17:25:19 -07:00
Alan Guo Xiang Tan
fde9e6bc25
DEV: Migrate sidebar site settings (#19336)
This new site setting replaces the
`enable_experimental_sidebar_hamburger` and `enable_sidebar` site
settings as the sidebar feature exits the experimental phase.

Note that we're replacing this without depreciation since the previous
site setting was considered experimental.

Internal Ref: /t/86563
2022-12-08 09:44:29 +08:00
Joffrey JAFFEUX
cc769ac916
FIX: new message brings a direct message channel to the top (#19332)
Co-authored-by: Alan Guo Xiang Tan <gxtan1990@gmail.com>
2022-12-05 22:49:42 +01:00
Joffrey JAFFEUX
1d42cc94a2
FIX: nullify active channel only when not on a chat channel (#19319)
This would nullify the active channel when going from channel settings page to the channel.
2022-12-05 22:42:35 +01:00
Martin Brennan
8437081d94
FIX: Add MessageBust.last_id to chat channel subscriptions (#19255)
This commit adds variousMessageBus.last_ids to serializer payloads
for chat channels and the chat view (for chat live pane) so
we can use those IDs when subscribing to MessageBus channels
from chat.

This allows us to ensure that any messages created between the
server being hit and the UI loaded and subscribing end up being
delivered to the client, rather than just silently dropped.

This commit also fixes an issue where we were subscribing to
the new-messages and new-mentions MessageBus channels multiple
times when following/unfollowing a channel multiple times.
2022-12-02 10:57:53 +10:00
Joffrey JAFFEUX
637fb9831b
FIX: ensures chat sidebar is present when core sidebar is disabled (#19197) 2022-11-25 19:28:10 +01:00
Joffrey JAFFEUX
9ade68233c
UX: alters chat icon behavior on drawer and mobile (#19192)
Refines the behavior of clicking the chat icon in mobile and when in drawer mode as follows: If chat is open, clicking the icon takes you to the index.
2022-11-25 15:12:32 +01:00
Joffrey JAFFEUX
84c1cc70d6
REFACTOR: naming and state refactor (#19187)
- better handling of drawer state using chat state manager
- removes various float and topic occurrences to use drawer
- ensures user can chat before doing a lot of chat setup
- fixes a bug which was creating presence errors in tests
- removes dead code
2022-11-25 14:15:38 +01:00
Kris
bc61629d0f
A11Y: improved titles for chat in the sidebar (#19134) 2022-11-22 09:24:39 +08:00
Martin Brennan
d3f02a1270
FEATURE: Generic hashtag autocomplete lookup and markdown cooking (#18937)
This commit fleshes out and adds functionality for the new `#hashtag` search and
lookup system, still hidden behind the `enable_experimental_hashtag_autocomplete`
feature flag.

**Serverside**

We have two plugin API registration methods that are used to define data sources
(`register_hashtag_data_source`) and hashtag result type priorities depending on
the context (`register_hashtag_type_in_context`). Reading the comments in plugin.rb
should make it clear what these are doing. Reading the `HashtagAutocompleteService`
in full will likely help a lot as well.

Each data source is responsible for providing its own **lookup** and **search**
method that returns hashtag results based on the arguments provided. For example,
the category hashtag data source has to take into account parent categories and
how they relate, and each data source has to define their own icon to use for the
hashtag, and so on.

The `Site` serializer has two new attributes that source data from `HashtagAutocompleteService`.
There is `hashtag_icons` that is just a simple array of all the different icons that
can be used for allowlisting in our markdown pipeline, and there is `hashtag_context_configurations`
that is used to store the type priority orders for each registered context.

When sending emails, we cannot render the SVG icons for hashtags, so
we need to change the HTML hashtags to the normal `#hashtag` text.

**Markdown**

The `hashtag-autocomplete.js` file is where I have added the new `hashtag-autocomplete`
markdown rule, and like all of our rules this is used to cook the raw text on both the clientside
and on the serverside using MiniRacer. Only on the server side do we actually reach out to
the database with the `hashtagLookup` function, on the clientside we just render a plainer
version of the hashtag HTML. Only in the composer preview do we do further lookups based
on this.

This rule is the first one (that I can find) that uses the `currentUser` based on a passed
in `user_id` for guardian checks in markdown rendering code. This is the `last_editor_id`
for both the post and chat message. In some cases we need to cook without a user present,
so the `Discourse.system_user` is used in this case.

**Chat Channels**

This also contains the changes required for chat so that chat channels can be used
as a data source for hashtag searches and lookups. This data source will only be
used when `enable_experimental_hashtag_autocomplete` is `true`, so we don't have
to worry about channel results suddenly turning up.

------

**Known Rough Edges**

- Onebox excerpts will not render the icon svg/use tags, I plan to address that in a follow up PR
- Selecting a hashtag + pressing the Quote button will result in weird behaviour, I plan to address that in a follow up PR
- Mixed hashtag contexts for hashtags without a type suffix will not work correctly, e.g. #ux which is both a category and a channel slug will resolve to a category when used inside a post or within a [chat] transcript in that post. Users can get around this manually by adding the correct suffix, for example ::channel. We may get to this at some point in future
- Icons will not show for the hashtags in emails since SVG support is so terrible in email (this is not likely to be resolved, but still noting for posterity)
- Additional refinements and review fixes wil
2022-11-21 08:37:06 +10:00
Joffrey JAFFEUX
895898b363
FIX: correctly opens drawer to message id when given (#18994) 2022-11-14 08:16:09 +01:00
Joffrey JAFFEUX
88ede43ec5
FIX: correctly highlights active channel (#18991)
Prior to this change, only hovering the row would highlight it.
2022-11-11 22:32:06 +01:00
Joffrey JAFFEUX
66130dc8c1
REFACTOR: handles every chat resource as an URL (#18961)
- Note this is also tweaking the UI a little bit as we are now using links/buttons in the header as needed
- It disables the find ideal channel in drawer mode, if loading `/chat` in drawer mode it will either reopen at the last position or just stay on index
2022-11-11 06:39:15 +01:00
Joffrey JAFFEUX
074aa5eb5e
FIX: handles starting draft dm from sidebar (#18946) 2022-11-08 23:58:11 +01:00
Joffrey JAFFEUX
21570410ab
FIX: makes sidebar links respect drawer mode (#18918)
Clicking a link of the sidebar will now open the drawer and load the correct channel.

This solution should correctly solve these cases:

closing drawer, clicking sidebar channel, should open the drawer on correct channel
visiting /chat then visiting / and clicking sidebar channel, should open full page chat on correct channel
2022-11-08 16:23:13 +01:00
Joffrey JAFFEUX
0a02a5d05a
FIX: follow up to #7fca078 (#18915)
- prevents triggering chat:open-channel two times
- builds a correct URL for home page
2022-11-07 19:31:08 +01:00
Joffrey JAFFEUX
7fca07821b
FIX: simplfies previous route handling (#18895)
This commits makes sure we correctly wait for the end of the transition to reopen the drawer on the correct channel/view. Also fixes a bug when previous URL was `/` and causing a double transition.
2022-11-07 14:48:18 +01:00
Joffrey JAFFEUX
a51e5e1987
DEV: separates preferred-chat-mode service (#18883)
Also adds end to end system tests to ensure navigation scenarios are working correctly. This separation will make it easier to implement state in/out from chat.
2022-11-07 09:04:43 +01:00
Joffrey JAFFEUX
11f3618b80
DEV: initial system tests for chat and plugins (#18881)
This is a very basic to ensure it's working and open future possible work
2022-11-04 15:06:24 +01:00