From d5b7a4b116d37e8b87f3ed9ebdc6adf07a088766 Mon Sep 17 00:00:00 2001 From: Sasha Sorokin Date: Fri, 13 Dec 2019 01:50:23 +0700 Subject: Avoid using pluralize on moderation pages (#12589) Pluralize function from Rails framework does not work with other languages than English, moreover it does not even work properly with English [1]. Not that the latest applies to this context, it's just a sign that we best to avoid this function, especially when there are more reliable ways. This commit changes how reports pages generated in order to avoid usage of pluralize function, replacing it with default translation function, called with given counter. On top of that, we have to make strings pluralizable, so have to change locale files. [1]: https://medium.com/@anna7/b3927de2ca8e#6a60 --- app/views/admin/reports/index.html.haml | 2 +- app/views/admin/reports/show.html.haml | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'app/views/admin') diff --git a/app/views/admin/reports/index.html.haml b/app/views/admin/reports/index.html.haml index b09472270..30c7549b0 100644 --- a/app/views/admin/reports/index.html.haml +++ b/app/views/admin/reports/index.html.haml @@ -28,7 +28,7 @@ .report-card__profile = account_link_to target_account, '', size: 36, path: admin_account_path(target_account.id) .report-card__profile__stats - = link_to pluralize(target_account.targeted_moderation_notes.count, t('admin.reports.account.note')), admin_account_path(target_account.id) + = link_to t('admin.reports.account.notes', count: target_account.targeted_moderation_notes.count), admin_account_path(target_account.id) %br/ - if target_account.suspended? %span.red= t('admin.accounts.suspended') diff --git a/app/views/admin/reports/show.html.haml b/app/views/admin/reports/show.html.haml index bbe83c979..aee9a3aef 100644 --- a/app/views/admin/reports/show.html.haml +++ b/app/views/admin/reports/show.html.haml @@ -25,16 +25,16 @@ %tr %th= t('admin.reports.reported_account') %td= admin_account_link_to @report.target_account - %td= table_link_to 'flag', pluralize(@report.target_account.targeted_reports.count, t('admin.reports.account.report')), admin_reports_path(target_account_id: @report.target_account.id) - %td= table_link_to 'file', pluralize(@report.target_account.targeted_moderation_notes.count, t('admin.reports.account.note')), admin_reports_path(target_account_id: @report.target_account.id) + %td= table_link_to 'flag', t('admin.reports.account.reports', count: @report.target_account.targeted_reports.count), admin_reports_path(target_account_id: @report.target_account.id) + %td= table_link_to 'file', t('admin.reports.account.notes', count: @report.target_account.targeted_moderation_notes.count), admin_reports_path(target_account_id: @report.target_account.id) %tr %th= t('admin.reports.reported_by') - if @report.account.instance_actor? %td{ colspan: 3 }= site_hostname - elsif @report.account.local? %td= admin_account_link_to @report.account - %td= table_link_to 'flag', pluralize(@report.account.targeted_reports.count, t('admin.reports.account.report')), admin_reports_path(target_account_id: @report.account.id) - %td= table_link_to 'file', pluralize(@report.account.targeted_moderation_notes.count, t('admin.reports.account.note')), admin_reports_path(target_account_id: @report.account.id) + %td= table_link_to 'flag', t('admin.reports.account.reports', count: @report.account.targeted_reports.count), admin_reports_path(target_account_id: @report.account.id) + %td= table_link_to 'file', t('admin.reports.account.notes', count: @report.account.targeted_moderation_notes.count), admin_reports_path(target_account_id: @report.account.id) - else %td{ colspan: 3 }= @report.account.domain %tr -- cgit From 34aa5c7cb2090bf9d995eafdfbf5f9bd01336491 Mon Sep 17 00:00:00 2001 From: Sasha Sorokin Date: Tue, 17 Dec 2019 05:55:16 +0700 Subject: Improve report page structure (#12615) * Move resolved button to the heading This is one of the commits on improving overall reports page structure. It changes where resolved button is located, moving it to the heading, right next to the "Report #n" header, so-called "hot-place" to look at. To accomplish this we have to declare one more content variable, change admin dashboard template to respect it and CSS files for minor styling, so buttons are inlined and centrally aligned according to the heading. * Move actions buttons below the report table I believe that actions to react on report should not be located at the top of the page, instead they should be either after the table or reporter's comment. This is just a logical sign that you should not react to the report without reading all the details first. --- app/javascript/styles/mastodon/admin.scss | 31 ++++++++++++++++++++++++++----- app/views/admin/reports/show.html.haml | 24 +++++++++++++----------- app/views/layouts/admin.html.haml | 7 ++++++- 3 files changed, 45 insertions(+), 17 deletions(-) (limited to 'app/views/admin') diff --git a/app/javascript/styles/mastodon/admin.scss b/app/javascript/styles/mastodon/admin.scss index dde1d69ba..203365f5e 100644 --- a/app/javascript/styles/mastodon/admin.scss +++ b/app/javascript/styles/mastodon/admin.scss @@ -181,18 +181,39 @@ $content-width: 840px; padding-top: 30px; } - h2 { - color: $secondary-text-color; - font-size: 24px; - line-height: 28px; - font-weight: 400; + &-heading { + display: flex; + padding-bottom: 40px; border-bottom: 1px solid lighten($ui-base-color, 8%); margin-bottom: 40px; + flex-wrap: wrap; + align-items: center; + + justify-content: space-between; + + &-actions { + display: inline-flex; + + & > * { + margin-left: 5px; + } + } + @media screen and (max-width: $no-columns-breakpoint) { border-bottom: 0; padding-bottom: 0; + } + } + + h2 { + color: $secondary-text-color; + font-size: 24px; + line-height: 28px; + font-weight: 400; + + @media screen and (max-width: $no-columns-breakpoint) { font-weight: 700; } } diff --git a/app/views/admin/reports/show.html.haml b/app/views/admin/reports/show.html.haml index aee9a3aef..7f3ec35a4 100644 --- a/app/views/admin/reports/show.html.haml +++ b/app/views/admin/reports/show.html.haml @@ -4,21 +4,12 @@ - content_for :page_title do = t('admin.reports.report', id: @report.id) -%div{ style: 'overflow: hidden; margin-bottom: 20px' } +- content_for :page_heading_actions do - if @report.unresolved? - %div{ style: 'float: right' } - - if @report.target_account.local? - = link_to t('admin.accounts.warn'), new_admin_account_action_path(@report.target_account_id, type: 'none', report_id: @report.id), class: 'button' - = link_to t('admin.accounts.disable'), new_admin_account_action_path(@report.target_account_id, type: 'disable', report_id: @report.id), class: 'button button--destructive' - = link_to t('admin.accounts.silence'), new_admin_account_action_path(@report.target_account_id, type: 'silence', report_id: @report.id), class: 'button button--destructive' - = link_to t('admin.accounts.perform_full_suspension'), new_admin_account_action_path(@report.target_account_id, type: 'suspend', report_id: @report.id), class: 'button button--destructive' - %div{ style: 'float: left' } - = link_to t('admin.reports.mark_as_resolved'), resolve_admin_report_path(@report), method: :post, class: 'button' + = link_to t('admin.reports.mark_as_resolved'), resolve_admin_report_path(@report), method: :post, class: 'button' - else = link_to t('admin.reports.mark_as_unresolved'), reopen_admin_report_path(@report), method: :post, class: 'button' -%hr.spacer - .table-wrapper %table.table.inline-table %tbody @@ -77,6 +68,17 @@ %hr.spacer +%div{ style: 'overflow: hidden; margin-bottom: 20px; clear: both' } + - if @report.unresolved? + %div{ style: 'float: right' } + - if @report.target_account.local? + = link_to t('admin.accounts.warn'), new_admin_account_action_path(@report.target_account_id, type: 'none', report_id: @report.id), class: 'button' + = link_to t('admin.accounts.disable'), new_admin_account_action_path(@report.target_account_id, type: 'disable', report_id: @report.id), class: 'button button--destructive' + = link_to t('admin.accounts.silence'), new_admin_account_action_path(@report.target_account_id, type: 'silence', report_id: @report.id), class: 'button button--destructive' + = link_to t('admin.accounts.perform_full_suspension'), new_admin_account_action_path(@report.target_account_id, type: 'suspend', report_id: @report.id), class: 'button button--destructive' + +%hr.spacer + .speech-bubble .speech-bubble__bubble= simple_format(@report.comment.presence || t('admin.reports.comment.none')) .speech-bubble__owner diff --git a/app/views/layouts/admin.html.haml b/app/views/layouts/admin.html.haml index 57bda45e2..059bf8579 100644 --- a/app/views/layouts/admin.html.haml +++ b/app/views/layouts/admin.html.haml @@ -21,7 +21,12 @@ .content-wrapper .content - %h2= yield :page_title + .content-heading + %h2= yield :page_title + + - if :page_heading_actions + .content-heading-actions + = yield :page_heading_actions = render 'application/flashes' -- cgit From 668f6980774e124a1cc4c80b280172de04ca7973 Mon Sep 17 00:00:00 2001 From: Alice Gaudon Date: Mon, 16 Dec 2019 23:55:50 +0100 Subject: Admin setting to disable default follows (#12566) --- app/javascript/packs/admin.js | 22 ++++++++++++++++++++-- app/models/form/admin_settings.rb | 2 ++ app/services/bootstrap_timeline_service.rb | 2 +- app/views/admin/settings/edit.html.haml | 7 ++++++- config/locales/en.yml | 2 ++ config/settings.yml | 1 + 6 files changed, 32 insertions(+), 4 deletions(-) (limited to 'app/views/admin') diff --git a/app/javascript/packs/admin.js b/app/javascript/packs/admin.js index 42c747d2e..b318cadc6 100644 --- a/app/javascript/packs/admin.js +++ b/app/javascript/packs/admin.js @@ -45,7 +45,25 @@ const onDomainBlockSeverityChange = (target) => { delegate(document, '#domain_block_severity', 'change', ({ target }) => onDomainBlockSeverityChange(target)); +const onEnableBootstrapTimelineAccountsChange = (target) => { + const bootstrapTimelineAccountsField = document.querySelector('#form_admin_settings_bootstrap_timeline_accounts'); + + if (bootstrapTimelineAccountsField) { + bootstrapTimelineAccountsField.disabled = !target.checked; + if (target.checked) { + bootstrapTimelineAccountsField.parentElement.classList.remove('disabled'); + } else { + bootstrapTimelineAccountsField.parentElement.classList.add('disabled'); + } + } +}; + +delegate(document, '#form_admin_settings_enable_bootstrap_timeline_accounts', 'change', ({ target }) => onEnableBootstrapTimelineAccountsChange(target)); + ready(() => { - const input = document.getElementById('domain_block_severity'); - if (input) onDomainBlockSeverityChange(input); + const domainBlockSeverityInput = document.getElementById('domain_block_severity'); + if (domainBlockSeverityInput) onDomainBlockSeverityChange(domainBlockSeverityInput); + + const enableBootstrapTimelineAccounts = document.getElementById('form_admin_settings_enable_bootstrap_timeline_accounts'); + if (enableBootstrapTimelineAccounts) onEnableBootstrapTimelineAccountsChange(enableBootstrapTimelineAccounts); }); diff --git a/app/models/form/admin_settings.rb b/app/models/form/admin_settings.rb index 70e9c21f1..390836f28 100644 --- a/app/models/form/admin_settings.rb +++ b/app/models/form/admin_settings.rb @@ -16,6 +16,7 @@ class Form::AdminSettings open_deletion timeline_preview show_staff_badge + enable_bootstrap_timeline_accounts bootstrap_timeline_accounts theme min_invite_role @@ -40,6 +41,7 @@ class Form::AdminSettings open_deletion timeline_preview show_staff_badge + enable_bootstrap_timeline_accounts activity_api_enabled peers_api_enabled show_known_fediverse_at_about_page diff --git a/app/services/bootstrap_timeline_service.rb b/app/services/bootstrap_timeline_service.rb index c489601c1..8412aa7e7 100644 --- a/app/services/bootstrap_timeline_service.rb +++ b/app/services/bootstrap_timeline_service.rb @@ -5,7 +5,7 @@ class BootstrapTimelineService < BaseService @source_account = source_account autofollow_inviter! - autofollow_bootstrap_timeline_accounts! + autofollow_bootstrap_timeline_accounts! if Setting.enable_bootstrap_timeline_accounts end private diff --git a/app/views/admin/settings/edit.html.haml b/app/views/admin/settings/edit.html.haml index 6282bb39c..d7b493051 100644 --- a/app/views/admin/settings/edit.html.haml +++ b/app/views/admin/settings/edit.html.haml @@ -1,3 +1,6 @@ +- content_for :header_tags do + = javascript_pack_tag 'admin', integrity: true, async: true, crossorigin: 'anonymous' + - content_for :page_title do = t('admin.settings.title') @@ -38,7 +41,9 @@ %hr.spacer/ .fields-group - = f.input :bootstrap_timeline_accounts, wrapper: :with_block_label, label: t('admin.settings.bootstrap_timeline_accounts.title'), hint: t('admin.settings.bootstrap_timeline_accounts.desc_html') + = f.input :enable_bootstrap_timeline_accounts, as: :boolean, wrapper: :with_label, label: t('admin.settings.enable_bootstrap_timeline_accounts.title') + .fields-group + = f.input :bootstrap_timeline_accounts, wrapper: :with_block_label, label: t('admin.settings.bootstrap_timeline_accounts.title'), hint: t('admin.settings.bootstrap_timeline_accounts.desc_html'), disabled: !Setting.enable_bootstrap_timeline_accounts %hr.spacer/ diff --git a/config/locales/en.yml b/config/locales/en.yml index ea94928e7..5edd6e0d3 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -456,6 +456,8 @@ en: users: To logged-in local users domain_blocks_rationale: title: Show rationale + enable_bootstrap_timeline_accounts: + title: Enable default follows for new users hero: desc_html: Displayed on the frontpage. At least 600x100px recommended. When not set, falls back to server thumbnail title: Hero image diff --git a/config/settings.yml b/config/settings.yml index f66e3922e..002473643 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -61,6 +61,7 @@ defaults: &defaults - mod - moderator disallowed_hashtags: # space separated string or list of hashtags without the hash + enable_bootstrap_timeline_accounts: true bootstrap_timeline_accounts: '' activity_api_enabled: true peers_api_enabled: true -- cgit