diff --git a/app/views/works/show.html.erb b/app/views/works/show.html.erb
index cc7ecb7d0..401b23653 100644
--- a/app/views/works/show.html.erb
+++ b/app/views/works/show.html.erb
@@ -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) %>
@@ -286,7 +286,7 @@
Location notes
<%= @work.location_notes %>
<% end %>
- Total Size
+ Total Size
<%= number_to_human_size(@work.total_file_size)%>
@@ -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;
diff --git a/spec/system/authz_super_admin_spec.rb b/spec/system/authz_super_admin_spec.rb
index a0967406f..cda10d7ae 100644
--- a/spec/system/authz_super_admin_spec.rb
+++ b/spec/system/authz_super_admin_spec.rb
@@ -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
diff --git a/spec/system/migrate_submission_spec.rb b/spec/system/migrate_submission_spec.rb
index 59ef803da..41efda062 100644
--- a/spec/system/migrate_submission_spec.rb
+++ b/spec/system/migrate_submission_spec.rb
@@ -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
diff --git a/spec/system/work_approve_spec.rb b/spec/system/work_approve_spec.rb
index f2909c390..670543871 100644
--- a/spec/system/work_approve_spec.rb
+++ b/spec/system/work_approve_spec.rb
@@ -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