-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add batch actions to all/managed works page. #2434
Add batch actions to all/managed works page. #2434
Conversation
This addresses issue #2280 - Make read access works available to add to collections |
Added suggested tests: batch edit/delete that includes read-only works updates/deletes the edit access works and not the read access works. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you remove DashboardHelperBehavior#on_my_works?
now? It doesn't appear to be used anymore.
@@ -12,6 +12,7 @@ | |||
|
|||
context "on my works page" do | |||
before do | |||
view.lookup_context.prefixes.push "hyrax/my/works" | |||
allow(view).to receive(:on_my_works?).and_return(true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove
before do | ||
view.lookup_context.prefixes.push "hyrax/my/collections" | ||
allow(view).to receive(:on_my_works?).and_return(false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove?
@jcoyne I'm fine with removing |
@jonathandixon I think you should just remove it here because we have no other uses of it in hyrax. If you don't want to remove it here out of an abundance of caution, you should at least deprecate it. |
@@ -1,7 +1,7 @@ | |||
<ul class="nav nav-tabs" id="my_nav" role="navigation"> | |||
<span class="sr-only">You are currently listing your works. You have <%= @response.docs.count %> <%= 'work'.pluralize(@response.docs.count)%> </span> | |||
<li<%= ' class="active"'.html_safe if current_page?(hyrax.dashboard_works_path(locale: nil)) %>> | |||
<%= link_to t("hyrax.dashboard.#{current_ability.admin? ? 'all' : 'managed'}.works"), hyrax.dashboard_works_path %> | |||
<%= link_to t("hyrax.dashboard.#{current_ability.admin? ? 'all' : 'managed'}.works"), hyrax.dashboard_works_path, data: { turbolinks: false } %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you doing turbolinks: false
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This relates to issue #1191. Without it, you end up with an ActionController::InvalidAuthenticityToken
error.
<div class="batch-toggle"> | ||
<% session[:batch_edit_state] = "on" %> | ||
<div class="button_to-inline"> | ||
<%= button_to "Edit Selected", hyrax.edit_batch_edits_path, method: :get, class: "btn btn-update btn-primary hidden submits-batches", data: { behavior: 'batch-edit' }, id: 'batch-edit' %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add this string to i18n? and on line 10?
end | ||
|
||
it "is successful" do | ||
put :update, params: { update_type: "delete_all" } | ||
expect(response).to redirect_to(dashboard_path(locale: 'en')) | ||
expect { GenericWork.find(one.id) }.to raise_error(Ldp::Gone) | ||
expect { GenericWork.find(two.id) }.to raise_error(Ldp::Gone) | ||
expect(GenericWork.find(three.id).id).to eq(three.id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be expect(GenericWork).to exist(three.id)
(or alternately expect(GenericWork.exists?(three.id).to be true
)
@@ -61,13 +70,15 @@ | |||
expect(response).to be_redirect | |||
expect(GenericWork.find(one.id).subject).to eq ["zzz"] | |||
expect(GenericWork.find(two.id).subject).to eq ["zzz"] | |||
expect(GenericWork.find(three.id).subject).not_to eq ["zzz"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Negative assertions are not nearly as specific as positive assertions. Is there a reason you can't do expect(GenericWork.find(three.id).subject).to eq ["whavever value it initially had"]
?
end | ||
|
||
it "updates permissions" do | ||
put :update, params: { update_type: "update", visibility: "authenticated" } | ||
expect(response).to be_redirect | ||
expect(GenericWork.find(one.id).visibility).to eq "authenticated" | ||
expect(GenericWork.find(two.id).visibility).to eq "authenticated" | ||
expect(GenericWork.find(three.id).visibility).not_to eq "authenticated" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we assert what we expect it to be? restricted
?
@@ -74,7 +74,7 @@ | |||
|
|||
it "adds docs to the collection and adds the collection id to the documents in the collection" do | |||
post :create, params: { | |||
batch_document_ids: [asset1.id], | |||
batch_document_ids: [asset1.id, unowned_asset.id], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you doing this change? It seems odd that no assertions are changing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is to verify that only works the user has access to are added to the collection. This passes an ID of an unowned work with the request but that shouldn't change the original expectation that only asset1
is added to the collection.
@@ -35,20 +37,27 @@ | |||
let!(:two) do | |||
create(:generic_work, creator: ["Fred"], title: ["abc"], language: ['en'], user: user) | |||
end | |||
|
|||
let!(:three) do | |||
create(:generic_work, creator: ["Fred"], title: ["abc"], language: ['en']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On line 13 above you are using create(:work,...)
can we stick with that for consistency?
@@ -1,4 +1,8 @@ | |||
<tr id="document_<%= document.id %>"> | |||
<td> | |||
<label for="batch_document_<%= document.id %>" class="sr-only"><%=t("hyrax.dashboard.my.sr.batch_checkbox")%></label> | |||
<%= render 'hyrax/batch_select/add_button', document: document %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the point of the  
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was a copy and paste. It appears the
is used to manipulate the vertical position of the checkbox inside the table cell (without it the checkbox renders below verticle center).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me. @jcoyne Are you questions answered? This looks ready to merge to me.
Basic changes look good, but there are test failures.
Adds ability to batch select works on the All/Managed page (dashboard/works) and perform batch operations: delete, add to a collection, and edit.
@samvera/hyrax-code-reviewers