From 29e1e938d55dea4f0221329d8d5545f48ceb6841 Mon Sep 17 00:00:00 2001 From: Marcel Klehr Date: Sun, 10 Dec 2023 15:35:38 +0100 Subject: [PATCH] fix: drop collaboration resources integration to be compatible with nc 28 Signed-off-by: Marcel Klehr --- lib/AppInfo/Application.php | 15 ---- .../Resources/FolderResourceProvider.php | 90 ------------------- .../Resources/ResourceProvider.php | 90 ------------------- src/collections.js | 51 ----------- templates/main.php | 1 - webpack.js | 1 - 6 files changed, 248 deletions(-) delete mode 100644 lib/Collaboration/Resources/FolderResourceProvider.php delete mode 100644 lib/Collaboration/Resources/ResourceProvider.php delete mode 100644 src/collections.js diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 43a711ab7c..7b7a87fd1f 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -8,11 +8,7 @@ namespace OCA\Bookmarks\AppInfo; -use Closure; -use OC\EventDispatcher\SymfonyAdapter; use OCA\Bookmarks\Activity\ActivityPublisher; -use OCA\Bookmarks\Collaboration\Resources\FolderResourceProvider; -use OCA\Bookmarks\Collaboration\Resources\ResourceProvider; use OCA\Bookmarks\Dashboard\Frequent; use OCA\Bookmarks\Dashboard\Recent; use OCA\Bookmarks\Events\BeforeDeleteEvent; @@ -32,7 +28,6 @@ use OCP\AppFramework\Bootstrap\IRegistrationContext; use OCP\AppFramework\Http\Events\BeforeTemplateRenderedEvent; use OCP\Collaboration\Reference\RenderReferenceEvent; -use OCP\Collaboration\Resources\IProviderManager; use OCP\EventDispatcher\IEventDispatcher; use OCP\Group\Events\UserAddedEvent; use OCP\Group\Events\UserRemovedEvent; @@ -101,17 +96,7 @@ public function register(IRegistrationContext $context): void { * @throws \Throwable */ public function boot(IBootContext $context): void { - $context->injectFn(Closure::fromCallable([$this, 'registerCollaborationResources'])); $container = $context->getServerContainer(); CreateBookmark::register($container->get(IEventDispatcher::class)); } - - protected function registerCollaborationResources(IProviderManager $resourceManager, SymfonyAdapter $symfonyAdapter): void { - $resourceManager->registerResourceProvider(ResourceProvider::class); - $resourceManager->registerResourceProvider(FolderResourceProvider::class); - - $symfonyAdapter->addListener('\OCP\Collaboration\Resources::loadAdditionalScripts', static function () { - Util::addScript('bookmarks', 'bookmarks-collections'); - }); - } } diff --git a/lib/Collaboration/Resources/FolderResourceProvider.php b/lib/Collaboration/Resources/FolderResourceProvider.php deleted file mode 100644 index 1ffc1a2c5a..0000000000 --- a/lib/Collaboration/Resources/FolderResourceProvider.php +++ /dev/null @@ -1,90 +0,0 @@ -url = $url; - $this->authorizer = $authorizer; - $this->folderMapper = $folderMapper; - } - - /** - * @inheritDoc - */ - public function getType(): string { - return self::RESOURCE_TYPE; - } - - /** - * @inheritDoc - */ - public function getResourceRichObject(IResource $resource): array { - $folder = $this->getFolder($resource); - $favicon = $this->url->imagePath('bookmarks', 'bookmarks-black.svg'); - $resourceUrl = $this->url->linkToRouteAbsolute('bookmarks.web_view.indexfolder', ['folder' => $folder->getId()]); - - return [ - 'type' => self::RESOURCE_TYPE, - 'id' => $resource->getId(), - 'name' => $folder->getTitle(), - 'link' => $resourceUrl, - 'iconUrl' => $favicon, - ]; - } - - /** - * @inheritDoc - */ - public function canAccessResource(IResource $resource, ?IUser $user): bool { - if ($resource->getType() !== self::RESOURCE_TYPE || !($user instanceof IUser)) { - return false; - } - $folder = $this->getFolder($resource); - if ($folder === null) { - return false; - } - if ($folder->getUserId() === $user->getUID()) { - return true; - } - $permissions = $this->authorizer->getUserPermissionsForFolder($user->getUID(), $folder->getId()); - return Authorizer::hasPermission(Authorizer::PERM_READ, $permissions); - } - - private function getFolder(IResource $resource) : ?Folder { - try { - return $this->folderMapper->find((int) $resource->getId()); - } catch (MultipleObjectsReturnedException|DoesNotExistException $e) { - return null; - } - } -} diff --git a/lib/Collaboration/Resources/ResourceProvider.php b/lib/Collaboration/Resources/ResourceProvider.php deleted file mode 100644 index 52701743ff..0000000000 --- a/lib/Collaboration/Resources/ResourceProvider.php +++ /dev/null @@ -1,90 +0,0 @@ -bookmarkMapper = $bookmarkMapper; - $this->url = $url; - $this->authorizer = $authorizer; - } - - /** - * @inheritDoc - */ - public function getType(): string { - return self::RESOURCE_TYPE; - } - - /** - * @inheritDoc - */ - public function getResourceRichObject(IResource $resource): array { - $bookmark = $this->getBookmark($resource); - $favicon = $this->url->linkToRouteAbsolute('bookmarks.internal_bookmark.get_bookmark_favicon', ['id' => $bookmark->getId()]); - $resourceUrl = $this->url->linkToRouteAbsolute('bookmarks.web_view.indexbookmark', ['bookmark' => $bookmark->getId()]); - - return [ - 'type' => self::RESOURCE_TYPE, - 'id' => $resource->getId(), - 'name' => $bookmark->getTitle(), - 'link' => $resourceUrl, - 'iconUrl' => $favicon, - ]; - } - - /** - * @inheritDoc - */ - public function canAccessResource(IResource $resource, ?IUser $user): bool { - if ($resource->getType() !== self::RESOURCE_TYPE || !($user instanceof IUser)) { - return false; - } - $bookmark = $this->getBookmark($resource); - if ($bookmark === null) { - return false; - } - if ($bookmark->getUserId() === $user->getUID()) { - return true; - } - $permissions = $this->authorizer->getUserPermissionsForBookmark($user->getUID(), $bookmark->getId()); - return Authorizer::hasPermission(Authorizer::PERM_READ, $permissions); - } - - private function getBookmark(IResource $resource) : ?Bookmark { - try { - return $this->bookmarkMapper->find((int) $resource->getId()); - } catch (MultipleObjectsReturnedException|DoesNotExistException $e) { - return null; - } - } -} diff --git a/src/collections.js b/src/collections.js deleted file mode 100644 index e3d522cdfd..0000000000 --- a/src/collections.js +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2022. The Nextcloud Bookmarks contributors. - * - * This file is licensed under the Affero General Public License version 3 or later. See the COPYING file. - */ - -import Vue from 'vue' -import FolderPickerDialog from './components/FolderPickerDialog.vue' -import { Store } from 'vuex' -import deepClone from 'clone-deep' -import store, { actions } from './store/index.js' -import AppGlobal from './mixins/AppGlobal.js' -import { Tooltip } from '@nextcloud/vue' - -// eslint-disable-next-line -__webpack_nonce__ = btoa(OC.requestToken) -// eslint-disable-next-line -__webpack_public_path__ = OC.linkTo('bookmarks', 'js/') - -Vue.mixin(AppGlobal) -Vue.directive('tooltip', Tooltip) - -OCP.Collaboration.registerType('bookmarks-folder', { - action: () => { - return new Promise((resolve, reject) => { - const container = document.createElement('div') - container.id = 'bookmarks-bookmark-folder-select' - const body = document.getElementById('body-user') - body.appendChild(container) - const ComponentVM = new Vue({ - render: h => h(FolderPickerDialog), - store: new Store(deepClone(store)), - }) - ComponentVM.$store.dispatch(actions.LOAD_FOLDERS, true) - ComponentVM.$mount(container) - window.bookmarksPicker = ComponentVM - ComponentVM.$root.$on('close', () => { - ComponentVM.$el.remove() - ComponentVM.$destroy() - reject(new Error('User cancelled resource selection')) - }) - ComponentVM.$root.$on('select', (id) => { - resolve(id) - ComponentVM.$el.remove() - ComponentVM.$destroy() - }) - }) - }, - typeString: t('bookmarks', 'Link to a bookmark folder'), - typeIconClass: 'icon-favorite', -}) diff --git a/templates/main.php b/templates/main.php index 82d45c1dad..c94c256df5 100644 --- a/templates/main.php +++ b/templates/main.php @@ -1,5 +1,4 @@ getEventDispatcher()->dispatch('\OCP\Collaboration\Resources::loadAdditionalScripts'); ?>
diff --git a/webpack.js b/webpack.js index 921cd9045f..2d03676e2b 100644 --- a/webpack.js +++ b/webpack.js @@ -8,5 +8,4 @@ webpackConfig.entry['service-worker'] = path.join(__dirname, 'src', 'service-wor webpackConfig.entry.flow = path.join(__dirname, 'src', 'flow.js') webpackConfig.entry.dashboard = path.join(__dirname, 'src', 'dashboard.js') webpackConfig.entry.talk = path.join(__dirname, 'src', 'talk.js') -webpackConfig.entry.collections = path.join(__dirname, 'src', 'collections.js') webpackConfig.entry.references = path.join(__dirname, 'src', 'references.js')