cdm_migrator 3.2.1 → 3.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/MIT-LICENSE +20 -20
- data/README.md +41 -41
- data/Rakefile +38 -38
- data/app/assets/config/cdm_migrator_manifest.js +2 -2
- data/app/assets/javascripts/cdm_migrator/application.js +13 -13
- data/app/assets/stylesheets/cdm_migrator/application.css +15 -15
- data/app/assets/stylesheets/cdm_migrator/csv_checker.css +36 -36
- data/app/controllers/cdm_migrator/application_controller.rb +10 -10
- data/app/controllers/cdm_migrator/cdm_controller.rb +216 -213
- data/app/controllers/cdm_migrator/csv_controller.rb +428 -408
- data/app/helpers/cdm_migrator/application_helper.rb +4 -4
- data/app/jobs/cdm_migrator/application_job.rb +4 -4
- data/app/jobs/cdm_migrator/batch_create_files_job.rb +32 -20
- data/app/jobs/cdm_migrator/batch_create_files_with_ordered_members_job.rb +45 -0
- data/app/jobs/cdm_migrator/batch_create_works_job.rb +20 -14
- data/app/jobs/cdm_migrator/cdm_ingest_files_job.rb +35 -35
- data/app/jobs/cdm_migrator/create_work_job.rb +36 -25
- data/app/jobs/cdm_migrator/restart_upload_from_middle_job.rb +36 -0
- data/app/jobs/cdm_migrator/update_object_job.rb +10 -10
- data/app/mailers/cdm_migrator/application_mailer.rb +6 -6
- data/app/models/cdm_migrator/application_record.rb +5 -5
- data/app/models/cdm_migrator/batch_ingest.rb +33 -33
- data/app/models/cdm_migrator/ingest_work.rb +7 -16
- data/app/views/cdm_migrator/cdm/collection.html.erb +11 -11
- data/app/views/cdm_migrator/cdm/mappings.html.erb +54 -53
- data/app/views/cdm_migrator/csv/_batches_list.html.erb +4 -4
- data/app/views/cdm_migrator/csv/_default_group.html.erb +17 -17
- data/app/views/cdm_migrator/csv/_error_list.html.erb +20 -20
- data/app/views/cdm_migrator/csv/_list_batches.html.erb +21 -21
- data/app/views/cdm_migrator/csv/_tabs.html.erb +8 -8
- data/app/views/cdm_migrator/csv/csv_checker.html.erb +45 -45
- data/app/views/cdm_migrator/csv/edit.html.erb +17 -18
- data/app/views/cdm_migrator/csv/index.html.erb +19 -19
- data/app/views/cdm_migrator/csv/upload.html.erb +18 -18
- data/app/views/layouts/cdm_migrator/application.html.erb +14 -14
- data/config/routes.rb +19 -19
- data/db/migrate/20191211193859_create_batch_ingests.rb +19 -19
- data/db/migrate/20191212192315_create_ingest_works.rb +18 -18
- data/lib/cdm_migrator/engine.rb +29 -29
- data/lib/cdm_migrator/version.rb +3 -3
- data/lib/cdm_migrator.rb +5 -5
- data/lib/generators/cdm_migrator/install/install_generator.rb +79 -79
- data/lib/generators/cdm_migrator/install/templates/config/cdm_migrator.yml +53 -50
- data/lib/generators/cdm_migrator/install/templates/presenters/hyku/menu_presenter.rb +47 -47
- data/lib/generators/cdm_migrator/install/templates/presenters/hyrax/menu_presenter.rb +66 -66
- data/lib/generators/cdm_migrator/install/templates/sidebar/_tasks.html.erb +55 -55
- data/lib/tasks/cdm_migrator_tasks.rake +4 -4
- metadata +7 -5
@@ -1,79 +1,79 @@
|
|
1
|
-
class CdmMigrator::InstallGenerator < Rails::Generators::Base
|
2
|
-
source_root File.expand_path('../templates', __FILE__)
|
3
|
-
|
4
|
-
def inject_dashboard_link
|
5
|
-
file_path = "app/views/hyrax/dashboard/sidebar/_tasks.html.erb"
|
6
|
-
if File.file?(file_path)
|
7
|
-
title = "<li class=\"h5\"><%= t('hyrax.admin.sidebar.tasks') %></li>"
|
8
|
-
perm = " <% if can? :review, :submissions %>"
|
9
|
-
gsub_file file_path,/[ \t]*(<li class="h5"><%= t\('hyrax\.admin\.sidebar\.tasks'\) %><\/li>)\n[\s\S]*[ \t]*(<% if can\? :review, :submissions %>)\n/ do |match|
|
10
|
-
""
|
11
|
-
end
|
12
|
-
gsub_file file_path,/[ \t]*(<% if can\? :review, :submissions %>)\n[\s\S]*[ \t]*(<li class="h5"><%= t\('hyrax\.admin\.sidebar\.tasks'\) %><\/li>)\n/ do |match|
|
13
|
-
""
|
14
|
-
end
|
15
|
-
prepend_to_file file_path do
|
16
|
-
title + "\n" \
|
17
|
-
"<li>\n" \
|
18
|
-
" <%= menu.collapsable_section t('CDM Migrator'),\n" \
|
19
|
-
" icon_class: \"fa fa-map-signs\",\n" \
|
20
|
-
" id: 'collapseCdmMigrator',\n" \
|
21
|
-
" open: menu.cdm_migrator_section? do %>\n" \
|
22
|
-
" <%= menu.nav_link(main_app.cdm_start_path) do %>\n" \
|
23
|
-
" <span class=\"fa fa-map\"></span> <span class=\"sidebar-action-text\"><%= t('CDM Mapping Tool') %></span>\n" \
|
24
|
-
" <% end %>\n" \
|
25
|
-
" <%= menu.nav_link(main_app.csv_checker_path) do %>\n" \
|
26
|
-
" <span class=\"fa fa-check-circle\"></span><span>CSV Checker</span>\n" \
|
27
|
-
" <% end %>\n" \
|
28
|
-
" <%= menu.nav_link(main_app.csv_upload_path) do %>\n"\
|
29
|
-
" <span class=\"fa fa-angle-double-up\"></span> <span class=\"sidebar-action-text\"><%= t('CSV Batch Uploader') %></span>\n" \
|
30
|
-
" <% end %>\n" \
|
31
|
-
" <%= menu.nav_link(main_app.csv_my_batches_path) do %>\n" \
|
32
|
-
" <span class=\"fa fa-database\"></span> <span class=\"sidebar-action-text\"><%= t('Batches') %></span>\n" \
|
33
|
-
" <% end %>\n" \
|
34
|
-
" <% end %>\n" \
|
35
|
-
" </li>\n" + perm + "\n"
|
36
|
-
|
37
|
-
end
|
38
|
-
else
|
39
|
-
copy_file "sidebar/_tasks.html.erb", "app/views/hyrax/dashboard/sidebar/_tasks.html.erb"
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def inject_menu_presenter
|
44
|
-
hyku_file_path = "app/presenters/hyku/menu_presenter.rb"
|
45
|
-
hyrax_file_path = "app/presenters/hyrax/menu_presenter.rb"
|
46
|
-
if File.file?(hyku_file_path) && File.readlines(hyku_file_path).join.include?("cdm_migrator_section")
|
47
|
-
insert_into_file hyku_file_path, :after => /def settings_section\?\n.*\(controller_name\)\n[ \t]*end/ do
|
48
|
-
"\n\n" \
|
49
|
-
" def cdm_migrator_section?\n" \
|
50
|
-
" %w[cdm csv].include?(controller_name)\n" \
|
51
|
-
" end\n"
|
52
|
-
end
|
53
|
-
elsif File.file?(hyrax_file_path) && File.readlines(hyrax_file_path).join.include?("cdm_migrator_section")
|
54
|
-
insert_into_file hyrax_file_path, :after => /def settings_section\?\n.*\(controller_name\)\n[ \t]*end/ do
|
55
|
-
"\n\n" \
|
56
|
-
" def cdm_migrator_section?\n" \
|
57
|
-
" %w[cdm csv].include?(controller_name)\n" \
|
58
|
-
" end\n"
|
59
|
-
end
|
60
|
-
elsif Hyku
|
61
|
-
copy_file "presenters/hyku/menu_presenter.rb", "app/presenters/hyku/menu_presenter.rb"
|
62
|
-
elsif Hyrax
|
63
|
-
copy_file "presenters/hyrax/menu_presenter.rb", "app/presenters/hyrax/menu_presenter.rb"
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
def inject_content_dm_yml
|
68
|
-
copy_file("config/cdm_migrator.yml", "config/cdm_migrator.yml") unless File.file?("config/cdm_migrator.yml")
|
69
|
-
end
|
70
|
-
|
71
|
-
def inject_stylesheets
|
72
|
-
css_file_path = "app/assets/stylesheets/application.css"
|
73
|
-
copy_file("stylesheets/csv_checker.css", "app/assets/stylesheets/csv_checker.css") unless File.file?("app/assets/styelsheets/csv_checker.css")
|
74
|
-
insert_into_file css_file_path, :before => " *= require_self\n" do
|
75
|
-
" *= require csv_checker\n "
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
end
|
1
|
+
class CdmMigrator::InstallGenerator < Rails::Generators::Base
|
2
|
+
source_root File.expand_path('../templates', __FILE__)
|
3
|
+
|
4
|
+
def inject_dashboard_link
|
5
|
+
file_path = "app/views/hyrax/dashboard/sidebar/_tasks.html.erb"
|
6
|
+
if File.file?(file_path)
|
7
|
+
title = "<li class=\"h5\"><%= t('hyrax.admin.sidebar.tasks') %></li>"
|
8
|
+
perm = " <% if can? :review, :submissions %>"
|
9
|
+
gsub_file file_path,/[ \t]*(<li class="h5"><%= t\('hyrax\.admin\.sidebar\.tasks'\) %><\/li>)\n[\s\S]*[ \t]*(<% if can\? :review, :submissions %>)\n/ do |match|
|
10
|
+
""
|
11
|
+
end
|
12
|
+
gsub_file file_path,/[ \t]*(<% if can\? :review, :submissions %>)\n[\s\S]*[ \t]*(<li class="h5"><%= t\('hyrax\.admin\.sidebar\.tasks'\) %><\/li>)\n/ do |match|
|
13
|
+
""
|
14
|
+
end
|
15
|
+
prepend_to_file file_path do
|
16
|
+
title + "\n" \
|
17
|
+
"<li>\n" \
|
18
|
+
" <%= menu.collapsable_section t('CDM Migrator'),\n" \
|
19
|
+
" icon_class: \"fa fa-map-signs\",\n" \
|
20
|
+
" id: 'collapseCdmMigrator',\n" \
|
21
|
+
" open: menu.cdm_migrator_section? do %>\n" \
|
22
|
+
" <%= menu.nav_link(main_app.cdm_start_path) do %>\n" \
|
23
|
+
" <span class=\"fa fa-map\"></span> <span class=\"sidebar-action-text\"><%= t('CDM Mapping Tool') %></span>\n" \
|
24
|
+
" <% end %>\n" \
|
25
|
+
" <%= menu.nav_link(main_app.csv_checker_path) do %>\n" \
|
26
|
+
" <span class=\"fa fa-check-circle\"></span><span>CSV Checker</span>\n" \
|
27
|
+
" <% end %>\n" \
|
28
|
+
" <%= menu.nav_link(main_app.csv_upload_path) do %>\n"\
|
29
|
+
" <span class=\"fa fa-angle-double-up\"></span> <span class=\"sidebar-action-text\"><%= t('CSV Batch Uploader') %></span>\n" \
|
30
|
+
" <% end %>\n" \
|
31
|
+
" <%= menu.nav_link(main_app.csv_my_batches_path) do %>\n" \
|
32
|
+
" <span class=\"fa fa-database\"></span> <span class=\"sidebar-action-text\"><%= t('Batches') %></span>\n" \
|
33
|
+
" <% end %>\n" \
|
34
|
+
" <% end %>\n" \
|
35
|
+
" </li>\n" + perm + "\n"
|
36
|
+
|
37
|
+
end
|
38
|
+
else
|
39
|
+
copy_file "sidebar/_tasks.html.erb", "app/views/hyrax/dashboard/sidebar/_tasks.html.erb"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def inject_menu_presenter
|
44
|
+
hyku_file_path = "app/presenters/hyku/menu_presenter.rb"
|
45
|
+
hyrax_file_path = "app/presenters/hyrax/menu_presenter.rb"
|
46
|
+
if File.file?(hyku_file_path) && File.readlines(hyku_file_path).join.include?("cdm_migrator_section")
|
47
|
+
insert_into_file hyku_file_path, :after => /def settings_section\?\n.*\(controller_name\)\n[ \t]*end/ do
|
48
|
+
"\n\n" \
|
49
|
+
" def cdm_migrator_section?\n" \
|
50
|
+
" %w[cdm csv].include?(controller_name)\n" \
|
51
|
+
" end\n"
|
52
|
+
end
|
53
|
+
elsif File.file?(hyrax_file_path) && File.readlines(hyrax_file_path).join.include?("cdm_migrator_section")
|
54
|
+
insert_into_file hyrax_file_path, :after => /def settings_section\?\n.*\(controller_name\)\n[ \t]*end/ do
|
55
|
+
"\n\n" \
|
56
|
+
" def cdm_migrator_section?\n" \
|
57
|
+
" %w[cdm csv].include?(controller_name)\n" \
|
58
|
+
" end\n"
|
59
|
+
end
|
60
|
+
elsif Hyku
|
61
|
+
copy_file "presenters/hyku/menu_presenter.rb", "app/presenters/hyku/menu_presenter.rb"
|
62
|
+
elsif Hyrax
|
63
|
+
copy_file "presenters/hyrax/menu_presenter.rb", "app/presenters/hyrax/menu_presenter.rb"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def inject_content_dm_yml
|
68
|
+
copy_file("config/cdm_migrator.yml", "config/cdm_migrator.yml") unless File.file?("config/cdm_migrator.yml")
|
69
|
+
end
|
70
|
+
|
71
|
+
def inject_stylesheets
|
72
|
+
css_file_path = "app/assets/stylesheets/application.css"
|
73
|
+
copy_file("stylesheets/csv_checker.css", "app/assets/stylesheets/csv_checker.css") unless File.file?("app/assets/styelsheets/csv_checker.css")
|
74
|
+
insert_into_file css_file_path, :before => " *= require_self\n" do
|
75
|
+
" *= require csv_checker\n "
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
@@ -1,50 +1,53 @@
|
|
1
|
-
tenant_settings:
|
2
|
-
tenant1.institution.com:
|
3
|
-
cdm_api:
|
4
|
-
url: 'http://your-content-dm-host'
|
5
|
-
port: 8080
|
6
|
-
type: 'front'
|
7
|
-
dirs:
|
8
|
-
dir1: '/dir1/path/goes/here'
|
9
|
-
dir2: '/dir2/path/goes/here'
|
10
|
-
tenant2.institution.com:
|
11
|
-
cdm_api:
|
12
|
-
url: 'http://your-content-dm-host'
|
13
|
-
port: 8080
|
14
|
-
type: 'front'
|
15
|
-
dirs:
|
16
|
-
dir1: '/dir1/path/goes/here'
|
17
|
-
dir2: '/dir2/path/goes/here'
|
18
|
-
default:
|
19
|
-
cdm_api:
|
20
|
-
url: 'http://your-content-dm-host'
|
21
|
-
port: 8080
|
22
|
-
type: 'front'
|
23
|
-
dirs:
|
24
|
-
dir1: '/dir1/path/goes/here'
|
25
|
-
dir2: '/dir2/path/goes/here'
|
26
|
-
csv_checker:
|
27
|
-
|
28
|
-
#
|
29
|
-
|
30
|
-
# -
|
31
|
-
|
32
|
-
|
33
|
-
# -
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
-
|
41
|
-
-
|
42
|
-
-
|
43
|
-
-
|
44
|
-
-
|
45
|
-
-
|
46
|
-
-
|
47
|
-
-
|
48
|
-
-
|
49
|
-
-
|
50
|
-
-
|
1
|
+
tenant_settings:
|
2
|
+
tenant1.institution.com:
|
3
|
+
cdm_api:
|
4
|
+
url: 'http://your-content-dm-host'
|
5
|
+
port: 8080
|
6
|
+
type: 'front'
|
7
|
+
dirs:
|
8
|
+
dir1: '/dir1/path/goes/here'
|
9
|
+
dir2: '/dir2/path/goes/here'
|
10
|
+
tenant2.institution.com:
|
11
|
+
cdm_api:
|
12
|
+
url: 'http://your-content-dm-host'
|
13
|
+
port: 8080
|
14
|
+
type: 'front'
|
15
|
+
dirs:
|
16
|
+
dir1: '/dir1/path/goes/here'
|
17
|
+
dir2: '/dir2/path/goes/here'
|
18
|
+
default:
|
19
|
+
cdm_api:
|
20
|
+
url: 'http://your-content-dm-host'
|
21
|
+
port: 8080
|
22
|
+
type: 'front'
|
23
|
+
dirs:
|
24
|
+
dir1: '/dir1/path/goes/here'
|
25
|
+
dir2: '/dir2/path/goes/here'
|
26
|
+
csv_checker:
|
27
|
+
date_indexing_service:
|
28
|
+
# - DateIndexingService # The class name of your date validation/indexing service
|
29
|
+
date_fields:
|
30
|
+
# - date_created
|
31
|
+
valid_uri_fields:
|
32
|
+
# - rights_statement
|
33
|
+
# - genre
|
34
|
+
separator_fields:
|
35
|
+
# - subject
|
36
|
+
multi_value_separator: # '|'
|
37
|
+
path_to_drive: #'/mnt/drive'
|
38
|
+
max_file_size: # 17179869184 # in bytes
|
39
|
+
default_fields:
|
40
|
+
- title
|
41
|
+
- creator
|
42
|
+
- keyword
|
43
|
+
- license
|
44
|
+
- resource_type
|
45
|
+
- contributor
|
46
|
+
- description
|
47
|
+
- publisher
|
48
|
+
- date_created
|
49
|
+
- subject
|
50
|
+
- language
|
51
|
+
- identifier
|
52
|
+
- based_near
|
53
|
+
- related_url
|
@@ -1,47 +1,47 @@
|
|
1
|
-
module Hyku
|
2
|
-
# view-model for the admin menu
|
3
|
-
class MenuPresenter < Hyrax::MenuPresenter
|
4
|
-
# Returns true if the current controller happens to be one of the controllers that deals
|
5
|
-
# with settings. This is used to keep the parent section on the sidebar open.
|
6
|
-
def settings_section?
|
7
|
-
%w[appearances content_blocks labels features pages].include?(controller_name)
|
8
|
-
end
|
9
|
-
|
10
|
-
def cdm_migrator_section?
|
11
|
-
%w[cdm csv].include?(controller_name)
|
12
|
-
end
|
13
|
-
|
14
|
-
# Returns true if the current controller happens to be one of the controllers that deals
|
15
|
-
# with roles and permissions. This is used to keep the parent section on the sidebar open.
|
16
|
-
def roles_and_permissions_section?
|
17
|
-
# we're using a case here because we need to differentiate UsersControllers
|
18
|
-
# in different namespaces (Hyrax & Admin)
|
19
|
-
case controller
|
20
|
-
when Hyrax::Admin::UsersController, ::Admin::GroupsController
|
21
|
-
true
|
22
|
-
else
|
23
|
-
false
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
# Returns true if the current controller happens to be one of the controllers that deals
|
28
|
-
# with repository activity This is used to keep the parent section on the sidebar open.
|
29
|
-
def repository_activity_section?
|
30
|
-
%w[admin dashboard status].include?(controller_name)
|
31
|
-
end
|
32
|
-
|
33
|
-
# Returns true if we ought to show the user the 'Configuration' section
|
34
|
-
# of the menu
|
35
|
-
def show_configuration?
|
36
|
-
super ||
|
37
|
-
can?(:manage, Site) ||
|
38
|
-
can?(:manage, User) ||
|
39
|
-
can?(:manage, Hyku::Group)
|
40
|
-
end
|
41
|
-
|
42
|
-
# Returns true if we ought to show the user Admin-only areas of the menu
|
43
|
-
def show_admin_menu_items?
|
44
|
-
can?(:read, :admin_dashboard)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
1
|
+
module Hyku
|
2
|
+
# view-model for the admin menu
|
3
|
+
class MenuPresenter < Hyrax::MenuPresenter
|
4
|
+
# Returns true if the current controller happens to be one of the controllers that deals
|
5
|
+
# with settings. This is used to keep the parent section on the sidebar open.
|
6
|
+
def settings_section?
|
7
|
+
%w[appearances content_blocks labels features pages].include?(controller_name)
|
8
|
+
end
|
9
|
+
|
10
|
+
def cdm_migrator_section?
|
11
|
+
%w[cdm csv].include?(controller_name)
|
12
|
+
end
|
13
|
+
|
14
|
+
# Returns true if the current controller happens to be one of the controllers that deals
|
15
|
+
# with roles and permissions. This is used to keep the parent section on the sidebar open.
|
16
|
+
def roles_and_permissions_section?
|
17
|
+
# we're using a case here because we need to differentiate UsersControllers
|
18
|
+
# in different namespaces (Hyrax & Admin)
|
19
|
+
case controller
|
20
|
+
when Hyrax::Admin::UsersController, ::Admin::GroupsController
|
21
|
+
true
|
22
|
+
else
|
23
|
+
false
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# Returns true if the current controller happens to be one of the controllers that deals
|
28
|
+
# with repository activity This is used to keep the parent section on the sidebar open.
|
29
|
+
def repository_activity_section?
|
30
|
+
%w[admin dashboard status].include?(controller_name)
|
31
|
+
end
|
32
|
+
|
33
|
+
# Returns true if we ought to show the user the 'Configuration' section
|
34
|
+
# of the menu
|
35
|
+
def show_configuration?
|
36
|
+
super ||
|
37
|
+
can?(:manage, Site) ||
|
38
|
+
can?(:manage, User) ||
|
39
|
+
can?(:manage, Hyku::Group)
|
40
|
+
end
|
41
|
+
|
42
|
+
# Returns true if we ought to show the user Admin-only areas of the menu
|
43
|
+
def show_admin_menu_items?
|
44
|
+
can?(:read, :admin_dashboard)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -1,66 +1,66 @@
|
|
1
|
-
module Hyrax
|
2
|
-
# view-model for the admin menu
|
3
|
-
class MenuPresenter
|
4
|
-
def initialize(view_context)
|
5
|
-
@view_context = view_context
|
6
|
-
end
|
7
|
-
|
8
|
-
attr_reader :view_context
|
9
|
-
|
10
|
-
delegate :controller, :controller_name, :action_name, :content_tag,
|
11
|
-
:current_page?, :link_to, :can?, to: :view_context
|
12
|
-
|
13
|
-
# Returns true if the current controller happens to be one of the controllers that deals
|
14
|
-
# with settings. This is used to keep the parent section on the sidebar open.
|
15
|
-
def settings_section?
|
16
|
-
%w[appearances content_blocks features pages collection_types].include?(controller_name)
|
17
|
-
end
|
18
|
-
|
19
|
-
def cdm_migrator_section?
|
20
|
-
%w[cdm csv].include?(controller_name)
|
21
|
-
end
|
22
|
-
|
23
|
-
# @param options [Hash, String] a hash or string representing the path. Hash is prefered as it
|
24
|
-
# allows us to workaround https://github.com/rails/rails/issues/28253
|
25
|
-
# @param also_active_for [Hash, String] a hash or string with alternative paths that should be 'active'
|
26
|
-
def nav_link(options, also_active_for: nil, **link_html_options)
|
27
|
-
active_urls = [options, also_active_for].compact
|
28
|
-
list_options = active_urls.any? { |url| current_page?(url) } ? { class: 'active' } : {}
|
29
|
-
content_tag(:li, list_options) do
|
30
|
-
link_to(options, link_html_options) do
|
31
|
-
yield
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
# @return [Boolean] true if the current controller happens to be one of the controllers that deals
|
37
|
-
# with user activity This is used to keep the parent section on the sidebar open.
|
38
|
-
def user_activity_section?
|
39
|
-
# we're using a case here because we need to differentiate UsersControllers
|
40
|
-
# in different namespaces (Hyrax & Admin)
|
41
|
-
case controller
|
42
|
-
when Hyrax::UsersController, Hyrax::NotificationsController, Hyrax::TransfersController, Hyrax::DepositorsController
|
43
|
-
true
|
44
|
-
else
|
45
|
-
false
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
# Draw a collaspable menu section. The passed block should contain <li> items.
|
50
|
-
def collapsable_section(text, id:, icon_class:, open:, &block)
|
51
|
-
CollapsableSectionPresenter.new(view_context: view_context,
|
52
|
-
text: text,
|
53
|
-
id: id,
|
54
|
-
icon_class: icon_class,
|
55
|
-
open: open).render(&block)
|
56
|
-
end
|
57
|
-
|
58
|
-
# @return [Boolean] will the configuration section be displayed to the user
|
59
|
-
def show_configuration?
|
60
|
-
can?(:update, :appearance) ||
|
61
|
-
can?(:manage, :collection_types) ||
|
62
|
-
can?(:manage, Sipity::WorkflowResponsibility) ||
|
63
|
-
can?(:manage, Hyrax::Feature)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
1
|
+
module Hyrax
|
2
|
+
# view-model for the admin menu
|
3
|
+
class MenuPresenter
|
4
|
+
def initialize(view_context)
|
5
|
+
@view_context = view_context
|
6
|
+
end
|
7
|
+
|
8
|
+
attr_reader :view_context
|
9
|
+
|
10
|
+
delegate :controller, :controller_name, :action_name, :content_tag,
|
11
|
+
:current_page?, :link_to, :can?, to: :view_context
|
12
|
+
|
13
|
+
# Returns true if the current controller happens to be one of the controllers that deals
|
14
|
+
# with settings. This is used to keep the parent section on the sidebar open.
|
15
|
+
def settings_section?
|
16
|
+
%w[appearances content_blocks features pages collection_types].include?(controller_name)
|
17
|
+
end
|
18
|
+
|
19
|
+
def cdm_migrator_section?
|
20
|
+
%w[cdm csv].include?(controller_name)
|
21
|
+
end
|
22
|
+
|
23
|
+
# @param options [Hash, String] a hash or string representing the path. Hash is prefered as it
|
24
|
+
# allows us to workaround https://github.com/rails/rails/issues/28253
|
25
|
+
# @param also_active_for [Hash, String] a hash or string with alternative paths that should be 'active'
|
26
|
+
def nav_link(options, also_active_for: nil, **link_html_options)
|
27
|
+
active_urls = [options, also_active_for].compact
|
28
|
+
list_options = active_urls.any? { |url| current_page?(url) } ? { class: 'active' } : {}
|
29
|
+
content_tag(:li, list_options) do
|
30
|
+
link_to(options, link_html_options) do
|
31
|
+
yield
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# @return [Boolean] true if the current controller happens to be one of the controllers that deals
|
37
|
+
# with user activity This is used to keep the parent section on the sidebar open.
|
38
|
+
def user_activity_section?
|
39
|
+
# we're using a case here because we need to differentiate UsersControllers
|
40
|
+
# in different namespaces (Hyrax & Admin)
|
41
|
+
case controller
|
42
|
+
when Hyrax::UsersController, Hyrax::NotificationsController, Hyrax::TransfersController, Hyrax::DepositorsController
|
43
|
+
true
|
44
|
+
else
|
45
|
+
false
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# Draw a collaspable menu section. The passed block should contain <li> items.
|
50
|
+
def collapsable_section(text, id:, icon_class:, open:, &block)
|
51
|
+
CollapsableSectionPresenter.new(view_context: view_context,
|
52
|
+
text: text,
|
53
|
+
id: id,
|
54
|
+
icon_class: icon_class,
|
55
|
+
open: open).render(&block)
|
56
|
+
end
|
57
|
+
|
58
|
+
# @return [Boolean] will the configuration section be displayed to the user
|
59
|
+
def show_configuration?
|
60
|
+
can?(:update, :appearance) ||
|
61
|
+
can?(:manage, :collection_types) ||
|
62
|
+
can?(:manage, Sipity::WorkflowResponsibility) ||
|
63
|
+
can?(:manage, Hyrax::Feature)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -1,55 +1,55 @@
|
|
1
|
-
<li class="h5"><%= t('hyrax.admin.sidebar.tasks') %></li>
|
2
|
-
<li>
|
3
|
-
<%= menu.collapsable_section t('CDM Migrator'),
|
4
|
-
icon_class: "fa fa-map-signs",
|
5
|
-
id: 'collapseCdmMigrator',
|
6
|
-
open: menu.cdm_migrator_section? do %>
|
7
|
-
<%= menu.nav_link(main_app.cdm_start_path) do %>
|
8
|
-
<span class="fa fa-map"></span> <span class="sidebar-action-text"><%= t('CDM Mapping Tool') %></span>
|
9
|
-
<% end %>
|
10
|
-
|
11
|
-
<%= menu.nav_link(main_app.csv_checker_path) do %>
|
12
|
-
<span class="fa fa-check-circle"></span><span class="sidebar-action-text"><%= t('CSV Checker') %></span>
|
13
|
-
<% end %>
|
14
|
-
|
15
|
-
<%= menu.nav_link(main_app.csv_upload_path) do %>
|
16
|
-
<span class="fa fa-angle-double-up"></span> <span class="sidebar-action-text"><%= t('CSV Batch Uploader') %></span>
|
17
|
-
<% end %>
|
18
|
-
|
19
|
-
<%= menu.nav_link(main_app.csv_my_batches_path) do %>
|
20
|
-
<span class="fa fa-database"></span> <span class="sidebar-action-text"><%= t('Batches') %></span>
|
21
|
-
<% end %>
|
22
|
-
|
23
|
-
<%= menu.nav_link(main_app.csv_edit_path) do %>
|
24
|
-
<span class="fa fa-angle-double-up"></span> <span class="sidebar-action-text"><%= t('Batch Update') %></span>
|
25
|
-
<% end %>
|
26
|
-
<% end %>
|
27
|
-
</li>
|
28
|
-
|
29
|
-
<% if can? :review, :submissions %>
|
30
|
-
<%= menu.nav_link(hyrax.admin_workflows_path) do %>
|
31
|
-
<span class="fa fa-flag" aria-hidden="true"></span> <span class="sidebar-action-text"><%= t('hyrax.admin.sidebar.workflow_review') %></span>
|
32
|
-
<% end %>
|
33
|
-
<% end %>
|
34
|
-
|
35
|
-
<% if can? :manage, User %>
|
36
|
-
<%= menu.nav_link(hyrax.admin_users_path) do %>
|
37
|
-
<span class="fa fa-user" aria-hidden="true"></span> <span class="sidebar-action-text"><%= t('hyrax.admin.sidebar.users') %></span>
|
38
|
-
<% end %>
|
39
|
-
<% end %>
|
40
|
-
|
41
|
-
<% if can? :manage, Hyku::Group %>
|
42
|
-
<%= menu.nav_link(main_app.admin_groups_path) do %>
|
43
|
-
<span class="fa fa-users"></span> <span class="sidebar-action-text"><%= t('hyrax.admin.sidebar.manage_groups') %></span>
|
44
|
-
<% end %>
|
45
|
-
<% end %>
|
46
|
-
|
47
|
-
<% if can? :read, :admin_dashboard %>
|
48
|
-
<%= menu.nav_link(hyrax.embargoes_path) do %>
|
49
|
-
<span class="fa fa-flag" aria-hidden="true"></span> <span class="sidebar-action-text"><%= t('hyrax.embargoes.index.manage_embargoes') %></span>
|
50
|
-
<% end %>
|
51
|
-
|
52
|
-
<%= menu.nav_link(hyrax.leases_path) do %>
|
53
|
-
<span class="fa fa-flag" aria-hidden="true"></span> <span class="sidebar-action-text"><%= t('hyrax.leases.index.manage_leases') %></span>
|
54
|
-
<% end %>
|
55
|
-
<% end %>
|
1
|
+
<li class="h5"><%= t('hyrax.admin.sidebar.tasks') %></li>
|
2
|
+
<li>
|
3
|
+
<%= menu.collapsable_section t('CDM Migrator'),
|
4
|
+
icon_class: "fa fa-map-signs",
|
5
|
+
id: 'collapseCdmMigrator',
|
6
|
+
open: menu.cdm_migrator_section? do %>
|
7
|
+
<%= menu.nav_link(main_app.cdm_start_path) do %>
|
8
|
+
<span class="fa fa-map"></span> <span class="sidebar-action-text"><%= t('CDM Mapping Tool') %></span>
|
9
|
+
<% end %>
|
10
|
+
|
11
|
+
<%= menu.nav_link(main_app.csv_checker_path) do %>
|
12
|
+
<span class="fa fa-check-circle"></span><span class="sidebar-action-text"><%= t('CSV Checker') %></span>
|
13
|
+
<% end %>
|
14
|
+
|
15
|
+
<%= menu.nav_link(main_app.csv_upload_path) do %>
|
16
|
+
<span class="fa fa-angle-double-up"></span> <span class="sidebar-action-text"><%= t('CSV Batch Uploader') %></span>
|
17
|
+
<% end %>
|
18
|
+
|
19
|
+
<%= menu.nav_link(main_app.csv_my_batches_path) do %>
|
20
|
+
<span class="fa fa-database"></span> <span class="sidebar-action-text"><%= t('Batches') %></span>
|
21
|
+
<% end %>
|
22
|
+
|
23
|
+
<%= menu.nav_link(main_app.csv_edit_path) do %>
|
24
|
+
<span class="fa fa-angle-double-up"></span> <span class="sidebar-action-text"><%= t('Batch Update') %></span>
|
25
|
+
<% end %>
|
26
|
+
<% end %>
|
27
|
+
</li>
|
28
|
+
|
29
|
+
<% if can? :review, :submissions %>
|
30
|
+
<%= menu.nav_link(hyrax.admin_workflows_path) do %>
|
31
|
+
<span class="fa fa-flag" aria-hidden="true"></span> <span class="sidebar-action-text"><%= t('hyrax.admin.sidebar.workflow_review') %></span>
|
32
|
+
<% end %>
|
33
|
+
<% end %>
|
34
|
+
|
35
|
+
<% if can? :manage, User %>
|
36
|
+
<%= menu.nav_link(hyrax.admin_users_path) do %>
|
37
|
+
<span class="fa fa-user" aria-hidden="true"></span> <span class="sidebar-action-text"><%= t('hyrax.admin.sidebar.users') %></span>
|
38
|
+
<% end %>
|
39
|
+
<% end %>
|
40
|
+
|
41
|
+
<% if can? :manage, Hyku::Group %>
|
42
|
+
<%= menu.nav_link(main_app.admin_groups_path) do %>
|
43
|
+
<span class="fa fa-users"></span> <span class="sidebar-action-text"><%= t('hyrax.admin.sidebar.manage_groups') %></span>
|
44
|
+
<% end %>
|
45
|
+
<% end %>
|
46
|
+
|
47
|
+
<% if can? :read, :admin_dashboard %>
|
48
|
+
<%= menu.nav_link(hyrax.embargoes_path) do %>
|
49
|
+
<span class="fa fa-flag" aria-hidden="true"></span> <span class="sidebar-action-text"><%= t('hyrax.embargoes.index.manage_embargoes') %></span>
|
50
|
+
<% end %>
|
51
|
+
|
52
|
+
<%= menu.nav_link(hyrax.leases_path) do %>
|
53
|
+
<span class="fa fa-flag" aria-hidden="true"></span> <span class="sidebar-action-text"><%= t('hyrax.leases.index.manage_leases') %></span>
|
54
|
+
<% end %>
|
55
|
+
<% end %>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# desc "Explaining what the task does"
|
2
|
-
# task :cdm_migrator do
|
3
|
-
# # Task goes here
|
4
|
-
# end
|
1
|
+
# desc "Explaining what the task does"
|
2
|
+
# task :cdm_migrator do
|
3
|
+
# # Task goes here
|
4
|
+
# end
|