Commit 00dce737 authored by Angelina Filippova's avatar Angelina Filippova

Fix deleting settings when changing between mailer adapters

parent fd0392c1
......@@ -30,6 +30,16 @@ export async function updateSettings(configs, authHost, token) {
})
}
export async function removeSettings(configs, authHost, token) {
return await request({
baseURL: baseName(authHost),
url: `/api/pleroma/admin/config`,
method: 'post',
headers: authHeaders(token),
data: { configs }
})
}
export async function uploadMedia(file, authHost, token) {
const formData = new FormData()
formData.append('file', file)
......
import { fetchDescription, fetchSettings, updateSettings, uploadMedia } from '@/api/settings'
import { fetchDescription, fetchSettings, removeSettings, updateSettings, uploadMedia } from '@/api/settings'
import { parseNonTuples, parseTuples, partialUpdate, valueHasTuples, wrapUpdatedSettings } from './normalizers'
const settings = {
......@@ -27,9 +27,6 @@ const settings = {
CLEAR_UPDATED_SETTINGS: (state) => {
state.updatedSettings = {}
},
REWRITE_CONFIG: (state, { tab, data }) => {
state.settings[tab] = data
},
SET_DESCRIPTION: (state, data) => {
state.description = data
},
......@@ -69,8 +66,8 @@ const settings = {
commit('SET_SETTINGS', response.data.configs)
commit('SET_LOADING', false)
},
RewriteConfig({ commit }, { tab, data }) {
commit('REWRITE_CONFIG', { tab, data })
async RemoveSetting({ getters }, configs) {
await removeSettings(configs, getters.authHost, getters.token)
},
async SubmitChanges({ getters, commit, state }) {
const updatedData = Object.keys(state.updatedSettings).reduce((acc, group) => {
......@@ -103,7 +100,14 @@ const settings = {
? commit('UPDATE_SETTINGS', { group, key, input, value, type })
: commit('UPDATE_SETTINGS', { group, key: input, input: '_value', value, type })
},
UpdateState({ commit }, { group, key, input, value }) {
UpdateState({ commit, dispatch, state }, { group, key, input, value }) {
if (key === 'Pleroma.Emails.Mailer' && input === ':adapter') {
const subkeys = Object.keys(state.settings[group][key]).filter(el => el !== ':adapter')
const emailsValue = subkeys.map(el => {
return { 'tuple': [el, state.settings[group][key][el]] }
})
dispatch('RemoveSetting', [{ group, key, value: emailsValue, delete: true, subkeys }])
}
key
? commit('UPDATE_STATE', { group, key, input, value })
: commit('UPDATE_STATE', { group, key: input, input: 'value', value })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment