Skip to content

Commit

Permalink
Prevent the user from deleting the README while on the Wizard. (#1776)
Browse files Browse the repository at this point in the history
  • Loading branch information
hectorcorrea authored Apr 18, 2024
1 parent d0bb22e commit 49a6b3a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
7 changes: 7 additions & 0 deletions app/views/works/_s3_resources.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
fileListUrl = '<%= root_path %>';
}
var isEditMode = <%= edit_mode %>;
// Notice that Ruby's `defined?` does not return a boolean, hence the `!= nil` comparison.
var isWizardMode = <%= defined?(wizard_mode) != nil && wizard_mode == true %>;

// Wire DataTable for the file list.
// Related documentation
Expand Down Expand Up @@ -146,6 +148,11 @@
},
{
render: function (data, type, row) {
// Don't render the delete icon for the readme while in the Wizard
if (isWizardMode && row.filename.includes("README")) {
return "";
}

// delete icon
var html = null;
if (type == "display") {
Expand Down
2 changes: 1 addition & 1 deletion app/views/works_wizard/file_upload.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<div class="deposit-uploads">
<section class="uploads">
<h2 class="h2"><%= t('works.uploads.post_curation.heading') %></h2>
<%= render(partial: 'works/s3_resources', locals: { edit_mode: true, form: f }) %>
<%= render(partial: 'works/s3_resources', locals: { edit_mode: true, form: f, wizard_mode: true }) %>
</section>
<div class="container-fluid deposit-uploads">
<span id="uppy_upload_url" class="hidden"><%= work_wizard_upload_files_path(@work) %></span>
Expand Down
5 changes: 5 additions & 0 deletions spec/system/work_wizard_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@
click_on "Save"
sleep(1) # no actual upload occured so no real change to be seen
expect(page).to have_css(file_upload_form_css)

# The README file is displayed but cannot be deleted
expect(page).to have_content("README.txt")
expect(page).to_not have_content("Delete file")

click_on "Next"
expect(page).to have_css(validate_form_css)

Expand Down

0 comments on commit 49a6b3a

Please sign in to comment.