From 5b9ae7981e2458a322f9e2fbeac9b334a15936bc Mon Sep 17 00:00:00 2001 From: unarist Date: Mon, 14 Aug 2017 21:09:00 +0900 Subject: Update /admin/accounts/:id view for ActivityPub (#4600) * Add protocol field * Switch protocol specific information according to active protocol * Hide PuSH subscription related buttons if ActivityPub is active --- app/views/admin/accounts/show.html.haml | 43 +++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 15 deletions(-) (limited to 'app/views/admin/accounts/show.html.haml') diff --git a/app/views/admin/accounts/show.html.haml b/app/views/admin/accounts/show.html.haml index 5ad1fd6ee..5c781e817 100644 --- a/app/views/admin/accounts/show.html.haml +++ b/app/views/admin/accounts/show.html.haml @@ -32,18 +32,30 @@ %th= t('admin.accounts.profile_url') %td= link_to @account.url, @account.url %tr - %th= t('admin.accounts.feed_url') - %td= link_to @account.remote_url, @account.remote_url - %tr - %th= t('admin.accounts.push_subscription_expires') - %td - - if @account.subscribed? - = l @account.subscription_expires_at - - else - = t('admin.accounts.not_subscribed') - %tr - %th= t('admin.accounts.salmon_url') - %td= link_to @account.salmon_url, @account.salmon_url + %th= t('admin.accounts.protocol') + %td= @account.protocol + + - if @account.ostatus? + %tr + %th= t('admin.accounts.feed_url') + %td= link_to @account.remote_url, @account.remote_url + %tr + %th= t('admin.accounts.push_subscription_expires') + %td + - if @account.subscribed? + = l @account.subscription_expires_at + - else + = t('admin.accounts.not_subscribed') + %tr + %th= t('admin.accounts.salmon_url') + %td= link_to @account.salmon_url, @account.salmon_url + - elsif @account.activitypub? + %tr + %th= t('admin.accounts.inbox_url') + %td= link_to @account.inbox_url, @account.inbox_url + %tr + %th= t('admin.accounts.outbox_url') + %td= link_to @account.outbox_url, @account.outbox_url %tr %th= t('admin.accounts.follows') @@ -74,9 +86,10 @@ - if @account.user&.otp_required_for_login? = link_to t('admin.accounts.disable_two_factor_authentication'), admin_user_two_factor_authentication_path(@account.user.id), method: :delete, class: 'button' - else - = link_to @account.subscribed? ? t('admin.accounts.resubscribe') : t('admin.accounts.subscribe'), subscribe_admin_account_path(@account.id), method: :post, class: 'button' - - if @account.subscribed? - = link_to t('admin.accounts.unsubscribe'), unsubscribe_admin_account_path(@account.id), method: :post, class: 'button negative' + - if @account.ostatus? + = link_to @account.subscribed? ? t('admin.accounts.resubscribe') : t('admin.accounts.subscribe'), subscribe_admin_account_path(@account.id), method: :post, class: 'button' + - if @account.subscribed? + = link_to t('admin.accounts.unsubscribe'), unsubscribe_admin_account_path(@account.id), method: :post, class: 'button negative' = link_to t('admin.accounts.redownload'), redownload_admin_account_path(@account.id), method: :post, class: 'button' %div{ style: 'float: left' } -- cgit From 075d6a1e13aa6477c656e9dbe03e6720cb4e2b32 Mon Sep 17 00:00:00 2001 From: nullkal Date: Fri, 18 Aug 2017 00:52:40 +0900 Subject: Show what protocol is used for accounts in admin/accounts#index (#4622) * Show what protocol used for in admin/accounts#index * Add frozen_string_literal --- app/helpers/account_helper.rb | 14 ++++++++++++++ app/views/admin/accounts/_account.html.haml | 3 +++ app/views/admin/accounts/index.html.haml | 1 + app/views/admin/accounts/show.html.haml | 2 +- spec/helpers/account_helper_spec.rb | 30 +++++++++++++++++++++++++++++ 5 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 app/helpers/account_helper.rb create mode 100644 spec/helpers/account_helper_spec.rb (limited to 'app/views/admin/accounts/show.html.haml') diff --git a/app/helpers/account_helper.rb b/app/helpers/account_helper.rb new file mode 100644 index 000000000..00d4fc657 --- /dev/null +++ b/app/helpers/account_helper.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +module AccountHelper + def protocol_for_display(protocol) + case protocol + when 'activitypub' + 'ActivityPub' + when 'ostatus' + 'OStatus' + else + protocol + end + end +end diff --git a/app/views/admin/accounts/_account.html.haml b/app/views/admin/accounts/_account.html.haml index c513776b7..a7fca6b3e 100644 --- a/app/views/admin/accounts/_account.html.haml +++ b/app/views/admin/accounts/_account.html.haml @@ -4,6 +4,9 @@ %td.domain - unless account.local? = link_to account.domain, admin_accounts_path(by_domain: account.domain) + %td.protocol + - unless account.local? + = protocol_for_display(account.protocol) %td.confirmed - if account.local? - if account.user_confirmed? diff --git a/app/views/admin/accounts/index.html.haml b/app/views/admin/accounts/index.html.haml index 07c8d1632..1f36aeb31 100644 --- a/app/views/admin/accounts/index.html.haml +++ b/app/views/admin/accounts/index.html.haml @@ -55,6 +55,7 @@ %tr %th= t('admin.accounts.username') %th= t('admin.accounts.domain') + %th= t('admin.accounts.protocol') %th= t('admin.accounts.confirmed') %th= fa_icon 'paper-plane-o' %th diff --git a/app/views/admin/accounts/show.html.haml b/app/views/admin/accounts/show.html.haml index 5c781e817..f0e4e303c 100644 --- a/app/views/admin/accounts/show.html.haml +++ b/app/views/admin/accounts/show.html.haml @@ -33,7 +33,7 @@ %td= link_to @account.url, @account.url %tr %th= t('admin.accounts.protocol') - %td= @account.protocol + %td= protocol_for_display(@account.protocol) - if @account.ostatus? %tr diff --git a/spec/helpers/account_helper_spec.rb b/spec/helpers/account_helper_spec.rb new file mode 100644 index 000000000..63e7c78b6 --- /dev/null +++ b/spec/helpers/account_helper_spec.rb @@ -0,0 +1,30 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the AccountHelper. For example: +# +# describe AccountHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# expect(helper.concat_strings("this","that")).to eq("this that") +# end +# end +# end +RSpec.describe AccountHelper, type: :helper do + describe '#protocol_for_display' do + it "returns OStatus when the protocol is 'ostatus'" do + protocol = 'ostatus' + expect(protocol_for_display(protocol)).to eq 'OStatus' + end + + it "returns ActivityPub when the protocol is 'activitypub'" do + protocol = 'activitypub' + expect(protocol_for_display(protocol)).to eq 'ActivityPub' + end + + it "returns the same string when the protocol is unknown" do + protocol = 'wave' + expect(protocol_for_display(protocol)).to eq protocol + end + end +end -- cgit From efec02f1538adc7f75ba9ca3716ea25b3f2ef4df Mon Sep 17 00:00:00 2001 From: nightpool Date: Thu, 17 Aug 2017 17:20:50 -0400 Subject: use existing inflections instead of custom helper (#4624) * use existing inflections instead of custom helper * use ActiveSupport versions --- app/helpers/account_helper.rb | 14 -------------- app/views/admin/accounts/_account.html.haml | 2 +- app/views/admin/accounts/show.html.haml | 2 +- spec/helpers/account_helper_spec.rb | 30 ----------------------------- 4 files changed, 2 insertions(+), 46 deletions(-) delete mode 100644 app/helpers/account_helper.rb delete mode 100644 spec/helpers/account_helper_spec.rb (limited to 'app/views/admin/accounts/show.html.haml') diff --git a/app/helpers/account_helper.rb b/app/helpers/account_helper.rb deleted file mode 100644 index 00d4fc657..000000000 --- a/app/helpers/account_helper.rb +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -module AccountHelper - def protocol_for_display(protocol) - case protocol - when 'activitypub' - 'ActivityPub' - when 'ostatus' - 'OStatus' - else - protocol - end - end -end diff --git a/app/views/admin/accounts/_account.html.haml b/app/views/admin/accounts/_account.html.haml index a7fca6b3e..5265d77f6 100644 --- a/app/views/admin/accounts/_account.html.haml +++ b/app/views/admin/accounts/_account.html.haml @@ -6,7 +6,7 @@ = link_to account.domain, admin_accounts_path(by_domain: account.domain) %td.protocol - unless account.local? - = protocol_for_display(account.protocol) + = account.protocol.humanize %td.confirmed - if account.local? - if account.user_confirmed? diff --git a/app/views/admin/accounts/show.html.haml b/app/views/admin/accounts/show.html.haml index f0e4e303c..18bcd5e8e 100644 --- a/app/views/admin/accounts/show.html.haml +++ b/app/views/admin/accounts/show.html.haml @@ -33,7 +33,7 @@ %td= link_to @account.url, @account.url %tr %th= t('admin.accounts.protocol') - %td= protocol_for_display(@account.protocol) + %td= @account.protocol.humanize - if @account.ostatus? %tr diff --git a/spec/helpers/account_helper_spec.rb b/spec/helpers/account_helper_spec.rb deleted file mode 100644 index 63e7c78b6..000000000 --- a/spec/helpers/account_helper_spec.rb +++ /dev/null @@ -1,30 +0,0 @@ -require 'rails_helper' - -# Specs in this file have access to a helper object that includes -# the AccountHelper. For example: -# -# describe AccountHelper do -# describe "string concat" do -# it "concats two strings with spaces" do -# expect(helper.concat_strings("this","that")).to eq("this that") -# end -# end -# end -RSpec.describe AccountHelper, type: :helper do - describe '#protocol_for_display' do - it "returns OStatus when the protocol is 'ostatus'" do - protocol = 'ostatus' - expect(protocol_for_display(protocol)).to eq 'OStatus' - end - - it "returns ActivityPub when the protocol is 'activitypub'" do - protocol = 'activitypub' - expect(protocol_for_display(protocol)).to eq 'ActivityPub' - end - - it "returns the same string when the protocol is unknown" do - protocol = 'wave' - expect(protocol_for_display(protocol)).to eq protocol - end - end -end -- cgit From 00f9f16f94feeaf2fae9a5a1a7bcb3a06b86a036 Mon Sep 17 00:00:00 2001 From: Yamagishi Kazutoshi Date: Sat, 26 Aug 2017 00:21:00 +0900 Subject: Change timezone of the datetime to what browser specifies (#4688) --- app/views/admin/accounts/show.html.haml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'app/views/admin/accounts/show.html.haml') diff --git a/app/views/admin/accounts/show.html.haml b/app/views/admin/accounts/show.html.haml index 18bcd5e8e..85841d7a1 100644 --- a/app/views/admin/accounts/show.html.haml +++ b/app/views/admin/accounts/show.html.haml @@ -24,7 +24,8 @@ %th= t('admin.accounts.most_recent_activity') %td - if @account.user_current_sign_in_at - = l @account.user_current_sign_in_at + %time.formatted{ datetime: @account.user_current_sign_in_at.iso8601, title: l(@account.user_current_sign_in_at) } + = l @account.user_current_sign_in_at - else Never - else @@ -43,7 +44,8 @@ %th= t('admin.accounts.push_subscription_expires') %td - if @account.subscribed? - = l @account.subscription_expires_at + %time.formatted{ datetime: account.subscription_expires_at.iso8601, title: l(account.subscription_expires_at) } + = l @account.subscription_expires_at - else = t('admin.accounts.not_subscribed') %tr -- cgit From 3ac7b353f8ba74bce9e20974bcc1832930424ef2 Mon Sep 17 00:00:00 2001 From: Yamagishi Kazutoshi Date: Sat, 26 Aug 2017 19:39:26 +0900 Subject: Fix missing at-sign (regression from #4688) (#4705) --- app/views/admin/accounts/show.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/views/admin/accounts/show.html.haml') diff --git a/app/views/admin/accounts/show.html.haml b/app/views/admin/accounts/show.html.haml index 85841d7a1..dc2f16cc9 100644 --- a/app/views/admin/accounts/show.html.haml +++ b/app/views/admin/accounts/show.html.haml @@ -44,7 +44,7 @@ %th= t('admin.accounts.push_subscription_expires') %td - if @account.subscribed? - %time.formatted{ datetime: account.subscription_expires_at.iso8601, title: l(account.subscription_expires_at) } + %time.formatted{ datetime: @account.subscription_expires_at.iso8601, title: l(@account.subscription_expires_at) } = l @account.subscription_expires_at - else = t('admin.accounts.not_subscribed') -- cgit