diff --git a/app/controllers/hyrax/admin/workflow_roles_controller.rb b/app/controllers/hyrax/admin/workflow_roles_controller.rb new file mode 100644 index 0000000000..58c60e9359 --- /dev/null +++ b/app/controllers/hyrax/admin/workflow_roles_controller.rb @@ -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 diff --git a/app/presenters/hyku/menu_presenter.rb b/app/presenters/hyku/menu_presenter.rb index 9144656030..af3c49de83 100644 --- a/app/presenters/hyku/menu_presenter.rb +++ b/app/presenters/hyku/menu_presenter.rb @@ -16,6 +16,12 @@ def settings_section? %w(appearances content_blocks labels features).include?(controller_name) end + # Returns true if the current controller happens to be one of the controllers that deals + # with workflow. This is used to keep the parent section on the sidebar open. + def workflows_section? + %w(admin workflow_roles).include?(controller_name) + end + # Returns true if the current controller happens to be one of the controllers that deals # with roles and permissions. This is used to keep the parent section on the sidebar open. def roles_and_permissions_section? diff --git a/app/views/hyrax/admin/_sidebar.html.erb b/app/views/hyrax/admin/_sidebar.html.erb index 1997eddeaf..db5f08002e 100644 --- a/app/views/hyrax/admin/_sidebar.html.erb +++ b/app/views/hyrax/admin/_sidebar.html.erb @@ -67,6 +67,23 @@ <%= t('hyrax.admin.sidebar.admin_sets') %> <% end %> +
  • + + <% workflows_class = 'collapse ' unless menu.workflows_section? %> + +
  • + <% if can?(:manage, Role) || can?(:manage, User) %>