diff options
Diffstat (limited to 'apps/files_sharing')
-rw-r--r-- | apps/files_sharing/css/mobile.css | 10 | ||||
-rw-r--r-- | apps/files_sharing/css/mobile.scss | 10 | ||||
-rw-r--r-- | apps/files_sharing/css/public.css | 18 | ||||
-rw-r--r-- | apps/files_sharing/css/public.scss | 18 | ||||
-rw-r--r-- | apps/files_sharing/css/publicView.css | 28 | ||||
-rw-r--r-- | apps/files_sharing/js/app.js | 12 | ||||
-rw-r--r-- | apps/files_sharing/js/files_drop.js | 2 | ||||
-rw-r--r-- | apps/files_sharing/js/public.js | 4 | ||||
-rw-r--r-- | apps/files_sharing/js/sharedfilelist.js | 6 | ||||
-rw-r--r-- | apps/files_sharing/lib/Updater.php | 41 | ||||
-rw-r--r-- | apps/files_sharing/src/services/ConfigService.js | 4 | ||||
-rw-r--r-- | apps/files_sharing/templates/list.php | 15 | ||||
-rw-r--r-- | apps/files_sharing/templates/public.php | 2 | ||||
-rw-r--r-- | apps/files_sharing/tests/UpdaterTest.php | 119 | ||||
-rw-r--r-- | apps/files_sharing/tests/js/appSpec.js | 2 | ||||
-rw-r--r-- | apps/files_sharing/tests/js/publicAppSpec.js | 10 | ||||
-rw-r--r-- | apps/files_sharing/tests/js/shareSpec.js | 4 |
17 files changed, 221 insertions, 84 deletions
diff --git a/apps/files_sharing/css/mobile.css b/apps/files_sharing/css/mobile.css index 63acecb90c8..114949d8c48 100644 --- a/apps/files_sharing/css/mobile.css +++ b/apps/files_sharing/css/mobile.css @@ -27,9 +27,9 @@ } /* hide size and date columns */ - table th#headerSize, + table th.column-size, table td.filesize, -table th#headerDate, +table th.column-mtime, table td.date { display: none; } @@ -52,12 +52,12 @@ table td.date { } /* some padding for better clickability */ - #fileList a.action img { + .files-fileList a.action img { padding: 0 6px 0 12px; } /* hide text of the actions on mobile */ - #fileList a.action:not(.menuitem) span { + .files-fileList a.action:not(.menuitem) span { display: none; } @@ -78,7 +78,7 @@ table td.date { padding: 0 20px; } - #emptycontent { + .emptycontent { margin-top: 10vh; } } diff --git a/apps/files_sharing/css/mobile.scss b/apps/files_sharing/css/mobile.scss index 38a7a9cd711..d058ad2a30e 100644 --- a/apps/files_sharing/css/mobile.scss +++ b/apps/files_sharing/css/mobile.scss @@ -8,9 +8,9 @@ } /* hide size and date columns */ -table th#headerSize, +table th.column-size, table td.filesize, -table th#headerDate, +table th.column-mtime, table td.date { display: none; } @@ -32,11 +32,11 @@ table td.filename .nametext { } /* some padding for better clickability */ -#fileList a.action img { +.files-fileList a.action img { padding: 0 6px 0 12px; } /* hide text of the actions on mobile */ -#fileList a.action:not(.menuitem) span { +.files-fileList a.action:not(.menuitem) span { display: none; } @@ -56,7 +56,7 @@ table td.filename .nametext { padding: 0 20px; } -#emptycontent { +.emptycontent { margin-top: 10vh; } } diff --git a/apps/files_sharing/css/public.css b/apps/files_sharing/css/public.css index 21dd876905c..a07b00b7b3d 100644 --- a/apps/files_sharing/css/public.css +++ b/apps/files_sharing/css/public.css @@ -122,19 +122,19 @@ thead { margin: 0 auto; } -#emptycontent.has-note { +.emptycontent.has-note { margin-top: 5vh; } -#public-upload #emptycontent h2 { +#public-upload .emptycontent h2 { margin: 10px 0 5px 0; } -#public-upload #emptycontent h2 + p { +#public-upload .emptycontent h2 + p { margin-bottom: 30px; } -#public-upload #emptycontent .icon-folder { +#public-upload .emptycontent .icon-folder { height: 16px; width: 16px; background-size: 16px; @@ -145,13 +145,13 @@ thead { opacity: 1; } -#public-upload #emptycontent #displayavatar .icon-folder { +#public-upload .emptycontent #displayavatar .icon-folder { height: 48px; width: 48px; background-size: 48px; } -#public-upload #emptycontent .button { +#public-upload .emptycontent .button { display: inline-block; height: auto; width: auto; @@ -165,20 +165,20 @@ thead { padding-left: 42px; } -#public-upload #emptycontent ul { +#public-upload .emptycontent ul { width: 230px; margin: 5px auto 5vh; text-align: left; } -#public-upload #emptycontent li { +#public-upload .emptycontent li { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 7px 0; } -#public-upload #emptycontent li img { +#public-upload .emptycontent li img { margin-right: 5px; position: relative; top: 2px; diff --git a/apps/files_sharing/css/public.scss b/apps/files_sharing/css/public.scss index a3754b7be9f..4b3ea818be8 100644 --- a/apps/files_sharing/css/public.scss +++ b/apps/files_sharing/css/public.scss @@ -101,21 +101,21 @@ thead { margin: 0 auto; } -#emptycontent { +.emptycontent { &.has-note { margin-top: 5vh; } } -#public-upload #emptycontent h2 { +#public-upload .emptycontent h2 { margin: 10px 0 5px 0; } -#public-upload #emptycontent h2+p { +#public-upload .emptycontent h2+p { margin-bottom: 30px; } -#public-upload #emptycontent .icon-folder { +#public-upload .emptycontent .icon-folder { height: 16px; width: 16px; background-size: 16px; @@ -126,13 +126,13 @@ thead { opacity: 1; } -#public-upload #emptycontent #displayavatar .icon-folder { +#public-upload .emptycontent #displayavatar .icon-folder { height: 48px; width: 48px; background-size: 48px; } -#public-upload #emptycontent .button { +#public-upload .emptycontent .button { display: inline-block; height: auto; width: auto; @@ -146,20 +146,20 @@ thead { padding-left: 42px; } -#public-upload #emptycontent ul { +#public-upload .emptycontent ul { width: 230px; margin: 5px auto 5vh; text-align: left; } -#public-upload #emptycontent li { +#public-upload .emptycontent li { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 7px 0; } -#public-upload #emptycontent li img { +#public-upload .emptycontent li img { margin-right: 5px; position: relative; top: 2px; diff --git a/apps/files_sharing/css/publicView.css b/apps/files_sharing/css/publicView.css index c10620e59bf..91429ffbdab 100644 --- a/apps/files_sharing/css/publicView.css +++ b/apps/files_sharing/css/publicView.css @@ -122,19 +122,19 @@ thead { margin: 0 auto; } -#emptycontent.has-note { +.emptycontent.has-note { margin-top: 5vh; } -#public-upload #emptycontent h2 { +#public-upload .emptycontent h2 { margin: 10px 0 5px 0; } -#public-upload #emptycontent h2 + p { +#public-upload .emptycontent h2 + p { margin-bottom: 30px; } -#public-upload #emptycontent .icon-folder { +#public-upload .emptycontent .icon-folder { height: 16px; width: 16px; background-size: 16px; @@ -145,13 +145,13 @@ thead { opacity: 1; } -#public-upload #emptycontent #displayavatar .icon-folder { +#public-upload .emptycontent #displayavatar .icon-folder { height: 48px; width: 48px; background-size: 48px; } -#public-upload #emptycontent .button { +#public-upload .emptycontent .button { display: inline-block; height: auto; width: auto; @@ -165,20 +165,20 @@ thead { padding-left: 42px; } -#public-upload #emptycontent ul { +#public-upload .emptycontent ul { width: 230px; margin: 5px auto 5vh; text-align: left; } -#public-upload #emptycontent li { +#public-upload .emptycontent li { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 7px 0; } -#public-upload #emptycontent li img { +#public-upload .emptycontent li img { margin-right: 5px; position: relative; top: 2px; @@ -261,9 +261,9 @@ thead { } /* hide size and date columns */ - table th#headerSize, + table th.column-size, table td.filesize, -table th#headerDate, +table th.column-mtime, table td.date { display: none; } @@ -286,12 +286,12 @@ table td.date { } /* some padding for better clickability */ - #fileList a.action img { + .files-fileList a.action img { padding: 0 6px 0 12px; } /* hide text of the actions on mobile */ - #fileList a.action:not(.menuitem) span { + .files-fileList a.action:not(.menuitem) span { display: none; } @@ -312,7 +312,7 @@ table td.date { padding: 0 20px; } - #emptycontent { + .emptycontent { margin-top: 10vh; } } diff --git a/apps/files_sharing/js/app.js b/apps/files_sharing/js/app.js index 24416fd5a3f..b9a60c73dab 100644 --- a/apps/files_sharing/js/app.js +++ b/apps/files_sharing/js/app.js @@ -46,7 +46,7 @@ OCA.Sharing.App = { this._extendFileList(this._inFileList) this._inFileList.appName = t('files_sharing', 'Shared with you') - this._inFileList.$el.find('#emptycontent').html('<div class="icon-shared"></div>' + this._inFileList.$el.find('.emptyfilelist.emptycontent').html('<div class="icon-shared"></div>' + '<h2>' + t('files_sharing', 'Nothing shared with you yet') + '</h2>' + '<p>' + t('files_sharing', 'Files and folders others share with you will show up here') + '</p>') return this._inFileList @@ -72,7 +72,7 @@ OCA.Sharing.App = { this._extendFileList(this._outFileList) this._outFileList.appName = t('files_sharing', 'Shared with others') - this._outFileList.$el.find('#emptycontent').html('<div class="icon-shared"></div>' + this._outFileList.$el.find('.emptyfilelist.emptycontent').html('<div class="icon-shared"></div>' + '<h2>' + t('files_sharing', 'Nothing shared yet') + '</h2>' + '<p>' + t('files_sharing', 'Files and folders you share will show up here') + '</p>') return this._outFileList @@ -98,7 +98,7 @@ OCA.Sharing.App = { this._extendFileList(this._linkFileList) this._linkFileList.appName = t('files_sharing', 'Shared by link') - this._linkFileList.$el.find('#emptycontent').html('<div class="icon-public"></div>' + this._linkFileList.$el.find('.emptyfilelist.emptycontent').html('<div class="icon-public"></div>' + '<h2>' + t('files_sharing', 'No shared links') + '</h2>' + '<p>' + t('files_sharing', 'Files and folders you share by link will show up here') + '</p>') return this._linkFileList @@ -126,7 +126,7 @@ OCA.Sharing.App = { this._extendFileList(this._deletedFileList) this._deletedFileList.appName = t('files_sharing', 'Deleted shares') - this._deletedFileList.$el.find('#emptycontent').html('<div class="icon-share"></div>' + this._deletedFileList.$el.find('.emptyfilelist.emptycontent').html('<div class="icon-share"></div>' + '<h2>' + t('files_sharing', 'No deleted shares') + '</h2>' + '<p>' + t('files_sharing', 'Shares you deleted will show up here') + '</p>') return this._deletedFileList @@ -155,7 +155,7 @@ OCA.Sharing.App = { this._extendFileList(this._pendingFileList) this._pendingFileList.appName = t('files_sharing', 'Pending shares') - this._pendingFileList.$el.find('#emptycontent').html('<div class="icon-share"></div>' + this._pendingFileList.$el.find('.emptyfilelist.emptycontent').html('<div class="icon-share"></div>' + '<h2>' + t('files_sharing', 'No pending shares') + '</h2>' + '<p>' + t('files_sharing', 'Shares you have received but not confirmed will show up here') + '</p>') return this._pendingFileList @@ -181,7 +181,7 @@ OCA.Sharing.App = { this._extendFileList(this._overviewFileList) this._overviewFileList.appName = t('files_sharing', 'Shares') - this._overviewFileList.$el.find('#emptycontent').html('<div class="icon-share"></div>' + this._overviewFileList.$el.find('.emptyfilelist.emptycontent').html('<div class="icon-share"></div>' + '<h2>' + t('files_sharing', 'No shares') + '</h2>' + '<p>' + t('files_sharing', 'Shares will show up here') + '</p>') return this._overviewFileList diff --git a/apps/files_sharing/js/files_drop.js b/apps/files_sharing/js/files_drop.js index e2830aeea9e..42151bca1cb 100644 --- a/apps/files_sharing/js/files_drop.js +++ b/apps/files_sharing/js/files_drop.js @@ -140,7 +140,7 @@ }); $('#public-upload .button.icon-upload').click(function(e) { e.preventDefault(); - $('#public-upload #emptycontent input').focus().trigger('click'); + $('#public-upload .emptycontent input').focus().trigger('click'); }); window.onbeforeunload = function() { return self.confirmBeforeUnload(); diff --git a/apps/files_sharing/js/public.js b/apps/files_sharing/js/public.js index bfb035fb817..c08d72d6e05 100644 --- a/apps/files_sharing/js/public.js +++ b/apps/files_sharing/js/public.js @@ -60,7 +60,7 @@ OCA.Sharing.PublicApp = { } // file list mode ? - if ($el.find('#filestable').length) { + if ($el.find('.files-filestable').length) { var filesClient = new OC.Files.Client({ host: OC.getHost(), port: OC.getPort(), @@ -277,7 +277,7 @@ OCA.Sharing.PublicApp = { }; this.fileList.updateEmptyContent = function() { - this.$el.find('#emptycontent .uploadmessage').text( + this.$el.find('.emptycontent .uploadmessage').text( t('files_sharing', 'You can upload into this folder') ); OCA.Files.FileList.prototype.updateEmptyContent.apply(this, arguments); diff --git a/apps/files_sharing/js/sharedfilelist.js b/apps/files_sharing/js/sharedfilelist.js index e8420113ad9..7d7e91dd965 100644 --- a/apps/files_sharing/js/sharedfilelist.js +++ b/apps/files_sharing/js/sharedfilelist.js @@ -17,7 +17,7 @@ * @classdesc Sharing file list. * Contains both "shared with others" and "shared with you" modes. * - * @param $el container element with existing markup for the #controls + * @param $el container element with existing markup for the .files-controls * and a table * @param [options] map of options, see other parameters * @param {boolean} [options.sharedWithUser] true to return files shared with @@ -158,8 +158,8 @@ var dir = this.getCurrentDirectory() if (dir === '/') { // root has special permissions - this.$el.find('#emptycontent').toggleClass('hidden', !this.isEmpty) - this.$el.find('#filestable thead th').toggleClass('hidden', this.isEmpty) + this.$el.find('.emptyfilelist.emptycontent').toggleClass('hidden', !this.isEmpty) + this.$el.find('.files-filestable thead th').toggleClass('hidden', this.isEmpty) // hide expiration date header for non link only shares if (!this._linksOnly) { diff --git a/apps/files_sharing/lib/Updater.php b/apps/files_sharing/lib/Updater.php index ad194dde016..59e06e60299 100644 --- a/apps/files_sharing/lib/Updater.php +++ b/apps/files_sharing/lib/Updater.php @@ -29,6 +29,7 @@ namespace OCA\Files_Sharing; use OC\Files\Mount\MountPoint; use OCP\Constants; use OCP\Share\IShare; +use OCP\Files\Folder; class Updater { @@ -37,7 +38,7 @@ class Updater { */ public static function renameHook($params) { self::renameChildren($params['oldpath'], $params['newpath']); - self::moveShareToShare($params['newpath']); + self::moveShareInOrOutOfShare($params['newpath']); } /** @@ -50,7 +51,7 @@ class Updater { * * @param string $path */ - private static function moveShareToShare($path) { + private static function moveShareInOrOutOfShare($path): void { $userFolder = \OC::$server->getUserFolder(); // If the user folder can't be constructed (e.g. link share) just return. @@ -62,10 +63,18 @@ class Updater { $shareManager = \OC::$server->getShareManager(); + // FIXME: should CIRCLES be included here ?? $shares = $shareManager->getSharesBy($userFolder->getOwner()->getUID(), IShare::TYPE_USER, $src, false, -1); $shares = array_merge($shares, $shareManager->getSharesBy($userFolder->getOwner()->getUID(), IShare::TYPE_GROUP, $src, false, -1)); $shares = array_merge($shares, $shareManager->getSharesBy($userFolder->getOwner()->getUID(), IShare::TYPE_ROOM, $src, false, -1)); + if ($src instanceof Folder) { + $subShares = $shareManager->getSharesInFolder($userFolder->getOwner()->getUID(), $src, false, false); + foreach ($subShares as $subShare) { + $shares = array_merge($shares, array_values($subShare)); + } + } + // If the path we move is not a share we don't care if (empty($shares)) { return; @@ -74,21 +83,31 @@ class Updater { // Check if the destination is inside a share $mountManager = \OC::$server->getMountManager(); $dstMount = $mountManager->find($src->getPath()); - if (!($dstMount instanceof \OCA\Files_Sharing\SharedMount)) { - return; - } - - $newOwner = $dstMount->getShare()->getShareOwner(); //Ownership is moved over foreach ($shares as $share) { - /** @var IShare $share */ - if (!($dstMount->getShare()->getPermissions() & Constants::PERMISSION_SHARE)) { - $shareManager->deleteShare($share); + if ( + $share->getShareType() !== IShare::TYPE_USER && + $share->getShareType() !== IShare::TYPE_GROUP && + $share->getShareType() !== IShare::TYPE_ROOM + ) { continue; } + + if ($dstMount instanceof \OCA\Files_Sharing\SharedMount) { + if (!($dstMount->getShare()->getPermissions() & Constants::PERMISSION_SHARE)) { + $shareManager->deleteShare($share); + continue; + } + $newOwner = $dstMount->getShare()->getShareOwner(); + $newPermissions = $share->getPermissions() & $dstMount->getShare()->getPermissions(); + } else { + $newOwner = $userFolder->getOwner()->getUID(); + $newPermissions = $share->getPermissions(); + } + $share->setShareOwner($newOwner); - $share->setPermissions($share->getPermissions() & $dstMount->getShare()->getPermissions()); + $share->setPermissions($newPermissions); $shareManager->updateShare($share); } } diff --git a/apps/files_sharing/src/services/ConfigService.js b/apps/files_sharing/src/services/ConfigService.js index cd9bed2a2a7..bfef48a8ade 100644 --- a/apps/files_sharing/src/services/ConfigService.js +++ b/apps/files_sharing/src/services/ConfigService.js @@ -32,8 +32,8 @@ export default class Config { * @memberof Config */ get isPublicUploadEnabled() { - return document.getElementById('filestable') - && document.getElementById('filestable').dataset.allowPublicUpload === 'yes' + return document.getElementsByClassName('files-filestable')[0] + && document.getElementsByClassName('files-filestable')[0].dataset.allowPublicUpload === 'yes' } /** diff --git a/apps/files_sharing/templates/list.php b/apps/files_sharing/templates/list.php index 983e70d4433..023726c6833 100644 --- a/apps/files_sharing/templates/list.php +++ b/apps/files_sharing/templates/list.php @@ -1,7 +1,6 @@ <?php /** @var \OCP\IL10N $l */ ?> -<div id='notification'></div> -<div id="emptycontent" class="hidden"></div> +<div class="emptyfilelist emptycontent hidden"></div> <input type="hidden" name="dir" value="" id="dir"> @@ -10,23 +9,23 @@ <h2><?php p($l->t('No entries found in this folder')); ?></h2> </div> -<table id="filestable" class="list-container <?php p($_['showgridview'] ? 'view-grid' : '') ?>"> +<table class="files-filestable list-container <?php p($_['showgridview'] ? 'view-grid' : '') ?>"> <thead> <tr> - <th id='headerName' class="hidden column-name"> - <div id="headerName-container"> + <th class="hidden column-name"> + <div class="column-name-container"> <a class="name sort columntitle" data-sort="name"><span><?php p($l->t('Name')); ?></span><span class="sort-indicator"></span></a> </div> </th> - <th id="headerDate" class="hidden column-mtime"> - <a id="modified" class="columntitle" data-sort="mtime"><span><?php p($l->t('Share time')); ?></span><span class="sort-indicator"></span></a> + <th class="hidden column-mtime"> + <a class="columntitle" data-sort="mtime"><span><?php p($l->t('Share time')); ?></span><span class="sort-indicator"></span></a> </th> <th class="hidden column-expiration"> <a class="columntitle"><span><?php p($l->t('Expiration date')); ?></span></a> </th> </tr> </thead> - <tbody id="fileList"> + <tbody class="files-fileList"> </tbody> <tfoot> </tfoot> diff --git a/apps/files_sharing/templates/public.php b/apps/files_sharing/templates/public.php index d49c7a01b63..0e8f59e9f2a 100644 --- a/apps/files_sharing/templates/public.php +++ b/apps/files_sharing/templates/public.php @@ -105,7 +105,7 @@ $maxUploadFilesize = min($upload_max_filesize, $post_max_size); <div id="public-upload"> <div id="emptycontent" - class="<?php if (!empty($_['note'])) { ?>has-note<?php } ?>"> + class="emptycontent <?php if (!empty($_['note'])) { ?>has-note<?php } ?>"> <?php if ($_['shareOwner']) { ?> <div id="displayavatar"><div class="avatardiv"></div></div> <h2><?php p($l->t('Upload files to %s', [$_['shareOwner']])) ?></h2> diff --git a/apps/files_sharing/tests/UpdaterTest.php b/apps/files_sharing/tests/UpdaterTest.php index 464dff412a8..fbdfad2f9cb 100644 --- a/apps/files_sharing/tests/UpdaterTest.php +++ b/apps/files_sharing/tests/UpdaterTest.php @@ -237,4 +237,123 @@ class UpdaterTest extends TestCase { // cleanup $this->shareManager->deleteShare($share); } + + /** + * If a folder gets moved into shared folder, children shares should have their uid_owner and permissions adjusted + * user1 + * |-folder1 --> shared with user2 + * user2 + * |-folder2 --> shared with user3 and moved into folder1 + * |-subfolder1 --> shared with user3 + * |-file1.txt --> shared with user3 + * |-subfolder2 + * |-file2.txt --> shared with user3 + */ + public function testMovedIntoShareChangeOwner() { + $this->markTestSkipped('Skipped because this is failing with S3 as primary as file id are change when moved.'); + + // user1 creates folder1 + $viewUser1 = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER1 . '/files'); + $folder1 = 'folder1'; + $viewUser1->mkdir($folder1); + + // user1 shares folder1 to user2 + $folder1Share = $this->share( + IShare::TYPE_USER, + $folder1, + self::TEST_FILES_SHARING_API_USER1, + self::TEST_FILES_SHARING_API_USER2, + \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_SHARE + ); + + $this->loginHelper(self::TEST_FILES_SHARING_API_USER2); + $viewUser2 = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files'); + // Create user2 files + $folder2 = 'folder2'; + $viewUser2->mkdir($folder2); + $file1 = 'folder2/file1.txt'; + $viewUser2->touch($file1); + $subfolder1 = 'folder2/subfolder1'; + $viewUser2->mkdir($subfolder1); + $subfolder2 = 'folder2/subfolder2'; + $viewUser2->mkdir($subfolder2); + $file2 = 'folder2/subfolder2/file2.txt'; + $viewUser2->touch($file2); + + // user2 shares folder2 to user3 + $folder2Share = $this->share( + IShare::TYPE_USER, + $folder2, + self::TEST_FILES_SHARING_API_USER2, + self::TEST_FILES_SHARING_API_USER3, + \OCP\Constants::PERMISSION_ALL + ); + // user2 shares folder2/file1 to user3 + $file1Share = $this->share( + IShare::TYPE_USER, + $file1, + self::TEST_FILES_SHARING_API_USER2, + self::TEST_FILES_SHARING_API_USER3, + \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_SHARE + ); + // user2 shares subfolder1 to user3 + $subfolder1Share = $this->share( + IShare::TYPE_USER, + $subfolder1, + self::TEST_FILES_SHARING_API_USER2, + self::TEST_FILES_SHARING_API_USER3, + \OCP\Constants::PERMISSION_ALL + ); + // user2 shares subfolder2/file2.txt to user3 + $file2Share = $this->share( + IShare::TYPE_USER, + $file2, + self::TEST_FILES_SHARING_API_USER2, + self::TEST_FILES_SHARING_API_USER3, + \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_SHARE + ); + + // user2 moves folder2 into folder1 + $viewUser2->rename($folder2, $folder1.'/'.$folder2); + $folder2Share = $this->shareManager->getShareById($folder2Share->getFullId()); + $file1Share = $this->shareManager->getShareById($file1Share->getFullId()); + $subfolder1Share = $this->shareManager->getShareById($subfolder1Share->getFullId()); + $file2Share = $this->shareManager->getShareById($file2Share->getFullId()); + + // Expect uid_owner of both shares to be user1 + $this->assertEquals(self::TEST_FILES_SHARING_API_USER1, $folder2Share->getShareOwner()); + $this->assertEquals(self::TEST_FILES_SHARING_API_USER1, $file1Share->getShareOwner()); + $this->assertEquals(self::TEST_FILES_SHARING_API_USER1, $subfolder1Share->getShareOwner()); + $this->assertEquals(self::TEST_FILES_SHARING_API_USER1, $file2Share->getShareOwner()); + // Expect permissions to be limited by the permissions of the destination share + $this->assertEquals(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_SHARE, $folder2Share->getPermissions()); + $this->assertEquals(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_SHARE, $file1Share->getPermissions()); + $this->assertEquals(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_SHARE, $subfolder1Share->getPermissions()); + $this->assertEquals(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_SHARE, $file2Share->getPermissions()); + + // user2 moves folder2 out of folder1 + $viewUser2->rename($folder1.'/'.$folder2, $folder2); + $folder2Share = $this->shareManager->getShareById($folder2Share->getFullId()); + $file1Share = $this->shareManager->getShareById($file1Share->getFullId()); + $subfolder1Share = $this->shareManager->getShareById($subfolder1Share->getFullId()); + $file2Share = $this->shareManager->getShareById($file2Share->getFullId()); + + // Expect uid_owner of both shares to be user2 + $this->assertEquals(self::TEST_FILES_SHARING_API_USER2, $folder2Share->getShareOwner()); + $this->assertEquals(self::TEST_FILES_SHARING_API_USER2, $file1Share->getShareOwner()); + $this->assertEquals(self::TEST_FILES_SHARING_API_USER2, $subfolder1Share->getShareOwner()); + $this->assertEquals(self::TEST_FILES_SHARING_API_USER2, $file2Share->getShareOwner()); + // Expect permissions to not change + $this->assertEquals(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_SHARE, $folder2Share->getPermissions()); + $this->assertEquals(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_SHARE, $file1Share->getPermissions()); + $this->assertEquals(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_SHARE, $subfolder1Share->getPermissions()); + $this->assertEquals(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_SHARE, $file2Share->getPermissions()); + + // cleanup + $this->shareManager->deleteShare($folder1Share); + $this->shareManager->deleteShare($folder2Share); + $this->shareManager->deleteShare($file1Share); + $this->shareManager->deleteShare($subfolder1Share); + $this->shareManager->deleteShare($file2Share); + } } diff --git a/apps/files_sharing/tests/js/appSpec.js b/apps/files_sharing/tests/js/appSpec.js index e1249f5b4d7..4d2e5211d7c 100644 --- a/apps/files_sharing/tests/js/appSpec.js +++ b/apps/files_sharing/tests/js/appSpec.js @@ -95,7 +95,7 @@ describe('OCA.Sharing.App tests', function() { var setActiveViewStub = sinon.stub(OCA.Files.App, 'setActiveView'); // create dummy table so we can click the dom - var $table = '<table><thead></thead><tbody id="fileList"></tbody></table>'; + var $table = '<table><thead></thead><tbody class="files-fileList"></tbody></table>'; $('#app-content-sharingin').append($table); App._inFileList = null; diff --git a/apps/files_sharing/tests/js/publicAppSpec.js b/apps/files_sharing/tests/js/publicAppSpec.js index ed88913b1f6..b9d8cbe28e2 100644 --- a/apps/files_sharing/tests/js/publicAppSpec.js +++ b/apps/files_sharing/tests/js/publicAppSpec.js @@ -59,7 +59,7 @@ describe('OCA.Sharing.PublicApp tests', function() { '<input type="hidden" id="dir" value="/subdir"/>' + '<input type="hidden" id="permissions" value="31"/>' + // dummy controls - '<div id="controls">' + + '<div class="files-controls">' + ' <div class="actions creatable"></div>' + ' <div class="notCreatable"></div>' + '</div>' + @@ -67,9 +67,9 @@ describe('OCA.Sharing.PublicApp tests', function() { '<input type="file" id="file_upload_start" name="files[]" multiple="multiple">' + // dummy table // TODO: at some point this will be rendered by the fileList class itself! - '<table id="filestable" class="list-container view-grid">' + + '<table class="files-filestable list-container view-grid">' + '<thead><tr>' + - '<th id="headerName" class="hidden column-name">' + + '<th class="hidden column-name">' + '<input type="checkbox" id="select_all_files" class="select-all">' + '<a class="name columntitle" data-sort="name"><span>Name</span><span class="sort-indicator"></span></a>' + '<span class="selectedActions hidden">' + @@ -78,11 +78,11 @@ describe('OCA.Sharing.PublicApp tests', function() { '<th class="hidden column-size"><a class="columntitle" data-sort="size"><span class="sort-indicator"></span></a></th>' + '<th class="hidden column-mtime"><a class="columntitle" data-sort="mtime"><span class="sort-indicator"></span></a></th>' + '</tr></thead>' + - '<tbody id="fileList"></tbody>' + + '<tbody class="files-fileList"></tbody>' + '<tfoot></tfoot>' + '</table>' + // TODO: move to handlebars template - '<div id="emptycontent"><h2>Empty content message</h2><p class="uploadmessage">Upload message</p></div>' + + '<div class="emptyfilelist emptycontent"><h2>Empty content message</h2><p class="uploadmessage">Upload message</p></div>' + '<div class="nofilterresults hidden"></div>' + '</div>' ); diff --git a/apps/files_sharing/tests/js/shareSpec.js b/apps/files_sharing/tests/js/shareSpec.js index f99c838eda3..6b4dd35ec85 100644 --- a/apps/files_sharing/tests/js/shareSpec.js +++ b/apps/files_sharing/tests/js/shareSpec.js @@ -46,9 +46,9 @@ describe('OCA.Sharing.Util tests', function() { // dummy file list var $div = $( '<div id="listContainer">' + - '<table id="filestable" class="list-container view-grid">' + + '<table class="files-filestable list-container view-grid">' + '<thead></thead>' + - '<tbody id="fileList"></tbody>' + + '<tbody class="files-fileList"></tbody>' + '</table>' + '</div>'); $('#content').append($div); |