-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Add account warnings to admin settings #40744
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
88d6c8e
Add ClientDiagnostic mapper and controller
come-nc 86fd999
Add migration to create DB table for client diagnostics
come-nc 4687603
json_encode client diagnostic
come-nc e67969e
Add OCP API to register account warnings providers
come-nc f398b31
Add a provider of account warnings for outdated clients
come-nc a24a3d8
Implement account provider registration in RegistrationContext
come-nc b0528d3
Add route to get account warnings from server
come-nc d01ad74
Add QuotaWarningsProvider to warn about account close to full quota
come-nc 2f96c57
Add user id information to quota warning
come-nc 3298503
Add ClientDiagnosticWarningsProvider and fix diagnostic PUT route
come-nc 0cde8b9
Move the route for pushing diagnostics to ocs endpoint
come-nc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add route to get account warnings from server
Signed-off-by: Côme Chilliet <[email protected]>
- Loading branch information
commit b0528d3bf82bab60fffcf282db97d42454b0a4b8
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
58 changes: 58 additions & 0 deletions
58
apps/settings/lib/AccountWarnings/AccountWarningsManager.php
This file contains hidden or 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,58 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| /** | ||
| * @copyright Copyright (c) 2023 Côme Chilliet <[email protected]> | ||
| * | ||
| * @author Côme Chilliet <[email protected]> | ||
| * | ||
| * @license AGPL-3.0 | ||
| * | ||
| * This code is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU Affero General Public License, version 3, | ||
| * as published by the Free Software Foundation. | ||
| * | ||
| * 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, version 3, | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/> | ||
| * | ||
| */ | ||
|
|
||
| namespace OCA\Settings\AccountWarnings; | ||
|
|
||
| use OCP\Settings\IAccountWarningsProvider; | ||
| use OC\AppFramework\Bootstrap\Coordinator; | ||
|
|
||
| class AccountWarningsManager { | ||
| public function __construct( | ||
| private Coordinator $coordinator, | ||
| ) { | ||
| } | ||
|
|
||
| /** | ||
| * @return array<class-string, array{name:string,warnings:array<string,string>}> | ||
| */ | ||
| public function getAll(): array { | ||
| $results = []; | ||
| $providerRegistrations = $this->coordinator->getRegistrationContext()->getAccountWarningsProviders(); | ||
Check noticeCode scanning / Psalm PossiblyNullReference
Cannot call method getAccountWarningsProviders on possibly null value
|
||
| foreach ($providerRegistrations as $providerRegistration) { | ||
| /** @var IAccountWarningsProvider $provider */ | ||
| $provider = \OCP\Server::get($providerRegistration->getService()); | ||
| $warnings = $provider->getAccountWarnings(); | ||
| $results[$provider::class] = ['name' => $provider->getName(),'warnings' => []]; | ||
| foreach ($warnings as $warning) { | ||
| $category = $warning->getSeverity(); | ||
| if (!isset($results[$provider::class]['warnings'][$category])) { | ||
| $results[$provider::class]['warnings'][$category] = []; | ||
| } | ||
| $results[$provider::class]['warnings'][$category][] = $warning->getText(); | ||
| } | ||
| } | ||
| return $results; | ||
Check failureCode scanning / Psalm InvalidReturnStatement
The inferred type 'array<class-string<OCP\Settings\IAccountWarningsProvider>, array{name: string, warnings: array<'error'|'info'|'warning', non-empty-list<string>>}>' does not match the declared return type 'array<class-string, array{name: string, warnings: array<string, string>}>' for OCA\Settings\AccountWarnings\AccountWarningsManager::getAll
|
||
| } | ||
| } | ||
45 changes: 45 additions & 0 deletions
45
apps/settings/lib/Controller/AccountWarningsController.php
This file contains hidden or 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,45 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| /** | ||
| * @copyright Copyright (c) 2023 Côme Chilliet <[email protected]> | ||
| * | ||
| * @author Côme Chilliet <[email protected]> | ||
| * | ||
| * @license AGPL-3.0 | ||
| * | ||
| * This code is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU Affero General Public License, version 3, | ||
| * as published by the Free Software Foundation. | ||
| * | ||
| * 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, version 3, | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/> | ||
| * | ||
| */ | ||
|
|
||
| namespace OCA\Settings\Controller; | ||
|
|
||
| use OCA\Settings\AccountWarnings\AccountWarningsManager; | ||
| use OCP\AppFramework\Controller; | ||
| use OCP\AppFramework\Http\DataResponse; | ||
| use OCP\IRequest; | ||
|
|
||
| class AccountWarningsController extends Controller { | ||
| public function __construct( | ||
| string $appName, | ||
| IRequest $request, | ||
| private AccountWarningsManager $manager, | ||
| ) { | ||
| parent::__construct($appName, $request); | ||
| } | ||
|
|
||
| public function getAll(): DataResponse { | ||
| return new DataResponse($this->manager->getAll()); | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check failure
Code scanning / Psalm
InvalidReturnType