0
0
Fork 0
mirror of https://github.com/verdigado/organization_folders.git synced 2024-11-21 11:37:26 +01:00

Load frontend js on files pages

This commit is contained in:
Jonathan Treffler 2024-11-16 03:25:50 +01:00
parent bdc5bf0f9c
commit 816d189422
2 changed files with 58 additions and 0 deletions

View file

@ -11,8 +11,10 @@ use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\IUserSession;
use OCA\DAV\Events\SabrePluginAddEvent;
use OCA\Files\Event\LoadAdditionalScriptsEvent;
use OCA\OrganizationFolders\Listener\SabrePluginAddListener;
use OCA\OrganizationFolders\Listener\LoadAdditionalScripts;
use OCA\OrganizationFolders\Security\AuthorizationService;
use OCA\OrganizationFolders\Security\ResourceVoter;
@ -24,6 +26,7 @@ class Application extends App implements IBootstrap {
}
public function register(IRegistrationContext $context): void {
$context->registerEventListener(LoadAdditionalScriptsEvent::class, LoadAdditionalScripts::class);
$context->registerEventListener(SabrePluginAddEvent::class, SabrePluginAddListener::class);
$context->registerService(AuthorizationService::class, function (ContainerInterface $c) {

View file

@ -0,0 +1,55 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2019, Roeland Jago Douma <roeland@famdouma.nl>
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author John Molakvoæ <skjnldsv@protonmail.com>
* @author Roeland Jago Douma <roeland@famdouma.nl>
* @author Jonathan Treffler <jonathan.treffler@verdigado.com>
*
* @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\OrganizationFolders\Listener;
use OCA\Files\Event\LoadAdditionalScriptsEvent;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCP\AppFramework\Services\IInitialState;
use OCP\App\IAppManager;
use OCP\Util;
use OCA\OrganizationFolders\AppInfo\Application;
class LoadAdditionalScripts implements IEventListener {
public function __construct(
private IAppManager $appManager,
private IInitialState $initialState,
) {}
public function handle(Event $event): void {
if (!($event instanceof LoadAdditionalScriptsEvent)) {
return;
}
Util::addScript(Application::APP_ID, 'organization_folders-main', 'files');
$this->initialState->provideInitialState('snapshot_integration_active', $this->appManager->isEnabledForUser("groupfolder_filesystem_snapshots"));
}
}