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 %>
+
+
+
+ <%= t('hyrax.admin.sidebar.workflow') %>
+
+ <% workflows_class = 'collapse ' unless menu.workflows_section? %>
+
+ <%= menu.nav_link(hyrax.admin_workflow_roles_path) do %>
+ <%= t('hyrax.admin.sidebar.workflow_roles') %>
+ <% end %>
+
+ <%= menu.nav_link(hyrax.admin_workflows_path) do %>
+ <%= t('hyrax.admin.sidebar.workflow_review') %>
+ <% end %>
+
+
+
<% if can?(:manage, Role) || can?(:manage, User) %>
diff --git a/config/locales/hyrax.en.yml b/config/locales/hyrax.en.yml
index 87b0a64741..6fbc56e874 100644
--- a/config/locales/hyrax.en.yml
+++ b/config/locales/hyrax.en.yml
@@ -6,5 +6,6 @@ en:
account_name: "Hydra in a Box Account Id"
directory:
suffix: "@hydrainabox.org"
- footer:
- copyright_html: "Copyright © 2016 Project Hydra Licensed under the Apache License, Version 2.0"
+ admin:
+ workflow_roles:
+ header: "Workflow Roles"
diff --git a/config/locales/hyrax.es.yml b/config/locales/hyrax.es.yml
index 6b920fe608..1bdcc6a634 100644
--- a/config/locales/hyrax.es.yml
+++ b/config/locales/hyrax.es.yml
@@ -6,3 +6,6 @@ es:
account_name: "Hydra-en-una-Caja Cuenta ID"
directory:
suffix: "@hydrainabox.org"
+ admin:
+ workflow_roles:
+ header: "Funciones del Flujo de Trabajo"
diff --git a/config/workflows/mediated_deposit_workflow.json b/config/workflows/mediated_deposit_workflow.json
index 2d1df1e021..722705c449 100644
--- a/config/workflows/mediated_deposit_workflow.json
+++ b/config/workflows/mediated_deposit_workflow.json
@@ -3,7 +3,7 @@
{
"name": "one_step_mediated_deposit",
"label": "One-step mediated deposit workflow",
- "description": "A single-step workflow for mediated deposit",
+ "description": "A single-step workflow for mediated deposit in which all deposits must be approved by a reviewer. Reviewer may also send deposits back to the depositor.",
"actions": [
{
"name": "deposit",
@@ -15,9 +15,25 @@
"name": "Hyrax::Workflow::PendingReviewNotification",
"to": ["approving"]
}
+ ],
+ "methods": [
+ "Hyrax::Workflow::DeactivateObject"
]
- },
- {
+ }, {
+ "name": "request_changes",
+ "from_states": [{"names": ["complete", "pending_review"], "roles": ["approving"]}],
+ "transition_to": "changes_required",
+ "notifications": [
+ {
+ "notification_type": "email",
+ "name": "Hyrax::Workflow::ChangesRequiredNotification",
+ "to": ["approving"]
+ }
+ ],
+ "methods": [
+ "Hyrax::Workflow::DeactivateObject"
+ ]
+ }, {
"name": "approve",
"from_states": [{"names": ["pending_review"], "roles": ["approving"]}],
"transition_to": "complete",
@@ -29,7 +45,18 @@
}
],
"methods": [
- "CurationConcerns::Workflow::ActivateObject"
+ "Hyrax::Workflow::ActivateObject"
+ ]
+ }, {
+ "name": "request_review",
+ "from_states": [{"names": ["changes_required"], "roles": ["depositing"]}],
+ "transition_to": "pending_review",
+ "notifications": [
+ {
+ "notification_type": "email",
+ "name": "Hyrax::Workflow::PendingReviewNotification",
+ "to": ["approving"]
+ }
]
}
]
diff --git a/spec/controllers/hyrax/admin/workflow_roles_controller_spec.rb b/spec/controllers/hyrax/admin/workflow_roles_controller_spec.rb
new file mode 100644
index 0000000000..a1cd3798d3
--- /dev/null
+++ b/spec/controllers/hyrax/admin/workflow_roles_controller_spec.rb
@@ -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
diff --git a/spec/presenters/hyku/menu_presenter_spec.rb b/spec/presenters/hyku/menu_presenter_spec.rb
index 4c0234dafd..c23e84698e 100644
--- a/spec/presenters/hyku/menu_presenter_spec.rb
+++ b/spec/presenters/hyku/menu_presenter_spec.rb
@@ -54,6 +54,22 @@
end
end
+ describe "#workflows_section?" do
+ before do
+ allow(context).to receive(:controller_name).and_return(controller_name)
+ allow(context).to receive(:controller).and_return(controller)
+ end
+ subject { instance.workflows_section? }
+ context "for the WorkflowRolesController" do
+ let(:controller) { Hyrax::Admin::WorkflowRolesController.new }
+ it { is_expected.to be true }
+ end
+ context "for the Admin::UsersController" do
+ let(:controller) { Admin::UsersController.new }
+ it { is_expected.to be false }
+ end
+ end
+
describe "#roles_and_permissions_section?" do
before do
allow(context).to receive(:controller_name).and_return(controller_name)