Commit Graph

179 Commits

Author SHA1 Message Date
Joffrey JAFFEUX 3507a7dd98
FIX: correctly refresh UI when changing group preference (#560)
Prior to this fix the state change was not reflected in the UI when changing the "who can assign" preference of a group.

This was actually saved in the backend but would require a full page refresh to see the updated state on the group preferences page.
2024-04-05 18:46:08 +02:00
Andrei Prigorshnev 51920a99c0
FIX: Assignments limit shouldn't prevent from reassigning a post (#556)
At the moment, it's possible to have maximum 5 assignments per topic 
(that includes topic and post assignments). When trying to assign more, 
a message "Limit of 5 assignments per topic has been reached" appears.

One possible edge case here is _reassigning_ a topic or a post. Reassignment 
doesn't lead to exceeding the limit, and therefore it should be possible. But 
at the moment we handle correctly only _topic_  reassignments, while when 
reassigning a _post_, we show the error message "the limit has been reached".

This commit makes post reassignments work correctly too.
2024-03-29 15:50:02 +04:00
Blake Erickson ed059d3dfe
DEV: Changes for new bulk action dropdown modal (#553)
When the new bulk actions dropdown is enabled use a new component for bulk assigning.

Co-authored-by: Martin Brennan <martin@discourse.org>
2024-03-25 15:13:36 -06:00
Loïc Guitaut c696e44714 FIX: Recreate notifications on topic reopening
Currently, when reopening a topic that has assignments, the
notifications in the user menu aren’t recreated.

This patch fixes that issue. It also addresses the same type of issue
with posts being destroyed and recovered.
2024-03-18 10:56:08 +01:00
Loïc Guitaut c33297316a
DEV: Fix new Rubocop offenses (#548) 2024-02-29 18:23:48 +01:00
Alan Guo Xiang Tan 56b0de3896
DEV: Remove `capture_logs: true` metadata (#547)
Why this change?

We believe we have figured out the problem and not longer need the debugging information.
2024-02-22 20:09:22 +08:00
Alan Guo Xiang Tan 87e74f7948
DEV: Capture logs for all tests in `spec/system/assign_topic_spec.rb` (#542)
Why this change?

We have been getting flaky test failures from these specs and the
failure screenshot shows that the user is not logged in when it is
supposed to be. Futher investigation shows that when the test flakes, it
is because the request to view the topic is using an auth token that is
different from the one which was created when the user was signed in.

What does this change do?

1. Add the `capture_log` metadata to all the tests in this file.

2. Enables the `verbose_auth_token_logging` site setting to give us more
   debugging information in the logs.
2024-01-04 11:18:53 +08:00
Alan Guo Xiang Tan 4ac3f02b39
DEV: Unskip flaky tests and capture logs (#541)
Why this change?

The tests are supposedly flaky but we are unskipping them and capturing
logs to figure out why.
2024-01-03 13:11:03 +08:00
Alan Guo Xiang Tan 1f24dca1cc
DEV: Fix flaky system tests (#540)
Why this change?

The spec is flaky and it seems to be DB transaction related where after
signing in as a user, the failure screenshot shows that the user has not
been signed in.

What does this change do?

Set `capture_log: true` which will log all ActiveRecord DB statements
execute while running the spec.
2024-01-02 07:37:44 +08:00
Loïc Guitaut cac9a763dd FEATURE: Allow to reassign to same user
Currently, when only one user is available for the random auto-assign
and if that user was already assigned, then the assign will fail.

This patch addresses this issue by allowing to reassign a user who’s
already assigned. A new parameter (`allow_self_reassign`) has been added
to `Assigner#assign` with a default value of `false`.
2023-11-27 16:17:25 +01:00
Loïc Guitaut eb073febb0 DEV: Fix a flaky spec
Sometimes, the topic id actually exists for that spec (id being 1) and
it will raise about not finding the group id instead of not finding the
provided topic because the assignees group wasn’t provided in the
`fields` parameter.
2023-11-27 14:46:35 +01:00
Loïc Guitaut fbd1fa3794 FEATURE: Add a fallback to auto-assign
Currently, when the auto-assign logic can’t find a user to assign, it
will fail saying there was no one to assign. The current logic is this
one:
- Don’t pick anyone who’s been picked in the last 180 days
- If no one has been found, then try the same thing but only for the
  last 14 days.
While this is working relatively well for large enough groups, it
doesn’t work at all with very small groups (like 2 people) and it
creates unnecessary noise.

This patch addresses this issue by adding a fallback to the current
logic. Now, if the two first rules fail, instead of saying that no one
was assigned, we assign the least recently assigned person. This way,
the logic will continue to work with large groups but will also work
nicely with small groups.
2023-11-22 10:11:15 +01:00
David Taylor da20a2bf53
DEV: Update tests for core change (#525)
https://github.com/discourse/discourse/pull/23967
2023-11-15 09:23:36 +00:00
Loïc Guitaut be53c06e5a DEV: Rewrite post-migration in pure SQL 2023-11-15 09:50:54 +01:00
Loïc Guitaut 5055bcbb2c FIX: Order items properly in user menu
The recent changes to the user menu changed how we were ordering the
items in it. A small bug was noticed though, as we’re not displaying the
unread assignments at the very top.

This patch fixes the ordering like this:

- Unread individual assignment notifications
- Unread group assignment notifications
- Read individual assignments
- Read group assignments

In each group of items, they are sorted by date, the most recent ones
being at the top.
2023-11-09 16:41:48 +01:00
Loïc Guitaut 80604e9012 FIX: Display assignments in user menu properly
Currently, we display a mix of topics and notifications in the user menu
assignments tab. This has a number of issues like having to maintain
hard to understand code instead of simply relying on the notifications
system we have, we can’t display more than one assignment per topic and
it’s not clear if an assignment is for a topic or a post nor if it’s a
group assignment or an individual one.

This patch addresses those issues by relying on the notifications system
we’re using for most of the other user menu tabs instead of a custom
implementation. This led to some heavy refactoring but it was
worthwhile as things are a bit more normalized and easier to reason
about. Instead of serializing topics with different attributes to access
various assignments, we now simply return a notification for each
existing assignment.

The UI changed a bit: tooltips are now explaining if the assignment is
for a topic or a post and if it’s for an individual or a group. Icons
are also properly set (so no more individual icon for group assignments)
and the assigned group name is displayed.

The background jobs signatures changed a bit (`assignment_id` is now
needed for the unassign job) so when deploying this patch, it’s expected
to have some jobs failing. That’s why a post-migration has been written
to handle the creation of missing notifications and the deletion of
extra notifications too.
2023-11-08 15:26:57 +01:00
Natalie Tay 20cdd5ae87
DEV: Use match_array for spec allowed groups (#520) 2023-11-02 19:16:54 +08:00
Jarek Radosz 6ed4a13fe7
DEV: Update ruby linting (#518) 2023-10-20 17:04:03 +02:00
Natalie Tay e434be7969
UX: Don't change topic notification level when unassigning (#513)
* UX: Don't change topic notification level when unassigning

* Update test
2023-10-16 04:41:44 +00:00
Krzysztof Kotlarek 0c01e8fdfd
FIX: granular webhooks (#498)
After those core changes we need additional translations

https://github.com/discourse/discourse/pull/23070
2023-10-09 03:26:40 +00:00
Jarek Radosz e9c7cb5c3f
DEV: Skip a flaky spec (#508) 2023-09-12 07:43:24 +08:00
Natalie Tay 55f8d24b1f
DEV: Increase the buffer used to determine whether to send out the reminder email (#499)
Increase the buffer used to determine whether to send out the reminder email
2023-08-15 14:12:10 +08:00
Natalie Tay f5cc748986
FIX: Fix reminder frequency not getting sent daily when early by a few seconds/minutes (#496)
Add a buffer in determining whether to remind a user about assignments
2023-08-10 12:04:27 +08:00
Joffrey JAFFEUX 8f04d82ae7
DEV: skip flakey spec (#495)
We already tried to make this spec more reliable in eb3b97b834 but that didn't work out.

https://github.com/discourse/discourse/actions/runs/5694495045/job/15435791690?pr=22860
2023-07-28 19:31:55 +02:00
Alan Guo Xiang Tan eb3b97b834
DEV: Try to make system tests more stable (#492)
Why this change?

We have been seeing tests failures due to errors like

```
Capybara::ElementNotFound:
  Unable to find css "#topic-footer-button-assign"
```

when running our system tests in CI. However, I can't quite figure out
why that is happening and have invested way too much time to do so.
Therefore, I'm trying to fix this by closing a topic via the topic
timeline controls instead of the footer button instead.
2023-07-12 08:31:24 +08:00
Alan Guo Xiang Tan 7867cc4b03
DEV: Fix incorrect fabrication leading to index violation errors (#488)
This was causing the tests to be flaky with the following errors on CI:

```
PG::UniqueViolation: ERROR:  duplicate key value violates unique constraint "index_assignments_on_target_id_and_target_type"
       DETAIL:  Key (target_id, target_type)=(39, Topic) already exists.
```
2023-07-06 07:30:41 +08:00
Natalie Tay 76f92ba253
DEV: Fabricate assignments (#487)
- Fabricate and use slightly more accurate names for users and groups
- Use fabricator instead of assigner in controller setup
- Remove unneeded user
2023-07-05 15:23:34 +08:00
Martin Brennan 7d9207a275
DEV: Try fix flaky spec (#485)
For some reason sometimes clicking the admin wrench doesn't work
2023-07-05 12:10:48 +10:00
Natalie Tay 59fa9d7dbf
FIX: Sum assignments for group and group users (#482)
Use the assignment count rather than the number of topics assigned for the number of assignments in the nav
2023-07-03 10:58:46 +08:00
Vinoth Kannan fb89a23530
FEATURE: skip group invite if all members can see topic already. (#474)
We don't want to invite a group when all of its members are part of another group that is already allowed to the topic.
2023-05-27 22:29:38 +05:30
Vinoth Kannan f97da59dee
FIX: don't invite user when already a member of an allowed group. (#473)
Otherwise, when an allowed group member is assigned to the PM it invites the user (which is unnecessary) and creates a public small post for the invite.
2023-05-24 11:45:50 +05:30
Vinoth Kannan dcaadb75dc
FEATURE: invite user/group to PM if not a participant already. (#471)
When a group or user is assigned to a personal message, if they are not already a participant, invite them to the PM before assignment.
2023-05-22 14:48:08 +05:30
Ted Johansson afb54c7c1e
DEV: Replace #pluck_first monkey patch with native #pick (#467) 2023-05-09 12:59:41 +08:00
Arpit Jalan 69cbe1f3ee
FEATURE: allow adding note when bulk assigning topics (#466) 2023-05-02 15:20:44 +05:30
Natalie Tay 7562925e0d
FIX: Also evaluate list controller extensions (#455) 2023-03-23 21:35:12 +08:00
Bianca Nenciu d8ad876368
DEV: Update plugin to match latest guidelines (#446)
- Define extension modules
- Use different files instead of plugin.rb
- Make sure the plugin is disabled according to the setting
2023-02-17 17:35:41 +02:00
Kris e724a7ee69
UX: class for small posts when assigns are private (#400)
The goal is to add a class so when assigns are not public, their descriptions can be styled similar to whispers... this is a light way to reassure admins of assign message visibility.
2023-02-02 15:11:53 +08:00
Krzysztof Kotlarek a907a98d87
FIX: n+1 in search result (#438)
When assignment data is preloaded, cache variable should be set when topic is assigned but also when topic is not assigned to avoid additional queries.
2023-02-01 16:28:21 +11:00
Bianca Nenciu a9b44a973c
FIX: Use same limit as default for user search (#437) 2023-01-26 16:28:30 +02:00
Krzysztof Kotlarek c036d030dc
FIX: reassign when assignment limit is fulfilled (#419)
Previously, when topic was already assigned 5 times, reassign was not possible. User had to first unassign topic and then assign to someone else.
2023-01-20 13:34:22 +11:00
Jan Cernik a7df68b9c2
FIX: System tests failing due to assignee chooser (#430)
Since now the assignee chooser opens automatically, clicking on it was causing it to close
2023-01-17 09:55:21 -03:00
Jan Cernik 896d0e3445
FIX: Broken posts when assigning a closed topic (#425)
The previous behavior was:
1. Assign a topic to someone
2. Close the topic with the setting unassign_on_close enabled
3. Assign the topic to the same user as before

This caused small broken or empty posts to be displayed.

This commit also introduces system specs
2023-01-17 08:09:35 -03:00
Alan Guo Xiang Tan 4fe2ded608
DEV: Change flaky spec to provide more information when it fails (#418)
This spec has been detected to be flaky by
https://github.com/discourse/flaky-tests-detective which we run
internally. However, I could not reproduce the flakiness after multiple
attempts so I rewrote the assertions such that we set up the
expectations of what `Assignment#assigned_to_id` should be before and
after the triggering of the DiscourseEvent.
2023-01-04 07:27:23 +08:00
Gerhard Schlager 4777d0179c
UX: Rephrase notification message (#417)
* UX: Rephrase notification message

* Fix specs
2023-01-03 21:25:13 +01:00
David Taylor 46dd26963c
DEV: Introduce syntax_tree for ruby formatting (#408) 2022-12-23 20:35:55 +00:00
David Taylor 4902ba6993
DEV: Bump rubocop-discourse and correct violations (#409) 2022-12-23 19:55:31 +00:00
Bianca Nenciu eeccf78c1e
DEV: Admins and mods are already members of staff (#404)
This hack is no longer necessary because fabricated admins and mods are already members of the staff group.
2022-12-20 16:24:21 +02:00
Andrei Prigorshnev 31d1a798f4
FEATURE: do not suggest users on vacation (#395) 2022-12-14 12:42:17 +04:00
Penar Musaraj 4b8afc301a
FEATURE: Cleanup notifications when reassigning (#394)
If a topic is initially assigned to user A then reassigned to user B,
this change will make it so that notifications sent to user A are
removed. This matches the plugin's behaviour when unassigning a topic.
2022-11-24 10:42:19 -05:00
Alan Guo Xiang Tan ed1b344d32
DEV: Persist records to DB in tests (#390)
There is almost no reason for us to use `Fabricate.build` which does not persist the record to the database and is not what we encounter in production.
2022-10-21 17:47:29 +08:00