mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
fix: postinstall form
This commit is contained in:
parent
55cdc2a3d7
commit
65da87bee2
4 changed files with 19 additions and 11 deletions
|
@ -127,11 +127,15 @@ export function useUsersAndGroups(username?: MaybeRefOrGetter<string>) {
|
|||
}
|
||||
}
|
||||
|
||||
export function useDomains(domain_?: MaybeRefOrGetter<string>) {
|
||||
export function useDomains(
|
||||
domain_?: MaybeRefOrGetter<string>,
|
||||
installed: boolean = true,
|
||||
) {
|
||||
const { mainDomain, domains: domains_, domainDetails } = useData()
|
||||
|
||||
const domains = computed(() => {
|
||||
if (!domains_.value) throw new Error(getNoDataMessage('domains'))
|
||||
if (!domains_.value && installed)
|
||||
throw new Error(getNoDataMessage('domains'))
|
||||
return domains_.value
|
||||
})
|
||||
|
||||
|
|
|
@ -123,7 +123,7 @@ export const useInfos = createGlobalState(() => {
|
|||
if (!installed.value) {
|
||||
router.push({ name: 'post-install' })
|
||||
} else {
|
||||
_onLogin()
|
||||
await _onLogin()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -133,11 +133,9 @@ async function performPostInstall(force = false) {
|
|||
} else if (hasWordsInError(['domain', 'dyndns'])) {
|
||||
step.value = 'domain'
|
||||
serverError.value = err.message
|
||||
} else if (hasWordsInError(['password', 'user'])) {
|
||||
} else {
|
||||
step.value = 'user'
|
||||
serverErrors.global = [err.message]
|
||||
} else {
|
||||
throw err
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import { useI18n } from 'vue-i18n'
|
|||
|
||||
import { useDomains } from '@/composables/data'
|
||||
import { useForm } from '@/composables/form'
|
||||
import { useInfos } from '@/composables/useInfos'
|
||||
import {
|
||||
domain,
|
||||
dynDomain,
|
||||
|
@ -34,8 +35,9 @@ const emit = defineEmits<{
|
|||
}>()
|
||||
|
||||
const { t } = useI18n()
|
||||
const { installed } = useInfos()
|
||||
|
||||
const { domains } = useDomains()
|
||||
const { domains } = useDomains(undefined, installed.value)
|
||||
const dynDomains = ['nohost.me', 'noho.st', 'ynh.fr']
|
||||
|
||||
const dynDnsForbiden = computed(() => {
|
||||
|
@ -75,17 +77,21 @@ const fields = {
|
|||
},
|
||||
}) satisfies FieldProps<'InputItem', Form['domain']>,
|
||||
|
||||
dynDomain: {
|
||||
dynDomain: reactive({
|
||||
component: 'AdressItem',
|
||||
label: t('domain_name'),
|
||||
rules: { localPart: { required, dynDomain } },
|
||||
rules: computed(() => {
|
||||
return selected.value === 'dynDomain'
|
||||
? { localPart: { required, dynDomain }, domain: { required } }
|
||||
: undefined
|
||||
}),
|
||||
cProps: {
|
||||
id: 'dyn-domain',
|
||||
placeholder: t('placeholder.domain').split('.')[0],
|
||||
type: 'domain',
|
||||
choices: dynDomains,
|
||||
},
|
||||
} satisfies FieldProps<'AdressItem', Form['dynDomain']>,
|
||||
}) satisfies FieldProps<'AdressItem', Form['dynDomain']>,
|
||||
|
||||
dynDomainPassword: reactive({
|
||||
component: 'InputItem',
|
||||
|
@ -121,7 +127,7 @@ const fields = {
|
|||
label: t('domain_name'),
|
||||
rules: computed(() =>
|
||||
selected.value === 'localDomain'
|
||||
? { localPart: { required, dynDomain } }
|
||||
? { localPart: { required, dynDomain }, domain: { required } }
|
||||
: undefined,
|
||||
),
|
||||
cProps: {
|
||||
|
|
Loading…
Add table
Reference in a new issue