mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 02:11:53 +00:00
remove non option from smtp for better package compat
This commit is contained in:
@@ -84,10 +84,6 @@ export const customSmtp = smtpFields()
|
||||
* Each variant has SMTP fields pre-filled with the provider's recommended settings.
|
||||
*/
|
||||
export const smtpProviderVariants = Variants.of({
|
||||
none: {
|
||||
name: 'None',
|
||||
spec: InputSpec.of({}),
|
||||
},
|
||||
gmail: {
|
||||
name: 'Gmail',
|
||||
spec: smtpFields({
|
||||
@@ -140,7 +136,7 @@ export const smtpProviderVariants = Variants.of({
|
||||
export const systemSmtpSpec = InputSpec.of({
|
||||
provider: Value.union({
|
||||
name: 'Provider',
|
||||
default: 'none',
|
||||
default: 'gmail',
|
||||
variants: smtpProviderVariants,
|
||||
}),
|
||||
})
|
||||
|
||||
@@ -360,7 +360,6 @@ export default {
|
||||
377: 'StartOS-Sicherungen erkannt',
|
||||
378: 'Keine StartOS-Sicherungen erkannt',
|
||||
379: 'StartOS-Version',
|
||||
381: 'SMTP-Zugangsdaten',
|
||||
382: 'Test-E-Mail senden',
|
||||
383: 'Senden',
|
||||
384: 'E-Mail wird gesendet',
|
||||
|
||||
@@ -359,7 +359,6 @@ export const ENGLISH: Record<string, number> = {
|
||||
'StartOS backups detected': 377,
|
||||
'No StartOS backups detected': 378,
|
||||
'StartOS Version': 379,
|
||||
'SMTP Credentials': 381,
|
||||
'Send test email': 382,
|
||||
'Send': 383,
|
||||
'Sending email': 384,
|
||||
|
||||
@@ -360,7 +360,6 @@ export default {
|
||||
377: 'Copias de seguridad de StartOS detectadas',
|
||||
378: 'No se detectaron copias de seguridad de StartOS',
|
||||
379: 'Versión de StartOS',
|
||||
381: 'Credenciales SMTP',
|
||||
382: 'Enviar correo de prueba',
|
||||
383: 'Enviar',
|
||||
384: 'Enviando correo',
|
||||
|
||||
@@ -360,7 +360,6 @@ export default {
|
||||
377: 'Sauvegardes StartOS détectées',
|
||||
378: 'Aucune sauvegarde StartOS détectée',
|
||||
379: 'Version de StartOS',
|
||||
381: 'Identifiants SMTP',
|
||||
382: 'Envoyer un email de test',
|
||||
383: 'Envoyer',
|
||||
384: 'Envoi de l’email',
|
||||
|
||||
@@ -360,7 +360,6 @@ export default {
|
||||
377: 'Wykryto kopie zapasowe StartOS',
|
||||
378: 'Nie wykryto kopii zapasowych StartOS',
|
||||
379: 'Wersja StartOS',
|
||||
381: 'Dane logowania SMTP',
|
||||
382: 'Wyślij e-mail testowy',
|
||||
383: 'Wyślij',
|
||||
384: 'Wysyłanie e-maila',
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
i18nPipe,
|
||||
LoadingService,
|
||||
} from '@start9labs/shared'
|
||||
import { inputSpec, utils } from '@start9labs/start-sdk'
|
||||
import { inputSpec, ISB, utils } from '@start9labs/start-sdk'
|
||||
import { TuiButton, TuiError, TuiTextfield, TuiTitle } from '@taiga-ui/core'
|
||||
import { TuiHeader } from '@taiga-ui/layout'
|
||||
import { PatchDB } from 'patch-db-client'
|
||||
@@ -43,14 +43,14 @@ function detectProviderKey(host: string | undefined): string {
|
||||
<a routerLink=".." tuiIconButton iconStart="@tui.arrow-left">
|
||||
{{ 'Back' | i18n }}
|
||||
</a>
|
||||
{{ 'SMTP' | i18n }}
|
||||
SMTP
|
||||
</ng-container>
|
||||
@if (form$ | async; as data) {
|
||||
<form [formGroup]="data.form">
|
||||
<header tuiHeader="body-l">
|
||||
<h3 tuiTitle>
|
||||
<b>
|
||||
{{ 'SMTP Credentials' | i18n }}
|
||||
SMTP
|
||||
<a
|
||||
tuiIconButton
|
||||
size="xs"
|
||||
@@ -66,6 +66,16 @@ function detectProviderKey(host: string | undefined): string {
|
||||
</header>
|
||||
<form-group [spec]="data.spec" />
|
||||
<footer>
|
||||
@if (!data.form.pristine) {
|
||||
<button
|
||||
tuiButton
|
||||
size="l"
|
||||
appearance="secondary"
|
||||
(click)="cancel(data)"
|
||||
>
|
||||
{{ 'Cancel' | i18n }}
|
||||
</button>
|
||||
}
|
||||
<button
|
||||
tuiButton
|
||||
size="l"
|
||||
@@ -76,7 +86,7 @@ function detectProviderKey(host: string | undefined): string {
|
||||
</button>
|
||||
</footer>
|
||||
</form>
|
||||
@if (data.form.value.provider?.selection !== 'none') {
|
||||
@if (data.form.value.smtp?.selection === 'enabled') {
|
||||
<form>
|
||||
<header tuiHeader="body-l">
|
||||
<h3 tuiTitle>
|
||||
@@ -163,12 +173,32 @@ export default class SystemEmailComponent {
|
||||
return !!value && !this.emailRegex.test(value)
|
||||
}
|
||||
|
||||
private readonly smtpSpec = ISB.InputSpec.of({
|
||||
smtp: ISB.Value.union({
|
||||
name: this.i18n.transform('SMTP'),
|
||||
default: 'disabled',
|
||||
variants: ISB.Variants.of({
|
||||
disabled: {
|
||||
name: this.i18n.transform('Disabled'),
|
||||
spec: ISB.InputSpec.of({}),
|
||||
},
|
||||
enabled: {
|
||||
name: this.i18n.transform('Enabled'),
|
||||
spec: inputSpec.constants.systemSmtpSpec,
|
||||
},
|
||||
}),
|
||||
}),
|
||||
})
|
||||
|
||||
readonly form$ = this.patch.watch$('serverInfo', 'smtp').pipe(
|
||||
switchMap(async value => {
|
||||
const spec = await configBuilderToSpec(inputSpec.constants.systemSmtpSpec)
|
||||
const spec = await configBuilderToSpec(this.smtpSpec)
|
||||
|
||||
const formData = value
|
||||
? {
|
||||
smtp: {
|
||||
selection: 'enabled' as const,
|
||||
value: {
|
||||
provider: {
|
||||
selection: detectProviderKey(value.host),
|
||||
value: {
|
||||
@@ -182,16 +212,18 @@ export default class SystemEmailComponent {
|
||||
password: value.password,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
: undefined
|
||||
const form = this.formService.createForm(spec, formData)
|
||||
|
||||
return { form, spec }
|
||||
return { form, spec, formData }
|
||||
}),
|
||||
)
|
||||
|
||||
private getSmtpValue(formValue: Record<string, any>) {
|
||||
const { security, ...rest } = formValue['provider'].value
|
||||
const { security, ...rest } = formValue['smtp'].value.provider.value
|
||||
return {
|
||||
...rest,
|
||||
security: security.selection,
|
||||
@@ -203,7 +235,7 @@ export default class SystemEmailComponent {
|
||||
const loader = this.loader.open('Saving').subscribe()
|
||||
|
||||
try {
|
||||
if (formValue['provider'].selection === 'none') {
|
||||
if (formValue['smtp'].selection === 'disabled') {
|
||||
await this.api.clearSmtp({})
|
||||
} else {
|
||||
await this.api.setSmtp(this.getSmtpValue(formValue))
|
||||
@@ -215,6 +247,13 @@ export default class SystemEmailComponent {
|
||||
}
|
||||
}
|
||||
|
||||
cancel(data: {
|
||||
form: ReturnType<FormService['createForm']>
|
||||
formData: Record<string, any> | undefined
|
||||
}) {
|
||||
data.form.reset(data.formData)
|
||||
}
|
||||
|
||||
async sendTestEmail(formValue: Record<string, any>) {
|
||||
const smtpValue = this.getSmtpValue(formValue)
|
||||
const address = this.testEmailControl.value!
|
||||
@@ -28,7 +28,7 @@ export default [
|
||||
{
|
||||
path: 'email',
|
||||
title: titleResolver,
|
||||
loadComponent: () => import('./routes/email/email.component'),
|
||||
loadComponent: () => import('./routes/smtp/smtp.component'),
|
||||
},
|
||||
{
|
||||
path: 'backup',
|
||||
|
||||
Reference in New Issue
Block a user