-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
[stable28] fix(files): Make the navigation reactive to view changes and show also sub routes as active #43119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
24f4997
fix(files): Add declaration for `$navigation`
susnux d1fc93e
fix(files): Set default view and match also child routes
susnux 5db658c
fix(files): Make sure `$navigation` is observable to react on changes
susnux 3add75c
fix(files): Make sure to add the `fileid` on favorite folders navigat…
susnux 6a5181f
fix(files): Ensure the correct `dir` query is set on folder action
susnux 732283f
chore(assets): Recompile assets
nextcloud-command File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
| * | ||
| * @author Christoph Wurst <[email protected]> | ||
| * @author Joas Schilling <[email protected]> | ||
| * @author Ferdinand Thiessen <[email protected]> | ||
| * | ||
| * @license AGPL-3.0 | ||
| * | ||
|
|
@@ -23,30 +24,30 @@ | |
| namespace OCA\Files\Activity; | ||
|
|
||
| use OCP\Files\Folder; | ||
| use OCP\Files\IRootFolder; | ||
| use OCP\Files\Node; | ||
| use OCP\ITagManager; | ||
|
|
||
| class Helper { | ||
| /** If a user has a lot of favorites the query might get too slow and long */ | ||
| public const FAVORITE_LIMIT = 50; | ||
|
|
||
| /** @var ITagManager */ | ||
| protected $tagManager; | ||
|
|
||
| /** | ||
| * @param ITagManager $tagManager | ||
| */ | ||
| public function __construct(ITagManager $tagManager) { | ||
| $this->tagManager = $tagManager; | ||
| public function __construct( | ||
| protected ITagManager $tagManager, | ||
| protected IRootFolder $rootFolder, | ||
| ) { | ||
| } | ||
|
|
||
| /** | ||
| * Returns an array with the favorites | ||
| * Return an array with nodes marked as favorites | ||
| * | ||
| * @param string $user | ||
| * @return array | ||
| * @param string $user User ID | ||
| * @param bool $foldersOnly Only return folders (default false) | ||
| * @return Node[] | ||
| * @psalm-return ($foldersOnly is true ? Folder[] : Node[]) | ||
| * @throws \RuntimeException when too many or no favorites where found | ||
| */ | ||
| public function getFavoriteFilePaths($user) { | ||
| public function getFavoriteNodes(string $user, bool $foldersOnly = false): array { | ||
| $tags = $this->tagManager->load('files', [], false, $user); | ||
| $favorites = $tags->getFavorites(); | ||
|
|
||
|
|
@@ -57,26 +58,45 @@ public function getFavoriteFilePaths($user) { | |
| } | ||
|
|
||
| // Can not DI because the user is not known on instantiation | ||
| $rootFolder = \OC::$server->getUserFolder($user); | ||
| $folders = $items = []; | ||
| $userFolder = $this->rootFolder->getUserFolder($user); | ||
| $favoriteNodes = []; | ||
| foreach ($favorites as $favorite) { | ||
| $nodes = $rootFolder->getById($favorite); | ||
| $nodes = $userFolder->getById($favorite); | ||
| if (!empty($nodes)) { | ||
| /** @var \OCP\Files\Node $node */ | ||
| $node = array_shift($nodes); | ||
| $path = substr($node->getPath(), strlen($user . '/files/')); | ||
|
|
||
| $items[] = $path; | ||
| if ($node instanceof Folder) { | ||
| $folders[] = $path; | ||
| if (!$foldersOnly || $node instanceof Folder) { | ||
| $favoriteNodes[] = $node; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| if (empty($items)) { | ||
| if (empty($favoriteNodes)) { | ||
| throw new \RuntimeException('No favorites', 1); | ||
| } | ||
|
|
||
| return $favoriteNodes; | ||
| } | ||
|
|
||
| /** | ||
| * Returns an array with the favorites | ||
| * | ||
| * @param string $user | ||
| * @return array | ||
| * @throws \RuntimeException when too many or no favorites where found | ||
| */ | ||
| public function getFavoriteFilePaths(string $user): array { | ||
| $userFolder = $this->rootFolder->getUserFolder($user); | ||
| $nodes = $this->getFavoriteNodes($user); | ||
| $folders = $items = []; | ||
| foreach ($nodes as $node) { | ||
| $path = $userFolder->getRelativePath($node->getPath()); | ||
|
|
||
| $items[] = $path; | ||
| if ($node instanceof Folder) { | ||
| $folders[] = $path; | ||
| } | ||
| } | ||
|
|
||
| return [ | ||
| 'items' => $items, | ||
| 'folders' => $folders, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.