Skip to content

Commit

Permalink
Cleanup updatenotification
Browse files Browse the repository at this point in the history
- 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>
  • Loading branch information
CarlSchwan committed Sep 8, 2022
1 parent 107aeb3 commit 048b38c
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 125 deletions.
5 changes: 0 additions & 5 deletions apps/settings/css/settings.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apps/settings/css/settings.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions apps/settings/css/settings.scss
Original file line number Diff line number Diff line change
Expand Up @@ -900,10 +900,6 @@ span.version {
}
}

#version.section {
border-bottom: none;
}

.section {
margin-bottom: 0;
/* section divider lines, none needed for last one */
Expand All @@ -926,7 +922,6 @@ span.version {
.followupsection {
display: block;
padding: 0 30px 30px 30px;
color: #555;
}

.app-image {
Expand Down
48 changes: 15 additions & 33 deletions apps/updatenotification/lib/Settings/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
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;
Expand All @@ -44,22 +45,14 @@
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;

public function __construct(
IConfig $config,
Expand All @@ -69,7 +62,8 @@ public function __construct(
IFactory $l10nFactory,
IRegistry $subscriptionRegistry,
IUserManager $userManager,
LoggerInterface $logger
LoggerInterface $logger,
IInitialState $initialState
) {
$this->config = $config;
$this->updateChecker = $updateChecker;
Expand All @@ -79,6 +73,7 @@ public function __construct(
$this->subscriptionRegistry = $subscriptionRegistry;
$this->userManager = $userManager;
$this->logger = $logger;
$this->initialState = $initialState;
}

/**
Expand Down Expand Up @@ -131,12 +126,9 @@ public function getForm(): TemplateResponse {
'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 {
Expand Down Expand Up @@ -174,26 +166,16 @@ protected function getSelectedGroups(array $groupIds): array {
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;
}
Expand Down
Loading

0 comments on commit 048b38c

Please sign in to comment.