-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Collaboration resources #11871
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
Collaboration resources #11871
Changes from all commits
Commits
Show all changes
53 commits
Select commit
Hold shift + click to select a range
69b530a
Basic implementation of resource and collection handling
nickvergessen 65a9ab4
Add a controller with the most important methods
nickvergessen 136d2c3
Provider functionality
nickvergessen 5dfc56e
Allow to create collections
nickvergessen 702dcfb
Make names mandatory
nickvergessen ab4b293
Insert new collection into database
juliusknorr d6aae43
Move files_sharing to webpack
juliusknorr 322f7c3
Add vue app for collaboration resources
juliusknorr a72a6d7
Adjust parameter names on createCollectionOnResource
juliusknorr 7a4b2db
Add javascript API for collaboration resources
juliusknorr 51057c5
Use proper public javascript methods
juliusknorr 7843b8b
Adjust OCP.Collaboration
juliusknorr 555afff
Make sure we query the node before fetching the name
juliusknorr 88aa3de
Add iconClass to resources
juliusknorr d85e3e3
Allow apps to register resource providers
juliusknorr 506eb88
Only call resource provider if type matches
juliusknorr 3777df6
Add link to resource provider
juliusknorr 53ac9bd
Implement frontend for search/rename
juliusknorr e404ce7
Implement search and rename in backend
juliusknorr d1a4856
Add eslint settings and reorganize files
juliusknorr 31340b8
Add icon for resource type and icons for folder/file
juliusknorr dee6f7f
Fix doc blocks
nickvergessen ece471d
Start implementing access cache
nickvergessen 59c92a7
Further work on the access cache
nickvergessen a8a5472
Improve searchCollections()
nickvergessen c8c59e6
Make sure the results are always sorted the same
nickvergessen 103298e
Use icon-close to remove resources
juliusknorr fd434da
Fix SQL statement and provider method call
juliusknorr cab704f
Merge webpack into main one
juliusknorr 7207a77
Use nextcloud-vue-collections library
juliusknorr 43c8d0c
Add default value, because null does not trigger unique-key
nickvergessen eecd932
Also check the access to collections on preparing
nickvergessen 995cad0
Cache the access manually too
nickvergessen 901f1d4
Don't throw on UniqueConstraintViolationException since a written val…
nickvergessen 30dff37
Add invalidation methods to the interface
nickvergessen 1a73cab
Fix doc block
nickvergessen 066238a
Fix unused variable $access
nickvergessen 4113505
Also cache the resource type because it is part of the identifier
nickvergessen 55ae7fa
Invalidate the cache when a share is updated
nickvergessen 01b4db6
Add dispatcher events to User and Group objects
nickvergessen 752276f
Add a listener for the events
nickvergessen fdfe984
Register providers via class names
nickvergessen 1c4436d
Access for a collection can only become true
nickvergessen 55cd9ea
Update autoloader
nickvergessen 37e6488
Use nextcloud-vue-collection 0.1.2
juliusknorr ba2b542
Listen to IUser::postDelete
juliusknorr 6ee7286
Fix tests
juliusknorr c778032
Properly handle null as ownerId if file system access is denied by ac…
juliusknorr e5162fb
Fix tests
juliusknorr f0e50bc
Fetch node and filename also if access cache was used
juliusknorr 0c32b21
Fix files_external tests
nickvergessen 48f34b8
Add bundled files
juliusknorr ca0624d
Remove unneeded files
juliusknorr 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| <?php | ||
| declare(strict_types=1); | ||
| /** | ||
| * @copyright Copyright (c) 2019 Joas Schilling <[email protected]> | ||
| * | ||
| * @license GNU AGPL version 3 or any later version | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU Affero General Public License as | ||
| * published by the Free Software Foundation, either version 3 of the | ||
| * License, or (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU Affero General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Affero General Public License | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| * | ||
| */ | ||
|
|
||
| namespace OCA\Files\Collaboration\Resources; | ||
|
|
||
|
|
||
| use OCP\Collaboration\Resources\IManager; | ||
| use Symfony\Component\EventDispatcher\EventDispatcherInterface; | ||
|
|
||
| class Listener { | ||
| public static function register(EventDispatcherInterface $dispatcher): void { | ||
| $dispatcher->addListener('OCP\Share::postShare', [self::class, 'shareModification']); | ||
| $dispatcher->addListener('OCP\Share::postUnshare', [self::class, 'shareModification']); | ||
| $dispatcher->addListener('OCP\Share::postUnshareFromSelf', [self::class, 'shareModification']); | ||
| } | ||
|
|
||
| public static function shareModification(): void { | ||
| /** @var IManager $resourceManager */ | ||
| $resourceManager = \OC::$server->query(IManager::class); | ||
| /** @var ResourceProvider $resourceProvider */ | ||
| $resourceProvider = \OC::$server->query(ResourceProvider::class); | ||
|
|
||
| $resourceManager->invalidateAccessCacheForProvider($resourceProvider); | ||
| } | ||
| } |
140 changes: 140 additions & 0 deletions
140
apps/files/lib/Collaboration/Resources/ResourceProvider.php
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 |
|---|---|---|
| @@ -0,0 +1,140 @@ | ||
| <?php | ||
| /** | ||
| * @copyright Copyright (c) 2018 Joas Schilling <[email protected]> | ||
| * | ||
| * @license GNU AGPL version 3 or any later version | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU Affero General Public License as | ||
| * published by the Free Software Foundation, either version 3 of the | ||
| * License, or (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU Affero General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Affero General Public License | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| * | ||
| */ | ||
|
|
||
| namespace OCA\Files\Collaboration\Resources; | ||
|
|
||
|
|
||
| use OCP\Collaboration\Resources\IProvider; | ||
| use OCP\Collaboration\Resources\IResource; | ||
| use OCP\Collaboration\Resources\ResourceException; | ||
| use OCP\Files\IRootFolder; | ||
| use OCP\Files\Node; | ||
| use OCP\IURLGenerator; | ||
| use OCP\IUser; | ||
|
|
||
| class ResourceProvider implements IProvider { | ||
|
|
||
| const RESOURCE_TYPE = 'files'; | ||
|
|
||
| /** @var IRootFolder */ | ||
| protected $rootFolder; | ||
|
|
||
| /** @var IURLGenerator */ | ||
| private $urlGenerator; | ||
|
|
||
| /** @var array */ | ||
| protected $nodes = []; | ||
|
|
||
| public function __construct(IRootFolder $rootFolder, IURLGenerator $urlGenerator) { | ||
| $this->rootFolder = $rootFolder; | ||
| $this->urlGenerator = $urlGenerator; | ||
| } | ||
|
|
||
| private function getNode(IResource $resource): ?Node { | ||
| if (isset($this->nodes[(int) $resource->getId()])) { | ||
| return $this->nodes[(int) $resource->getId()]; | ||
| } | ||
| $nodes = $this->rootFolder->getById((int) $resource->getId()); | ||
| if (!empty($nodes)) { | ||
| $this->nodes[(int) $resource->getId()] = array_shift($nodes); | ||
| return $this->nodes[(int) $resource->getId()]; | ||
| } | ||
| return null; | ||
| } | ||
|
|
||
| /** | ||
| * Get the display name of a resource | ||
| * | ||
| * @param IResource $resource | ||
| * @return string | ||
| * @since 15.0.0 | ||
| */ | ||
| public function getName(IResource $resource): string { | ||
| if (isset($this->nodes[(int) $resource->getId()])) { | ||
| return $this->nodes[(int) $resource->getId()]->getPath(); | ||
| } | ||
| $node = $this->getNode($resource); | ||
| if ($node) { | ||
| return $node->getName(); | ||
| } | ||
| return ''; | ||
| } | ||
|
|
||
| /** | ||
| * Can a user/guest access the collection | ||
| * | ||
| * @param IResource $resource | ||
| * @param IUser $user | ||
| * @return bool | ||
| * @since 15.0.0 | ||
| */ | ||
| public function canAccessResource(IResource $resource, IUser $user = null): bool { | ||
| if (!$user instanceof IUser) { | ||
| return false; | ||
| } | ||
|
|
||
| $userFolder = $this->rootFolder->getUserFolder($user->getUID()); | ||
| $nodes = $userFolder->getById((int) $resource->getId()); | ||
|
|
||
| if (!empty($nodes)) { | ||
| $this->nodes[(int) $resource->getId()] = array_shift($nodes); | ||
| return true; | ||
| } | ||
|
|
||
| return false; | ||
| } | ||
|
|
||
| /** | ||
| * Get the icon class of a resource | ||
| * | ||
| * @param IResource $resource | ||
| * @return string | ||
| * @since 15.0.0 | ||
| */ | ||
| public function getIconClass(IResource $resource): string { | ||
| $node = $this->getNode($resource); | ||
| if ($node && $node->getMimetype() === 'httpd/unix-directory') { | ||
| return 'icon-files-dark'; | ||
| } | ||
| return 'icon-filetype-file'; | ||
| } | ||
|
|
||
| /** | ||
| * Get the resource type of the provider | ||
| * | ||
| * @return string | ||
| * @since 15.0.0 | ||
| */ | ||
| public function getType(): string { | ||
| return self::RESOURCE_TYPE; | ||
| } | ||
|
|
||
| /** | ||
| * Get the link to a resource | ||
| * | ||
| * @param IResource $resource | ||
| * @return string | ||
| * @since 15.0.0 | ||
| */ | ||
| public function getLink(IResource $resource): string { | ||
| return $this->urlGenerator->linkToRoute('files.viewcontroller.showFile', ['fileid' => $resource->getId()]); | ||
| } | ||
| } | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| module.exports = { | ||
| presets: [ | ||
| [ | ||
| '@babel/preset-env', | ||
| { | ||
| targets: { | ||
| browsers: ['last 2 versions', 'ie >= 11'] | ||
| } | ||
| } | ||
| ] | ||
| ], | ||
| plugins: ['@babel/plugin-syntax-dynamic-import'] | ||
| } |
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 |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| module.exports = { | ||
| env: { | ||
| browser: true, | ||
| es6: true | ||
| }, | ||
| globals: { | ||
| t: true, | ||
| n: true, | ||
| OC: true, | ||
| OCA: true | ||
| }, | ||
| extends: 'eslint:recommended', | ||
| parserOptions: { | ||
| sourceType: 'module' | ||
| }, | ||
| rules: { | ||
| indent: ['error', 'tab'], | ||
| 'linebreak-style': ['error', 'unix'], | ||
| quotes: ['error', 'single'], | ||
| semi: ['error', 'always'] | ||
| } | ||
| }; |
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.