mirror of
https://github.com/discourse/discourse.git
synced 2025-02-24 00:14:09 +08:00
DEV: Separate admins and moderators on about page (#31272)
This PR does some things to the about page: - Hide the stat if there are 0 admins/moderators. - Count admins and moderators separately, so a user who is both will add to both counts. - A user who is both will still show up as a moderator, even if `admins` is hidden.
This commit is contained in:
parent
441620ce61
commit
2cafd7e79b
@ -37,6 +37,7 @@ export default class AboutPage extends Component {
|
||||
{
|
||||
class: "members",
|
||||
icon: "users",
|
||||
display: true,
|
||||
text: i18n("about.member_count", {
|
||||
count: this.args.model.stats.users_count,
|
||||
formatted_number: I18n.toNumber(this.args.model.stats.users_count, {
|
||||
@ -47,6 +48,7 @@ export default class AboutPage extends Component {
|
||||
{
|
||||
class: "admins",
|
||||
icon: "shield-halved",
|
||||
display: this.adminsCount > 0,
|
||||
text: i18n("about.admin_count", {
|
||||
count: this.adminsCount,
|
||||
formatted_number: I18n.toNumber(this.adminsCount, { precision: 0 }),
|
||||
@ -55,6 +57,7 @@ export default class AboutPage extends Component {
|
||||
{
|
||||
class: "moderators",
|
||||
icon: "shield-halved",
|
||||
display: this.moderatorsCount > 0,
|
||||
text: i18n("about.moderator_count", {
|
||||
count: this.moderatorsCount,
|
||||
formatted_number: I18n.toNumber(this.moderatorsCount, {
|
||||
@ -65,6 +68,7 @@ export default class AboutPage extends Component {
|
||||
{
|
||||
class: "site-creation-date",
|
||||
icon: "calendar-days",
|
||||
display: true,
|
||||
text: this.siteAgeString,
|
||||
},
|
||||
];
|
||||
@ -253,10 +257,12 @@ export default class AboutPage extends Component {
|
||||
<div class="about__left-side">
|
||||
<div class="about__stats">
|
||||
{{#each this.stats as |stat|}}
|
||||
{{#if stat.display}}
|
||||
<span class="about__stats-item {{stat.class}}">
|
||||
{{icon stat.icon}}
|
||||
<span>{{stat.text}}</span>
|
||||
</span>
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
</div>
|
||||
|
||||
|
@ -67,7 +67,8 @@ class About
|
||||
def moderators
|
||||
@moderators ||=
|
||||
apply_excluded_groups(
|
||||
User.where(moderator: true, admin: false).human_users.order(last_seen_at: :desc),
|
||||
User.where(moderator: true).human_users.order(last_seen_at: :desc),
|
||||
ignore_groups: [Group::AUTO_GROUPS[:admins]],
|
||||
)
|
||||
end
|
||||
|
||||
@ -75,7 +76,10 @@ class About
|
||||
@admins ||=
|
||||
DiscoursePluginRegistry.apply_modifier(
|
||||
:about_admins,
|
||||
apply_excluded_groups(User.where(admin: true).human_users.order(last_seen_at: :desc)),
|
||||
apply_excluded_groups(
|
||||
User.where(admin: true).human_users.order(last_seen_at: :desc),
|
||||
ignore_groups: [Group::AUTO_GROUPS[:moderators]],
|
||||
),
|
||||
)
|
||||
end
|
||||
|
||||
@ -139,8 +143,8 @@ class About
|
||||
|
||||
private
|
||||
|
||||
def apply_excluded_groups(query)
|
||||
group_ids = SiteSetting.about_page_hidden_groups_map
|
||||
def apply_excluded_groups(query, ignore_groups: [])
|
||||
group_ids = SiteSetting.about_page_hidden_groups_map - ignore_groups
|
||||
return query if group_ids.blank?
|
||||
|
||||
query.joins(
|
||||
|
Loading…
x
Reference in New Issue
Block a user