Skip to content

Commit

Permalink
YDA-5889: add warning when uploading file with non-UTF8 names in rese…
Browse files Browse the repository at this point in the history
…arch space
  • Loading branch information
leonidastri authored Aug 27, 2024
1 parent 55f776f commit e897234
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
9 changes: 9 additions & 0 deletions research/static/research/js/research.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ $(function () {
r.cancel()
$('#files').html('')
$('#uploads').addClass('hidden')
$('#nonUTF-8FilenameWarning').addClass('hidden')
// clear information present for next time dialog is presented
$('.uploads-progress-information').html('')
$('.uploads-total-progress-bar').css('width', '0%')
Expand Down Expand Up @@ -407,6 +408,14 @@ $(function () {
$self.find('.msg').html('<i class="fa-solid fa-spinner fa-spin fa-fw"></i>')
})

try {
decodeURIComponent(escape(file.name))
} catch (e) {
if ($('#nonUTF-8FilenameWarning').hasClass('hidden')) {
$('#nonUTF-8FilenameWarning').removeClass('hidden')
}
}

// No Overwrite btn
$self.find('.upload-no-overwrite').on('click', function () {
file.cancel()
Expand Down
3 changes: 3 additions & 0 deletions research/templates/research/browse.html
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,9 @@ <h5 class="modal-title">Uploads
<button type="button" class="btn-close btn-close-uploads-overview" data-bs-dismiss="modal" aria-label="Close" title="Close"></button>
</div>
<div class="modal-body">
<div id="nonUTF-8FilenameWarning" class="hidden alert alert-primary">
Uploaded filenames contain unsupported characters and are renamed for compatibility.
</div>
<div id="files"></div>
</div>
<div class="modal-footer">
Expand Down

0 comments on commit e897234

Please sign in to comment.