aboutsummaryrefslogtreecommitdiffstats
path: root/apps/sharebymail
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@protonmail.com>2023-09-01 12:02:17 +0200
committerJohn Molakvoæ <skjnldsv@protonmail.com>2023-09-02 01:16:41 +0200
commite040d939e5fcd0a4835c0d06d3181fb48c8d9294 (patch)
tree28f57ee2c350773e2d44758405bb5752c8d0c2df /apps/sharebymail
parente2303d0cc1166e95b65753f26d46c544df339e86 (diff)
downloadnextcloud-server-e040d939e5fcd0a4835c0d06d3181fb48c8d9294.tar.gz
nextcloud-server-e040d939e5fcd0a4835c0d06d3181fb48c8d9294.zip
feat(files): add sharing icon in header
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/sharebymail')
-rw-r--r--apps/sharebymail/lib/Capabilities.php13
-rw-r--r--apps/sharebymail/tests/CapabilitiesTest.php9
2 files changed, 19 insertions, 3 deletions
diff --git a/apps/sharebymail/lib/Capabilities.php b/apps/sharebymail/lib/Capabilities.php
index 8be0ca380cf..2fe8bef653e 100644
--- a/apps/sharebymail/lib/Capabilities.php
+++ b/apps/sharebymail/lib/Capabilities.php
@@ -28,6 +28,7 @@ declare(strict_types=1);
namespace OCA\ShareByMail;
use OCA\ShareByMail\Settings\SettingsManager;
+use OCP\App\IAppManager;
use OCP\Capabilities\ICapability;
use OCP\Share\IManager;
@@ -39,10 +40,15 @@ class Capabilities implements ICapability {
/** @var SettingsManager */
private $settingsManager;
+ /** @var IAppManager */
+ private $appManager;
+
public function __construct(IManager $manager,
- SettingsManager $settingsManager) {
+ SettingsManager $settingsManager,
+ IAppManager $appManager) {
$this->manager = $manager;
$this->settingsManager = $settingsManager;
+ $this->appManager = $appManager;
}
/**
@@ -64,9 +70,12 @@ class Capabilities implements ICapability {
* },
* }
* }
- * }
+ * }|array<empty>
*/
public function getCapabilities(): array {
+ if (!$this->appManager->isEnabledForUser('files_sharing')) {
+ return [];
+ }
return [
'files_sharing' =>
[
diff --git a/apps/sharebymail/tests/CapabilitiesTest.php b/apps/sharebymail/tests/CapabilitiesTest.php
index 19e91ab51e4..cf8043c5f6e 100644
--- a/apps/sharebymail/tests/CapabilitiesTest.php
+++ b/apps/sharebymail/tests/CapabilitiesTest.php
@@ -27,6 +27,7 @@ namespace OCA\ShareByMail\Tests;
use OCA\ShareByMail\Capabilities;
use OCA\ShareByMail\Settings\SettingsManager;
+use OCP\App\IAppManager;
use OCP\Share\IManager;
use Test\TestCase;
@@ -40,13 +41,17 @@ class CapabilitiesTest extends TestCase {
/** @var IManager | \PHPUnit\Framework\MockObject\MockObject */
private $settingsManager;
+ /** @var IAppManager | \PHPUnit\Framework\MockObject\MockObject */
+ private $appManager;
+
protected function setUp(): void {
parent::setUp();
$this->manager = $this::createMock(IManager::class);
$this->settingsManager = $this::createMock(SettingsManager::class);
- $this->capabilities = new Capabilities($this->manager, $this->settingsManager);
+ $this->appManager = $this::createMock(IAppManager::class);
+ $this->capabilities = new Capabilities($this->manager, $this->settingsManager, $this->appManager);
}
public function testGetCapabilities() {
@@ -58,6 +63,8 @@ class CapabilitiesTest extends TestCase {
->willReturn(false);
$this->settingsManager->method('sendPasswordByMail')
->willReturn(true);
+ $this->appManager->method('isEnabledForUser')
+ ->willReturn(true);
$capabilities = [
'files_sharing' =>