-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🎁 Add admin dashboard data repair jobs menu
Adds a new menu, `Data Repair` which contains buttons to submit RolesService repair tasks as jobs. Jobs included are: * CreateCollectionAccessesJob, * CreateAdminSetAccessesJob, * CreateCollectionTypeParticipantsJob, * GrantWorkflowRolesForAllAdminSetsJob Refs: #844
- Loading branch information
LaRita Robinson
committed
Dec 8, 2023
1 parent
4ce94a5
commit 5130c25
Showing
9 changed files
with
248 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# frozen_string_literal: true | ||
|
||
module Admin | ||
class RolesServiceController < ApplicationController | ||
layout 'hyrax/dashboard' | ||
|
||
def index | ||
authorize! :update, RolesService | ||
add_breadcrumb t(:'hyrax.controls.home'), root_path | ||
add_breadcrumb t(:'hyrax.dashboard.breadcrumbs.admin'), hyrax.dashboard_path | ||
add_breadcrumb t(:'hyrax.admin.sidebar.roles_service_jobs'), main_app.admin_roles_service_jobs_path | ||
end | ||
|
||
# post "admin/roles_service/:job_name_key | ||
def update_roles | ||
authorize! :update, RolesService | ||
job = RolesService.valid_jobs.fetch(params[:job_name_key]) | ||
|
||
job.perform_later | ||
|
||
respond_to do |wants| | ||
wants.html { redirect_to main_app.admin_roles_service_jobs_path, notice: "#{job} has been submitted." } | ||
wants.json { render json: { notice: "#{job} has been submitted." }, status: :ok } | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<% content_for :page_title, construct_page_title(t('hyrax.admin.roles_service_jobs.header'), t('hyku.admin.title')) %> | ||
<% provide :page_header do %> | ||
<h1><span class="fa fa-wrench" aria-hidden="true"></span> | ||
<%= t('hyrax.admin.roles_service_jobs.header') %></h1> | ||
<% end %> | ||
|
||
<div class='panel panel-default'> | ||
<div class='panel-body'> | ||
<div class='table-responsive'> | ||
<table class='table table-striped datatable'> | ||
<tbody> | ||
<% RolesService.valid_jobs.each do |key, klass| %> | ||
<tr> | ||
<td><%= button_to t("hyrax.admin.roles_service_jobs.jobs.#{key}.label"), main_app.admin_update_roles_path(job_name_key: key), method: :post, class: 'btn btn-danger' %></td> | ||
<td><%= t("hyrax.admin.roles_service_jobs.jobs.#{key}.description") %></td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe Admin::RolesServiceController, type: :controller do | ||
context 'as an anonymous user' do | ||
describe 'GET #index' do | ||
subject { get :index } | ||
|
||
it { is_expected.to redirect_to new_user_session_path } | ||
end | ||
end | ||
|
||
context 'as an admin user' do | ||
before { sign_in create(:admin) } | ||
|
||
describe 'GET #index' do | ||
subject { get :index } | ||
|
||
it { is_expected.to render_template('layouts/hyrax/dashboard') } | ||
it { is_expected.to render_template('admin/roles_service/index') } | ||
end | ||
end | ||
|
||
context 'as an admin user' do | ||
before { sign_in create(:admin) } | ||
|
||
describe 'GET #index' do | ||
subject { get :index } | ||
|
||
it { is_expected.to render_template('layouts/hyrax/dashboard') } | ||
it { is_expected.to render_template('admin/roles_service/index') } | ||
end | ||
|
||
describe 'POST #update_roles' do | ||
it 'submits a job when it receives a valid job name' do | ||
expect(RolesService::CreateCollectionAccessesJob).to receive(:perform_later) | ||
post :update_roles, params: { job_name_key: :create_collection_accesses } | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe Admin::RolesServiceController, type: :routing do | ||
describe "routing" do | ||
it "routes to #index" do | ||
expect(get: "/admin/roles_service").to route_to("admin/roles_service#index") | ||
end | ||
|
||
it "routes to #update_roles via POST" do | ||
expect(post: "/admin/roles_service/create_collection_accesses").to route_to("admin/roles_service#update_roles", job_name_key: 'create_collection_accesses') | ||
end | ||
end | ||
end |