Merge pull request #271 from nextcloud/enh/settings_section

Include settings section
This commit is contained in:
Joas Schilling 2021-02-04 11:17:24 +01:00 committed by GitHub
commit 42f13d6189
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 82 additions and 9 deletions

View File

@ -42,5 +42,6 @@ This app allows users to register a new account.
</dependencies> </dependencies>
<settings> <settings>
<admin>OCA\Registration\Settings\RegistrationSettings</admin> <admin>OCA\Registration\Settings\RegistrationSettings</admin>
<admin-section>OCA\Registration\Settings\RegistrationSettingsSection</admin-section>
</settings> </settings>
</info> </info>

1
img/app-dark.svg Normal file
View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="24" height="24" viewBox="0 0 24 24"><path d="M15,14C12.33,14 7,15.33 7,18V20H23V18C23,15.33 17.67,14 15,14M6,10V7H4V10H1V12H4V15H6V12H9V10M15,12A4,4 0 0,0 19,8A4,4 0 0,0 15,4A4,4 0 0,0 11,8A4,4 0 0,0 15,12Z" /></svg>

After

Width:  |  Height:  |  Size: 321 B

View File

@ -1,7 +1 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="24" height="24" viewBox="0 0 24 24"><path d="M15,14C12.33,14 7,15.33 7,18V20H23V18C23,15.33 17.67,14 15,14M6,10V7H4V10H1V12H4V15H6V12H9V10M15,12A4,4 0 0,0 19,8A4,4 0 0,0 15,4A4,4 0 0,0 11,8A4,4 0 0,0 15,12Z" fill="#FFFFFF"/></svg>
<svg xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://www.w3.org/2000/svg" height="32" width="32" version="1.1" xmlns:cc="http://creativecommons.org/ns#" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/">
<g transform="translate(573.14 110.3)" fill-rule="evenodd">
<path d="m-570.22-108.3c-0.50115 0-0.92082 0.41966-0.92082 0.92081v24.158c0 0.51739 0.40324 0.92073 0.92082 0.92073h26.158c0.51756 0 0.92081-0.40316 0.92081-0.92073l0.00069-14.154c0-0.5011-0.41966-0.92524-0.92081-0.92524h-21.079l-0.0007 11.005c0 0.48012-0.52409 0.97706-1.0042 0.97706-0.48012 0-0.99573-0.49694-0.99573-0.97706l0.0007-12.143c0-0.48012 0.40484-0.86215 0.88497-0.86215h4.5944l14.521 0.00052-0.0007-2.9516c0-0.56713-0.42551-1.0481-0.99245-1.0481h-13.007v-3.0791c0-0.50118-0.40586-0.92081-0.90701-0.92081z"/>
<path d="m-570.22-107.3c-0.50115 0-0.92082 0.41966-0.92082 0.92081v24.158c0 0.51739 0.40324 0.92073 0.92082 0.92073h26.158c0.51756 0 0.92081-0.40316 0.92081-0.92073l0.00069-14.154c0-0.5011-0.41966-0.92524-0.92081-0.92524h-21.079l-0.0007 11.005c0 0.48012-0.52409 0.97706-1.0042 0.97706-0.48012 0-0.99573-0.49694-0.99573-0.97706l0.0007-12.143c0-0.48012 0.40484-0.86214 0.88497-0.86214h4.5944l14.521 0.00052-0.0007-2.9516c0-0.56713-0.42551-1.0481-0.99245-1.0481h-13.007v-3.0791c0-0.50118-0.40586-0.92081-0.90701-0.92081z" fill="#fff"/>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 335 B

View File

@ -25,6 +25,7 @@ declare(strict_types=1);
namespace OCA\Registration\Settings; namespace OCA\Registration\Settings;
use OCA\Registration\AppInfo\Application;
use OCP\AppFramework\Http\TemplateResponse; use OCP\AppFramework\Http\TemplateResponse;
use OCP\IConfig; use OCP\IConfig;
use OCP\IGroupManager; use OCP\IGroupManager;
@ -44,7 +45,6 @@ class RegistrationSettings implements ISettings {
$this->appName = $appName; $this->appName = $appName;
$this->config = $config; $this->config = $config;
$this->groupManager = $groupManager; $this->groupManager = $groupManager;
$this->appName = $appName;
} }
public function getForm(): TemplateResponse { public function getForm(): TemplateResponse {
@ -86,7 +86,7 @@ class RegistrationSettings implements ISettings {
} }
public function getSection(): string { public function getSection(): string {
return 'additional'; return Application::APP_ID;
} }
public function getPriority(): int { public function getPriority(): int {

View File

@ -0,0 +1,77 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2021 Jonas Rittershofer <jotoeri@users.noreply.github.com>
*
* @author Jonas Rittershofer <jotoeri@users.noreply.github.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* 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
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Registration\Settings;
use OCA\Registration\AppInfo\Application;
use OCP\IL10N;
use OCP\IURLGenerator;
use OCP\Settings\IIconSection;
class RegistrationSettingsSection implements IIconSection {
/** @var IL10N */
private $l10n;
/** @var IURLGenerator */
private $urlGenerator;
public function __construct(IL10N $l10n, IURLGenerator $urlGenerator) {
$this->l10n = $l10n;
$this->urlGenerator = $urlGenerator;
}
/**
* Section ID to be set in Settings
* @return string
*/
public function getID(): string {
return Application::APP_ID;
}
/**
* Section Name to be displayed
* @return string
*/
public function getName(): string {
return $this->l10n->t('Registration');
}
/**
* Return Priority of section 0-100
* @return int
*/
public function getPriority(): int {
return 80;
}
/**
* Pass the relative path to the icon
* @return string
*/
public function getIcon(): string {
return $this->urlGenerator->imagePath(Application::APP_ID, 'app-dark.svg');
}
}