mirror of
https://github.com/discourse/discourse.git
synced 2025-02-24 09:17:23 +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",
|
class: "members",
|
||||||
icon: "users",
|
icon: "users",
|
||||||
|
display: true,
|
||||||
text: i18n("about.member_count", {
|
text: i18n("about.member_count", {
|
||||||
count: this.args.model.stats.users_count,
|
count: this.args.model.stats.users_count,
|
||||||
formatted_number: I18n.toNumber(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",
|
class: "admins",
|
||||||
icon: "shield-halved",
|
icon: "shield-halved",
|
||||||
|
display: this.adminsCount > 0,
|
||||||
text: i18n("about.admin_count", {
|
text: i18n("about.admin_count", {
|
||||||
count: this.adminsCount,
|
count: this.adminsCount,
|
||||||
formatted_number: I18n.toNumber(this.adminsCount, { precision: 0 }),
|
formatted_number: I18n.toNumber(this.adminsCount, { precision: 0 }),
|
||||||
@ -55,6 +57,7 @@ export default class AboutPage extends Component {
|
|||||||
{
|
{
|
||||||
class: "moderators",
|
class: "moderators",
|
||||||
icon: "shield-halved",
|
icon: "shield-halved",
|
||||||
|
display: this.moderatorsCount > 0,
|
||||||
text: i18n("about.moderator_count", {
|
text: i18n("about.moderator_count", {
|
||||||
count: this.moderatorsCount,
|
count: this.moderatorsCount,
|
||||||
formatted_number: I18n.toNumber(this.moderatorsCount, {
|
formatted_number: I18n.toNumber(this.moderatorsCount, {
|
||||||
@ -65,6 +68,7 @@ export default class AboutPage extends Component {
|
|||||||
{
|
{
|
||||||
class: "site-creation-date",
|
class: "site-creation-date",
|
||||||
icon: "calendar-days",
|
icon: "calendar-days",
|
||||||
|
display: true,
|
||||||
text: this.siteAgeString,
|
text: this.siteAgeString,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
@ -253,10 +257,12 @@ export default class AboutPage extends Component {
|
|||||||
<div class="about__left-side">
|
<div class="about__left-side">
|
||||||
<div class="about__stats">
|
<div class="about__stats">
|
||||||
{{#each this.stats as |stat|}}
|
{{#each this.stats as |stat|}}
|
||||||
|
{{#if stat.display}}
|
||||||
<span class="about__stats-item {{stat.class}}">
|
<span class="about__stats-item {{stat.class}}">
|
||||||
{{icon stat.icon}}
|
{{icon stat.icon}}
|
||||||
<span>{{stat.text}}</span>
|
<span>{{stat.text}}</span>
|
||||||
</span>
|
</span>
|
||||||
|
{{/if}}
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -67,7 +67,8 @@ class About
|
|||||||
def moderators
|
def moderators
|
||||||
@moderators ||=
|
@moderators ||=
|
||||||
apply_excluded_groups(
|
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
|
end
|
||||||
|
|
||||||
@ -75,7 +76,10 @@ class About
|
|||||||
@admins ||=
|
@admins ||=
|
||||||
DiscoursePluginRegistry.apply_modifier(
|
DiscoursePluginRegistry.apply_modifier(
|
||||||
:about_admins,
|
: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
|
end
|
||||||
|
|
||||||
@ -139,8 +143,8 @@ class About
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def apply_excluded_groups(query)
|
def apply_excluded_groups(query, ignore_groups: [])
|
||||||
group_ids = SiteSetting.about_page_hidden_groups_map
|
group_ids = SiteSetting.about_page_hidden_groups_map - ignore_groups
|
||||||
return query if group_ids.blank?
|
return query if group_ids.blank?
|
||||||
|
|
||||||
query.joins(
|
query.joins(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user