mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
fix users state when removing the last user and fix 'cached' check
This commit is contained in:
parent
4dd44ec9d1
commit
ad5c0c0cde
1 changed files with 10 additions and 5 deletions
|
@ -1,6 +1,8 @@
|
||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
|
|
||||||
import api from '@/api'
|
import api from '@/api'
|
||||||
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
state: () => ({
|
state: () => ({
|
||||||
domains: undefined, // Array
|
domains: undefined, // Array
|
||||||
|
@ -37,7 +39,7 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
'ADD_USERS' (state, user) {
|
'ADD_USERS' (state, user) {
|
||||||
if (state.users === undefined) state.users = {}
|
if (!state.users) state.users = {}
|
||||||
Vue.set(state.users, user.username, user)
|
Vue.set(state.users, user.username, user)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -62,6 +64,9 @@ export default {
|
||||||
Vue.delete(state.users_details, username)
|
Vue.delete(state.users_details, username)
|
||||||
if (state.users) {
|
if (state.users) {
|
||||||
Vue.delete(state.users, username)
|
Vue.delete(state.users, username)
|
||||||
|
if (Object.keys(state.users).length === 0) {
|
||||||
|
state.users = null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -108,8 +113,8 @@ export default {
|
||||||
return { storeKey, param, responseData }
|
return { storeKey, param, responseData }
|
||||||
})
|
})
|
||||||
})).then(responsesData => {
|
})).then(responsesData => {
|
||||||
return responsesData.map(({ storeKey, param, responseData, cached = null }) => {
|
return responsesData.map(({ storeKey, param, responseData, cached = undefined }) => {
|
||||||
if (cached) return cached
|
if (cached !== undefined) return cached
|
||||||
const data = responseData[storeKey] ? responseData[storeKey] : responseData
|
const data = responseData[storeKey] ? responseData[storeKey] : responseData
|
||||||
commit('SET_' + storeKey.toUpperCase(), param ? [param, data] : data)
|
commit('SET_' + storeKey.toUpperCase(), param ? [param, data] : data)
|
||||||
return param ? state[storeKey][param] : state[storeKey]
|
return param ? state[storeKey][param] : state[storeKey]
|
||||||
|
@ -146,8 +151,8 @@ export default {
|
||||||
users: state => state.users,
|
users: state => state.users,
|
||||||
|
|
||||||
userNames: state => {
|
userNames: state => {
|
||||||
if (state.users !== undefined) return Object.keys(state.users)
|
if (state.users) return Object.keys(state.users)
|
||||||
return undefined
|
return []
|
||||||
},
|
},
|
||||||
|
|
||||||
usersAsChoices: state => {
|
usersAsChoices: state => {
|
||||||
|
|
Loading…
Reference in a new issue