From 990c67baeab7b994817ba221d2831af1c6735ea4 Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Sat, 2 Jul 2022 12:19:56 +0200 Subject: [PATCH] Move unban into own view --- app/views/modal/_ban.haml | 12 +----------- app/views/modal/ban/_history.haml | 15 ++++++++++++++- app/views/modal/ban/_unban.haml | 11 +++++++++++ config/locales/views.en.yml | 14 ++++++++++---- 4 files changed, 36 insertions(+), 16 deletions(-) create mode 100644 app/views/modal/ban/_unban.haml diff --git a/app/views/modal/_ban.haml b/app/views/modal/_ban.haml index b23f5833..e91fd8c7 100644 --- a/app/views/modal/_ban.haml +++ b/app/views/modal/_ban.haml @@ -28,14 +28,4 @@ - else = render 'modal/ban/controls', f: f, user: user - else - = f.hidden_field :ban, value: '0' - .modal-body - - if current_ban.expires_at.nil? - = t '.banned_permanently_html', reason: current_ban.reason - - else - = t '.banned_temporarily_html', reason: current_ban.reason, until: current_ban.expires_at.strftime('%Y-%m-%d %H:%M:%S') - - if current_ban.banned_by.present? - %br - = t '.banned_by_html', user: current_ban.banned_by.screen_name, on: current_ban.created_at.strftime('%Y-%m-%d %H:%M:%S') - .modal-footer - = f.submit t '.unban', class: 'btn btn-primary', name: 'hammer-time' + = render 'modal/ban/unban', user: user diff --git a/app/views/modal/ban/_history.haml b/app/views/modal/ban/_history.haml index 9e4398b8..a0076c82 100644 --- a/app/views/modal/ban/_history.haml +++ b/app/views/modal/ban/_history.haml @@ -1 +1,14 @@ -Ban history here. \ No newline at end of file +.modal-body + %p= t '.count', user: user.screen_name, count: user.bans.count + .list-group + - user.bans.each do |ban| + .list-group-item + .d-flex.w-100.justify-content-between + %h5.mb-1= ban.reason + %small.text-muted= time_ago_in_words ban.created_at + - if ban.banned_by.present? + %p= t('.issued_by', user: ban.banned_by.screen_name) + - if ban.expires_at.present? + %small= t('.until', until: ban.expires_at.strftime('%Y-%m-%d %H:%M:%S')) + - else + %small= t('.permanent') diff --git a/app/views/modal/ban/_unban.haml b/app/views/modal/ban/_unban.haml new file mode 100644 index 00000000..3aa25ca7 --- /dev/null +++ b/app/views/modal/ban/_unban.haml @@ -0,0 +1,11 @@ += f.hidden_field :ban, value: '0' +.modal-body + - if current_ban.expires_at.nil? + = t '.banned_permanently_html', reason: current_ban.reason + - else + = t '.banned_temporarily_html', reason: current_ban.reason, until: current_ban.expires_at.strftime('%Y-%m-%d %H:%M:%S') + - if current_ban.banned_by.present? + %br + = t '.banned_by_html', user: current_ban.banned_by.screen_name, on: current_ban.created_at.strftime('%Y-%m-%d %H:%M:%S') +.modal-footer + = f.submit t '.unban', class: 'btn btn-primary', name: 'hammer-time' \ No newline at end of file diff --git a/config/locales/views.en.yml b/config/locales/views.en.yml index 18ada9bf..c07013ee 100644 --- a/config/locales/views.en.yml +++ b/config/locales/views.en.yml @@ -91,10 +91,16 @@ en: tabs: controls: "Ban" history: "History" - banned_permanently_html: "This user is currently permanently banned for %{reason}" - banned_temporarily_html: "This user is currently banned until %{until} for %{reason}" - banned_by_html: "This ban was instated by %{user} on %{on}" - unban: "Unban" + unban: + banned_permanently_html: "This user is currently permanently banned for %{reason}" + banned_temporarily_html: "This user is currently banned until %{until} for %{reason}" + banned_by_html: "This ban was instated by %{user} on %{on}" + unban: "Unban" + history: + count: "%{user} has been banned %{count} times." + issued_by: "Issued by %{user}" + permanent: "Permanent" + until: "Until %{until}" services: index: title: "Service Settings"