You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.2 KiB

6 years ago
6 years ago
6 years ago
6 years ago
  1. import _ from 'lodash'
  2. import Vue from 'vue'
  3. import Vuex from 'vuex'
  4. import pathify from 'vuex-pathify' // eslint-disable-line import/no-duplicates
  5. import { make } from 'vuex-pathify' // eslint-disable-line import/no-duplicates
  6. import site from './site'
  7. Vue.use(Vuex)
  8. const state = {
  9. loadingStack: [],
  10. notification: {
  11. message: '',
  12. style: 'primary',
  13. icon: 'cached',
  14. isActive: false
  15. }
  16. }
  17. export default new Vuex.Store({
  18. strict: process.env.NODE_ENV !== 'production',
  19. plugins: [
  20. pathify.plugin
  21. ],
  22. state,
  23. getters: {
  24. isLoading: state => { return state.loadingStack.length > 0 }
  25. },
  26. mutations: {
  27. ...make.mutations(state),
  28. loadingStart (state, stackName) {
  29. state.loadingStack = _.union(state.loadingStack, [stackName])
  30. },
  31. loadingStop (state, stackName) {
  32. state.loadingStack = _.without(state.loadingStack, stackName)
  33. },
  34. showNotification (state, opts) {
  35. state.notification = _.defaults(opts, {
  36. message: '',
  37. style: 'primary',
  38. icon: 'cached',
  39. isActive: true
  40. })
  41. },
  42. updateNotificationState (state, newState) {
  43. state.notification.isActive = newState
  44. }
  45. },
  46. actions: { },
  47. modules: {
  48. site
  49. }
  50. })