Add Terms of Services on Other tab

This commit is contained in:
Angelina Filippova 2020-09-18 02:48:30 +03:00
parent d414750cd5
commit 208431dd00
5 changed files with 40 additions and 9 deletions

View file

@ -439,7 +439,8 @@ export default {
changeImage: 'Change image', changeImage: 'Change image',
uploadImage: 'Upload image', uploadImage: 'Upload image',
remove: 'Remove', remove: 'Remove',
instancePanel: 'Instance Panel Document' instancePanel: 'Instance Panel Document',
termsOfServices: 'Terms of Service'
}, },
invites: { invites: {
inviteTokens: 'Invite tokens', inviteTokens: 'Invite tokens',

View file

@ -66,6 +66,9 @@ const settings = {
state.settings = newSettings state.settings = newSettings
state.db = newDbSettings state.db = newDbSettings
}, },
SET_TERMS_OF_SERVICES: (state, data) => {
state.termsOfServices = data
},
TOGGLE_TABS: (state, status) => { TOGGLE_TABS: (state, status) => {
state.configDisabled = status state.configDisabled = status
}, },
@ -85,7 +88,13 @@ const settings = {
actions: { actions: {
async FetchInstanceDocument({ commit, getters }, name) { async FetchInstanceDocument({ commit, getters }, name) {
const { data } = await getInstanceDocument(name, getters.authHost, getters.token) const { data } = await getInstanceDocument(name, getters.authHost, getters.token)
console.log(data)
if (name === 'instance-panel') {
commit('SET_INSTANCE_PANEL', data) commit('SET_INSTANCE_PANEL', data)
} else {
console.log(name)
commit('SET_TERMS_OF_SERVICES', data)
}
}, },
async FetchSettings({ commit, getters }) { async FetchSettings({ commit, getters }) {
commit('SET_LOADING', true) commit('SET_LOADING', true)
@ -107,7 +116,7 @@ const settings = {
}, },
async RemoveInstanceDocument({ dispatch, getters }, name) { async RemoveInstanceDocument({ dispatch, getters }, name) {
await deleteInstanceDocument(name, getters.authHost, getters.token) await deleteInstanceDocument(name, getters.authHost, getters.token)
await dispatch('FetchInstanceDocument', 'instance-panel') await dispatch('FetchInstanceDocument', name)
}, },
async RemoveSetting({ commit, getters }, configs) { async RemoveSetting({ commit, getters }, configs) {
await removeSettings(configs, getters.authHost, getters.token) await removeSettings(configs, getters.authHost, getters.token)

View file

@ -3,7 +3,7 @@
<el-form :model="instanceData" :label-position="labelPosition" :label-width="labelWidth"> <el-form :model="instanceData" :label-position="labelPosition" :label-width="labelWidth">
<setting :setting-group="instance" :data="instanceData"/> <setting :setting-group="instance" :data="instanceData"/>
</el-form> </el-form>
<editor-input :content="instancePanelContent" @input="handleEditorUpdate"/> <editor-input :content="instancePanelContent" :name="'terms-of-service'" @input="handleEditorUpdate"/>
<el-divider v-if="instance" class="divider thick-line"/> <el-divider v-if="instance" class="divider thick-line"/>
<el-form :model="restrictUnauthenticatedData" :label-position="labelPosition" :label-width="labelWidth"> <el-form :model="restrictUnauthenticatedData" :label-position="labelPosition" :label-width="labelWidth">
<setting :setting-group="restrictUnauthenticated" :data="restrictUnauthenticatedData"/> <setting :setting-group="restrictUnauthenticated" :data="restrictUnauthenticatedData"/>

View file

@ -1,5 +1,6 @@
<template> <template>
<div v-if="!loading" :class="isSidebarOpen" class="form-container"> <div v-if="!loading" :class="isSidebarOpen" class="form-container">
<editor-input :content="termsOfServicesContent" :name="'terms-of-service'" @input="handleEditorUpdate"/>
<el-form :model="mimeTypesData" :label-position="labelPosition" :label-width="labelWidth"> <el-form :model="mimeTypesData" :label-position="labelPosition" :label-width="labelWidth">
<setting :setting-group="mimeTypes" :data="mimeTypesData"/> <setting :setting-group="mimeTypes" :data="mimeTypesData"/>
</el-form> </el-form>
@ -25,11 +26,17 @@
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
import i18n from '@/lang' import i18n from '@/lang'
import Setting from './Setting' import Setting from './Setting'
import { EditorInput } from './inputComponents'
import _ from 'lodash' import _ from 'lodash'
export default { export default {
name: 'Other', name: 'Other',
components: { Setting }, components: { EditorInput, Setting },
data() {
return {
editorContent: ''
}
},
computed: { computed: {
...mapGetters([ ...mapGetters([
'settings' 'settings'
@ -81,12 +88,22 @@ export default {
}, },
remoteIpData() { remoteIpData() {
return _.get(this.settings.settings, [':pleroma', 'Pleroma.Web.Plugs.RemoteIp']) || {} return _.get(this.settings.settings, [':pleroma', 'Pleroma.Web.Plugs.RemoteIp']) || {}
},
termsOfServicesContent() {
return this.$store.state.settings.termsOfServices
} }
}, },
async mounted() {
await this.$store.dispatch('FetchInstanceDocument', 'terms-of-service')
},
methods: { methods: {
handleEditorUpdate(content) {
this.editorContent = content
},
async onSubmit() { async onSubmit() {
try { try {
await this.$store.dispatch('SubmitChanges') await this.$store.dispatch('SubmitChanges')
await this.$store.dispatch('UpdateInstanceDocs', { name: 'terms-of-service', content: this.editorContent })
} catch (e) { } catch (e) {
return return
} }

View file

@ -1,8 +1,8 @@
<template> <template>
<el-form :label-position="labelPosition" :label-width="labelWidth"> <el-form :label-position="labelPosition" :label-width="labelWidth">
<el-form-item label="Instance panel doc" class="editor-form-item"> <el-form-item class="editor-form-item">
<span slot="label"> <span slot="label">
{{ $t('settings.instancePanel') }} {{ name === 'instance-panel' ? $t('settings.instancePanel') : $t('settings.termsOfServices') }}
<el-tooltip :content="$t('settings.removeFromDB')" placement="bottom-end"> <el-tooltip :content="$t('settings.removeFromDB')" placement="bottom-end">
<el-button icon="el-icon-delete" circle size="mini" class="delete-setting-button" @click="removeInstanceDoc"/> <el-button icon="el-icon-delete" circle size="mini" class="delete-setting-button" @click="removeInstanceDoc"/>
</el-tooltip> </el-tooltip>
@ -126,6 +126,10 @@ export default {
content: { content: {
type: String, type: String,
default: '' default: ''
},
name: {
type: String,
default: ''
} }
}, },
data() { data() {
@ -173,8 +177,8 @@ export default {
this.editor.destroy() this.editor.destroy()
}, },
methods: { methods: {
async removeInstanceDoc(name) { async removeInstanceDoc() {
await this.$store.dispatch('RemoveInstanceDocument', 'instance-panel') await this.$store.dispatch('RemoveInstanceDocument', this.name)
this.editor.setContent(this.content) this.editor.setContent(this.content)
} }
} }