Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2020-10-04 16:33:17 +0300
committerJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2020-10-20 14:58:06 +0300
commite7f5516b4d04c16ed2c12dcc9c9c5f34d9f1f73b (patch)
treea4c187c3dacfa5e9bf28fb97941678a515f3e571 /apps/comments/lib
parent3d2024faf94720125855db980d8bbebb658902d1 (diff)
Init vue comments tab
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/comments/lib')
-rw-r--r--apps/comments/lib/AppInfo/Application.php6
-rw-r--r--apps/comments/lib/Event/LoadCommentsApp.php35
-rw-r--r--apps/comments/lib/Listener/LoadCommentsAppListener.php55
-rw-r--r--apps/comments/lib/Listener/LoadSidebarScripts.php13
4 files changed, 109 insertions, 0 deletions
diff --git a/apps/comments/lib/AppInfo/Application.php b/apps/comments/lib/AppInfo/Application.php
index 4eb097ff001..0f22cd309ec 100644
--- a/apps/comments/lib/AppInfo/Application.php
+++ b/apps/comments/lib/AppInfo/Application.php
@@ -30,6 +30,8 @@ namespace OCA\Comments\AppInfo;
use Closure;
use OCA\Comments\Capabilities;
use OCA\Comments\Controller\Notifications;
+use OCA\Comments\Event\LoadCommentsApp;
+use OCA\Comments\Listener\LoadCommentsAppListener;
use OCA\Comments\EventHandler;
use OCA\Comments\JSSettingsHelper;
use OCA\Comments\Listener\CommentsEntityEventListener;
@@ -71,6 +73,10 @@ class Application extends App implements IBootstrap {
LoadSidebarScripts::class
);
$context->registerEventListener(
+ LoadCommentsApp::class,
+ LoadCommentsAppListener::class
+ );
+ $context->registerEventListener(
CommentsEntityEvent::EVENT_ENTITY,
CommentsEntityEventListener::class
);
diff --git a/apps/comments/lib/Event/LoadCommentsApp.php b/apps/comments/lib/Event/LoadCommentsApp.php
new file mode 100644
index 00000000000..74ed93ad447
--- /dev/null
+++ b/apps/comments/lib/Event/LoadCommentsApp.php
@@ -0,0 +1,35 @@
+<?php
+
+declare(strict_types=1);
+/**
+ * @copyright Copyright (c) 2020, John Molakvoæ <skjnldsv@protonmail.com>
+ *
+ * @author John Molakvoæ <skjnldsv@protonmail.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\Comments\Event;
+
+use OCP\EventDispatcher\Event;
+
+/**
+ * This event is used to load and init the comments app
+ *
+ * @since 21.0.0
+ */
+class LoadCommentsApp extends Event {
+}
diff --git a/apps/comments/lib/Listener/LoadCommentsAppListener.php b/apps/comments/lib/Listener/LoadCommentsAppListener.php
new file mode 100644
index 00000000000..755bdaee1ba
--- /dev/null
+++ b/apps/comments/lib/Listener/LoadCommentsAppListener.php
@@ -0,0 +1,55 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * @copyright Copyright (c) 2020, John Molakvoæ <skjnldsv@protonmail.com>
+ *
+ * @author John Molakvoæ <skjnldsv@protonmail.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\Comments\Listener;
+
+use OCA\Comments\AppInfo\Application;
+use OCA\Comments\Event\LoadCommentsApp;
+use OCP\AppFramework\Services\IInitialState;
+use OCP\Comments\IComment;
+use OCP\EventDispatcher\Event;
+use OCP\EventDispatcher\IEventListener;
+use OCP\Util;
+
+class LoadCommentsAppListener implements IEventListener {
+
+ /** @var IInitialState */
+ private $initialStateService;
+
+ public function __construct(IInitialState $initialStateService) {
+ $this->initialStateService = $initialStateService;
+ }
+
+ public function handle(Event $event): void {
+ if (!($event instanceof LoadCommentsApp)) {
+ return;
+ }
+
+ $this->initialStateService->provideInitialState('max-message-length', IComment::MAX_MESSAGE_LENGTH);
+
+ Util::addScript(Application::APP_ID, 'comments-app');
+ }
+}
diff --git a/apps/comments/lib/Listener/LoadSidebarScripts.php b/apps/comments/lib/Listener/LoadSidebarScripts.php
index dfa7e511b1f..0b76d88363d 100644
--- a/apps/comments/lib/Listener/LoadSidebarScripts.php
+++ b/apps/comments/lib/Listener/LoadSidebarScripts.php
@@ -28,19 +28,32 @@ declare(strict_types=1);
namespace OCA\Comments\Listener;
use OCA\Comments\AppInfo\Application;
+use OCA\Comments\Event\LoadCommentsApp;
use OCA\Files\Event\LoadSidebar;
use OCP\EventDispatcher\Event;
+use OCP\EventDispatcher\IEventDispatcher;
use OCP\EventDispatcher\IEventListener;
use OCP\Util;
class LoadSidebarScripts implements IEventListener {
+
+ /** @var IEventDispatcher */
+ private $eventDispatcher;
+
+ public function __construct(IEventDispatcher $eventDispatcher) {
+ $this->eventDispatcher = $eventDispatcher;
+ }
+
public function handle(Event $event): void {
if (!($event instanceof LoadSidebar)) {
return;
}
+ $this->eventDispatcher->dispatchTyped(new LoadCommentsApp());
+
// TODO: make sure to only include the sidebar script when
// we properly split it between files list and sidebar
Util::addScript(Application::APP_ID, 'comments');
+ Util::addScript(Application::APP_ID, 'comments-tab');
}
}