diff options
author | Jörn Friedrich Dreyer <jfd@butonic.de> | 2014-12-08 15:26:31 +0100 |
---|---|---|
committer | Jörn Friedrich Dreyer <jfd@butonic.de> | 2014-12-11 16:32:27 +0100 |
commit | c615b3527f7c472afbc93d3293c7f467a99cbd0b (patch) | |
tree | d0ad68fee618b2c30e6da61d208ba283a487af6a /apps | |
parent | 85176ec0721f5a1ac2dd8f08dd34f7d8d51b6a19 (diff) | |
download | nextcloud-server-c615b3527f7c472afbc93d3293c7f467a99cbd0b.tar.gz nextcloud-server-c615b3527f7c472afbc93d3293c7f467a99cbd0b.zip |
show readonly message in file conflict dialog, make it always selected
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files/ajax/upload.php | 24 | ||||
-rw-r--r-- | apps/files/css/upload.css | 22 | ||||
-rw-r--r-- | apps/files/js/file-upload.js | 15 | ||||
-rw-r--r-- | apps/files/templates/fileexists.html | 1 |
4 files changed, 54 insertions, 8 deletions
diff --git a/apps/files/ajax/upload.php b/apps/files/ajax/upload.php index eb99d0644f7..fcee0166da6 100644 --- a/apps/files/ajax/upload.php +++ b/apps/files/ajax/upload.php @@ -117,6 +117,12 @@ if (strpos($dir, '..') === false) { $fileCount = count($files['name']); for ($i = 0; $i < $fileCount; $i++) { + if (isset($_POST['resolution'])) { + $resolution = $_POST['resolution']; + } else { + $resolution = null; + } + // target directory for when uploading folders $relativePath = ''; if(!empty($_POST['file_directory'])) { @@ -124,7 +130,7 @@ if (strpos($dir, '..') === false) { } // $path needs to be normalized - this failed within drag'n'drop upload to a sub-folder - if (isset($_POST['resolution']) && $_POST['resolution']==='autorename') { + if ($resolution === 'autorename') { // append a number in brackets like 'filename (2).ext' $target = OCP\Files::buildNotExistingFileName(stripslashes($dir . $relativePath), $files['name'][$i]); } else { @@ -141,9 +147,12 @@ if (strpos($dir, '..') === false) { } $returnedDir = \OC\Files\Filesystem::normalizePath($returnedDir); - if ( ! \OC\Files\Filesystem::file_exists($target) - || (isset($_POST['resolution']) && $_POST['resolution']==='replace') - ) { + + $exists = \OC\Files\Filesystem::file_exists($target); + if ($exists) { + $updatable = \OC\Files\Filesystem::isUpdatable($target); + } + if ( ! $exists || ($updatable && $resolution === 'replace' ) ) { // upload and overwrite file try { @@ -181,8 +190,11 @@ if (strpos($dir, '..') === false) { $error = $l->t('Upload failed. Could not get file info.'); } else { $data = \OCA\Files\Helper::formatFileInfo($meta); - $data['permissions'] = $data['permissions'] & $allowedPermissions; - $data['status'] = 'existserror'; + if ($updatable) { + $data['status'] = 'existserror'; + } else { + $data['status'] = 'readonly'; + } $data['originalname'] = $files['tmp_name'][$i]; $data['uploadMaxFilesize'] = $maxUploadFileSize; $data['maxHumanFilesize'] = $maxHumanFileSize; diff --git a/apps/files/css/upload.css b/apps/files/css/upload.css index 98754b910de..cc383879fb2 100644 --- a/apps/files/css/upload.css +++ b/apps/files/css/upload.css @@ -64,6 +64,28 @@ font-size: 13px; } +.oc-dialog .fileexists { + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +.oc-dialog .fileexists .conflict .filename, +.oc-dialog .fileexists .conflict .mtime, +.oc-dialog .fileexists .conflict .size { + -webkit-touch-callout: initial; + -webkit-user-select: initial; + -khtml-user-select: initial; + -moz-user-select: initial; + -ms-user-select: initial; + user-select: initial; +} +.oc-dialog .fileexists .conflict .message { + color: #e9322d; +} .oc-dialog .fileexists table { width: 100%; } diff --git a/apps/files/js/file-upload.js b/apps/files/js/file-upload.js index ab450dc5cac..9fe623075bc 100644 --- a/apps/files/js/file-upload.js +++ b/apps/files/js/file-upload.js @@ -175,7 +175,14 @@ OC.Upload = { * @param {function} callbacks.onCancel */ checkExistingFiles: function (selection, callbacks) { - // TODO check filelist before uploading and show dialog on conflicts, use callbacks + /* + $.each(selection.uploads, function(i, upload) { + var $row = OCA.Files.App.fileList.findFileEl(upload.files[0].name); + if ($row) { + // TODO check filelist before uploading and show dialog on conflicts, use callbacks + } + }); + */ callbacks.onNoConflicts(selection); }, @@ -417,11 +424,15 @@ OC.Upload = { data.textStatus = 'servererror'; data.errorThrown = t('files', 'Could not get result from server.'); fu._trigger('fail', e, data); + } else if (result[0].status === 'readonly') { + var original = result[0]; + var replacement = data.files[0]; + OC.dialogs.fileexists(data, original, replacement, OC.Upload); } else if (result[0].status === 'existserror') { //show "file already exists" dialog var original = result[0]; var replacement = data.files[0]; - OC.dialogs.fileexists(data, original, replacement, OC.Upload, fu); + OC.dialogs.fileexists(data, original, replacement, OC.Upload); } else if (result[0].status !== 'success') { //delete data.jqXHR; data.textStatus = 'servererror'; diff --git a/apps/files/templates/fileexists.html b/apps/files/templates/fileexists.html index 79beccef3e5..5360a7c8e8f 100644 --- a/apps/files/templates/fileexists.html +++ b/apps/files/templates/fileexists.html @@ -20,6 +20,7 @@ <span class="svg icon"></span> <div class="mtime"></div> <div class="size"></div> + <div class="message"></div> </div> </div> </div> |