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 { mainDomain, domains: domains_, domainDetails } = useData()
|
||||||
|
|
||||||
const domains = computed(() => {
|
const domains = computed(() => {
|
||||||
if (!domains_.value) throw new Error(getNoDataMessage('domains'))
|
if (!domains_.value && installed)
|
||||||
|
throw new Error(getNoDataMessage('domains'))
|
||||||
return domains_.value
|
return domains_.value
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -123,7 +123,7 @@ export const useInfos = createGlobalState(() => {
|
||||||
if (!installed.value) {
|
if (!installed.value) {
|
||||||
router.push({ name: 'post-install' })
|
router.push({ name: 'post-install' })
|
||||||
} else {
|
} else {
|
||||||
_onLogin()
|
await _onLogin()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -133,11 +133,9 @@ async function performPostInstall(force = false) {
|
||||||
} else if (hasWordsInError(['domain', 'dyndns'])) {
|
} else if (hasWordsInError(['domain', 'dyndns'])) {
|
||||||
step.value = 'domain'
|
step.value = 'domain'
|
||||||
serverError.value = err.message
|
serverError.value = err.message
|
||||||
} else if (hasWordsInError(['password', 'user'])) {
|
} else {
|
||||||
step.value = 'user'
|
step.value = 'user'
|
||||||
serverErrors.global = [err.message]
|
serverErrors.global = [err.message]
|
||||||
} else {
|
|
||||||
throw err
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import { useI18n } from 'vue-i18n'
|
||||||
|
|
||||||
import { useDomains } from '@/composables/data'
|
import { useDomains } from '@/composables/data'
|
||||||
import { useForm } from '@/composables/form'
|
import { useForm } from '@/composables/form'
|
||||||
|
import { useInfos } from '@/composables/useInfos'
|
||||||
import {
|
import {
|
||||||
domain,
|
domain,
|
||||||
dynDomain,
|
dynDomain,
|
||||||
|
@ -34,8 +35,9 @@ const emit = defineEmits<{
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
|
const { installed } = useInfos()
|
||||||
|
|
||||||
const { domains } = useDomains()
|
const { domains } = useDomains(undefined, installed.value)
|
||||||
const dynDomains = ['nohost.me', 'noho.st', 'ynh.fr']
|
const dynDomains = ['nohost.me', 'noho.st', 'ynh.fr']
|
||||||
|
|
||||||
const dynDnsForbiden = computed(() => {
|
const dynDnsForbiden = computed(() => {
|
||||||
|
@ -75,17 +77,21 @@ const fields = {
|
||||||
},
|
},
|
||||||
}) satisfies FieldProps<'InputItem', Form['domain']>,
|
}) satisfies FieldProps<'InputItem', Form['domain']>,
|
||||||
|
|
||||||
dynDomain: {
|
dynDomain: reactive({
|
||||||
component: 'AdressItem',
|
component: 'AdressItem',
|
||||||
label: t('domain_name'),
|
label: t('domain_name'),
|
||||||
rules: { localPart: { required, dynDomain } },
|
rules: computed(() => {
|
||||||
|
return selected.value === 'dynDomain'
|
||||||
|
? { localPart: { required, dynDomain }, domain: { required } }
|
||||||
|
: undefined
|
||||||
|
}),
|
||||||
cProps: {
|
cProps: {
|
||||||
id: 'dyn-domain',
|
id: 'dyn-domain',
|
||||||
placeholder: t('placeholder.domain').split('.')[0],
|
placeholder: t('placeholder.domain').split('.')[0],
|
||||||
type: 'domain',
|
type: 'domain',
|
||||||
choices: dynDomains,
|
choices: dynDomains,
|
||||||
},
|
},
|
||||||
} satisfies FieldProps<'AdressItem', Form['dynDomain']>,
|
}) satisfies FieldProps<'AdressItem', Form['dynDomain']>,
|
||||||
|
|
||||||
dynDomainPassword: reactive({
|
dynDomainPassword: reactive({
|
||||||
component: 'InputItem',
|
component: 'InputItem',
|
||||||
|
@ -121,7 +127,7 @@ const fields = {
|
||||||
label: t('domain_name'),
|
label: t('domain_name'),
|
||||||
rules: computed(() =>
|
rules: computed(() =>
|
||||||
selected.value === 'localDomain'
|
selected.value === 'localDomain'
|
||||||
? { localPart: { required, dynDomain } }
|
? { localPart: { required, dynDomain }, domain: { required } }
|
||||||
: undefined,
|
: undefined,
|
||||||
),
|
),
|
||||||
cProps: {
|
cProps: {
|
||||||
|
|
Loading…
Add table
Reference in a new issue