Merge branch 'master' into feature/opengraph

This commit is contained in:
Karina Kwiatek 2021-08-08 14:24:05 +02:00 committed by GitHub
commit 86d179d590
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 0 deletions

View File

@ -171,4 +171,8 @@ module ApplicationHelper
def list_title(list)
generate_title list.name
end
def rails_admin_path_for_resource(resource)
[rails_admin_path, resource.model_name.param_key, resource.id].join('/')
end
end

View File

@ -38,3 +38,7 @@
%a.dropdown-item{ href: '#', data: { a_id: a.id, action: 'ab-report' } }
%i.fa.fa-exclamation-triangle
= t 'views.actions.report'
- if current_user.has_role? :administrator
%a.dropdown-item{ href: rails_admin_path_for_resource(a), target: '_blank' }
%i.fa.fa-gears
View in Kontrollzentrum

View File

@ -18,6 +18,10 @@
%a.dropdown-item{ href: '#', tabindex: -1, data: { action: 'ab-question-report', q_id: a.question.id } }
%i.fa.fa-exclamation-triangle
= t 'views.actions.report'
- if current_user.has_role? :administrator
%a.dropdown-item{ href: rails_admin_path_for_resource(a.question), target: '_blank' }
%i.fa.fa-gears
View in Kontrollzentrum
%h6.text-muted.media-heading.answerbox__question-user
= raw t('views.answerbox.asked', user: user_screen_name(a.question.user, anonymous: a.question.author_is_anonymous), time: time_tooltip(a.question))
- if !a.question.author_is_anonymous && a.question.answer_count > 1

View File

@ -28,3 +28,7 @@
%a.dropdown-item{ href: '#', data: { target: '#modal-ban', toggle: :modal } }
%i.fa.fa-ban
= t 'views.actions.ban'
- if current_user.has_role? :administrator
%a.dropdown-item{ href: rails_admin_path_for_resource(user), target: '_blank' }
%i.fa.fa-cogs
"View in Kontrollzentrum"

View File

@ -87,4 +87,15 @@ EOS
end
end
end
describe "#rails_admin_path_for_resource" do
context "user resource" do
let(:resource) { FactoryBot.create(:user) }
subject { rails_admin_path_for_resource(resource) }
it "should return a URL to the given resource within rails admin" do
expect(subject).to eq("/justask_admin/user/#{resource.id}")
end
end
end
end