show full path for trashbin tooltip

This commit is contained in:
Robin Appelman 2019-10-02 16:49:35 +02:00
parent af5bae52da
commit fd64ab8248
3 changed files with 42 additions and 8 deletions

View file

@ -30,7 +30,7 @@ Note: encrypting the contents of group folders is currently not supported.]]></d
<screenshot>https://raw.githubusercontent.com/nextcloud/groupfolders/master/screenshots/permissions.png</screenshot>
<dependencies>
<nextcloud min-version="17" max-version="17" />
<nextcloud min-version="17" max-version="18" />
</dependencies>
<background-jobs>

View file

@ -21,10 +21,36 @@
namespace OCA\GroupFolders\Trash;
use OCA\Files_Trashbin\Trash\ITrashBackend;
use OCA\Files_Trashbin\Trash\TrashItem;
use OCP\Files\FileInfo;
use OCP\IUser;
class GroupTrashItem extends TrashItem {
private $mountPoint;
public function __construct(
ITrashBackend $backend,
string $originalLocation,
int $deletedTime,
string $trashPath,
FileInfo $fileInfo,
IUser $user,
string $mountPoint
) {
parent::__construct($backend, $originalLocation, $deletedTime, $trashPath, $fileInfo, $user);
$this->mountPoint = $mountPoint;
}
public function isRootItem(): bool {
return substr_count($this->getTrashPath(), '/') === 2;
}
public function getGroupFolderMountPoint(): string {
return $this->mountPoint;
}
public function getTitle(): string {
return $this->getGroupFolderMountPoint() . '/' . $this->getOriginalLocation();
}
}

View file

@ -60,12 +60,13 @@ class TrashBackend implements ITrashBackend {
public function listTrashRoot(IUser $user): array {
$folders = $this->folderManager->getFoldersForUser($user);
return $this->getTrashForFolders($user, array_map(function (array $folder) {
return $folder['folder_id'];
}, $folders));
return $this->getTrashForFolders($user, $folders);
}
public function listTrashFolder(ITrashItem $trashItem): array {
if (!$trashItem instanceof GroupTrashItem) {
return [];
}
$user = $trashItem->getUser();
$folder = $this->getNodeForTrashItem($user, $trashItem);
if (!$folder instanceof Folder) {
@ -79,7 +80,8 @@ class TrashBackend implements ITrashBackend {
$trashItem->getDeletedTime(),
$trashItem->getTrashPath() . '/' . $node->getName(),
$node,
$user
$user,
$trashItem->getGroupFolderMountPoint()
);
}, $content);
}
@ -199,7 +201,10 @@ class TrashBackend implements ITrashBackend {
}
}
private function getTrashForFolders(IUser $user, array $folderIds) {
private function getTrashForFolders(IUser $user, array $folders) {
$folderIds = array_map(function(array $folder) {
return $folder['folder_id'];
}, $folders);
$rows = $this->trashManager->listTrashForFolders($folderIds);
$indexedRows = [];
foreach ($rows as $row) {
@ -207,7 +212,9 @@ class TrashBackend implements ITrashBackend {
$indexedRows[$key] = $row;
}
$items = [];
foreach ($folderIds as $folderId) {
foreach ($folders as $folder) {
$folderId = $folder['folder_id'];
$mountPoint = $folder['mount_point'];
$trashFolder = $this->getTrashFolder($folderId);
$content = $trashFolder->getDirectoryListing();
foreach ($content as $item) {
@ -224,7 +231,8 @@ class TrashBackend implements ITrashBackend {
$timestamp,
'/' . $folderId . '/' . $item->getName(),
$info,
$user
$user,
$mountPoint
);
}
}