From 8015b3aa3ae80f9729d3c48e282a857ff8b263f7 Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Wed, 16 Sep 2020 20:53:26 +0300 Subject: [PATCH] Add actions for moderating instance document --- src/store/modules/settings.js | 26 ++++++++++++++- src/views/settings/components/Instance.vue | 17 +++++++++- .../inputComponents/EditorInput.vue | 32 ++++++------------- 3 files changed, 51 insertions(+), 24 deletions(-) diff --git a/src/store/modules/settings.js b/src/store/modules/settings.js index 6c193e57..eaf9bda4 100644 --- a/src/store/modules/settings.js +++ b/src/store/modules/settings.js @@ -1,4 +1,11 @@ -import { fetchDescription, fetchSettings, removeSettings, updateSettings } from '@/api/settings' +import { + deleteInstanceDocument, + fetchDescription, + fetchSettings, + getInstanceDocument, + removeSettings, + updateInstanceDocument, + updateSettings } from '@/api/settings' import { formSearchObject, parseNonTuples, parseTuples, valueHasTuples, wrapUpdatedSettings } from './normalizers' import _ from 'lodash' @@ -8,15 +15,20 @@ const settings = { configDisabled: true, db: {}, description: [], + instancePanel: '', loading: true, searchData: {}, settings: {}, + termsOfServices: '', updatedSettings: {} }, mutations: { CLEAR_UPDATED_SETTINGS: (state) => { state.updatedSettings = {} }, + SET_INSTANCE_PANEL: (state, data) => { + state.instancePanel = data + }, REMOVE_SETTING_FROM_UPDATED: (state, { group, key, subkeys }) => { if (_.get(state.updatedSettings, [group, key, subkeys[0]])) { const { [subkeys[0]]: value, ...updatedSettings } = state.updatedSettings[group][key] @@ -71,6 +83,10 @@ const settings = { } }, actions: { + async FetchInstanceDocument({ commit, getters }, name) { + const { data } = await getInstanceDocument(name, getters.authHost, getters.token) + commit('SET_INSTANCE_PANEL', data.url) + }, async FetchSettings({ commit, getters }) { commit('SET_LOADING', true) try { @@ -89,6 +105,9 @@ const settings = { commit('TOGGLE_TABS', false) commit('SET_LOADING', false) }, + async RemoveInstanceDocument({ getters }, name) { + await deleteInstanceDocument(name, getters.authHost, getters.token) + }, async RemoveSetting({ commit, getters }, configs) { await removeSettings(configs, getters.authHost, getters.token) const response = await fetchSettings(getters.authHost, getters.token) @@ -111,6 +130,11 @@ const settings = { commit('TOGGLE_REBOOT', response.data.need_reboot) commit('CLEAR_UPDATED_SETTINGS') }, + async UpdateInstanceDocs({ getters }, { name, content }) { + const formData = new FormData() + formData.append('file', content) + await updateInstanceDocument(name, formData, getters.authHost, getters.token) + }, UpdateSettings({ commit }, { group, key, input, value, type }) { key ? commit('UPDATE_SETTINGS', { group, key, input, value, type }) diff --git a/src/views/settings/components/Instance.vue b/src/views/settings/components/Instance.vue index 3e750eaf..ef47f705 100644 --- a/src/views/settings/components/Instance.vue +++ b/src/views/settings/components/Instance.vue @@ -1,6 +1,6 @@