mirror of
https://github.com/baserow/baserow.git
synced 2026-12-04 08:18:42 +00:00
* feat: let visitors report abuse on published applications * fix: let logged-in app users report published applications
73 lines
1.6 KiB
JavaScript
73 lines
1.6 KiB
JavaScript
import SettingsService from '@baserow/modules/core/services/settings'
|
|
import { clone } from '@baserow/modules/core/utils/object'
|
|
|
|
export const state = () => ({
|
|
loaded: false,
|
|
settings: {},
|
|
requestGeneration: 0,
|
|
})
|
|
|
|
export const mutations = {
|
|
SET_SETTINGS(state, values) {
|
|
state.settings = values
|
|
},
|
|
UPDATE_SETTINGS(state, values) {
|
|
state.settings = Object.assign({}, state.settings, values)
|
|
},
|
|
SET_LOADED(state, value) {
|
|
state.loaded = value
|
|
},
|
|
SET_REQUEST_GENERATION(state, value) {
|
|
state.requestGeneration = value
|
|
},
|
|
HIDE_ADMIN_SIGNUP_PAGE(state) {
|
|
state.settings.show_admin_signup_page = false
|
|
},
|
|
}
|
|
|
|
export const actions = {
|
|
async load({ commit, state }, { requestConfig = {} } = {}) {
|
|
const { $client } = this
|
|
const requestGeneration = state.requestGeneration + 1
|
|
commit('SET_REQUEST_GENERATION', requestGeneration)
|
|
const { data } = await SettingsService($client).get(requestConfig)
|
|
if (state.requestGeneration !== requestGeneration) {
|
|
return
|
|
}
|
|
commit('SET_SETTINGS', data)
|
|
commit('SET_LOADED', true)
|
|
},
|
|
async update({ commit, getters }, values) {
|
|
const { $client } = this
|
|
const oldValues = clone(getters.get)
|
|
commit('UPDATE_SETTINGS', values)
|
|
|
|
try {
|
|
await SettingsService($client).update(values)
|
|
} catch (e) {
|
|
commit('SET_SETTINGS', oldValues)
|
|
throw e
|
|
}
|
|
},
|
|
hideAdminSignupPage({ commit }) {
|
|
commit('HIDE_ADMIN_SIGNUP_PAGE')
|
|
},
|
|
}
|
|
|
|
export const getters = {
|
|
isLoaded(state) {
|
|
return state.loaded
|
|
},
|
|
get(state) {
|
|
return state.settings
|
|
},
|
|
}
|
|
|
|
export default {
|
|
namespaced: true,
|
|
state,
|
|
getters,
|
|
actions,
|
|
mutations,
|
|
}
|