Skip to content

Commit

Permalink
Display confirm dialog before approving a work (#1741)
Browse files Browse the repository at this point in the history
* embargo message

* Display the embargo date

Co-authored-by: Claudia Lee <[email protected]>

* Fix a couple of broken tests

Co-authored-by: Claudia Lee <[email protected]>

* Updated a few more tests

Co-authored-by: Claudia Lee <[email protected]>

* Add test to validate that canceling the approval dialog works

Co-authored-by: Claudia Lee <[email protected]>

---------

Co-authored-by: Hector Correa <[email protected]>
Co-authored-by: Claudia Lee <[email protected]>
Co-authored-by: Hector Correa <[email protected]>
  • Loading branch information
4 people authored Apr 9, 2024
1 parent 9d52026 commit 6866386
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
19 changes: 17 additions & 2 deletions app/views/works/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
<%= link_to("Edit", edit_work_path(@work, wizard: @work_decorator.wizard_mode?), class: "btn btn-primary") %>
<% end %>
<% if @work_decorator.show_approve_button? %>
<%= button_to("Approve Dataset", approve_work_path(@work), class: "btn btn-secondary", method: :post) %>
<%= button_to("Approve Dataset", approve_work_path(@work), class: "btn btn-secondary", method: :post, id: "approve-button") %>
<% end %>
<% if @work_decorator.show_complete_button? %>
<%= button_to("Complete", work_validate_path(@work), class: "btn btn-secondary", method: :post) %>
Expand Down Expand Up @@ -286,7 +286,7 @@
<dt>Location notes</dt>
<dd><%= @work.location_notes %></dd>
<% end %>
<dt>Total Size</dt>
<dt>Total Size</dt>
<dd>
<%= number_to_human_size(@work.total_file_size)%>
</dd>
Expand Down Expand Up @@ -329,6 +329,21 @@
$leftOfMessages.data("class", oldClass);
});

$("#approve-button").on("click", (event) => {
var embargo = <%= @work.embargoed? %>;
var message = "";
if(embargo == true){
message = "You're about to publish this dataset, files will be embargoed until <%= @work.embargo_date %>. There's no going back. Are you sure?";
}
else{
message = "You're about to publish this dataset. There's no going back. Are you sure?";
}
var input = confirm(message);
if(input == false){
event.preventDefault();
}
});

// Issues HTTP POST to update the curator assigned to the work.
$("#curator_select").on("change", function(event) {
var newCuratorId = event.currentTarget.value;
Expand Down
1 change: 1 addition & 0 deletions spec/system/authz_super_admin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
sign_in super_admin
visit work_path(work)
click_on "Approve Dataset"
page.driver.browser.switch_to.alert.accept
expect(page).to have_content "marked as Approved"
end
end
Expand Down
1 change: 1 addition & 0 deletions spec/system/migrate_submission_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@

visit work_path(work)
click_on "Approve"
page.driver.browser.switch_to.alert.accept
end

context "Approving a work with a DOI we own" do
Expand Down
12 changes: 12 additions & 0 deletions spec/system/work_approve_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,19 @@
click_link work.title
expect(page).to have_content(work.doi)
click_on "Approve Dataset"
page.driver.browser.switch_to.alert.accept
expect(page).to have_content("Uploads must be present for a work to be approved")
end

it "does not display warning if user cancels approval", js: true do
sign_in curator
visit(user_path(curator))
expect(page).to have_content curator.given_name
click_link work.title
expect(page).to have_content(work.doi)
click_on "Approve Dataset"
page.driver.browser.switch_to.alert.dismiss
expect(page).to_not have_content("Uploads must be present for a work to be approved")
end
end
end

0 comments on commit 6866386

Please sign in to comment.