Only show loading spinner over menu when loading namespaces
continuous-integration/drone/push Build is failing Details

This commit is contained in:
kolaente 2020-12-23 21:26:43 +01:00
parent ad33458a80
commit f9d295fc67
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
3 changed files with 17 additions and 6 deletions

View File

@ -133,7 +133,7 @@
<script> <script>
import {mapState} from 'vuex' import {mapState} from 'vuex'
import {CURRENT_LIST, IS_FULLPAGE, LOADING, MENU_ACTIVE} from '@/store/mutation-types' import {CURRENT_LIST, IS_FULLPAGE, MENU_ACTIVE} from '@/store/mutation-types'
export default { export default {
name: 'navigation', name: 'navigation',
@ -145,7 +145,7 @@ export default {
currentList: CURRENT_LIST, currentList: CURRENT_LIST,
background: 'background', background: 'background',
menuActive: MENU_ACTIVE, menuActive: MENU_ACTIVE,
loading: LOADING, loading: state => state.namespaces.loading,
}), }),
beforeCreate() { beforeCreate() {
this.$store.dispatch('namespaces/loadNamespaces') this.$store.dispatch('namespaces/loadNamespaces')

View File

@ -1,11 +1,19 @@
import {LOADING} from './mutation-types' import {LOADING} from './mutation-types'
export const setLoading = context => { export const setLoading = (context, loadFunc = null) => {
const timeout = setTimeout(() => { const timeout = setTimeout(() => {
context.commit(LOADING, true, {root: true}) if (loadFunc === null) {
context.commit(LOADING, true, {root: true})
} else {
loadFunc(true)
}
}, 100) }, 100)
return () => { return () => {
clearTimeout(timeout) clearTimeout(timeout)
context.commit(LOADING, false, {root: true}) if (loadFunc === null) {
context.commit(LOADING, false, {root: true})
} else {
loadFunc(false)
}
} }
} }

View File

@ -7,6 +7,7 @@ export default {
namespaced: true, namespaced: true,
state: () => ({ state: () => ({
namespaces: [], namespaces: [],
loading: false,
}), }),
mutations: { mutations: {
namespaces(state, namespaces) { namespaces(state, namespaces) {
@ -88,7 +89,9 @@ export default {
}, },
actions: { actions: {
loadNamespaces(ctx) { loadNamespaces(ctx) {
const cancel = setLoading(ctx) const cancel = setLoading(ctx, status => {
ctx.commit('loading', status, {root: true})
})
const namespaceService = new NamespaceService() const namespaceService = new NamespaceService()
// We always load all namespaces and filter them on the frontend // We always load all namespaces and filter them on the frontend