-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Load workflows when rendering workflow roles UI.
Refs #563 This is a temporary hack to automatically load workflows in the demo instance. It also: * Overrides the WorkflowRolesController to specify the admin layout (workaround for samvera/hyrax#67) * Adds breadcrumbs to the WorkflowRolesController override (should also be done in Hyrax) * Pulls in the workflow section to the admin sidebar from Hyrax (and tweaked to use the Hyku MenuPresenter) * Adds I18n for the workflow roles header * Updates the hyku mediated deposit json to pull in the latest from Hyrax
- Loading branch information
Showing
8 changed files
with
134 additions
and
6 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,41 @@ | ||
module Hyrax | ||
module Admin | ||
class WorkflowRolesController < ApplicationController | ||
before_action :require_permissions | ||
layout 'admin' | ||
|
||
def index | ||
# TODO: Find a better way to make sure workflows are loaded | ||
Hyrax::Workflow::WorkflowImporter.load_workflows | ||
add_breadcrumb t(:'hyrax.controls.home'), root_path | ||
add_breadcrumb t(:'hyrax.toolbar.admin.menu'), hyrax.admin_path | ||
add_breadcrumb t(:'hyrax.admin.workflow_roles.header'), hyrax.admin_workflow_roles_path | ||
@presenter = WorkflowRolePresenter.new | ||
end | ||
|
||
def destroy | ||
responsibility = Sipity::WorkflowResponsibility.find(params[:id]) | ||
authorize! :destroy, responsibility | ||
responsibility.destroy | ||
redirect_to admin_workflow_roles_path | ||
end | ||
|
||
def create | ||
authorize! :create, Sipity::WorkflowResponsibility | ||
form = Forms::WorkflowResponsibilityForm.new(params[:sipity_workflow_responsibility]) | ||
begin | ||
form.save! | ||
rescue ActiveRecord::RecordNotUnique | ||
logger.info "Not unique *****\n\n\n" | ||
end | ||
redirect_to admin_workflow_roles_path | ||
end | ||
|
||
private | ||
|
||
def require_permissions | ||
authorize! :read, :admin_dashboard | ||
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
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
17 changes: 17 additions & 0 deletions
17
spec/controllers/hyrax/admin/workflow_roles_controller_spec.rb
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,17 @@ | ||
require 'spec_helper' | ||
|
||
RSpec.describe Hyrax::Admin::WorkflowRolesController, :no_clean do | ||
routes { Hyrax::Engine.routes } | ||
|
||
describe "#get overrides" do | ||
before do | ||
allow(controller).to receive(:authorize!).with(:read, :admin_dashboard).and_return(true) | ||
end | ||
|
||
it "loads workflows and renders with the admin layout" do | ||
expect(Hyrax::Workflow::WorkflowImporter).to receive(:load_workflows).once | ||
get :index | ||
expect(response).to render_template(layout: 'admin') | ||
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