Skip to content

Commit

Permalink
Don't show the tasks section to depositors
Browse files Browse the repository at this point in the history
Fixes #907
  • Loading branch information
jcoyne committed Apr 10, 2017
1 parent 9734e6b commit 0359f59
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 12 deletions.
5 changes: 5 additions & 0 deletions app/presenters/hyku/menu_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,10 @@ def show_configuration?
can?(:manage, User) ||
can?(:manage, Hyku::Group)
end

# Returns true if we ought to show the user the 'Tasks' section of the menu
def show_tasks?
can?(:read, :admin_dashboard)
end
end
end
24 changes: 12 additions & 12 deletions app/views/hyrax/dashboard/_sidebar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -114,20 +114,20 @@
<span class="fa fa-file"></span> <span class="sidebar-action-text"><%= t('hyrax.admin.sidebar.works') %></span>
<% end %>
<% if can? :read, :admin_dashboard %>
<% if menu.show_tasks? %>
<li class="h5"><%= t('hyrax.admin.sidebar.tasks') %></li>
<% end %>
<% if Site.account && can?(:manage, Site.account) %>
<%= menu.nav_link(main_app.edit_admin_account_path) do %>
Account
<% end %>
<% end %>
<% if Site.account && can?(:manage, Site.account) %>
<%= menu.nav_link(main_app.edit_admin_account_path) do %>
Account
<%= menu.nav_link(hyrax.admin_workflows_path) do %>
<span class="fa fa-flag"></span> <span class="sidebar-action-text"><%= t('hyrax.admin.sidebar.workflow_review') %></span>
<% end %>
<% end %>
<%= menu.nav_link(hyrax.admin_workflows_path) do %>
<span class="fa fa-flag"></span> <span class="sidebar-action-text"><%= t('hyrax.admin.sidebar.workflow_review') %></span>
<% end %>
<%= menu.nav_link(hyrax.admin_stats_path) do %>
<span class="fa fa-bar-chart"></span> <span class="sidebar-action-text"><%= t('hyrax.admin.sidebar.statistics') %></span>
<% end %>
<%= menu.nav_link(hyrax.admin_stats_path) do %>
<span class="fa fa-bar-chart"></span> <span class="sidebar-action-text"><%= t('hyrax.admin.sidebar.statistics') %></span>
<% end %>
<% end # end of tasks block %>
</ul>
16 changes: 16 additions & 0 deletions spec/presenters/hyku/menu_presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,20 @@
it { is_expected.to be true }
end
end

describe "#show_tasks?" do
subject { instance.show_tasks? }
context "for a regular user" do
before do
allow(instance.view_context).to receive(:can?).and_return(false)
end
it { is_expected.to be false }
end
context "for a user who can manage users" do
before do
allow(instance.view_context).to receive(:can?).and_return(true)
end
it { is_expected.to be true }
end
end
end

0 comments on commit 0359f59

Please sign in to comment.