diff --git a/apps/settings/lib/Settings/Admin/Mail.php b/apps/settings/lib/Settings/Admin/Mail.php index f4c546b27a42f..93a1dada30fe6 100644 --- a/apps/settings/lib/Settings/Admin/Mail.php +++ b/apps/settings/lib/Settings/Admin/Mail.php @@ -1,4 +1,5 @@ * @@ -8,6 +9,7 @@ * @author Julius Härtl * @author Lukas Reschke * @author Roeland Jago Douma + * @author Carl Schwan * * @license GNU AGPL version 3 or any later version * @@ -28,30 +30,26 @@ namespace OCA\Settings\Settings\Admin; use OCP\AppFramework\Http\TemplateResponse; +use OCP\AppFramework\Services\IInitialState; use OCP\IConfig; use OCP\IL10N; use OCP\Settings\IDelegatedSettings; +use OCP\IURLGenerator; class Mail implements IDelegatedSettings { - /** @var IConfig */ - private $config; + private IConfig $config; + private IL10N $l; + private IInitialState $initialState; + private IURLGenerator $urlGenerator; - /** @var IL10N $l */ - private $l; - - /** - * @param IConfig $config - * @param IL10N $l - */ - public function __construct(IConfig $config, IL10N $l) { + public function __construct(IConfig $config, IL10N $l, IInitialState $initialState, IURLGenerator $urlGenerator) { $this->config = $config; $this->l = $l; + $this->initialState = $initialState; + $this->urlGenerator = $urlGenerator; } - /** - * @return TemplateResponse - */ - public function getForm() { + public function getForm(): TemplateResponse { $parameters = [ // Mail 'sendmail_is_available' => (bool) \OC_Helper::findBinaryPath('sendmail'), @@ -76,24 +74,19 @@ public function getForm() { $parameters['mail_smtpmode'] = 'smtp'; } + foreach ($parameters as $key => $parameter) { + $this->initialState->provideInitialState($key, $parameter); + } + $this->initialState->provideInitialState('emailAdminDocUrl', 'https://jroiere.com'); //$this->urlGenerator->linkToDocs('admin-email')); + return new TemplateResponse('settings', 'settings/admin/additional-mail', $parameters, ''); } - /** - * @return string the section ID, e.g. 'sharing' - */ - public function getSection() { + public function getSection(): string { return 'server'; } - /** - * @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() { + public function getPriority(): int { return 10; } diff --git a/apps/settings/src/components/MailDeliverySettings.vue b/apps/settings/src/components/MailDeliverySettings.vue new file mode 100644 index 0000000000000..d438d877d92d9 --- /dev/null +++ b/apps/settings/src/components/MailDeliverySettings.vue @@ -0,0 +1,263 @@ + + + + + + + diff --git a/apps/settings/src/main-admin-email.js b/apps/settings/src/main-admin-email.js new file mode 100644 index 0000000000000..b8a7e04008288 --- /dev/null +++ b/apps/settings/src/main-admin-email.js @@ -0,0 +1,35 @@ +/** + * @copyright 2022 Carl Schwa + * @license AGPL-3.0-or-later + * + * 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 . + * + */ + +import { loadState } from '@nextcloud/initial-state' +import Vue from 'vue' + +import MailDeliverySettings from './components/MailDeliverySettings.vue' + +// eslint-disable-next-line camelcase +__webpack_nonce__ = btoa(OC.requestToken) + +Vue.prototype.t = t + +// Not used here but required for legacy templates +window.OC = window.OC || {} +window.OC.Settings = window.OC.Settings || {} + +const View = Vue.extend(MailDeliverySettings) +new View().$mount('#mail_delivery_settings') diff --git a/apps/settings/templates/settings/admin/additional-mail.php b/apps/settings/templates/settings/admin/additional-mail.php index 6b85fcbe86753..938cbc4ebba4e 100644 --- a/apps/settings/templates/settings/admin/additional-mail.php +++ b/apps/settings/templates/settings/admin/additional-mail.php @@ -52,15 +52,19 @@ 'pipe' => 'pipe (-t)' ]; +\OCP\Util::addScript('settings', 'vue-settings-admin-mail'); + ?> +
+

t('Email server'));?>

-

t('It is important to set up this server to be able to send emails, like for password reset and notifications.')); ?>

+

t('')); ?>