Browse Source

Merge pull request #26571 from nextcloud/bugfix/noid/existing-link-no-reshare

Only allow removing existing shares that would not be allowed due to reshare restrictions
blizzz 2 years ago
parent
commit
818fc95b03

File diff suppressed because it is too large
+ 0 - 0
apps/files_sharing/js/dist/files_sharing_tab.js


File diff suppressed because it is too large
+ 0 - 0
apps/files_sharing/js/dist/files_sharing_tab.js.map


+ 6 - 0
apps/files_sharing/lib/Updater.php

@@ -26,6 +26,7 @@
  */
 namespace OCA\Files_Sharing;
 
+use OCP\Constants;
 use OCP\Share\IShare;
 
 class Updater {
@@ -81,7 +82,12 @@ class Updater {
 		//Ownership is moved over
 		foreach ($shares as $share) {
 			/** @var IShare $share */
+			if (!($dstMount->getShare()->getPermissions() & Constants::PERMISSION_SHARE)) {
+				$shareManager->deleteShare($share);
+				continue;
+			}
 			$share->setShareOwner($newOwner);
+			$share->setPermissions($share->getPermissions() & $dstMount->getShare()->getPermissions());
 			$shareManager->updateShare($share);
 		}
 	}

+ 1 - 1
apps/files_sharing/src/components/SharingEntryLink.vue

@@ -131,7 +131,7 @@
 			:open.sync="open"
 			@close="onMenuClose">
 			<template v-if="share">
-				<template v-if="share.canEdit">
+				<template v-if="share.canEdit && canReshare">
 					<!-- Custom Label -->
 					<ActionInput
 						ref="label"

+ 16 - 4
tests/acceptance/features/bootstrap/FilesAppSharingContext.php

@@ -220,6 +220,15 @@ class FilesAppSharingContext implements Context, ActorAwareInterface {
 				describedAs("Share link menu trigger in the details view in Files app");
 	}
 
+	/**
+	 * @return Locator
+	 */
+	public static function shareLinkSingleUnshareAction() {
+		return Locator::forThe()->css(".sharing-entry__actions.icon-close")->
+			descendantOf(self::shareLinkRow())->
+			describedAs("Unshare link single action in the details view in Files app");
+	}
+
 	/**
 	 * @return Locator
 	 */
@@ -505,10 +514,13 @@ class FilesAppSharingContext implements Context, ActorAwareInterface {
 	 * @When I unshare the link share
 	 */
 	public function iUnshareTheLink() {
-		$this->showShareLinkMenuIfNeeded();
-
-		$shareLinkMenuTriggerElement = $this->actor->find(self::shareLinkMenuTrigger(), 2);
-		$this->actor->find(self::unshareLinkButton($shareLinkMenuTriggerElement), 2)->click();
+		try {
+			$this->actor->find(self::shareLinkSingleUnshareAction(), 2)->click();
+		} catch (NoSuchElementException $e) {
+			$this->showShareLinkMenuIfNeeded();
+			$shareLinkMenuTriggerElement = $this->actor->find(self::shareLinkMenuTrigger(), 2);
+			$this->actor->find(self::unshareLinkButton($shareLinkMenuTriggerElement), 2)->click();
+		}
 	}
 
 	/**

Some files were not shown because too many files changed in this diff