mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
add status prop to store's history entries
This commit is contained in:
parent
1944c7cc2f
commit
56a3b29f65
2 changed files with 15 additions and 3 deletions
|
@ -32,7 +32,7 @@ async function _getResponseData (response) {
|
||||||
*/
|
*/
|
||||||
export async function handleResponse (response, method) {
|
export async function handleResponse (response, method) {
|
||||||
const responseData = await _getResponseData(response)
|
const responseData = await _getResponseData(response)
|
||||||
store.dispatch('SERVER_RESPONDED')
|
store.dispatch('SERVER_RESPONDED', response.ok)
|
||||||
return response.ok ? responseData : handleError(response, responseData, method)
|
return response.ok ? responseData : handleError(response, responseData, method)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,11 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
'ADD_HISTORY_ENTRY' (state, [uri, method, date]) {
|
'ADD_HISTORY_ENTRY' (state, [uri, method, date]) {
|
||||||
state.history.push({ uri, method, date, messages: [] })
|
state.history.push({ uri, method, date, status: 'pending', messages: [] })
|
||||||
|
},
|
||||||
|
|
||||||
|
'UPDATE_LAST_HISTORY_ENTRY' (state, [key, value]) {
|
||||||
|
Vue.set(state.history[state.history.length - 1], key, value)
|
||||||
},
|
},
|
||||||
|
|
||||||
'ADD_MESSAGE' (state, message) {
|
'ADD_MESSAGE' (state, message) {
|
||||||
|
@ -109,7 +113,15 @@ export default {
|
||||||
commit('ADD_HISTORY_ENTRY', [uri, method, Date.now()])
|
commit('ADD_HISTORY_ENTRY', [uri, method, Date.now()])
|
||||||
},
|
},
|
||||||
|
|
||||||
'SERVER_RESPONDED' ({ commit }) {
|
'SERVER_RESPONDED' ({ state, commit }, success) {
|
||||||
|
const action = state.history.length ? state.history[state.history.length - 1] : null
|
||||||
|
if (action) {
|
||||||
|
let status = success ? 'success' : 'error'
|
||||||
|
if (status === 'success' && action.messages.some(msg => msg.type === 'danger' || msg.type === 'warning')) {
|
||||||
|
status = 'warning'
|
||||||
|
}
|
||||||
|
commit('UPDATE_LAST_HISTORY_ENTRY', ['status', status])
|
||||||
|
}
|
||||||
commit('UPDATE_WAITING', false)
|
commit('UPDATE_WAITING', false)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue