From 8a5c7b2b3e479f1fffa86b15852b61be05493310 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Sat, 30 Jul 2022 02:55:32 +0200 Subject: [PATCH 1/6] Remove navbar style moderation navigation --- app/views/layouts/moderation.haml | 1 - app/views/navigation/_moderation.haml | 12 ------------ 2 files changed, 13 deletions(-) delete mode 100644 app/views/navigation/_moderation.haml diff --git a/app/views/layouts/moderation.haml b/app/views/layouts/moderation.haml index 22a48339..2d600a12 100644 --- a/app/views/layouts/moderation.haml +++ b/app/views/layouts/moderation.haml @@ -1,4 +1,3 @@ -= render 'navigation/moderation' .container-lg.container--main .row .col-md-3.col-sm-4.col-xs-12 diff --git a/app/views/navigation/_moderation.haml b/app/views/navigation/_moderation.haml deleted file mode 100644 index 007766cc..00000000 --- a/app/views/navigation/_moderation.haml +++ /dev/null @@ -1,12 +0,0 @@ -%nav.navbar.navbar-light.bg-light.navbar-static-top.j2-navbar.d-flex.d-sm-none{ role: :navigation } - %a.navbar-brand{ href: moderation_path } Moderation - %button.navbar-toggler{ data: { target: '#j2-tl-navbar-collapse', toggle: :collapse }, type: :button } - %span.sr-only Toggle navigation - %span.navbar-toggler-icon - .collapse.navbar-collapse#j2-tl-navbar-collapse - %ul.nav.navbar-nav - = nav_entry t('views.moderation.tabs.all'), moderation_path - = nav_entry t('views.general.answer').pluralize(2), moderation_path('answer') - = nav_entry t('views.general.comment').pluralize(2), moderation_path('comment') - = nav_entry t('views.general.user').pluralize(2), moderation_path('user') - = nav_entry t('views.general.question').pluralize(2), moderation_path('question') From 0ca8c2084552fafd499e7deb733b14e9cd28ad11 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Sat, 30 Jul 2022 02:55:56 +0200 Subject: [PATCH 2/6] Add new translations for moderation tabs --- app/views/tabs/_moderation.haml | 12 ++++++------ config/locales/views.en.yml | 6 ++++++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app/views/tabs/_moderation.haml b/app/views/tabs/_moderation.haml index a0ae3666..4b7c8f43 100644 --- a/app/views/tabs/_moderation.haml +++ b/app/views/tabs/_moderation.haml @@ -1,9 +1,9 @@ -.card.d-none.d-sm-block +.card .list-group - = list_group_item t('views.moderation.tabs.all'), moderation_path - = list_group_item t('views.general.answer').pluralize(2), moderation_path('answer') - = list_group_item t('views.general.comment').pluralize(2), moderation_path('comment') - = list_group_item t('views.general.user').pluralize(2), moderation_path('user') - = list_group_item t('views.general.question').pluralize(2), moderation_path('question') + = list_group_item t('.all'), moderation_path + = list_group_item t('.answers'), moderation_path('answer') + = list_group_item t('.comments'), moderation_path('comment') + = list_group_item t('.users'), moderation_path('user') + = list_group_item t('.questions'), moderation_path('question') .d-none.d-sm-block= render 'shared/links' diff --git a/config/locales/views.en.yml b/config/locales/views.en.yml index 3b838fde..b0c8f5b6 100644 --- a/config/locales/views.en.yml +++ b/config/locales/views.en.yml @@ -439,6 +439,12 @@ en: terms: "Terms of Service" privacy: "Privacy Policy" tabs: + moderation: + all: "All reports" + answers: :activerecord.models.answer.other + comments: :activerecord.models.comment.other + users: :activerecord.models.user.other + questions: :activerecord.models.question.other notifications: all: "All notifications" new: "New notifications" From a4c090d594d2fec4cc1370576b50c2c04b18cc73 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Sat, 30 Jul 2022 04:58:20 +0200 Subject: [PATCH 3/6] Add new translations for moderationbox --- app/views/moderation/_moderationbox.haml | 10 +++++----- config/locales/views.en.yml | 6 ++++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/views/moderation/_moderationbox.haml b/app/views/moderation/_moderationbox.haml index ddcc5656..d92f4e02 100644 --- a/app/views/moderation/_moderationbox.haml +++ b/app/views/moderation/_moderationbox.haml @@ -2,7 +2,7 @@ .card.moderationbox{ data: { id: report.id } } .card-header %img.avatar-sm{ src: report.user.profile_picture.url(:medium) } - = raw t('views.moderation.moderationbox.reported', + = t('.reported_html', user: user_screen_name(report.user), content: report.type.sub('Reports::', ''), time: time_tooltip(report)) @@ -13,10 +13,10 @@ - else = report.target.content %p - %b= t 'views.moderation.moderationbox.reason' + %b= t('.reason.heading') %br - if report.reason.nil? || report.reason.strip.blank? - No reason provided + = t('.reason.none') - else - report.reason.lines.each do |reason| - next if reason.strip.blank? @@ -24,10 +24,10 @@ .row .col-md-8.col-sm-8.col-xs-8.text-left %a.btn.btn-primary{ href: content_url(report) } - = t('views.moderation.moderationbox.view', content: report.type.sub('Reports::', '')) + = t('.view', content: report.type.sub('Reports::', '')) - if report.target.respond_to?(:user) && report.target.user %a.btn.btn-primary{ href: user_path(report.target.user) } - = t('views.moderation.moderationbox.view', content: t('views.general.user')) + = t('.view', content: t('activerecord.models.user.one')) .col-md-4.col-sm-4.col-xs-4.text-right %button.btn.btn-default.btn-sm{ type: :button, name: 'mod-delete-report', data: { id: report.id } } %i.fa.fa-trash-o diff --git a/config/locales/views.en.yml b/config/locales/views.en.yml index b0c8f5b6..5e31e844 100644 --- a/config/locales/views.en.yml +++ b/config/locales/views.en.yml @@ -469,3 +469,9 @@ en: title_html: "Viewing inbox for
%{screen_name} (#%{user_id})" index: title: "Inbox for %{user}" + moderationbox: + reported_html: "%{user} reported a %{content} %{time} ago" + reason: + heading: "Reason:" + none: "No reason provided" + view: "View reported %{content}" From 9c08522a7aad7f1bbca5b7728da9008b491e1083 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Sat, 30 Jul 2022 05:07:54 +0200 Subject: [PATCH 4/6] Remove legacy locales --- config/locales/en.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/config/locales/en.yml b/config/locales/en.yml index e1b03205..dc8cd92d 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -58,13 +58,6 @@ en: destroy: "Logout" create: "Sign in" new: "Sign up" - moderation: - tabs: - all: "All reports" - moderationbox: - reported: "%{user} reported a %{content} %{time} ago" - reason: "Reason:" - view: "View reported %{content}" question: title: "This question was not in your inbox? Answer it here!" navigation: From 08033361f7e4af7e66e6a926d6bd3da34b69c7ae Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Sat, 30 Jul 2022 05:11:29 +0200 Subject: [PATCH 5/6] Fix HAML codestyle of moderation views --- app/views/moderation/_moderationbox.haml | 16 ++++++++-------- app/views/moderation/index.haml | 6 +++--- app/views/tabs/_moderation.haml | 12 ++++++------ 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/app/views/moderation/_moderationbox.haml b/app/views/moderation/_moderationbox.haml index d92f4e02..aab36fe3 100644 --- a/app/views/moderation/_moderationbox.haml +++ b/app/views/moderation/_moderationbox.haml @@ -2,21 +2,21 @@ .card.moderationbox{ data: { id: report.id } } .card-header %img.avatar-sm{ src: report.user.profile_picture.url(:medium) } - = t('.reported_html', + = t(".reported_html", user: user_screen_name(report.user), - content: report.type.sub('Reports::', ''), + content: report.type.sub("Reports::", ""), time: time_tooltip(report)) .card-body %p - - if report.type == 'Reports::User' + - if report.type == "Reports::User" = user_screen_name report.target - else = report.target.content %p - %b= t('.reason.heading') + %b= t(".reason.heading") %br - if report.reason.nil? || report.reason.strip.blank? - = t('.reason.none') + = t(".reason.none") - else - report.reason.lines.each do |reason| - next if reason.strip.blank? @@ -24,10 +24,10 @@ .row .col-md-8.col-sm-8.col-xs-8.text-left %a.btn.btn-primary{ href: content_url(report) } - = t('.view', content: report.type.sub('Reports::', '')) + = t(".view", content: report.type.sub("Reports::", "")) - if report.target.respond_to?(:user) && report.target.user %a.btn.btn-primary{ href: user_path(report.target.user) } - = t('.view', content: t('activerecord.models.user.one')) + = t(".view", content: t("activerecord.models.user.one")) .col-md-4.col-sm-4.col-xs-4.text-right - %button.btn.btn-default.btn-sm{ type: :button, name: 'mod-delete-report', data: { id: report.id } } + %button.btn.btn-default.btn-sm{ type: :button, name: "mod-delete-report", data: { id: report.id } } %i.fa.fa-trash-o diff --git a/app/views/moderation/index.haml b/app/views/moderation/index.haml index 0b73d230..0bcb623a 100644 --- a/app/views/moderation/index.haml +++ b/app/views/moderation/index.haml @@ -1,11 +1,11 @@ #reports - @reports.each do |r| - = render 'moderation/moderationbox', report: r + = render "moderation/moderationbox", report: r - unless @reports.count.zero? - = render 'shared/cursored_pagination_dummy', more_data_available: @more_data_available, last_id: @reports_last_id, permitted_params: %i[type] + = render "shared/cursored_pagination_dummy", more_data_available: @more_data_available, last_id: @reports_last_id, permitted_params: %i[type] - if @more_data_available .d-flex.justify-content-center.justify-content-sm-start %button.btn.btn-light#load-more-btn{ type: :button, data: { last_id: @reports_last_id } } - = t 'views.actions.load' + = t("voc.load") diff --git a/app/views/tabs/_moderation.haml b/app/views/tabs/_moderation.haml index 4b7c8f43..5b2ccb89 100644 --- a/app/views/tabs/_moderation.haml +++ b/app/views/tabs/_moderation.haml @@ -1,9 +1,9 @@ .card .list-group - = list_group_item t('.all'), moderation_path - = list_group_item t('.answers'), moderation_path('answer') - = list_group_item t('.comments'), moderation_path('comment') - = list_group_item t('.users'), moderation_path('user') - = list_group_item t('.questions'), moderation_path('question') + = list_group_item t(".all"), moderation_path + = list_group_item t(".answers"), moderation_path("answer") + = list_group_item t(".comments"), moderation_path("comment") + = list_group_item t(".users"), moderation_path("user") + = list_group_item t(".questions"), moderation_path("question") -.d-none.d-sm-block= render 'shared/links' +.d-none.d-sm-block= render "shared/links" From 19e95d066ce14c159b6a4be6dd697527f98ebe62 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Sat, 30 Jul 2022 05:12:22 +0200 Subject: [PATCH 6/6] Remove superfluous report existence checks --- app/views/moderation/_moderationbox.haml | 63 ++++++++++++------------ 1 file changed, 31 insertions(+), 32 deletions(-) diff --git a/app/views/moderation/_moderationbox.haml b/app/views/moderation/_moderationbox.haml index aab36fe3..583d8c9a 100644 --- a/app/views/moderation/_moderationbox.haml +++ b/app/views/moderation/_moderationbox.haml @@ -1,33 +1,32 @@ -- unless report.nil? || report.target.nil? || report.user.nil? || report.type.nil? - .card.moderationbox{ data: { id: report.id } } - .card-header - %img.avatar-sm{ src: report.user.profile_picture.url(:medium) } - = t(".reported_html", - user: user_screen_name(report.user), - content: report.type.sub("Reports::", ""), - time: time_tooltip(report)) - .card-body - %p - - if report.type == "Reports::User" - = user_screen_name report.target +.card.moderationbox{ data: { id: report.id } } + .card-header + %img.avatar-sm{ src: report.user.profile_picture.url(:medium) } + = t(".reported_html", + user: user_screen_name(report.user), + content: report.type.sub("Reports::", ""), + time: time_tooltip(report)) + .card-body + %p + - if report.type == "Reports::User" + = user_screen_name report.target + - else + = report.target.content + %p + %b= t(".reason.heading") + %br + - if report.reason.nil? || report.reason.strip.blank? + = t(".reason.none") - else - = report.target.content - %p - %b= t(".reason.heading") - %br - - if report.reason.nil? || report.reason.strip.blank? - = t(".reason.none") - - else - - report.reason.lines.each do |reason| - - next if reason.strip.blank? - = reason.strip - .row - .col-md-8.col-sm-8.col-xs-8.text-left - %a.btn.btn-primary{ href: content_url(report) } - = t(".view", content: report.type.sub("Reports::", "")) - - if report.target.respond_to?(:user) && report.target.user - %a.btn.btn-primary{ href: user_path(report.target.user) } - = t(".view", content: t("activerecord.models.user.one")) - .col-md-4.col-sm-4.col-xs-4.text-right - %button.btn.btn-default.btn-sm{ type: :button, name: "mod-delete-report", data: { id: report.id } } - %i.fa.fa-trash-o + - report.reason.lines.each do |reason| + - next if reason.strip.blank? + = reason.strip + .row + .col-md-8.col-sm-8.col-xs-8.text-left + %a.btn.btn-primary{ href: content_url(report) } + = t(".view", content: report.type.sub("Reports::", "")) + - if report.target.respond_to?(:user) && report.target.user + %a.btn.btn-primary{ href: user_path(report.target.user) } + = t(".view", content: t("activerecord.models.user.one")) + .col-md-4.col-sm-4.col-xs-4.text-right + %button.btn.btn-default.btn-sm{ type: :button, name: "mod-delete-report", data: { id: report.id } } + %i.fa.fa-trash-o