Skip to content

Commit 7f83558

Browse files
Merge pull request #3410 from nextcloud/backport/3324/stable30
2 parents cce3193 + 356a266 commit 7f83558

30 files changed

+3412
-263
lines changed

β€Ž.eslintrc.js

+11
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,15 @@ module.exports = {
66
extends: [
77
'@nextcloud/eslint-config/typescript',
88
],
9+
overrides: [
10+
{
11+
files: ['src/types/openapi/*.ts'],
12+
rules: {
13+
'@typescript-eslint/no-explicit-any': 'off',
14+
quotes: 'off',
15+
'no-multiple-empty-lines': 'off',
16+
'no-use-before-define': 'off',
17+
},
18+
},
19+
],
920
}

β€Ž.github/workflows/openapi.yml

+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# This workflow is provided via the organization template repository
2+
#
3+
# https://github.com/nextcloud/.github
4+
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
5+
#
6+
# SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
7+
# SPDX-FileCopyrightText: 2024 Arthur Schiwon <[email protected]>
8+
# SPDX-License-Identifier: MIT
9+
10+
name: OpenAPI
11+
12+
on: pull_request
13+
14+
permissions:
15+
contents: read
16+
17+
concurrency:
18+
group: openapi-${{ github.head_ref || github.run_id }}
19+
cancel-in-progress: true
20+
21+
jobs:
22+
openapi:
23+
runs-on: ubuntu-latest
24+
25+
if: ${{ github.repository_owner != 'nextcloud-gmbh' }}
26+
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
30+
31+
- name: Get php version
32+
id: php_versions
33+
uses: icewind1991/nextcloud-version-matrix@58becf3b4bb6dc6cef677b15e2fd8e7d48c0908f # v1.3.1
34+
35+
- name: Set up php
36+
uses: shivammathur/setup-php@c541c155eee45413f5b09a52248675b1a2575231 # v2.31.1
37+
with:
38+
php-version: ${{ steps.php_versions.outputs.php-available }}
39+
extensions: xml
40+
coverage: none
41+
ini-file: development
42+
env:
43+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44+
45+
- name: Check Typescript OpenApi types
46+
id: check_typescript_openapi
47+
uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 # v3.0.0
48+
with:
49+
files: "src/types/openapi/openapi*.ts"
50+
51+
- name: Read package.json node and npm engines version
52+
if: steps.check_typescript_openapi.outputs.files_exists == 'true'
53+
uses: skjnldsv/read-package-engines-version-actions@06d6baf7d8f41934ab630e97d9e6c0bc9c9ac5e4 # v3
54+
id: node_versions
55+
# Continue if no package.json
56+
continue-on-error: true
57+
with:
58+
fallbackNode: '^20'
59+
fallbackNpm: '^10'
60+
61+
- name: Set up node ${{ steps.node_versions.outputs.nodeVersion }}
62+
if: ${{ steps.node_versions.outputs.nodeVersion }}
63+
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
64+
with:
65+
node-version: ${{ steps.node_versions.outputs.nodeVersion }}
66+
67+
- name: Set up npm ${{ steps.node_versions.outputs.npmVersion }}
68+
if: ${{ steps.node_versions.outputs.nodeVersion }}
69+
run: npm i -g 'npm@${{ steps.node_versions.outputs.npmVersion }}'
70+
71+
- name: Install dependencies & build
72+
if: ${{ steps.node_versions.outputs.nodeVersion }}
73+
env:
74+
CYPRESS_INSTALL_BINARY: 0
75+
PUPPETEER_SKIP_DOWNLOAD: true
76+
run: |
77+
npm ci
78+
79+
- name: Set up dependencies
80+
run: composer i
81+
82+
- name: Regenerate OpenAPI
83+
run: composer run openapi
84+
85+
- name: Check openapi*.json and typescript changes
86+
run: |
87+
bash -c "[[ ! \"`git status --porcelain `\" ]] || (echo 'Please run \"composer run openapi\" and commit the openapi*.json files and (if applicable) src/types/openapi/openapi*.ts, see the section \"Show changes on failure\" for details' && exit 1)"
88+
89+
- name: Show changes on failure
90+
if: failure()
91+
run: |
92+
git status
93+
git --no-pager diff
94+
exit 1 # make it red to grab attention

β€ŽREADME.md

+1-29
Original file line numberDiff line numberDiff line change
@@ -126,35 +126,7 @@ To disable the advanced permissions feature for a group folder, use `occ groupfo
126126

127127
### REST API
128128

129-
Group folders can be configured externally through REST APIs.
130-
131-
The following REST API's are supported:
132-
133-
- `GET apps/groupfolders/folders`: Returns a list of all configured folders and their settings
134-
- `POST apps/groupfolders/folders`: Create a new group folder
135-
- `mountpoint`: The name for the new folder
136-
- `GET apps/groupfolders/folders/$folderId`: Return a specific configured folder and its settings
137-
- `DELETE apps/groupfolders/folders/$folderId`: Delete a group folder
138-
- `POST apps/groupfolders/folders/$folderId/groups`: Give a group access to a folder
139-
- `group`: The id of the group to be given access to the folder
140-
- `DELETE apps/groupfolders/folders/$folderId/groups/$groupId`: Remove access from a group to a folder
141-
- `POST apps/groupfolders/folders/$folderId/acl`: Enable/Disable folder advanced permissions
142-
- `acl` 1 for enable, 0 for disable.
143-
- `POST apps/groupfolders/folders/$folderId/manageACL`: Grants/Removes a group or user the ability to manage a groupfolders' advanced permissions
144-
- `$mappingId`: the id of the group/user to be granted/removed access to/from the folder
145-
- `$mappingType`: 'group' or 'user'
146-
- `$manageAcl`: true to grants ability to manage a groupfolders' advanced permissions, false to remove
147-
- `POST apps/groupfolders/folders/$folderId/groups/$groupId`: Set the permissions a group has in a folder
148-
- `permissions` The new permissions for the group as bitmask of [permissions constants](https://github.com/nextcloud/server/blob/b4f36d44c43aac0efdc6c70ff8e46473341a9bfe/lib/public/Constants.php#L65)
149-
- `POST apps/groupfolders/folders/$folderId/quota`: Set the quota for a folder
150-
- `quota`: The new quota for the folder in bytes, user `-3` for unlimited
151-
- `POST apps/groupfolders/folders/$folderId/mountpoint`: Change the name of a folder
152-
- `mountpoint`: The new name for the folder
153-
154-
For all `POST` calls the required parameters are listed.
155-
156-
Non-admins can access the `GET` requests to retrieve info about group folders they have access to.
157-
Admins can add `applicable=1` as a parameter to the group folder list request to get the same filtered results of only folders they have direct access to.
129+
See the [OpenAPI specification](openapi.json) to learn about all available API endpoints: https://petstore.swagger.io/?url=https://raw.githubusercontent.com/nextcloud/groupfolders/master/openapi.json
158130

159131
### WebDAV API
160132

β€ŽREUSE.toml

+12
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ precedence = "aggregate"
3535
SPDX-FileCopyrightText = "2019 Nextcloud GmbH and Nextcloud contributors"
3636
SPDX-License-Identifier = "AGPL-3.0-or-later"
3737

38+
[[annotations]]
39+
path = ["vendor-bin/**"]
40+
precedence = "aggregate"
41+
SPDX-FileCopyrightText = "2024 Nextcloud GmbH and Nextcloud contributors"
42+
SPDX-License-Identifier = "AGPL-3.0-or-later"
43+
3844
[[annotations]]
3945
path = ["cypress/tsconfig.json", "cypress/fixtures/example.json", "screenshots/acl.png", "screenshots/aclAdmin.png", "screenshots/edit.png", "screenshots/folders.png", "screenshots/permissions.png"]
4046
precedence = "aggregate"
@@ -46,3 +52,9 @@ path = ["img/app-dark.svg", "img/app.svg", "img/deny.svg", "img/folder-group.svg
4652
precedence = "aggregate"
4753
SPDX-FileCopyrightText = "2018-2024 Google LLC"
4854
SPDX-License-Identifier = "Apache-2.0"
55+
56+
[[annotations]]
57+
path = ["openapi.json", "src/types/openapi/openapi.ts"]
58+
precedence = "aggregate"
59+
SPDX-FileCopyrightText = "2024 Nextcloud GmbH and Nextcloud contributors"
60+
SPDX-License-Identifier = "AGPL-3.0-or-later"

β€Žcomposer.json

+14-3
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,30 @@
1010
"require": {
1111
"php-parallel-lint/php-parallel-lint": "^1.2"
1212
},
13+
"require": {
14+
"bamarni/composer-bin-plugin": "^1.8"
15+
},
1316
"scripts": {
14-
"lint": "find . -name \\*.php -not -path './vendor/*' -print0 | xargs -0 -n1 php -l",
17+
"post-install-cmd": [
18+
"@composer bin all install --ansi"
19+
],
20+
"post-update-cmd": [
21+
"@composer bin all update --ansi"
22+
],
23+
"lint": "find . -name \\*.php -not -path './vendor/*' -not -path './vendor-bin/*' -print0 | xargs -0 -n1 php -l",
1524
"cs:check": "php-cs-fixer fix --dry-run --diff",
1625
"cs:fix": "php-cs-fixer fix",
1726
"psalm": "psalm.phar --threads=1",
1827
"psalm:update-baseline": "psalm.phar --threads=1 --update-baseline",
1928
"psalm:clear": "psalm.phar --clear-cache && psalm.phar --clear-global-cache",
2029
"psalm:fix": "psalm.phar --alter --issues=InvalidReturnType,InvalidNullableReturnType,MissingParamType,InvalidFalsableReturnType",
21-
"test:unit": "vendor/bin/phpunit -c tests/phpunit.xml"
30+
"test:unit": "vendor/bin/phpunit -c tests/phpunit.xml",
31+
"openapi": "generate-spec && npm run typescript:generate"
2232
},
2333
"config": {
2434
"allow-plugins": {
25-
"composer/package-versions-deprecated": true
35+
"composer/package-versions-deprecated": true,
36+
"bamarni/composer-bin-plugin": true
2637
},
2738
"platform": {
2839
"php": "8.0"

β€Žcomposer.lock

+36-40
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Žlib/AppInfo/Capabilities.php

+13-1
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,38 @@
88
namespace OCA\GroupFolders\AppInfo;
99

1010
use OCA\GroupFolders\Folder\FolderManager;
11+
use OCP\App\IAppManager;
1112
use OCP\Capabilities\ICapability;
1213
use OCP\IUser;
1314
use OCP\IUserSession;
1415

1516
class Capabilities implements ICapability {
1617
private IUserSession $userSession;
1718
private FolderManager $folderManager;
19+
private IAppManager $appManager;
1820

19-
public function __construct(IUserSession $userSession, FolderManager $folderManager) {
21+
public function __construct(IUserSession $userSession, FolderManager $folderManager, IAppManager $appManager) {
2022
$this->userSession = $userSession;
2123
$this->folderManager = $folderManager;
24+
$this->appManager = $appManager;
2225
}
2326

27+
/**
28+
* @return array{
29+
* groupfolders?: array{
30+
* appVersion: string,
31+
* hasGroupFolders: bool,
32+
* },
33+
* }
34+
*/
2435
public function getCapabilities(): array {
2536
$user = $this->userSession->getUser();
2637
if (!$user) {
2738
return [];
2839
}
2940
return [
3041
Application::APP_ID => [
42+
'appVersion' => $this->appManager->getAppVersion(Application::APP_ID),
3143
'hasGroupFolders' => $this->hasFolders($user),
3244
],
3345
];

β€Žlib/Command/FolderCommand.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
/**
1919
* Base command for commands asking the user for a folder id.
20+
*
21+
* @psalm-import-type InternalFolderOut from FolderManager
2022
*/
2123
abstract class FolderCommand extends Base {
2224
protected FolderManager $folderManager;
@@ -31,7 +33,7 @@ public function __construct(FolderManager $folderManager, IRootFolder $rootFolde
3133
}
3234

3335
/**
34-
* @psalm-return array{id: mixed, mount_point: string, groups: array<empty, empty>|mixed, quota: int, size: int|mixed, acl: bool}|false
36+
* @return InternalFolderOut|false
3537
*/
3638
protected function getFolder(InputInterface $input, OutputInterface $output) {
3739
$folderId = (int)$input->getArgument('folder_id');

0 commit comments

Comments
Β (0)