Skip to content

Commit

Permalink
Don't show export buttons on file set show page.
Browse files Browse the repository at this point in the history
Fixes #1654
  • Loading branch information
jcoyne committed Mar 28, 2016
1 parent 26ed9fd commit bac3648
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 13 deletions.
4 changes: 0 additions & 4 deletions app/presenters/sufia/file_set_presenter.rb
Expand Up @@ -36,10 +36,6 @@ def itemtype
'http://schema.org/CreativeWork'
end

def processing?
# TODO: Refactor this away per https://github.com/projecthydra/sufia/pull/1592
end

def stats_path
Sufia::Engine.routes.url_helpers.stats_file_path(self)
end
Expand Down
6 changes: 3 additions & 3 deletions app/views/curation_concerns/base/_show_actions.html.erb
Expand Up @@ -16,15 +16,15 @@
<%= link_to 'Export to EndNote', polymorphic_path([main_app, @presenter], format: 'endnote'), class: 'btn btn-default' %>
<%= link_to 'Export to Zotero', sufia.static_path('zotero'), id: 'zoteroLink', name: 'zotero', class: 'btn btn-default' %>
<%= link_to 'Export to Mendeley', sufia.static_path('mendeley'), id: 'mendeleyLink', name: 'mendeley', class: 'btn btn-default' %>
<% if @presenter.respond_to?(:display_feature_link?) && @presenter.display_feature_link? %>
<% if @presenter.display_feature_link? %>
<%= link_to "Feature", sufia.featured_work_path(@presenter, format: :json),
data: {behavior: 'feature'}, id: 'featureLink', name: 'featureLink', class: 'btn btn-default' %>
<% end %>
<% if @presenter.respond_to?(:display_unfeature_link?) && @presenter.display_unfeature_link? %>
<% if @presenter.display_unfeature_link? %>
<%= link_to "Unfeature", sufia.featured_work_path(@presenter, format: :json),
data: {behavior: 'unfeature'}, id: 'unfeatureLink', name: 'unfeatureLink', class: 'btn btn-default' %>
<% end %>
<!-- COinS hook for Zotero -->
<span class="Z3988" title="<%= export_as_openurl_ctx_kev(@presenter) %>"></span>
<% end %>
<% end %>
</div>
13 changes: 13 additions & 0 deletions app/views/curation_concerns/file_sets/_show_actions.html.erb
@@ -0,0 +1,13 @@
<div class="form-actions">
<% if Sufia.config.analytics %>
<%= link_to "Analytics", @presenter.stats_path, id: 'stats', class: 'btn btn-default' %>
<% end %>
<% if Sufia.config.citations %>
<%= link_to "Citations", sufia.citations_work_path(@presenter), id: 'citations', class: 'btn btn-default' %>
<% end %>
<% if @presenter.editor? %>
<%= link_to "Edit This #{@presenter.human_readable_type}", edit_polymorphic_path([main_app, @presenter]), class: 'btn btn-default' %>
<%= link_to "Delete This #{@presenter.human_readable_type}", [main_app, @presenter], class: 'btn btn-danger pull-right', data: { confirm: "Delete this #{@presenter.human_readable_type}?" }, method: :delete %>
<% end %>
</div>

5 changes: 0 additions & 5 deletions spec/presenters/sufia/file_set_presenter_spec.rb
Expand Up @@ -6,11 +6,6 @@
let(:presenter) { described_class.new(solr_document, ability) }
let(:file) { build(:file_set, id: '123abc', user: user) }

describe 'processing?' do
let(:user) { double(user_key: 'sarah') }
it { expect(presenter.processing?).to eq nil }
end

describe 'stats_path' do
let(:user) { double(user_key: 'sarah') }
it { expect(presenter.stats_path).to eq Sufia::Engine.routes.url_helpers.stats_file_path(id: file) }
Expand Down
@@ -0,0 +1,48 @@
require 'spec_helper'

describe 'curation_concerns/file_sets/_show_actions.html.erb', type: :view do
let(:user) { create(:user) }
let(:object_profile) { ["{\"id\":\"999\"}"] }
let(:contributor) { ['Frodo'] }
let(:creator) { ['Bilbo'] }
let(:solr_document) {
SolrDocument.new(
id: '999',
object_profile_ssm: object_profile,
has_model_ssim: ['FileSet'],
human_readable_type_tesim: ['File'],
contributor_tesim: contributor,
creator_tesim: creator,
rights_tesim: ['http://creativecommons.org/licenses/by/3.0/us/']
)
}
let(:ability) { Ability.new(user) }
let(:presenter) do
Sufia::WorkShowPresenter.new(solr_document, ability)
end
describe 'citations' do
let(:page) { Capybara::Node::Simple.new(rendered) }
before do
Sufia.config.citations = citations
allow(controller).to receive(:can?).with(:edit, presenter).and_return(false)
assign(:presenter, presenter)
render
end

context 'when enabled' do
let(:citations) { true }

it 'appears on page' do
expect(page).to have_selector('a#citations', count: 1)
end
end

context 'when disabled' do
let(:citations) { false }

it 'does not appear on page' do
expect(page).to have_no_selector('a#citations')
end
end
end
end
Expand Up @@ -20,7 +20,7 @@
allow(view).to receive(:parent).and_return(parent)
view.lookup_context.prefixes.push 'curation_concerns/base'
allow(view).to receive(:can?).with(:edit, SolrDocument).and_return(false)
allow(view).to receive(:can?).with(:edit, String).and_return(true)
allow(ability).to receive(:can?).with(:edit, SolrDocument).and_return(false)
allow(presenter).to receive(:audit_status).and_return(mock_metadata)
assign(:presenter, presenter)
assign(:document, solr_doc)
Expand Down

0 comments on commit bac3648

Please sign in to comment.