Browse Source

Add ICommentsManager::load method

Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
tags/v21.0.0beta1
John Molakvoæ (skjnldsv) 3 years ago
parent
commit
3e1916080a
No account linked to committer's email address

+ 0
- 2
apps/comments/composer/composer/autoload_classmap.php View File

@@ -15,11 +15,9 @@ return array(
'OCA\\Comments\\Collaboration\\CommentersSorter' => $baseDir . '/../lib/Collaboration/CommentersSorter.php',
'OCA\\Comments\\Controller\\Notifications' => $baseDir . '/../lib/Controller/Notifications.php',
'OCA\\Comments\\EventHandler' => $baseDir . '/../lib/EventHandler.php',
'OCA\\Comments\\Event\\LoadCommentsApp' => $baseDir . '/../lib/Event/LoadCommentsApp.php',
'OCA\\Comments\\JSSettingsHelper' => $baseDir . '/../lib/JSSettingsHelper.php',
'OCA\\Comments\\Listener\\CommentsEntityEventListener' => $baseDir . '/../lib/Listener/CommentsEntityEventListener.php',
'OCA\\Comments\\Listener\\LoadAdditionalScripts' => $baseDir . '/../lib/Listener/LoadAdditionalScripts.php',
'OCA\\Comments\\Listener\\LoadCommentsAppListener' => $baseDir . '/../lib/Listener/LoadCommentsAppListener.php',
'OCA\\Comments\\Listener\\LoadSidebarScripts' => $baseDir . '/../lib/Listener/LoadSidebarScripts.php',
'OCA\\Comments\\Notification\\Listener' => $baseDir . '/../lib/Notification/Listener.php',
'OCA\\Comments\\Notification\\Notifier' => $baseDir . '/../lib/Notification/Notifier.php',

+ 0
- 2
apps/comments/composer/composer/autoload_static.php View File

@@ -30,11 +30,9 @@ class ComposerStaticInitComments
'OCA\\Comments\\Collaboration\\CommentersSorter' => __DIR__ . '/..' . '/../lib/Collaboration/CommentersSorter.php',
'OCA\\Comments\\Controller\\Notifications' => __DIR__ . '/..' . '/../lib/Controller/Notifications.php',
'OCA\\Comments\\EventHandler' => __DIR__ . '/..' . '/../lib/EventHandler.php',
'OCA\\Comments\\Event\\LoadCommentsApp' => __DIR__ . '/..' . '/../lib/Event/LoadCommentsApp.php',
'OCA\\Comments\\JSSettingsHelper' => __DIR__ . '/..' . '/../lib/JSSettingsHelper.php',
'OCA\\Comments\\Listener\\CommentsEntityEventListener' => __DIR__ . '/..' . '/../lib/Listener/CommentsEntityEventListener.php',
'OCA\\Comments\\Listener\\LoadAdditionalScripts' => __DIR__ . '/..' . '/../lib/Listener/LoadAdditionalScripts.php',
'OCA\\Comments\\Listener\\LoadCommentsAppListener' => __DIR__ . '/..' . '/../lib/Listener/LoadCommentsAppListener.php',
'OCA\\Comments\\Listener\\LoadSidebarScripts' => __DIR__ . '/..' . '/../lib/Listener/LoadSidebarScripts.php',
'OCA\\Comments\\Notification\\Listener' => __DIR__ . '/..' . '/../lib/Notification/Listener.php',
'OCA\\Comments\\Notification\\Notifier' => __DIR__ . '/..' . '/../lib/Notification/Notifier.php',

+ 0
- 6
apps/comments/lib/AppInfo/Application.php View File

@@ -30,8 +30,6 @@ 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;
@@ -72,10 +70,6 @@ class Application extends App implements IBootstrap {
LoadSidebar::class,
LoadSidebarScripts::class
);
$context->registerEventListener(
LoadCommentsApp::class,
LoadCommentsAppListener::class
);
$context->registerEventListener(
CommentsEntityEvent::EVENT_ENTITY,
CommentsEntityEventListener::class

+ 0
- 35
apps/comments/lib/Event/LoadCommentsApp.php View File

@@ -1,35 +0,0 @@
<?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 {
}

+ 0
- 55
apps/comments/lib/Listener/LoadCommentsAppListener.php View File

@@ -1,55 +0,0 @@
<?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');
}
}

+ 6
- 7
apps/comments/lib/Listener/LoadSidebarScripts.php View File

@@ -28,20 +28,19 @@ 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\Comments\ICommentsManager;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\EventDispatcher\IEventListener;
use OCP\Util;

class LoadSidebarScripts implements IEventListener {

/** @var IEventDispatcher */
private $eventDispatcher;
/** @var ICommentsManager */
private $commentsManager;

public function __construct(IEventDispatcher $eventDispatcher) {
$this->eventDispatcher = $eventDispatcher;
public function __construct(ICommentsManager $commentsManager) {
$this->commentsManager = $commentsManager;
}

public function handle(Event $event): void {
@@ -49,7 +48,7 @@ class LoadSidebarScripts implements IEventListener {
return;
}

$this->eventDispatcher->dispatchTyped(new LoadCommentsApp());
$this->commentsManager->load();

// TODO: make sure to only include the sidebar script when
// we properly split it between files list and sidebar

+ 0
- 5
apps/comments/src/comments.js View File

@@ -3,9 +3,4 @@ import './templates'
import './filesplugin'
import './activitytabviewplugin'

import './vendor/Caret.js/dist/jquery.caret.min'

import './style/autocomplete.scss'
import './style/comments.scss'

window.OCA.Comments = OCA.Comments

+ 21
- 5
lib/private/Comments/Manager.php View File

@@ -30,6 +30,7 @@ namespace OC\Comments;

use Doctrine\DBAL\Exception\DriverException;
use Doctrine\DBAL\Exception\InvalidFieldNameException;
use OCA\Comments\AppInfo\Application;
use OCP\Comments\CommentsEvent;
use OCP\Comments\IComment;
use OCP\Comments\ICommentsEventHandler;
@@ -39,6 +40,8 @@ use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\IUser;
use OCP\IInitialStateService;
use OCP\Util;
use Psr\Log\LoggerInterface;

class Manager implements ICommentsManager {
@@ -52,6 +55,9 @@ class Manager implements ICommentsManager {
/** @var IConfig */
protected $config;

/** @var IInitialStateService */
protected $initialStateService;

/** @var IComment[] */
protected $commentsCache = [];

@@ -64,14 +70,14 @@ class Manager implements ICommentsManager {
/** @var \Closure[] */
protected $displayNameResolvers = [];

public function __construct(
IDBConnection $dbConn,
LoggerInterface $logger,
IConfig $config
) {
public function __construct(IDBConnection $dbConn,
LoggerInterface $logger,
IConfig $config,
IInitialStateService $initialStateService) {
$this->dbConn = $dbConn;
$this->logger = $logger;
$this->config = $config;
$this->initialStateService = $initialStateService;
}

/**
@@ -1120,4 +1126,14 @@ class Manager implements ICommentsManager {
$entity->handle($event);
}
}

/**
* Load the Comments app into the page
*
* @since 21.0.0
*/
public function load(): void {
$this->initialStateService->provideInitialState(Application::APP_ID, 'max-message-length', IComment::MAX_MESSAGE_LENGTH);
Util::addScript(Application::APP_ID, 'comments-app');
}
}

+ 3
- 1
lib/private/Comments/ManagerFactory.php View File

@@ -27,6 +27,7 @@ namespace OC\Comments;

use OCP\Comments\ICommentsManager;
use OCP\Comments\ICommentsManagerFactory;
use OCP\IInitialStateService;
use OCP\IServerContainer;
use Psr\Log\LoggerInterface;

@@ -58,7 +59,8 @@ class ManagerFactory implements ICommentsManagerFactory {
return new Manager(
$this->serverContainer->getDatabaseConnection(),
$this->serverContainer->get(LoggerInterface::class),
$this->serverContainer->getConfig()
$this->serverContainer->getConfig(),
$this->serverContainer->get(IInitialStateService::class)
);
}
}

+ 7
- 0
lib/public/Comments/ICommentsManager.php View File

@@ -322,4 +322,11 @@ interface ICommentsManager {
* provided ID is unknown. It must be ensured that a string is returned.
*/
public function resolveDisplayName($type, $id);

/**
* Load the Comments app into the page
*
* @since 21.0.0
*/
public function load(): void;
}

+ 87
- 12
package-lock.json View File

@@ -1197,6 +1197,21 @@
"core-js": "^3.6.4"
}
},
"@nextcloud/browser-storage": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/@nextcloud/browser-storage/-/browser-storage-0.1.1.tgz",
"integrity": "sha512-bWzs/A44rEK8b3CMOFw0ZhsenagrWdsB902LOEwmlMCcFysiFgWiOPbF4/0/ODlOYjvPrO02wf6RigWtb8P+gA==",
"requires": {
"core-js": "3.6.1"
},
"dependencies": {
"core-js": {
"version": "3.6.1",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-3.6.1.tgz",
"integrity": "sha512-186WjSik2iTGfDjfdCZAxv2ormxtKgemjC3SI6PL31qOA0j5LhTDVjHChccoc7brwLvpvLPiMyRlcO88C4l1QQ=="
}
}
},
"@nextcloud/browserslist-config": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/@nextcloud/browserslist-config/-/browserslist-config-1.0.0.tgz",
@@ -1364,24 +1379,29 @@
}
},
"@nextcloud/vue": {
"version": "2.7.0",
"resolved": "https://registry.npmjs.org/@nextcloud/vue/-/vue-2.7.0.tgz",
"integrity": "sha512-iZxTUWsDvfQdi3FRqEBfv5MGqJPPISk9FEXhX98wnWX37YaDwx9qOpvAQo+/6bjVVwwu8E7oWJN24NE4rxWhBg==",
"version": "2.8.0",
"resolved": "https://registry.npmjs.org/@nextcloud/vue/-/vue-2.8.0.tgz",
"integrity": "sha512-1pMKZl3wnPK9gJoDTQVBlvcr4VTsiSXZw396SNVPB3xVou3t9GnAMGo8GTpX5ZciI5KF1DB6cufzQaumyDXrlg==",
"requires": {
"@nextcloud/auth": "^1.2.3",
"@nextcloud/axios": "^1.3.2",
"@nextcloud/browser-storage": "^0.1.1",
"@nextcloud/capabilities": "^1.0.2",
"@nextcloud/dialogs": "^2.0.1",
"@nextcloud/dialogs": "^3.0.0",
"@nextcloud/event-bus": "^1.1.4",
"@nextcloud/l10n": "^1.2.3",
"@nextcloud/router": "^1.0.2",
"core-js": "^3.6.5",
"debounce": "1.2.0",
"emoji-mart-vue-fast": "^7.0.4",
"escape-html": "^1.0.3",
"hammerjs": "^2.0.8",
"linkifyjs": "~2.1.9",
"md5": "^2.2.1",
"regenerator-runtime": "^0.13.5",
"string-length": "^4.0.1",
"striptags": "^3.1.1",
"tributejs": "^5.1.3",
"v-click-outside": "^3.0.1",
"v-tooltip": "^2.0.3",
"vue": "^2.6.11",
@@ -1389,6 +1409,27 @@
"vue-multiselect": "^2.1.6",
"vue-visible": "^1.0.2",
"vue2-datepicker": "^3.6.2"
},
"dependencies": {
"@nextcloud/dialogs": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/@nextcloud/dialogs/-/dialogs-3.0.0.tgz",
"integrity": "sha512-5FVP0RSxIpKTKdSUlQ4osDDz/oCx2/4+InliB5MX2EcrjDe6q3fZMabSGnFTnIAu0CXRTzBk7RpneaIFGv+d5A==",
"requires": {
"@nextcloud/l10n": "^1.3.0",
"@nextcloud/typings": "^1.0.0",
"core-js": "^3.6.4",
"toastify-js": "^1.9.1"
}
},
"@nextcloud/typings": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/@nextcloud/typings/-/typings-1.0.0.tgz",
"integrity": "sha512-r8SRvXszWTyKWEhVd3gx7eBAcCKwdoLlr+ZrR8hrSxs2nfH00de/QoGdo0n/Rcv/9mMtX/haJNd71KwODM2+uQ==",
"requires": {
"@types/jquery": "2.0.54"
}
}
}
},
"@nextcloud/vue-dashboard": {
@@ -2754,6 +2795,11 @@
"supports-color": "^5.3.0"
}
},
"char-regex": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/char-regex/-/char-regex-1.0.2.tgz",
"integrity": "sha512-kWWXztvZ5SBQV+eRgKFeh8q5sLuZY2+8WUIzlxWVTg+oGwY14qylx1KbKzHd8P6ZYkAg0xyIDU9JMHhyJMZ1jw=="
},
"chardet": {
"version": "0.7.0",
"resolved": "https://registry.npmjs.org/chardet/-/chardet-0.7.0.tgz",
@@ -8735,6 +8781,30 @@
"resolved": "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz",
"integrity": "sha1-J5siXfHVgrH1TmWt3UNS4Y+qBxM="
},
"string-length": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/string-length/-/string-length-4.0.1.tgz",
"integrity": "sha512-PKyXUd0LK0ePjSOnWn34V2uD6acUWev9uy0Ft05k0E8xRW+SKcA0F7eMr7h5xlzfn+4O3N+55rduYyet3Jk+jw==",
"requires": {
"char-regex": "^1.0.2",
"strip-ansi": "^6.0.0"
},
"dependencies": {
"ansi-regex": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz",
"integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg=="
},
"strip-ansi": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz",
"integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==",
"requires": {
"ansi-regex": "^5.0.0"
}
}
}
},
"string-width": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz",
@@ -8802,6 +8872,11 @@
"integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==",
"dev": true
},
"striptags": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/striptags/-/striptags-3.1.1.tgz",
"integrity": "sha1-yMPn/db7S7OjKjt1LltePjgJPr0="
},
"style-loader": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/style-loader/-/style-loader-2.0.0.tgz",
@@ -9070,6 +9145,11 @@
"punycode": "^2.1.1"
}
},
"tributejs": {
"version": "5.1.3",
"resolved": "https://registry.npmjs.org/tributejs/-/tributejs-5.1.3.tgz",
"integrity": "sha512-B5CXihaVzXw+1UHhNFyAwUTMDk1EfoLP5Tj1VhD9yybZ1I8DZJEv8tZ1l0RJo0t0tk9ZhR8eG5tEsaCvRigmdQ=="
},
"trim-newlines": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-1.0.0.tgz",
@@ -9611,11 +9691,6 @@
"integrity": "sha512-4gDntzrifFnCEvyoO8PqyJDmguXgVPxKiIxrBKjIowvL9l+N66196+72XVYR8BBf1Uv1Fgt3bGevJ+sEmxfZzw==",
"dev": true
},
"vue-virtual-scroll-list": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/vue-virtual-scroll-list/-/vue-virtual-scroll-list-2.3.1.tgz",
"integrity": "sha512-2p0bvcmUIMet5tln+cOKt/XjNvgP+ebq9bBD+gquK2rivsSSAFHeqQidzMO3wPFfxWeTB1JpoSzkyL9nzZ9yfA=="
},
"vue-virtual-scroller": {
"version": "1.0.10",
"resolved": "https://registry.npmjs.org/vue-virtual-scroller/-/vue-virtual-scroller-1.0.10.tgz",
@@ -9632,9 +9707,9 @@
"integrity": "sha512-yaX2its9XAJKGuQqf7LsiZHHSkxsIK8rmCOQOvEGEoF41blKRK8qr9my4qYoD6ikdLss4n8tKqYBecmaY0+WJg=="
},
"vue2-datepicker": {
"version": "3.6.2",
"resolved": "https://registry.npmjs.org/vue2-datepicker/-/vue2-datepicker-3.6.2.tgz",
"integrity": "sha512-J2fCwUmCxIOPUvwQ12e8evFY9cCv6vJmgxRD9fGeUv6JeMMeLwkdpeQZOcqbMf/4mk1cSrY2/9Fr8DaB30LBpA==",
"version": "3.6.3",
"resolved": "https://registry.npmjs.org/vue2-datepicker/-/vue2-datepicker-3.6.3.tgz",
"integrity": "sha512-887cTxbEKTt35CvA58/Xh1n2I403UxutyjCoG8lAF/IjHsEVv4tYCa0cC27VvT2U9ABThg9pzkT0IWU3zDmB/w==",
"requires": {
"date-fns": "^2.0.1",
"date-format-parse": "^0.2.5"

+ 1
- 1
package.json View File

@@ -39,7 +39,7 @@
"@nextcloud/password-confirmation": "^1.0.1",
"@nextcloud/paths": "^1.1.2",
"@nextcloud/router": "^1.1.0",
"@nextcloud/vue": "^2.7.0",
"@nextcloud/vue": "^2.8.0",
"@nextcloud/vue-dashboard": "^1.0.1",
"autosize": "^4.0.2",
"backbone": "^1.4.0",

+ 3
- 0
tests/lib/Comments/FakeManager.php View File

@@ -83,4 +83,7 @@ class FakeManager implements ICommentsManager {

public function getActorsInTree($id) {
}

public function load(): void {
}
}

Loading…
Cancel
Save