Skip to content

Commit 341f6f2

Browse files
Gargronhiyuki2578
authored andcommitted
Change icons of features on admin dashboard to remove bias (mastodon#10366)
Red crosses implied that it was bad/unexpected that certain features were not enabled. In reality, they are options, so showing a green or grey power-off icon is more appropriate. Add status of timeline preview as well Fix sample accounts changing too frequently due to wrong query Sample accounts are intended to be sorted by popularity
1 parent 64db4ca commit 341f6f2

7 files changed

Lines changed: 43 additions & 72 deletions

File tree

app/controllers/admin/dashboard_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ def index
2929
@hidden_service = ENV['ALLOW_ACCESS_TO_HIDDEN_SERVICE'] == 'true'
3030
@trending_hashtags = TrendingTags.get(7)
3131
@profile_directory = Setting.profile_directory
32+
@timeline_preview = Setting.timeline_preview
3233
end
3334

3435
private

app/controllers/directories_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def set_tags
3232
end
3333

3434
def set_accounts
35-
@accounts = Account.discoverable.page(params[:page]).per(40).tap do |query|
35+
@accounts = Account.discoverable.by_recent_status.page(params[:page]).per(40).tap do |query|
3636
query.merge!(Account.tagged_with(@tag.id)) if @tag
3737
end
3838
end
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# frozen_string_literal: true
2+
3+
module Admin::DashboardHelper
4+
def feature_hint(feature, enabled)
5+
indicator = safe_join([enabled ? t('simple_form.yes') : t('simple_form.no'), fa_icon('power-off fw')], ' ')
6+
class_names = enabled ? 'pull-right positive-hint' : 'pull-right neutral-hint'
7+
8+
safe_join([feature, content_tag(:span, indicator, class: class_names)])
9+
end
10+
end

app/javascript/styles/mastodon/admin.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,11 @@ $content-width: 840px;
220220
color: $error-value-color;
221221
font-weight: 500;
222222
}
223+
224+
.neutral-hint {
225+
color: $dark-text-color;
226+
font-weight: 500;
227+
}
223228
}
224229

225230
@media screen and (max-width: $no-columns-breakpoint) {

app/models/account.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class Account < ApplicationRecord
9595
scope :matches_display_name, ->(value) { where(arel_table[:display_name].matches("#{value}%")) }
9696
scope :matches_domain, ->(value) { where(arel_table[:domain].matches("%#{value}%")) }
9797
scope :searchable, -> { without_suspended.where(moved_to_account_id: nil) }
98-
scope :discoverable, -> { searchable.without_silenced.where(discoverable: true).joins(:account_stat).where(AccountStat.arel_table[:followers_count].gteq(MIN_FOLLOWERS_DISCOVERY)).by_recent_status }
98+
scope :discoverable, -> { searchable.without_silenced.where(discoverable: true).joins(:account_stat).where(AccountStat.arel_table[:followers_count].gteq(MIN_FOLLOWERS_DISCOVERY)) }
9999
scope :tagged_with, ->(tag) { joins(:accounts_tags).where(accounts_tags: { tag_id: tag }) }
100100
scope :by_recent_status, -> { order(Arel.sql('(case when account_stats.last_status_at is null then 1 else 0 end) asc, account_stats.last_status_at desc')) }
101101
scope :popular, -> { order('account_stats.followers_count desc') }

app/views/admin/dashboard/index.html.haml

Lines changed: 24 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -40,35 +40,17 @@
4040
%h4= t 'admin.dashboard.features'
4141
%ul
4242
%li
43-
= link_to t('admin.dashboard.feature_registrations'), edit_admin_settings_path
44-
- if @registrations_enabled
45-
%span.pull-right.positive-hint= fa_icon 'check fw'
46-
- else
47-
%span.pull-right.negative-hint= fa_icon 'times fw'
48-
%li
49-
= link_to t('admin.dashboard.feature_invites'), edit_admin_settings_path
50-
- if @invites_enabled
51-
%span.pull-right.positive-hint= fa_icon 'check fw'
52-
- else
53-
%span.pull-right.negative-hint= fa_icon 'times fw'
54-
%li
55-
= link_to t('admin.dashboard.feature_deletions'), edit_admin_settings_path
56-
- if @deletions_enabled
57-
%span.pull-right.positive-hint= fa_icon 'check fw'
58-
- else
59-
%span.pull-right.negative-hint= fa_icon 'times fw'
60-
%li
61-
= link_to t('admin.dashboard.feature_profile_directory'), edit_admin_settings_path
62-
- if @profile_directory
63-
%span.pull-right.positive-hint= fa_icon 'check fw'
64-
- else
65-
%span.pull-right.negative-hint= fa_icon 'times fw'
66-
%li
67-
= link_to t('admin.dashboard.feature_relay'), admin_relays_path
68-
- if @relay_enabled
69-
%span.pull-right.positive-hint= fa_icon 'check fw'
70-
- else
71-
%span.pull-right.negative-hint= fa_icon 'times fw'
43+
= feature_hint(link_to(t('admin.dashboard.feature_registrations'), edit_admin_settings_path), @registrations_enabled)
44+
%li
45+
= feature_hint(link_to(t('admin.dashboard.feature_invites'), edit_admin_settings_path), @invites_enabled)
46+
%li
47+
= feature_hint(link_to(t('admin.dashboard.feature_deletions'), edit_admin_settings_path), @deletions_enabled)
48+
%li
49+
= feature_hint(link_to(t('admin.dashboard.feature_profile_directory'), edit_admin_settings_path), @profile_directory)
50+
%li
51+
= feature_hint(link_to(t('admin.dashboard.feature_timeline_preview'), edit_admin_settings_path), @timeline_preview)
52+
%li
53+
= feature_hint(link_to(t('admin.dashboard.feature_relay'), admin_relays_path), @relay_enabled)
7254

7355
.dashboard__widgets__versions
7456
%div
@@ -103,47 +85,19 @@
10385
%h4= t 'admin.dashboard.config'
10486
%ul
10587
%li
106-
= t('admin.dashboard.search')
107-
- if @search_enabled
108-
%span.pull-right.positive-hint= fa_icon 'check fw'
109-
- else
110-
%span.pull-right.negative-hint= fa_icon 'times fw'
111-
%li
112-
= t('admin.dashboard.single_user_mode')
113-
- if @single_user_mode
114-
%span.pull-right.positive-hint= fa_icon 'check fw'
115-
- else
116-
%span.pull-right.negative-hint= fa_icon 'times fw'
117-
%li
118-
LDAP
119-
- if @ldap_enabled
120-
%span.pull-right.positive-hint= fa_icon 'check fw'
121-
- else
122-
%span.pull-right.negative-hint= fa_icon 'times fw'
123-
%li
124-
CAS
125-
- if @cas_enabled
126-
%span.pull-right.positive-hint= fa_icon 'check fw'
127-
- else
128-
%span.pull-right.negative-hint= fa_icon 'times fw'
129-
%li
130-
SAML
131-
- if @saml_enabled
132-
%span.pull-right.positive-hint= fa_icon 'check fw'
133-
- else
134-
%span.pull-right.negative-hint= fa_icon 'times fw'
135-
%li
136-
PAM
137-
- if @pam_enabled
138-
%span.pull-right.positive-hint= fa_icon 'check fw'
139-
- else
140-
%span.pull-right.negative-hint= fa_icon 'times fw'
141-
%li
142-
= t 'admin.dashboard.hidden_service'
143-
- if @hidden_service
144-
%span.pull-right.positive-hint= fa_icon 'check fw'
145-
- else
146-
%span.pull-right.negative-hint= fa_icon 'times fw'
88+
= feature_hint(t('admin.dashboard.search'), @search_enabled)
89+
%li
90+
= feature_hint(t('admin.dashboard.single_user_mode'), @single_user_mode)
91+
%li
92+
= feature_hint('LDAP', @ldap_enabled)
93+
%li
94+
= feature_hint('CAS', @cas_enabled)
95+
%li
96+
= feature_hint('SAML', @saml_enabled)
97+
%li
98+
= feature_hint('PAM', @pam_enabled)
99+
%li
100+
= feature_hint(t('admin.dashboard.hidden_service'), @hidden_service)
147101

148102
.dashboard__widgets__trends
149103
%div

config/locales/en.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ en:
245245
feature_profile_directory: Profile directory
246246
feature_registrations: Registrations
247247
feature_relay: Federation relay
248+
feature_timeline_preview: Timeline preview
248249
features: Features
249250
hidden_service: Federation with hidden services
250251
open_reports: open reports

0 commit comments

Comments
 (0)