mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 12:12:26 +08:00
UX: hide warning if all users mentioned via group are already invited. (#23557)
Previously, a "`some_not_allowed`" warning message was appeared in composer even when all the users mentioned via group are already invited to the private message directly or via other groups.
This commit is contained in:
parent
7f7e7fe516
commit
e4849445ce
|
@ -65,8 +65,12 @@ class ComposerController < ApplicationController
|
||||||
.count
|
.count
|
||||||
|
|
||||||
if notified_count > 0
|
if notified_count > 0
|
||||||
group_reasons[group.name] = :some_not_allowed
|
if notified_count == group.user_count
|
||||||
serialized_group[:notified_count] = notified_count
|
group_reasons.delete(group.name)
|
||||||
|
else
|
||||||
|
group_reasons[group.name] = :some_not_allowed
|
||||||
|
serialized_group[:notified_count] = notified_count
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -185,7 +185,6 @@ RSpec.describe ComposerController do
|
||||||
other_group = Fabricate(:group, mentionable_level: Group::ALIAS_LEVELS[:everyone])
|
other_group = Fabricate(:group, mentionable_level: Group::ALIAS_LEVELS[:everyone])
|
||||||
other_group.add(allowed_user)
|
other_group.add(allowed_user)
|
||||||
other_group.add(user)
|
other_group.add(user)
|
||||||
other_group.add(Fabricate(:user))
|
|
||||||
|
|
||||||
# Trying to mention other_group which has not been invited, but two of
|
# Trying to mention other_group which has not been invited, but two of
|
||||||
# its members have been (allowed_user directly and user via group).
|
# its members have been (allowed_user directly and user via group).
|
||||||
|
@ -193,6 +192,15 @@ RSpec.describe ComposerController do
|
||||||
|
|
||||||
expect(response.status).to eq(200)
|
expect(response.status).to eq(200)
|
||||||
|
|
||||||
|
expect(response.parsed_body["groups"]).to eq(other_group.name => { "user_count" => 2 })
|
||||||
|
expect(response.parsed_body["group_reasons"]).to be_empty
|
||||||
|
|
||||||
|
other_group.add(Fabricate(:user))
|
||||||
|
|
||||||
|
get "/composer/mentions.json", params: { names: [other_group.name], topic_id: topic.id }
|
||||||
|
|
||||||
|
expect(response.status).to eq(200)
|
||||||
|
|
||||||
expect(response.parsed_body["groups"]).to eq(
|
expect(response.parsed_body["groups"]).to eq(
|
||||||
other_group.name => {
|
other_group.name => {
|
||||||
"user_count" => 3,
|
"user_count" => 3,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user