diff options
-rw-r--r-- | app/controllers/admin/dashboard_controller.rb | 1 | ||||
-rw-r--r-- | app/controllers/directories_controller.rb | 2 | ||||
-rw-r--r-- | app/helpers/admin/dashboard_helper.rb | 10 | ||||
-rw-r--r-- | app/javascript/styles/mastodon/admin.scss | 5 | ||||
-rw-r--r-- | app/models/account.rb | 2 | ||||
-rw-r--r-- | app/views/admin/dashboard/index.html.haml | 94 | ||||
-rw-r--r-- | config/locales/en.yml | 1 |
7 files changed, 43 insertions, 72 deletions
diff --git a/app/controllers/admin/dashboard_controller.rb b/app/controllers/admin/dashboard_controller.rb index 22bbcec19..f23ed1508 100644 --- a/app/controllers/admin/dashboard_controller.rb +++ b/app/controllers/admin/dashboard_controller.rb @@ -29,6 +29,7 @@ module Admin @hidden_service = ENV['ALLOW_ACCESS_TO_HIDDEN_SERVICE'] == 'true' @trending_hashtags = TrendingTags.get(7) @profile_directory = Setting.profile_directory + @timeline_preview = Setting.timeline_preview end private diff --git a/app/controllers/directories_controller.rb b/app/controllers/directories_controller.rb index ff7ff4a42..594907674 100644 --- a/app/controllers/directories_controller.rb +++ b/app/controllers/directories_controller.rb @@ -32,7 +32,7 @@ class DirectoriesController < ApplicationController end def set_accounts - @accounts = Account.discoverable.page(params[:page]).per(40).tap do |query| + @accounts = Account.discoverable.by_recent_status.page(params[:page]).per(40).tap do |query| query.merge!(Account.tagged_with(@tag.id)) if @tag end end diff --git a/app/helpers/admin/dashboard_helper.rb b/app/helpers/admin/dashboard_helper.rb new file mode 100644 index 000000000..4ee2cdef4 --- /dev/null +++ b/app/helpers/admin/dashboard_helper.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Admin::DashboardHelper + def feature_hint(feature, enabled) + indicator = safe_join([enabled ? t('simple_form.yes') : t('simple_form.no'), fa_icon('power-off fw')], ' ') + class_names = enabled ? 'pull-right positive-hint' : 'pull-right neutral-hint' + + safe_join([feature, content_tag(:span, indicator, class: class_names)]) + end +end diff --git a/app/javascript/styles/mastodon/admin.scss b/app/javascript/styles/mastodon/admin.scss index f6bfe44cf..fd5c08f04 100644 --- a/app/javascript/styles/mastodon/admin.scss +++ b/app/javascript/styles/mastodon/admin.scss @@ -220,6 +220,11 @@ $content-width: 840px; color: $error-value-color; font-weight: 500; } + + .neutral-hint { + color: $dark-text-color; + font-weight: 500; + } } @media screen and (max-width: $no-columns-breakpoint) { diff --git a/app/models/account.rb b/app/models/account.rb index c2a0709f9..51e01246e 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -94,7 +94,7 @@ class Account < ApplicationRecord scope :matches_display_name, ->(value) { where(arel_table[:display_name].matches("#{value}%")) } scope :matches_domain, ->(value) { where(arel_table[:domain].matches("%#{value}%")) } scope :searchable, -> { without_suspended.where(moved_to_account_id: nil) } - scope :discoverable, -> { searchable.without_silenced.where(discoverable: true).joins(:account_stat).where(AccountStat.arel_table[:followers_count].gteq(MIN_FOLLOWERS_DISCOVERY)).by_recent_status } + scope :discoverable, -> { searchable.without_silenced.where(discoverable: true).joins(:account_stat).where(AccountStat.arel_table[:followers_count].gteq(MIN_FOLLOWERS_DISCOVERY)) } scope :tagged_with, ->(tag) { joins(:accounts_tags).where(accounts_tags: { tag_id: tag }) } 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')) } scope :popular, -> { order('account_stats.followers_count desc') } diff --git a/app/views/admin/dashboard/index.html.haml b/app/views/admin/dashboard/index.html.haml index fa3d70e9e..d448e3862 100644 --- a/app/views/admin/dashboard/index.html.haml +++ b/app/views/admin/dashboard/index.html.haml @@ -40,35 +40,17 @@ %h4= t 'admin.dashboard.features' %ul %li - = link_to t('admin.dashboard.feature_registrations'), edit_admin_settings_path - - if @registrations_enabled - %span.pull-right.positive-hint= fa_icon 'check fw' - - else - %span.pull-right.negative-hint= fa_icon 'times fw' - %li - = link_to t('admin.dashboard.feature_invites'), edit_admin_settings_path - - if @invites_enabled - %span.pull-right.positive-hint= fa_icon 'check fw' - - else - %span.pull-right.negative-hint= fa_icon 'times fw' - %li - = link_to t('admin.dashboard.feature_deletions'), edit_admin_settings_path - - if @deletions_enabled - %span.pull-right.positive-hint= fa_icon 'check fw' - - else - %span.pull-right.negative-hint= fa_icon 'times fw' - %li - = link_to t('admin.dashboard.feature_profile_directory'), edit_admin_settings_path - - if @profile_directory - %span.pull-right.positive-hint= fa_icon 'check fw' - - else - %span.pull-right.negative-hint= fa_icon 'times fw' - %li - = link_to t('admin.dashboard.feature_relay'), admin_relays_path - - if @relay_enabled - %span.pull-right.positive-hint= fa_icon 'check fw' - - else - %span.pull-right.negative-hint= fa_icon 'times fw' + = feature_hint(link_to(t('admin.dashboard.feature_registrations'), edit_admin_settings_path), @registrations_enabled) + %li + = feature_hint(link_to(t('admin.dashboard.feature_invites'), edit_admin_settings_path), @invites_enabled) + %li + = feature_hint(link_to(t('admin.dashboard.feature_deletions'), edit_admin_settings_path), @deletions_enabled) + %li + = feature_hint(link_to(t('admin.dashboard.feature_profile_directory'), edit_admin_settings_path), @profile_directory) + %li + = feature_hint(link_to(t('admin.dashboard.feature_timeline_preview'), edit_admin_settings_path), @timeline_preview) + %li + = feature_hint(link_to(t('admin.dashboard.feature_relay'), admin_relays_path), @relay_enabled) .dashboard__widgets__versions %div @@ -103,47 +85,19 @@ %h4= t 'admin.dashboard.config' %ul %li - = t('admin.dashboard.search') - - if @search_enabled - %span.pull-right.positive-hint= fa_icon 'check fw' - - else - %span.pull-right.negative-hint= fa_icon 'times fw' - %li - = t('admin.dashboard.single_user_mode') - - if @single_user_mode - %span.pull-right.positive-hint= fa_icon 'check fw' - - else - %span.pull-right.negative-hint= fa_icon 'times fw' - %li - LDAP - - if @ldap_enabled - %span.pull-right.positive-hint= fa_icon 'check fw' - - else - %span.pull-right.negative-hint= fa_icon 'times fw' - %li - CAS - - if @cas_enabled - %span.pull-right.positive-hint= fa_icon 'check fw' - - else - %span.pull-right.negative-hint= fa_icon 'times fw' - %li - SAML - - if @saml_enabled - %span.pull-right.positive-hint= fa_icon 'check fw' - - else - %span.pull-right.negative-hint= fa_icon 'times fw' - %li - PAM - - if @pam_enabled - %span.pull-right.positive-hint= fa_icon 'check fw' - - else - %span.pull-right.negative-hint= fa_icon 'times fw' - %li - = t 'admin.dashboard.hidden_service' - - if @hidden_service - %span.pull-right.positive-hint= fa_icon 'check fw' - - else - %span.pull-right.negative-hint= fa_icon 'times fw' + = feature_hint(t('admin.dashboard.search'), @search_enabled) + %li + = feature_hint(t('admin.dashboard.single_user_mode'), @single_user_mode) + %li + = feature_hint('LDAP', @ldap_enabled) + %li + = feature_hint('CAS', @cas_enabled) + %li + = feature_hint('SAML', @saml_enabled) + %li + = feature_hint('PAM', @pam_enabled) + %li + = feature_hint(t('admin.dashboard.hidden_service'), @hidden_service) .dashboard__widgets__trends %div diff --git a/config/locales/en.yml b/config/locales/en.yml index b0bf2539c..ad1332fd2 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -245,6 +245,7 @@ en: feature_profile_directory: Profile directory feature_registrations: Registrations feature_relay: Federation relay + feature_timeline_preview: Timeline preview features: Features hidden_service: Federation with hidden services open_reports: open reports |