Skip to content

Commit

Permalink
🎁 Add title attribute
Browse files Browse the repository at this point in the history
This commit will add title attribute to sidebar links for hover
information display.  Some translations were missing in the yml so I
added those as well but only for English.  At some point we might want
to add support for other languages.  Bulkrax and AllinsonFlex had some
of the partials in the sidebar so those were also modified and the
revisions for those gems were updated.

Ref:
  - samvera-labs/allinson_flex#120
  - samvera/bulkrax#838
  - #41
  • Loading branch information
kirkkwang committed Jul 20, 2023
1 parent fbed225 commit 0ab2154
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 33 deletions.
31 changes: 31 additions & 0 deletions app/presenters/hyku/collapsable_section_presenter.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# frozen_string_literal: true

module Hyku
# Draws a collapsable list widget using the Bootstrap 3 / Collapse.js plugin
class CollapsableSectionPresenter < Hyrax::CollapsableSectionPresenter
# Override Hyrax 3.5.0 to pass in html_options
# rubocop:disable Metrics/ParameterLists
def initialize(view_context:, text:, id:, icon_class:, open:, html_options: {})
# rubocop:enable Metrics/ParameterLists
super(view_context: view_context, text: text, id: id, icon_class: icon_class, open: open)
@html_options = html_options
end

attr_reader :html_options

private

def button_tag
tag.a({ role: 'button',
class: "#{button_class}collapse-toggle",
data: { toggle: 'collapse' },
href: "##{id}",
onclick: "toggleCollapse(this)",
'aria-expanded' => open,
'aria-controls' => id }.merge(html_options)) do
safe_join([tag.span('', class: icon_class, 'aria-hidden': true),
tag.span(text)], ' ')
end
end
end
end
13 changes: 13 additions & 0 deletions app/presenters/hyku/menu_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,18 @@ def show_configuration?
def show_admin_menu_items?
can?(:read, :admin_dashboard)
end

# Draw a collaspable menu section. The passed block should contain <li> items.
# Override Hyrax 3.5.0 to pass in html_options
# rubocop:disable Metrics/ParameterLists
def collapsable_section(text, id:, icon_class:, open:, **html_options, &block)
# rubocop:enable Metrics/ParameterLists
CollapsableSectionPresenter.new(view_context: view_context,
text: text,
id: id,
icon_class: icon_class,
open: open,
html_options: html_options).render(&block)
end
end
end
2 changes: 1 addition & 1 deletion app/views/hyrax/dashboard/_sidebar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</div>
</li>
<li>
<%= link_to hyrax.dashboard_path do %>
<%= link_to hyrax.dashboard_path, title: t('hyrax.admin.sidebar.dashboard') do %>
<span class="fa fa-home" aria-hidden="true"></span> <span class="sidebar-action-text"><%= t('hyrax.admin.sidebar.dashboard') %></span>
<% end %>
</li>
Expand Down
40 changes: 26 additions & 14 deletions app/views/hyrax/dashboard/sidebar/_activity.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
<%= menu.collapsable_section t('hyrax.admin.sidebar.repository_activity'),
icon_class: "fa fa-line-chart",
id: 'collapseRepositoryActivity',
open: menu.repository_activity_section? do %>
<%= menu.nav_link(hyrax.dashboard_path) do %>
open: menu.repository_activity_section?,
title: t('hyrax.admin.sidebar.repository_activity') do %>
<%= menu.nav_link(hyrax.dashboard_path,
title: t('hyrax.admin.sidebar.activity_summary')) do %>
<span class="fa fa-dashboard"></span> <span class="sidebar-action-text"><%= t('hyrax.admin.sidebar.activity_summary') %></span>
<% end %>
<% if menu.show_admin_menu_items? %>
<%= menu.nav_link(main_app.status_path) do %>
<%= menu.nav_link(main_app.status_path,
title: t('hyrax.admin.sidebar.system_status')) do %>
<span class="fa fa-flag"></span> <span class="sidebar-action-text"><%= t('hyrax.admin.sidebar.system_status') %></span>
<% end %>
<% end %>
Expand All @@ -20,49 +23,58 @@
<%= menu.collapsable_section t('hyrax.admin.sidebar.user_activity'),
icon_class: "fa fa-line-chart",
id: 'collapseUserActivity',
open: menu.user_activity_section? do %>
open: menu.user_activity_section?,
title: t('hyrax.admin.sidebar.user_activity') do %>
<%= menu.nav_link(hyrax.dashboard_profile_path(current_user),
also_active_for: hyrax.edit_dashboard_profile_path(current_user)) do %>
also_active_for: hyrax.edit_dashboard_profile_path(current_user),
title: t('hyrax.admin.sidebar.profile')) do %>
<span class="fa fa-id-card" aria-hidden="true"></span> <span class="sidebar-action-text"><%= t('hyrax.admin.sidebar.profile') %></span>
<% end %>
<%= menu.nav_link(hyrax.notifications_path) do %>
<%= menu.nav_link(hyrax.notifications_path,
title: t('hyrax.admin.sidebar.notifications')) do %>
<span class="fa fa-bell" aria-hidden="true"></span> <span class="sidebar-action-text"><%= t('hyrax.admin.sidebar.notifications') %></span>
<% end %>
<%= menu.nav_link(hyrax.transfers_path) do %>
<%= menu.nav_link(hyrax.transfers_path,
title: t('hyrax.admin.sidebar.transfers')) do %>
<span class="fa fa-arrows-h" aria-hidden="true"></span> <span class="sidebar-action-text"><%= t('hyrax.admin.sidebar.transfers') %></span>
<% end %>
<% if Flipflop.proxy_deposit? %>
<%= menu.nav_link(hyrax.depositors_path) do %>
<%= menu.nav_link(hyrax.depositors_path,
title: t('hyrax.dashboard.manage_proxies')) do %>
<span class="fa fa-users" aria-hidden="true"></span> <span class="sidebar-action-text"><%= t('hyrax.dashboard.manage_proxies') %></span>
<% end %>
<% end %>
<% end %>
</li>

<% if can? :read, :admin_dashboard %>
<%= menu.nav_link(hyrax.admin_stats_path) do %>
<%= menu.nav_link(hyrax.admin_stats_path,
title: t('hyrax.admin.sidebar.statistics')) do %>
<span class="fa fa-bar-chart" aria-hidden="true"></span> <span class="sidebar-action-text"><%= t('hyrax.admin.sidebar.statistics') %></span>
<% end %>
<% end %>
<% if current_ability.can_create_any_work? %>
<li>
<%= menu.collapsable_section t('hyrax.admin.sidebar.analytics'),
icon_class: "fa fa-pie-chart",
id: 'collapseAnalytics',
open: menu.analytics_reporting_section? do %>
icon_class: "fa fa-pie-chart",
id: 'collapseAnalytics',
open: menu.analytics_reporting_section?,
title: t('hyrax.admin.sidebar.analytics') do %>
<% if can? :read, :admin_dashboard %>
<%= menu.nav_link(hyrax.admin_analytics_collection_reports_path,
onclick: "dontChangeAccordion(event);") do %>
onclick: "dontChangeAccordion(event);",
title: t('hyrax.admin.sidebar.collections_report')) do %>
<span class="fa fa-folder-open" aria-hidden="true"></span> <span class="sidebar-action-text"><%= t('hyrax.admin.sidebar.collections_report') %></span>
<% end %>
<% end %>
<%= menu.nav_link(hyrax.admin_analytics_work_reports_path,
onclick: "dontChangeAccordion(event);") do %>
onclick: "dontChangeAccordion(event);",
title: t('hyrax.admin.sidebar.works_report')) do %>
<span class="fa fa-file" aria-hidden="true"></span> <span class="sidebar-action-text"><%= t('hyrax.admin.sidebar.works_report') %></span>
<% end %>
Expand Down
35 changes: 22 additions & 13 deletions app/views/hyrax/dashboard/sidebar/_configuration.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,54 @@
<% if can? :manage, Site %>
<li>
<%= menu.collapsable_section t('hyrax.admin.sidebar.settings'),
icon_class: "fa fa-cog",
id: 'collapseSettings',
open: menu.settings_section? do %>
<%= menu.nav_link(main_app.edit_admin_account_path) do %>
icon_class: "fa fa-cog",
id: 'collapseSettings',
open: menu.settings_section?,
title: t('hyrax.admin.sidebar.settings') do %>
<%= menu.nav_link(main_app.edit_admin_account_path,
title: t('hyrax.admin.sidebar.account')) do %>
<span class="fa fa-gear"></span> <span class="sidebar-action-text"><%= t('hyrax.admin.sidebar.account') %></span>
<% end %>
<%= menu.nav_link(main_app.edit_site_labels_path) do %>
<%= menu.nav_link(main_app.edit_site_labels_path,
title: t('hyrax.admin.sidebar.labels')) do %>
<span class="fa fa-institution"></span> <span class="sidebar-action-text"><%= t('hyrax.admin.sidebar.labels') %></span>
<% end %>
<% if can?(:update, :appearance) %>
<%= menu.nav_link(hyrax.admin_appearance_path) do %>
<%= menu.nav_link(hyrax.admin_appearance_path,
title: t('hyrax.admin.sidebar.appearance')) do %>
<span class="fa fa-paint-brush" aria-hidden="true"></span> <span class="sidebar-action-text"><%= t('hyrax.admin.sidebar.appearance') %></span>
<% end %>
<% end %>
<% if can?(:manage, :collection_types) %>
<%= menu.nav_link(hyrax.admin_collection_types_path) do %>
<%= menu.nav_link(hyrax.admin_collection_types_path,
title: t('hyrax.admin.sidebar.collection_types')) do %>
<span class="fa fa-folder-open" aria-hidden="true"></span> <span class="sidebar-action-text"><%= t('hyrax.admin.sidebar.collection_types') %></span>
<% end %>
<% end %>
<% if can?(:manage, Hyrax::Feature) %>
<%= menu.nav_link(hyrax.edit_pages_path) do %>
<%= menu.nav_link(hyrax.edit_pages_path,
title: t('hyrax.admin.sidebar.pages')) do %>
<span class="fa fa-file-text-o" aria-hidden="true"></span> <span class="sidebar-action-text"><%= t('hyrax.admin.sidebar.pages') %></span>
<% end %>
<%= menu.nav_link(hyrax.edit_content_blocks_path) do %>
<%= menu.nav_link(hyrax.edit_content_blocks_path,
title: t('hyrax.admin.sidebar.content_blocks')) do %>
<span class="fa fa-square-o" aria-hidden="true"></span> <span class="sidebar-action-text"><%= t('hyrax.admin.sidebar.content_blocks') %></span>
<% end %>
<%= menu.nav_link(hyrax.admin_features_path) do %>
<%= menu.nav_link(hyrax.admin_features_path,
title: t('hyrax.admin.sidebar.technical')) do %>
<span class="fa fa-wrench" aria-hidden="true"></span> <span class="sidebar-action-text"><%= t('hyrax.admin.sidebar.technical') %></span>
<% end %>
<%= menu.nav_link('/admin/work_types/edit') do %>
<%= menu.nav_link('/admin/work_types/edit',
title: t('hyku.admin.work_types')) do %>
<span class="fa fa-address-book"></span> <span class="sidebar-action-text"><%= t('hyku.admin.work_types') %></span>
<% end %>
<% end %>
</li>
<% end %>
<% if can?(:manage, Sipity::WorkflowResponsibility) %>
<%= menu.nav_link(hyrax.admin_workflow_roles_path) do %>
<%= menu.nav_link(hyrax.admin_workflow_roles_path,
title: t('hyrax.admin.sidebar.workflow_roles')) do %>
<span class="fa fa-users" aria-hidden="true"></span> <span class="sidebar-action-text"><%= t('hyrax.admin.sidebar.workflow_roles') %></span>
<% end %>
<% end # end of configuration block %>
Expand Down
18 changes: 13 additions & 5 deletions app/views/hyrax/dashboard/sidebar/_tasks.html.erb
Original file line number Diff line number Diff line change
@@ -1,32 +1,40 @@
<% if can? :review, :submissions %>
<li class="h5"><%= t('hyrax.admin.sidebar.tasks') %></li>
<%= menu.nav_link(hyrax.admin_workflows_path,
onclick: "dontChangeAccordion(event);") do %>
onclick: "dontChangeAccordion(event);",
alt: t('hyrax.admin.sidebar.workflow_review'),
title: t('hyrax.admin.sidebar.workflow_review')) do %>
<span class="fa fa-flag" aria-hidden="true"></span> <span class="sidebar-action-text"><%= t('hyrax.admin.sidebar.workflow_review') %></span>
<% end %>
<% end %>
<% if can? :manage, User %>
<%= menu.nav_link(hyrax.admin_users_path,
onclick: "dontChangeAccordion(event);") do %>
onclick: "dontChangeAccordion(event);",
alt: t('hyrax.admin.sidebar.users'),
title: t('hyrax.admin.sidebar.users')) do %>
<span class="fa fa-user" aria-hidden="true"></span> <span class="sidebar-action-text"><%= t('hyrax.admin.sidebar.users') %></span>
<% end %>
<% end %>
<% if can? :manage, Hyku::Group %>
<%= menu.nav_link(main_app.admin_groups_path) do %>
<%= menu.nav_link(main_app.admin_groups_path,
alt: t('hyrax.admin.sidebar.manage_groups'),
title: t('hyrax.admin.sidebar.manage_groups')) do %>
<span class="fa fa-users"></span> <span class="sidebar-action-text"><%= t('hyrax.admin.sidebar.manage_groups') %></span>
<% end %>
<% end %>
<% if can? :read, :admin_dashboard %>
<%= menu.nav_link(hyrax.embargoes_path,
onclick: "dontChangeAccordion(event);") do %>
onclick: "dontChangeAccordion(event);",
title: t('hyrax.embargoes.index.manage_embargoes')) do %>
<span class="fa fa-flag" aria-hidden="true"></span> <span class="sidebar-action-text"><%= t('hyrax.embargoes.index.manage_embargoes') %></span>
<% end %>
<%= menu.nav_link(hyrax.leases_path,
onclick: "dontChangeAccordion(event);") do %>
onclick: "dontChangeAccordion(event);",
title: t('hyrax.leases.index.manage_leases')) do %>
<span class="fa fa-flag" aria-hidden="true"></span> <span class="sidebar-action-text"><%= t('hyrax.leases.index.manage_leases') %></span>
<% end %>
<% end %>
Expand Down
2 changes: 2 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,12 @@ en:
fonts: "Fonts"
themes: "Themes"
sidebar:
account: Account
accounts: Accounts
activity_summary: Activity Summary
labels: Labels
manage_groups: Manage Groups
repository_activity: Repository Activity
system_status: System Status
users:
destroy:
Expand Down

0 comments on commit 0ab2154

Please sign in to comment.