Skip to content

Commit b7e9ad9

Browse files
committed
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 <[email protected]>
1 parent 107aeb3 commit b7e9ad9

File tree

8 files changed

+100
-130
lines changed

8 files changed

+100
-130
lines changed

apps/settings/css/settings.css

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/settings/css/settings.css.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/settings/css/settings.scss

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -900,10 +900,6 @@ span.version {
900900
}
901901
}
902902

903-
#version.section {
904-
border-bottom: none;
905-
}
906-
907903
.section {
908904
margin-bottom: 0;
909905
/* section divider lines, none needed for last one */
@@ -926,7 +922,6 @@ span.version {
926922
.followupsection {
927923
display: block;
928924
padding: 0 30px 30px 30px;
929-
color: #555;
930925
}
931926

932927
.app-image {

apps/updatenotification/lib/Settings/Admin.php

Lines changed: 18 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
use OCP\User\Backend\ICountUsersBackend;
3434
use OCA\UpdateNotification\UpdateChecker;
3535
use OCP\AppFramework\Http\TemplateResponse;
36+
use OCP\AppFramework\Services\IInitialState;
3637
use OCP\IConfig;
3738
use OCP\IDateTimeFormatter;
3839
use OCP\IGroupManager;
@@ -44,22 +45,15 @@
4445
use Psr\Log\LoggerInterface;
4546

4647
class Admin implements ISettings {
47-
/** @var IConfig */
48-
private $config;
49-
/** @var UpdateChecker */
50-
private $updateChecker;
51-
/** @var IGroupManager */
52-
private $groupManager;
53-
/** @var IDateTimeFormatter */
54-
private $dateTimeFormatter;
55-
/** @var IFactory */
56-
private $l10nFactory;
57-
/** @var IRegistry */
58-
private $subscriptionRegistry;
59-
/** @var IUserManager */
60-
private $userManager;
61-
/** @var LoggerInterface */
62-
private $logger;
48+
private IConfig $config;
49+
private UpdateChecker $updateChecker;
50+
private IGroupManager $groupManager;
51+
private IDateTimeFormatter $dateTimeFormatter;
52+
private IFactory $l10nFactory;
53+
private IRegistry $subscriptionRegistry;
54+
private IUserManager $userManager;
55+
private LoggerInterface $logger;
56+
private IInitialState $initialState;
6357

6458
public function __construct(
6559
IConfig $config,
@@ -69,7 +63,8 @@ public function __construct(
6963
IFactory $l10nFactory,
7064
IRegistry $subscriptionRegistry,
7165
IUserManager $userManager,
72-
LoggerInterface $logger
66+
LoggerInterface $logger,
67+
IInitialState $initialState
7368
) {
7469
$this->config = $config;
7570
$this->updateChecker = $updateChecker;
@@ -79,11 +74,9 @@ public function __construct(
7974
$this->subscriptionRegistry = $subscriptionRegistry;
8075
$this->userManager = $userManager;
8176
$this->logger = $logger;
77+
$this->initialState = $initialState;
8278
}
8379

84-
/**
85-
* @return TemplateResponse
86-
*/
8780
public function getForm(): TemplateResponse {
8881
$lastUpdateCheckTimestamp = $this->config->getAppValue('core', 'lastupdatedat');
8982
$lastUpdateCheck = $this->dateTimeFormatter->formatDateTime($lastUpdateCheckTimestamp);
@@ -131,12 +124,9 @@ public function getForm(): TemplateResponse {
131124
'notifyGroups' => $this->getSelectedGroups($notifyGroups),
132125
'hasValidSubscription' => $hasValidSubscription,
133126
];
127+
$this->initialState->provideInitialState('data', $params);
134128

135-
$params = [
136-
'json' => json_encode($params),
137-
];
138-
139-
return new TemplateResponse('updatenotification', 'admin', $params, '');
129+
return new TemplateResponse('updatenotification', 'admin', [], '');
140130
}
141131

142132
protected function filterChanges(array $changes): array {
@@ -162,8 +152,8 @@ protected function filterChanges(array $changes): array {
162152
}
163153

164154
/**
165-
* @param array $groupIds
166-
* @return array
155+
* @param list<string> $groupIds
156+
* @return array{id: string, displayname: string}
167157
*/
168158
protected function getSelectedGroups(array $groupIds): array {
169159
$result = [];
@@ -174,26 +164,16 @@ protected function getSelectedGroups(array $groupIds): array {
174164
continue;
175165
}
176166

177-
$result[] = ['value' => $group->getGID(), 'label' => $group->getDisplayName()];
167+
$result[] = ['id' => $group->getGID(), 'displayname' => $group->getDisplayName()];
178168
}
179169

180170
return $result;
181171
}
182172

183-
/**
184-
* @return string the section ID, e.g. 'sharing'
185-
*/
186173
public function getSection(): string {
187174
return 'overview';
188175
}
189176

190-
/**
191-
* @return int whether the form should be rather on the top or bottom of
192-
* the admin section. The forms are arranged in ascending order of the
193-
* priority values. It is required to return a value between 0 and 100.
194-
*
195-
* E.g.: 70
196-
*/
197177
public function getPriority(): int {
198178
return 11;
199179
}

0 commit comments

Comments
 (0)