Merge pull request #22117 from nextcloud/activity-settings-grouping
allow grouping of activity settings
This commit is contained in:
commit
8fc877ff7d
|
@ -12,6 +12,7 @@ return array(
|
|||
'OCA\\Files\\Activity\\Helper' => $baseDir . '/../lib/Activity/Helper.php',
|
||||
'OCA\\Files\\Activity\\Provider' => $baseDir . '/../lib/Activity/Provider.php',
|
||||
'OCA\\Files\\Activity\\Settings\\FavoriteAction' => $baseDir . '/../lib/Activity/Settings/FavoriteAction.php',
|
||||
'OCA\\Files\\Activity\\Settings\\FileActivitySettings' => $baseDir . '/../lib/Activity/Settings/FileActivitySettings.php',
|
||||
'OCA\\Files\\Activity\\Settings\\FileChanged' => $baseDir . '/../lib/Activity/Settings/FileChanged.php',
|
||||
'OCA\\Files\\Activity\\Settings\\FileCreated' => $baseDir . '/../lib/Activity/Settings/FileCreated.php',
|
||||
'OCA\\Files\\Activity\\Settings\\FileDeleted' => $baseDir . '/../lib/Activity/Settings/FileDeleted.php',
|
||||
|
|
|
@ -27,6 +27,7 @@ class ComposerStaticInitFiles
|
|||
'OCA\\Files\\Activity\\Helper' => __DIR__ . '/..' . '/../lib/Activity/Helper.php',
|
||||
'OCA\\Files\\Activity\\Provider' => __DIR__ . '/..' . '/../lib/Activity/Provider.php',
|
||||
'OCA\\Files\\Activity\\Settings\\FavoriteAction' => __DIR__ . '/..' . '/../lib/Activity/Settings/FavoriteAction.php',
|
||||
'OCA\\Files\\Activity\\Settings\\FileActivitySettings' => __DIR__ . '/..' . '/../lib/Activity/Settings/FileActivitySettings.php',
|
||||
'OCA\\Files\\Activity\\Settings\\FileChanged' => __DIR__ . '/..' . '/../lib/Activity/Settings/FileChanged.php',
|
||||
'OCA\\Files\\Activity\\Settings\\FileCreated' => __DIR__ . '/..' . '/../lib/Activity/Settings/FileCreated.php',
|
||||
'OCA\\Files\\Activity\\Settings\\FileDeleted' => __DIR__ . '/..' . '/../lib/Activity/Settings/FileDeleted.php',
|
||||
|
|
|
@ -23,21 +23,7 @@
|
|||
|
||||
namespace OCA\Files\Activity\Settings;
|
||||
|
||||
use OCP\Activity\ISetting;
|
||||
use OCP\IL10N;
|
||||
|
||||
class FavoriteAction implements ISetting {
|
||||
|
||||
/** @var IL10N */
|
||||
protected $l;
|
||||
|
||||
/**
|
||||
* @param IL10N $l
|
||||
*/
|
||||
public function __construct(IL10N $l) {
|
||||
$this->l = $l;
|
||||
}
|
||||
|
||||
class FavoriteAction extends FileActivitySettings {
|
||||
/**
|
||||
* @return string Lowercase a-z and underscore only identifier
|
||||
* @since 11.0.0
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* @copyright Copyright (c) 2020 Robin Appelman <robin@icewind.nl>
|
||||
*
|
||||
* @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\Activity\Settings;
|
||||
|
||||
use OCP\Activity\ActivitySettings;
|
||||
use OCP\IL10N;
|
||||
|
||||
abstract class FileActivitySettings extends ActivitySettings {
|
||||
/** @var IL10N */
|
||||
protected $l;
|
||||
|
||||
/**
|
||||
* @param IL10N $l
|
||||
*/
|
||||
public function __construct(IL10N $l) {
|
||||
$this->l = $l;
|
||||
}
|
||||
|
||||
public function getGroupIdentifier() {
|
||||
return 'files';
|
||||
}
|
||||
|
||||
public function getGroupName() {
|
||||
return $this->l->t('Files');
|
||||
}
|
||||
}
|
|
@ -23,21 +23,7 @@
|
|||
|
||||
namespace OCA\Files\Activity\Settings;
|
||||
|
||||
use OCP\Activity\ISetting;
|
||||
use OCP\IL10N;
|
||||
|
||||
class FileChanged implements ISetting {
|
||||
|
||||
/** @var IL10N */
|
||||
protected $l;
|
||||
|
||||
/**
|
||||
* @param IL10N $l
|
||||
*/
|
||||
public function __construct(IL10N $l) {
|
||||
$this->l = $l;
|
||||
}
|
||||
|
||||
class FileChanged extends FileActivitySettings {
|
||||
/**
|
||||
* @return string Lowercase a-z and underscore only identifier
|
||||
* @since 11.0.0
|
||||
|
|
|
@ -23,21 +23,7 @@
|
|||
|
||||
namespace OCA\Files\Activity\Settings;
|
||||
|
||||
use OCP\Activity\ISetting;
|
||||
use OCP\IL10N;
|
||||
|
||||
class FileCreated implements ISetting {
|
||||
|
||||
/** @var IL10N */
|
||||
protected $l;
|
||||
|
||||
/**
|
||||
* @param IL10N $l
|
||||
*/
|
||||
public function __construct(IL10N $l) {
|
||||
$this->l = $l;
|
||||
}
|
||||
|
||||
class FileCreated extends FileActivitySettings {
|
||||
/**
|
||||
* @return string Lowercase a-z and underscore only identifier
|
||||
* @since 11.0.0
|
||||
|
|
|
@ -23,21 +23,7 @@
|
|||
|
||||
namespace OCA\Files\Activity\Settings;
|
||||
|
||||
use OCP\Activity\ISetting;
|
||||
use OCP\IL10N;
|
||||
|
||||
class FileDeleted implements ISetting {
|
||||
|
||||
/** @var IL10N */
|
||||
protected $l;
|
||||
|
||||
/**
|
||||
* @param IL10N $l
|
||||
*/
|
||||
public function __construct(IL10N $l) {
|
||||
$this->l = $l;
|
||||
}
|
||||
|
||||
class FileDeleted extends FileActivitySettings {
|
||||
/**
|
||||
* @return string Lowercase a-z and underscore only identifier
|
||||
* @since 11.0.0
|
||||
|
|
|
@ -23,21 +23,7 @@
|
|||
|
||||
namespace OCA\Files\Activity\Settings;
|
||||
|
||||
use OCP\Activity\ISetting;
|
||||
use OCP\IL10N;
|
||||
|
||||
class FileFavorite implements ISetting {
|
||||
|
||||
/** @var IL10N */
|
||||
protected $l;
|
||||
|
||||
/**
|
||||
* @param IL10N $l
|
||||
*/
|
||||
public function __construct(IL10N $l) {
|
||||
$this->l = $l;
|
||||
}
|
||||
|
||||
class FileFavorite extends FileActivitySettings {
|
||||
/**
|
||||
* @return string Lowercase a-z and underscore only identifier
|
||||
* @since 11.0.0
|
||||
|
|
|
@ -23,21 +23,7 @@
|
|||
|
||||
namespace OCA\Files\Activity\Settings;
|
||||
|
||||
use OCP\Activity\ISetting;
|
||||
use OCP\IL10N;
|
||||
|
||||
class FileRestored implements ISetting {
|
||||
|
||||
/** @var IL10N */
|
||||
protected $l;
|
||||
|
||||
/**
|
||||
* @param IL10N $l
|
||||
*/
|
||||
public function __construct(IL10N $l) {
|
||||
$this->l = $l;
|
||||
}
|
||||
|
||||
class FileRestored extends FileActivitySettings {
|
||||
/**
|
||||
* @return string Lowercase a-z and underscore only identifier
|
||||
* @since 11.0.0
|
||||
|
|
|
@ -25,6 +25,7 @@ namespace OC\Activity;
|
|||
|
||||
use OCP\Activity\ActivitySettings;
|
||||
use OCP\Activity\ISetting;
|
||||
use OCP\IL10N;
|
||||
|
||||
/**
|
||||
* Adapt the old interface based settings into the new abstract
|
||||
|
@ -32,9 +33,11 @@ use OCP\Activity\ISetting;
|
|||
*/
|
||||
class ActivitySettingsAdapter extends ActivitySettings {
|
||||
private $oldSettings;
|
||||
private $l10n;
|
||||
|
||||
public function __construct(ISetting $oldSettings) {
|
||||
public function __construct(ISetting $oldSettings, IL10N $l10n) {
|
||||
$this->oldSettings = $oldSettings;
|
||||
$this->l10n = $l10n;
|
||||
}
|
||||
|
||||
public function getIdentifier() {
|
||||
|
@ -45,6 +48,14 @@ class ActivitySettingsAdapter extends ActivitySettings {
|
|||
return $this->oldSettings->getName();
|
||||
}
|
||||
|
||||
public function getGroupIdentifier() {
|
||||
return 'other';
|
||||
}
|
||||
|
||||
public function getGroupName() {
|
||||
return $this->l10n->t('Other activities');
|
||||
}
|
||||
|
||||
public function getPriority() {
|
||||
return $this->oldSettings->getPriority();
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ use OCP\Activity\IManager;
|
|||
use OCP\Activity\IProvider;
|
||||
use OCP\Activity\ISetting;
|
||||
use OCP\IConfig;
|
||||
use OCP\IL10N;
|
||||
use OCP\IRequest;
|
||||
use OCP\IUser;
|
||||
use OCP\IUserSession;
|
||||
|
@ -66,14 +67,20 @@ class Manager implements IManager {
|
|||
/** @var string */
|
||||
protected $currentUserId;
|
||||
|
||||
public function __construct(IRequest $request,
|
||||
IUserSession $session,
|
||||
IConfig $config,
|
||||
IValidator $validator) {
|
||||
protected $l10n;
|
||||
|
||||
public function __construct(
|
||||
IRequest $request,
|
||||
IUserSession $session,
|
||||
IConfig $config,
|
||||
IValidator $validator,
|
||||
IL10N $l10n
|
||||
) {
|
||||
$this->request = $request;
|
||||
$this->session = $session;
|
||||
$this->config = $config;
|
||||
$this->validator = $validator;
|
||||
$this->l10n = $l10n;
|
||||
}
|
||||
|
||||
/** @var \Closure[] */
|
||||
|
@ -273,7 +280,7 @@ class Manager implements IManager {
|
|||
|
||||
if ($setting instanceof ISetting) {
|
||||
if (!$setting instanceof ActivitySettings) {
|
||||
$setting = new ActivitySettingsAdapter($setting);
|
||||
$setting = new ActivitySettingsAdapter($setting, $this->l10n);
|
||||
}
|
||||
} else {
|
||||
throw new \InvalidArgumentException('Invalid activity filter registered');
|
||||
|
|
|
@ -695,11 +695,13 @@ class Server extends ServerContainer implements IServerContainer {
|
|||
});
|
||||
|
||||
$this->registerService(\OCP\Activity\IManager::class, function (Server $c) {
|
||||
$l10n = $this->get(IFactory::class)->get('activity');
|
||||
return new \OC\Activity\Manager(
|
||||
$c->getRequest(),
|
||||
$c->getUserSession(),
|
||||
$c->getConfig(),
|
||||
$c->query(IValidator::class)
|
||||
$c->query(IValidator::class),
|
||||
$l10n
|
||||
);
|
||||
});
|
||||
$this->registerDeprecatedAlias('ActivityManager', \OCP\Activity\IManager::class);
|
||||
|
|
|
@ -39,6 +39,18 @@ abstract class ActivitySettings implements ISetting {
|
|||
*/
|
||||
abstract public function getName();
|
||||
|
||||
/**
|
||||
* @return string Lowercase a-z and underscore only group identifier
|
||||
* @since 20.0.0
|
||||
*/
|
||||
abstract public function getGroupIdentifier();
|
||||
|
||||
/**
|
||||
* @return string A translated string for the settings group
|
||||
* @since 20.0.0
|
||||
*/
|
||||
abstract public function getGroupName();
|
||||
|
||||
/**
|
||||
* @return int whether the filter should be rather on the top or bottom of
|
||||
* the admin section. The filters are arranged in ascending order of the
|
||||
|
|
|
@ -56,7 +56,8 @@ class ManagerTest extends TestCase {
|
|||
$this->request,
|
||||
$this->session,
|
||||
$this->config,
|
||||
$this->validator
|
||||
$this->validator,
|
||||
$this->createMock(IL10N::class)
|
||||
);
|
||||
|
||||
$this->assertSame([], self::invokePrivate($this->activityManager, 'getConsumers'));
|
||||
|
|
Loading…
Reference in New Issue