diff options
author | Carl Schwan <carl@carlschwan.eu> | 2022-09-07 18:04:23 +0200 |
---|---|---|
committer | nextcloud-command <nextcloud-command@users.noreply.github.com> | 2022-09-15 07:46:24 +0000 |
commit | 7bd83d9dcfbf95253cbce645da82488250451472 (patch) | |
tree | f084aa5a16e43c7a6f190af5e10ee0593c35817a /apps/updatenotification/lib | |
parent | 204a700f85e17966a15afaa2dc91250e3c8a77b4 (diff) | |
download | nextcloud-server-7bd83d9dcfbf95253cbce645da82488250451472.tar.gz nextcloud-server-7bd83d9dcfbf95253cbce645da82488250451472.zip |
Cleanup updatenotification
- Port away from jquery inside vue
- Use modern vue components when possible
- Fix some readability isssues particularly on dark theme
- Use IInitialState
- Use php7.4
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
Diffstat (limited to 'apps/updatenotification/lib')
-rw-r--r-- | apps/updatenotification/lib/Settings/Admin.php | 56 |
1 files changed, 18 insertions, 38 deletions
diff --git a/apps/updatenotification/lib/Settings/Admin.php b/apps/updatenotification/lib/Settings/Admin.php index b8062efd81f..fded4451408 100644 --- a/apps/updatenotification/lib/Settings/Admin.php +++ b/apps/updatenotification/lib/Settings/Admin.php @@ -33,6 +33,7 @@ use OC\User\Backend; use OCP\User\Backend\ICountUsersBackend; use OCA\UpdateNotification\UpdateChecker; use OCP\AppFramework\Http\TemplateResponse; +use OCP\AppFramework\Services\IInitialState; use OCP\IConfig; use OCP\IDateTimeFormatter; use OCP\IGroupManager; @@ -44,22 +45,15 @@ use OCP\IUserManager; use Psr\Log\LoggerInterface; class Admin implements ISettings { - /** @var IConfig */ - private $config; - /** @var UpdateChecker */ - private $updateChecker; - /** @var IGroupManager */ - private $groupManager; - /** @var IDateTimeFormatter */ - private $dateTimeFormatter; - /** @var IFactory */ - private $l10nFactory; - /** @var IRegistry */ - private $subscriptionRegistry; - /** @var IUserManager */ - private $userManager; - /** @var LoggerInterface */ - private $logger; + private IConfig $config; + private UpdateChecker $updateChecker; + private IGroupManager $groupManager; + private IDateTimeFormatter $dateTimeFormatter; + private IFactory $l10nFactory; + private IRegistry $subscriptionRegistry; + private IUserManager $userManager; + private LoggerInterface $logger; + private IInitialState $initialState; public function __construct( IConfig $config, @@ -69,7 +63,8 @@ class Admin implements ISettings { IFactory $l10nFactory, IRegistry $subscriptionRegistry, IUserManager $userManager, - LoggerInterface $logger + LoggerInterface $logger, + IInitialState $initialState ) { $this->config = $config; $this->updateChecker = $updateChecker; @@ -79,11 +74,9 @@ class Admin implements ISettings { $this->subscriptionRegistry = $subscriptionRegistry; $this->userManager = $userManager; $this->logger = $logger; + $this->initialState = $initialState; } - /** - * @return TemplateResponse - */ public function getForm(): TemplateResponse { $lastUpdateCheckTimestamp = $this->config->getAppValue('core', 'lastupdatedat'); $lastUpdateCheck = $this->dateTimeFormatter->formatDateTime($lastUpdateCheckTimestamp); @@ -131,12 +124,9 @@ class Admin implements ISettings { 'notifyGroups' => $this->getSelectedGroups($notifyGroups), 'hasValidSubscription' => $hasValidSubscription, ]; + $this->initialState->provideInitialState('data', $params); - $params = [ - 'json' => json_encode($params), - ]; - - return new TemplateResponse('updatenotification', 'admin', $params, ''); + return new TemplateResponse('updatenotification', 'admin', [], ''); } protected function filterChanges(array $changes): array { @@ -162,8 +152,8 @@ class Admin implements ISettings { } /** - * @param array $groupIds - * @return array + * @param list<string> $groupIds + * @return list<array{id: string, displayname: string}> */ protected function getSelectedGroups(array $groupIds): array { $result = []; @@ -174,26 +164,16 @@ class Admin implements ISettings { continue; } - $result[] = ['value' => $group->getGID(), 'label' => $group->getDisplayName()]; + $result[] = ['id' => $group->getGID(), 'displayname' => $group->getDisplayName()]; } return $result; } - /** - * @return string the section ID, e.g. 'sharing' - */ public function getSection(): string { return 'overview'; } - /** - * @return int whether the form should be rather on the top or bottom of - * the admin section. The forms are arranged in ascending order of the - * priority values. It is required to return a value between 0 and 100. - * - * E.g.: 70 - */ public function getPriority(): int { return 11; } |