Merge branch 'fix/link-registrations-and-invites' into 'develop'

Link enabling registrations and invites in settings

Closes #97

See merge request pleroma/admin-fe!117
This commit is contained in:
Angelina Filippova 2020-04-04 17:49:06 +00:00
commit 86777defc7
5 changed files with 91 additions and 14 deletions

View file

@ -41,7 +41,7 @@
class="input" class="input"
@input="update($event, settingGroup.group, settingGroup.key, settingParent, setting.key, setting.type, nested)"/> @input="update($event, settingGroup.group, settingGroup.key, settingParent, setting.key, setting.type, nested)"/>
<el-switch <el-switch
v-if="setting.type === 'boolean'" v-if="setting.type === 'boolean' && ![':registrations_open', ':invites_enabled'].includes(setting.key)"
:value="inputValue" :value="inputValue"
:data-search="setting.key || setting.group" :data-search="setting.key || setting.group"
class="switch-input" class="switch-input"
@ -103,6 +103,7 @@
<proxy-url-input v-if="setting.key === ':proxy_url'" :data="data[setting.key]" :setting-group="settingGroup" :setting="setting" :parents="settingParent"/> <proxy-url-input v-if="setting.key === ':proxy_url'" :data="data[setting.key]" :setting-group="settingGroup" :setting="setting" :parents="settingParent"/>
<prune-input v-if="setting.key === ':prune'" :data="data[setting.key]" :setting-group="settingGroup" :setting="setting"/> <prune-input v-if="setting.key === ':prune'" :data="data[setting.key]" :setting-group="settingGroup" :setting="setting"/>
<rate-limit-input v-if="settingGroup.key === ':rate_limit'" :data="data" :setting-group="settingGroup" :setting="setting"/> <rate-limit-input v-if="settingGroup.key === ':rate_limit'" :data="data" :setting-group="settingGroup" :setting="setting"/>
<reg-invites-input v-if="[':registrations_open', ':invites_enabled'].includes(setting.key)" :data="data" :setting-group="settingGroup" :setting="setting"/>
<!--------------------> <!-------------------->
<el-tooltip v-if="canBeDeleted && (isMobile || isTablet)" :content="$t('settings.removeFromDB')" placement="bottom-end" class="delete-setting-button-container"> <el-tooltip v-if="canBeDeleted && (isMobile || isTablet)" :content="$t('settings.removeFromDB')" placement="bottom-end" class="delete-setting-button-container">
<el-button icon="el-icon-delete" circle size="mini" class="delete-setting-button" @click="removeSetting"/> <el-button icon="el-icon-delete" circle size="mini" class="delete-setting-button" @click="removeSetting"/>
@ -118,7 +119,17 @@
<script> <script>
import i18n from '@/lang' import i18n from '@/lang'
import { AutoLinkerInput, CrontabInput, EditableKeywordInput, IconsInput, MascotsInput, MultipleSelect, ProxyUrlInput, PruneInput, RateLimitInput } from './inputComponents' import {
AutoLinkerInput,
CrontabInput,
EditableKeywordInput,
IconsInput,
MascotsInput,
MultipleSelect,
ProxyUrlInput,
PruneInput,
RateLimitInput,
RegInvitesInput } from './inputComponents'
import { processNested } from '@/store/modules/normalizers' import { processNested } from '@/store/modules/normalizers'
import _ from 'lodash' import _ from 'lodash'
import marked from 'marked' import marked from 'marked'
@ -134,7 +145,8 @@ export default {
MultipleSelect, MultipleSelect,
ProxyUrlInput, ProxyUrlInput,
PruneInput, PruneInput,
RateLimitInput RateLimitInput,
RegInvitesInput
}, },
props: { props: {
customLabelWidth: { customLabelWidth: {

View file

@ -12,10 +12,6 @@
<setting :setting-group="scheduledActivity" :data="scheduledActivityData"/> <setting :setting-group="scheduledActivity" :data="scheduledActivityData"/>
</el-form> </el-form>
<el-divider class="divider thick-line"/> <el-divider class="divider thick-line"/>
<el-form ref="fetchInitialPosts" :model="fetchInitialPostsData" :label-width="labelWidth">
<setting :setting-group="fetchInitialPosts" :data="fetchInitialPostsData"/>
</el-form>
<el-divider class="divider thick-line"/>
<el-form ref="manifest" :model="manifestData" :label-width="labelWidth"> <el-form ref="manifest" :model="manifestData" :label-width="labelWidth">
<setting :setting-group="manifest" :data="manifestData"/> <setting :setting-group="manifest" :data="manifestData"/>
</el-form> </el-form>
@ -67,12 +63,6 @@ export default {
feedData() { feedData() {
return _.get(this.settings.settings, [':pleroma', ':feed']) || {} return _.get(this.settings.settings, [':pleroma', ':feed']) || {}
}, },
fetchInitialPosts() {
return this.settings.description.find(setting => setting.key === ':fetch_initial_posts')
},
fetchInitialPostsData() {
return _.get(this.settings.settings, [':pleroma', ':fetch_initial_posts']) || {}
},
instance() { instance() {
return this.settings.description.find(setting => setting.key === ':instance') return this.settings.description.find(setting => setting.key === ':instance')
}, },

View file

@ -0,0 +1,74 @@
<template>
<el-switch
:value="data[setting.key]"
:data-search="setting.key"
class="switch-input"
@change="updateSetting($event, settingGroup.group, settingGroup.key, setting.key, setting.type)"/>
</template>
<script>
export default {
name: 'RegInvitesInput',
props: {
data: {
type: [Object, Array],
default: function() {
return {}
}
},
setting: {
type: Object,
default: function() {
return {}
}
},
settingGroup: {
type: Object,
default: function() {
return {}
}
}
},
methods: {
updateSetting(value, group, key, input, type) {
const registrationsOpen = this.$store.state.settings.settings[group][key][':registrations_open']
const invitesEnabled = this.$store.state.settings.settings[group][key][':invites_enabled']
if (input === ':registrations_open' && value && invitesEnabled) {
this.$confirm(
'Enabling this setting requires invites to be disabled. Are you sure you want to open registrations?',
'Warning',
{ confirmButtonText: 'OK',
cancelButtonText: 'Cancel',
type: 'warning'
}).then(() => {
this.$store.dispatch('UpdateSettings', { group, key, input, value, type })
this.$store.dispatch('UpdateSettings', { group, key, input: ':invites_enabled', value: false, type })
this.$store.dispatch('UpdateState', { group, key, input, value })
this.$store.dispatch('UpdateState', { group, key, input: ':invites_enabled', value: false })
})
} else if (input === ':invites_enabled' && value && registrationsOpen) {
this.$confirm(
'Enabling this setting requires registrations to be disabled. Are you sure you want to enable invitations?',
'Warning',
{ confirmButtonText: 'OK',
cancelButtonText: 'Cancel',
type: 'warning'
}).then(() => {
this.$store.dispatch('UpdateSettings', { group, key, input, value, type })
this.$store.dispatch('UpdateSettings', { group, key, input: ':registrations_open', value: false, type })
this.$store.dispatch('UpdateState', { group, key, input, value })
this.$store.dispatch('UpdateState', { group, key, input: ':registrations_open', value: false })
})
} else {
this.$store.dispatch('UpdateSettings', { group, key, input, value, type })
this.$store.dispatch('UpdateState', { group, key, input, value })
}
}
}
}
</script>
<style rel='stylesheet/scss' lang='scss'>
@import '../../styles/main';
@include settings
</style>

View file

@ -7,3 +7,4 @@ export { default as MultipleSelect } from './MultipleSelect'
export { default as ProxyUrlInput } from './ProxyUrlInput' export { default as ProxyUrlInput } from './ProxyUrlInput'
export { default as PruneInput } from './PruneInput' export { default as PruneInput } from './PruneInput'
export { default as RateLimitInput } from './RateLimitInput' export { default as RateLimitInput } from './RateLimitInput'
export { default as RegInvitesInput } from './RegInvitesInput'

View file

@ -33,7 +33,7 @@ export const tabs = {
}, },
'instance': { 'instance': {
label: 'settings.instance', label: 'settings.instance',
settings: [':admin_token', ':fetch_initial_posts', ':instance', ':manifest', 'Pleroma.User', 'Pleroma.ScheduledActivity', ':uri_schemes', ':feed', ':streamer'] settings: [':admin_token', ':instance', ':manifest', 'Pleroma.User', 'Pleroma.ScheduledActivity', ':uri_schemes', ':feed', ':streamer']
}, },
'job-queue': { 'job-queue': {
label: 'settings.jobQueue', label: 'settings.jobQueue',