-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #478 from nextcloud/backport/472
[Backport/472] Add capabilities
- Loading branch information
Showing
4 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OCA\OpenProject; | ||
|
||
use OCA\OpenProject\AppInfo\Application; | ||
use OCP\App\IAppManager; | ||
use OCP\Capabilities\IPublicCapability; | ||
|
||
class Capabilities implements IPublicCapability { | ||
|
||
/** @var IAppManager */ | ||
private $appManager; | ||
|
||
public function __construct( | ||
IAppManager $appManager | ||
) { | ||
$this->appManager = $appManager; | ||
} | ||
|
||
/** | ||
* @return array<string, array<string, bool|string>> | ||
*/ | ||
public function getCapabilities(): array { | ||
$appVersion = $this->appManager->getAppVersion(Application::APP_ID); | ||
$groupfoldersVersion = $this->appManager->getAppVersion('groupfolders'); | ||
$groupfoldersEnabled = $this->appManager->isEnabledForUser('groupfolders'); | ||
return [ | ||
Application::APP_ID => [ | ||
'app_version' => $appVersion, | ||
'groupfolder_version' => $groupfoldersVersion, | ||
'groupfolders_enabled' => $groupfoldersEnabled, | ||
], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
Feature: get capabilities of the app | ||
|
||
Scenario: Get capabilities when group folder app is enabled | ||
When the administrator requests the nextcloud capabilities | ||
Then the HTTP status code should be "200" | ||
And the ocs data of the response should match | ||
"""" | ||
{ | ||
"type": "object", | ||
"required": [ | ||
"capabilities" | ||
], | ||
"properties": { | ||
"capabilities": { | ||
"type": "object", | ||
"required": [ | ||
"integration_openproject" | ||
], | ||
"properties": { | ||
"integration_openproject": { | ||
"type": "object", | ||
"required": [ | ||
"app_version", | ||
"groupfolder_version", | ||
"groupfolders_enabled" | ||
], | ||
"properties": { | ||
"app_version": { | ||
"type": "string", | ||
"pattern": "^\\d+\\.\\d+\\.\\d+$" | ||
}, | ||
"groupfolder_version": { | ||
"type": "string", | ||
"pattern": "^\\d+\\.\\d+\\.\\d+(\\-\\w+)?$" | ||
}, | ||
"groupfolders_enabled": { | ||
"type": "boolean", | ||
"enum": [ | ||
true | ||
] | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters