fix several user errors when no users created

This commit is contained in:
axolotle 2021-04-17 19:23:20 +02:00
parent 4e8dad0435
commit 40ef5b4c26
2 changed files with 12 additions and 5 deletions

View file

@ -98,7 +98,11 @@ export function formatYunoHostArgument (arg) {
field.component = 'SelectItem'
field.link = { name: arg.type + '-list', text: i18n.t(`manage_${arg.type}s`) }
field.props.choices = store.getters[arg.type + 'sAsChoices']
value = arg.type === 'domain' ? store.getters.mainDomain : field.props.choices[0].value
if (arg.type === 'domain') {
value = store.getters.mainDomain
} else {
value = field.props.choices.length ? field.props.choices[0].value : null
}
// Unknown from the specs, try to display it as an input[text]
// FIXME throw an error instead ?

View file

@ -36,7 +36,7 @@ export default {
},
'SET_USERS' (state, [users]) {
state.users = Object.keys(users).length === 0 ? null : users
state.users = users || null
},
'ADD_USERS' (state, [user]) {
@ -161,9 +161,12 @@ export default {
},
usersAsChoices: state => {
return Object.values(state.users).map(({ username, fullname, mail }) => {
return { text: `${fullname} (${mail})`, value: username }
})
if (state.users) {
return Object.values(state.users).map(({ username, fullname, mail }) => {
return { text: `${fullname} (${mail})`, value: username }
})
}
return []
},
user: state => name => state.users_details[name], // not cached