generated from Nodarx/template
feat: lots more improvements
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { IdentityBasic } from '@KTXM/MailManager/models/identity'
|
||||
import { ServiceObject } from '@KTXM/MailManager/models/service'
|
||||
import type { ServiceIdentity } from '@KTXM/MailManager/types/service'
|
||||
import type { ServiceIdentity, ServiceIdentityBasic } from '@KTXM/MailManager/types/service'
|
||||
import type { ProviderAuthPanelProps, ProviderAuthPanelEmits } from '@KTXM/MailManager/types/integration'
|
||||
|
||||
const props = defineProps<ProviderAuthPanelProps>()
|
||||
@@ -15,7 +15,7 @@ const rules = {
|
||||
required: (value: unknown) => !!value || 'This field is required'
|
||||
}
|
||||
|
||||
const currentIdentity = computed((): ServiceIdentity | null => {
|
||||
const currentIdentity = computed((): ServiceIdentityBasic | null => {
|
||||
if (!identity.value || !secret.value) {
|
||||
return null
|
||||
}
|
||||
@@ -53,8 +53,21 @@ watch(
|
||||
return
|
||||
}
|
||||
|
||||
const nextService = createServiceObject(props.service)
|
||||
nextService.identity = value ? new IdentityBasic(value.identity, value.secret) : null
|
||||
const nextService = props.service ?? new ServiceObject()
|
||||
|
||||
if (value === null) {
|
||||
nextService.identity = null
|
||||
emit('update:service', nextService)
|
||||
return
|
||||
}
|
||||
|
||||
if (nextService.identity instanceof IdentityBasic) {
|
||||
nextService.identity.identity = value.identity
|
||||
nextService.identity.secret = value.secret
|
||||
} else {
|
||||
nextService.identity = new IdentityBasic(value.identity, value.secret)
|
||||
}
|
||||
|
||||
emit('update:service', nextService)
|
||||
},
|
||||
{ immediate: true, deep: true }
|
||||
@@ -73,16 +86,6 @@ function syncFromService(service?: ServiceObject) {
|
||||
secret.value = props.prefilledSecret || ''
|
||||
}
|
||||
|
||||
function createServiceObject(service?: ServiceObject): ServiceObject {
|
||||
const nextService = new ServiceObject()
|
||||
|
||||
if (service) {
|
||||
nextService.fromJson(service.toJson())
|
||||
}
|
||||
|
||||
return nextService
|
||||
}
|
||||
|
||||
function sameIdentity(a: ServiceIdentity | null, b: ServiceIdentity | null): boolean {
|
||||
if (a === null || b === null) {
|
||||
return a === b
|
||||
@@ -100,13 +103,8 @@ function sameIdentity(a: ServiceIdentity | null, b: ServiceIdentity | null): boo
|
||||
<h3 class="text-h6 mb-4">Authentication</h3>
|
||||
<p class="text-body-2 mb-6">Provide the username and password your IMAP server expects.</p>
|
||||
|
||||
<v-alert type="info" variant="tonal" class="mb-4">
|
||||
<template #prepend>
|
||||
<v-icon>mdi-information</v-icon>
|
||||
</template>
|
||||
<div class="text-caption">
|
||||
Most IMAP servers use your full email address as the username. Use an app password if your mail host requires one.
|
||||
</div>
|
||||
<v-alert type="info" variant="tonal">
|
||||
Most IMAP servers use your full email address as the username. Use an app password if your mail host requires one.
|
||||
</v-alert>
|
||||
|
||||
<v-text-field
|
||||
|
||||
Reference in New Issue
Block a user