1
0
Fork 0
mirror of https://gitlab.com/bramw/baserow.git synced 2025-04-14 09:08:32 +00:00
bramw_baserow/web-frontend/store/notification.js
2019-08-26 17:49:28 +00:00

43 lines
1,017 B
JavaScript

import { uuid } from '@/utils/string'
export const state = () => ({
items: []
})
export const mutations = {
ADD(state, notification) {
state.items.unshift(notification)
},
REMOVE(state, notification) {
const index = state.items.indexOf(notification)
state.items.splice(index, 1)
}
}
export const actions = {
add({ commit }, { type, title, message }) {
commit('ADD', {
id: uuid(),
type: type,
title: title,
message: message
})
},
info({ dispatch }, { title, message }) {
dispatch('add', { type: 'info', title, message })
},
error({ dispatch }, { title, message }) {
dispatch('add', { type: 'error', title, message })
},
warning({ dispatch }, { title, message }) {
dispatch('add', { type: 'warning', title, message })
},
success({ dispatch }, { title, message }) {
dispatch('add', { type: 'success', title, message })
},
remove({ commit }, notification) {
commit('REMOVE', notification)
}
}
export const getters = {}