From 8e4c783c978b1bfb58f20f5bc79f1b63cce731d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Tue, 22 Aug 2023 08:07:03 +0200 Subject: [PATCH] feat: Group deck activity settings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- appinfo/info.xml | 4 +- lib/Activity/{Setting.php => SettingBase.php} | 11 ++- lib/Activity/SettingChanges.php | 84 +++++++++++++++++++ lib/Activity/SettingComment.php | 4 +- ...tionSetting.php => SettingDescription.php} | 4 +- tests/unit/Activity/SettingTest.php | 6 +- 6 files changed, 103 insertions(+), 10 deletions(-) rename lib/Activity/{Setting.php => SettingBase.php} (91%) create mode 100644 lib/Activity/SettingChanges.php rename lib/Activity/{DescriptionSetting.php => SettingDescription.php} (89%) diff --git a/appinfo/info.xml b/appinfo/info.xml index 463b94591..0787b0683 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -58,9 +58,9 @@ - OCA\Deck\Activity\Setting + OCA\Deck\Activity\SettingChanges + OCA\Deck\Activity\SettingDescription OCA\Deck\Activity\SettingComment - OCA\Deck\Activity\DescriptionSetting OCA\Deck\Activity\Filter diff --git a/lib/Activity/Setting.php b/lib/Activity/SettingBase.php similarity index 91% rename from lib/Activity/Setting.php rename to lib/Activity/SettingBase.php index e28d1c65e..82157633a 100644 --- a/lib/Activity/Setting.php +++ b/lib/Activity/SettingBase.php @@ -23,9 +23,10 @@ namespace OCA\Deck\Activity; +use OCP\Activity\ActivitySettings; use OCP\IL10N; -class Setting implements \OCP\Activity\ISetting { +abstract class SettingBase extends ActivitySettings { /** @var IL10N */ protected $l; @@ -37,6 +38,14 @@ class Setting implements \OCP\Activity\ISetting { $this->l = $l; } + public function getGroupIdentifier() { + return 'deck'; + } + + public function getGroupName() { + return $this->l->t('Deck'); + } + /** * @return string Lowercase a-z and underscore only identifier * @since 11.0.0 diff --git a/lib/Activity/SettingChanges.php b/lib/Activity/SettingChanges.php new file mode 100644 index 000000000..c52414ba0 --- /dev/null +++ b/lib/Activity/SettingChanges.php @@ -0,0 +1,84 @@ + + * + * @author Julius Härtl + * + * @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 . + * + */ + +namespace OCA\Deck\Activity; + +class SettingChanges extends SettingBase { + /** + * @return string Lowercase a-z and underscore only identifier + * @since 11.0.0 + */ + public function getIdentifier(): string { + return 'deck'; + } + + /** + * @return string A translated string + * @since 11.0.0 + */ + public function getName(): string { + return $this->l->t('A board, list or card was changed'); + } + + /** + * @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 + * priority values. It is required to return a value between 0 and 100. + * @since 11.0.0 + */ + public function getPriority(): int { + return 90; + } + + /** + * @return bool True when the option can be changed for the stream + * @since 11.0.0 + */ + public function canChangeStream(): bool { + return true; + } + + /** + * @return bool True when the option can be changed for the stream + * @since 11.0.0 + */ + public function isDefaultEnabledStream(): bool { + return true; + } + + /** + * @return bool True when the option can be changed for the mail + * @since 11.0.0 + */ + public function canChangeMail(): bool { + return true; + } + + /** + * @return bool True when the option can be changed for the stream + * @since 11.0.0 + */ + public function isDefaultEnabledMail(): bool { + return false; + } +} diff --git a/lib/Activity/SettingComment.php b/lib/Activity/SettingComment.php index ef45a2337..9daff3af6 100644 --- a/lib/Activity/SettingComment.php +++ b/lib/Activity/SettingComment.php @@ -23,7 +23,7 @@ namespace OCA\Deck\Activity; -class SettingComment extends Setting { +class SettingComment extends SettingBase { /** * @return string Lowercase a-z and underscore only identifier @@ -38,7 +38,7 @@ class SettingComment extends Setting { * @since 11.0.0 */ public function getName(): string { - return $this->l->t('A comment was created on a Deck card'); + return $this->l->t('A comment was created on a card'); } /** diff --git a/lib/Activity/DescriptionSetting.php b/lib/Activity/SettingDescription.php similarity index 89% rename from lib/Activity/DescriptionSetting.php rename to lib/Activity/SettingDescription.php index 922cb2b02..c4b2ee34f 100644 --- a/lib/Activity/DescriptionSetting.php +++ b/lib/Activity/SettingDescription.php @@ -23,7 +23,7 @@ namespace OCA\Deck\Activity; -class DescriptionSetting extends Setting { +class SettingDescription extends SettingBase { /** * @return string Lowercase a-z and underscore only identifier @@ -38,6 +38,6 @@ class DescriptionSetting extends Setting { * @since 11.0.0 */ public function getName(): string { - return $this->l->t('A card description inside the Deck app has been changed'); + return $this->l->t('A card description has been changed'); } } diff --git a/tests/unit/Activity/SettingTest.php b/tests/unit/Activity/SettingTest.php index 6896b41dc..407e18d3b 100644 --- a/tests/unit/Activity/SettingTest.php +++ b/tests/unit/Activity/SettingTest.php @@ -30,7 +30,7 @@ class SettingTest extends TestCase { /** @var IL10N */ private $l10n; - /** @var Setting */ + /** @var SettingBase */ private $setting; public function setUp(): void { @@ -38,7 +38,7 @@ class SettingTest extends TestCase { $this->l10n->expects($this->any())->method('t')->will($this->returnCallback(function ($s) { return $s; })); - $this->setting = new Setting($this->l10n); + $this->setting = new SettingChanges($this->l10n); } public function testGetIdentifier() { @@ -46,7 +46,7 @@ class SettingTest extends TestCase { } public function testGetName() { - $this->assertEquals('Changes in the Deck app', $this->setting->getName()); + $this->assertEquals('A board, list or card was changed', $this->setting->getName()); } public function testGetPriority() {