Skip to content

Commit

Permalink
Fix cancel upload behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
VicDeo committed Jan 8, 2019
1 parent db95996 commit a3f4cd8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
10 changes: 9 additions & 1 deletion apps/files_sharing/js/PublicUploadView.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
' <input type="button" class="stop icon-close" style="display:none" value="" />' +
' </div>' +
' <label>' +
' <input type="file" class="uploader hiddenuploadfield" name="files[]" />' +
' <input type="file" id="file_upload_start" class="uploader hiddenuploadfield" name="files[]" />' +
' <div class="public-upload-view--dropzone">' +
' <span class="icon icon-upload"></span><span>{{uploadButtonLabel}}</span>' +
' </div>' +
Expand Down Expand Up @@ -67,6 +67,7 @@
'_onUploadBeforeAdd',
'_onUploadDone',
'_onUploadStop',
'onUploadCancel',
'_getUploadUrl'
);
},
Expand All @@ -88,6 +89,10 @@
this.$('#uploadprogresswrapper .stop, #uploadprogressbar .label').hide();
},

onUploadCancel: function () {
this._uploader.cancelUploads();
},

_getUploadUrl: function(fileName) {
return OC.getRootPath() + '/public.php/webdav/' + encodeURIComponent(fileName);
},
Expand Down Expand Up @@ -150,6 +155,9 @@
view.render();

$('#preview .uploadForm').append(view.$el);
$('#uploadprogresswrapper .stop').on('click', function () {
view.onUploadCancel();
});
});

})(OC,OCA);
Expand Down
6 changes: 6 additions & 0 deletions tests/acceptance/features/lib/PublicLinkFilesPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class PublicLinkFilesPage extends FilesPageBasic {
protected $fileNamesXpath = "//span[@class='nametext']";
protected $fileNameMatchXpath = "//span[@class='nametext' and .=%s]";
protected $fileListXpath = ".//tbody[@id='fileList']";
protected $uploadFormXpath = "//div[@class='uploadForm']";
protected $emptyContentXpath = ".//div[@id='emptycontent']";
protected $addToYourOcBtnId = "save-button";
protected $singleFileDownloadBtnXpath = "//a[@id='downloadFile']";
Expand Down Expand Up @@ -335,6 +336,9 @@ public function waitTillPageIsLoaded(
$downloadButton = $this->find(
"xpath", $this->singleFileDownloadBtnXpath
);
$uploadForm = $this->find(
"xpath", $this->uploadFormXpath
);
if ($fileList !== null) {
try {
$fileListIsVisible = $fileList->isVisible();
Expand Down Expand Up @@ -382,6 +386,8 @@ public function waitTillPageIsLoaded(
}
} elseif ($downloadButton !== null) {
break;
} elseif ($uploadForm !== null) {
break;
}

\usleep(STANDARD_SLEEP_TIME_MICROSEC);
Expand Down
8 changes: 7 additions & 1 deletion tests/acceptance/features/webUIUpload/upload.feature
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,10 @@ Feature: File Upload
And the public accesses the last created public link using the webUI
And the user uploads overwriting file "lorem.txt" using the webUI and retries if the file is locked
Then file "lorem.txt" should be listed on the webUI
And the content of "simple-folder/lorem.txt" should be the same as the local "lorem.txt"
And the content of "simple-folder/lorem.txt" should be the same as the local "lorem.txt"

Scenario: upload a file into files_drop share
Given the user has created a new public link for folder "simple-folder" using the webUI with
| permission | upload |
And the public accesses the last created public link using the webUI
Then the user uploads file "lorem.txt" using the webUI

0 comments on commit a3f4cd8

Please sign in to comment.