show full path for trashbin tooltip

This commit is contained in:
Robin Appelman 2019-10-02 16:49:35 +02:00
parent c1826286d3
commit 1db5c303c1
2 changed files with 41 additions and 7 deletions

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

@ -67,12 +67,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) {
@ -86,7 +87,8 @@ class TrashBackend implements ITrashBackend {
$trashItem->getDeletedTime(),
$trashItem->getTrashPath() . '/' . $node->getName(),
$node,
$user
$user,
$trashItem->getGroupFolderMountPoint()
);
}, $content);
}
@ -216,7 +218,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) {
@ -224,7 +229,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) {
@ -244,7 +251,8 @@ class TrashBackend implements ITrashBackend {
$timestamp,
'/' . $folderId . '/' . $item->getName(),
$info,
$user
$user,
$mountPoint
);
}
}