mirror of
https://github.com/Retrospring/retrospring.git
synced 2025-02-13 21:33:20 +01:00
Merge pull request #182 from Retrospring/feature/rails-admin-links
Add links for jumping to rails admin on answers, questions and profiles
This commit is contained in:
commit
47ef742c12
5 changed files with 32 additions and 0 deletions
|
@ -169,4 +169,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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
|
16
spec/helpers/application_helper_spec.rb
Normal file
16
spec/helpers/application_helper_spec.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require "rails_helper"
|
||||
|
||||
describe ApplicationHelper, :type => :helper do
|
||||
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
|
Loading…
Reference in a new issue