limits tab, backend descriptions
This commit is contained in:
parent
ab5408d36e
commit
332ad77e35
@ -12,6 +12,15 @@
|
||||
NAME
|
||||
</StringSetting>
|
||||
</li>
|
||||
<li>
|
||||
<StringSetting
|
||||
source="admin"
|
||||
path=":pleroma.:instance.:email"
|
||||
draft-mode
|
||||
>
|
||||
ADMIN EMAIL
|
||||
</StringSetting>
|
||||
</li>
|
||||
<li>
|
||||
<StringSetting
|
||||
source="admin"
|
||||
@ -22,13 +31,85 @@
|
||||
</StringSetting>
|
||||
</li>
|
||||
<li>
|
||||
<IntegerSetting
|
||||
<StringSetting
|
||||
source="admin"
|
||||
path=":pleroma.:instance.:limit"
|
||||
path=":pleroma.:instance.:short_description"
|
||||
draft-mode
|
||||
>
|
||||
POST LIMIT
|
||||
</IntegerSetting>
|
||||
SHORT DESCRIPTION
|
||||
</StringSetting>
|
||||
</li>
|
||||
<li>
|
||||
<StringSetting
|
||||
source="admin"
|
||||
path=":pleroma.:instance.:instance_thumbnail"
|
||||
draft-mode
|
||||
>
|
||||
INSTANCE THUMBNAIL
|
||||
</StringSetting>
|
||||
</li>
|
||||
<li>
|
||||
<StringSetting
|
||||
source="admin"
|
||||
path=":pleroma.:instance.:background_image"
|
||||
draft-mode
|
||||
>
|
||||
BACKGROUND IMAGE
|
||||
</StringSetting>
|
||||
</li>
|
||||
<li>
|
||||
<BooleanSetting
|
||||
source="admin"
|
||||
path=":pleroma.:instance.:public"
|
||||
draft-mode
|
||||
>
|
||||
PUBLIC
|
||||
</BooleanSetting>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="setting-item">
|
||||
<h2>{{ $t('admin_dash.registrations') }}</h2>
|
||||
<ul class="setting-list">
|
||||
<li>
|
||||
<BooleanSetting
|
||||
source="admin"
|
||||
path=":pleroma.:instance.:registrations_open"
|
||||
draft-mode
|
||||
>
|
||||
REGISTRATIONS OPEN
|
||||
</BooleanSetting>
|
||||
<ul class="setting-list suboptions">
|
||||
<li>
|
||||
<BooleanSetting
|
||||
source="admin"
|
||||
path=":pleroma.:instance.:invites_enabled"
|
||||
parent-path=":pleroma.:instance.:registrations_open"
|
||||
:parent-invert="true"
|
||||
draft-mode
|
||||
>
|
||||
INVITES ENABLED
|
||||
</BooleanSetting>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<BooleanSetting
|
||||
source="admin"
|
||||
path=":pleroma.:instance.:account_activation_required"
|
||||
draft-mode
|
||||
>
|
||||
ACTIVATION REQUIRED
|
||||
</BooleanSetting>
|
||||
</li>
|
||||
<li>
|
||||
<BooleanSetting
|
||||
source="admin"
|
||||
path=":pleroma.:instance.:account_approval_required"
|
||||
draft-mode
|
||||
>
|
||||
APPROVAL REQUIRED
|
||||
</BooleanSetting>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@ -36,17 +117,3 @@
|
||||
</template>
|
||||
|
||||
<script src="./instance_tab.js"></script>
|
||||
|
||||
<style lang="scss">
|
||||
.column-settings {
|
||||
display: flex;
|
||||
justify-content: space-evenly;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.column-settings .size-label {
|
||||
display: block;
|
||||
margin-bottom: 0.5em;
|
||||
margin-top: 0.5em;
|
||||
}
|
||||
</style>
|
||||
|
29
src/components/settings_modal/admin_tabs/limits_tab.js
Normal file
29
src/components/settings_modal/admin_tabs/limits_tab.js
Normal file
@ -0,0 +1,29 @@
|
||||
import BooleanSetting from '../helpers/boolean_setting.vue'
|
||||
import ChoiceSetting from '../helpers/choice_setting.vue'
|
||||
import IntegerSetting from '../helpers/integer_setting.vue'
|
||||
import StringSetting from '../helpers/string_setting.vue'
|
||||
|
||||
import SharedComputedObject from '../helpers/shared_computed_object.js'
|
||||
import { library } from '@fortawesome/fontawesome-svg-core'
|
||||
import {
|
||||
faGlobe
|
||||
} from '@fortawesome/free-solid-svg-icons'
|
||||
|
||||
library.add(
|
||||
faGlobe
|
||||
)
|
||||
|
||||
const LimitsTab = {
|
||||
data () {},
|
||||
components: {
|
||||
BooleanSetting,
|
||||
ChoiceSetting,
|
||||
IntegerSetting,
|
||||
StringSetting
|
||||
},
|
||||
computed: {
|
||||
...SharedComputedObject()
|
||||
}
|
||||
}
|
||||
|
||||
export default LimitsTab
|
152
src/components/settings_modal/admin_tabs/limits_tab.vue
Normal file
152
src/components/settings_modal/admin_tabs/limits_tab.vue
Normal file
@ -0,0 +1,152 @@
|
||||
<template>
|
||||
<div :label="$t('admin_dash.instance')">
|
||||
<div class="setting-item">
|
||||
<h2>{{ $t('admin_dash.arbitrary_limits') }}</h2>
|
||||
<ul class="setting-list">
|
||||
<li>
|
||||
<h3>{{ $t('admin_dash.limits.posts') }}</h3>
|
||||
</li>
|
||||
<li>
|
||||
<IntegerSetting
|
||||
source="admin"
|
||||
path=":pleroma.:instance.:limit"
|
||||
draft-mode
|
||||
>
|
||||
POST LIMIT
|
||||
</IntegerSetting>
|
||||
</li>
|
||||
<li>
|
||||
<IntegerSetting
|
||||
source="admin"
|
||||
path=":pleroma.:instance.:remote_limit"
|
||||
draft-mode
|
||||
>
|
||||
POST LIMIT (remote)
|
||||
</IntegerSetting>
|
||||
</li>
|
||||
<li>
|
||||
<h3>{{ $t('admin_dash.limits.uploads') }}</h3>
|
||||
</li>
|
||||
<li>
|
||||
<IntegerSetting
|
||||
source="admin"
|
||||
path=":pleroma.:instance.:description_limit"
|
||||
draft-mode
|
||||
>
|
||||
IMAGE DESCRIPTION LIMIT
|
||||
</IntegerSetting>
|
||||
</li>
|
||||
<li>
|
||||
<IntegerSetting
|
||||
source="admin"
|
||||
path=":pleroma.:instance.:upload_limit"
|
||||
draft-mode
|
||||
>
|
||||
UPLOAD LIMIT KiB
|
||||
</IntegerSetting>
|
||||
</li>
|
||||
<li>
|
||||
<IntegerSetting
|
||||
source="admin"
|
||||
path=":pleroma.:instance.:max_media_attachments"
|
||||
draft-mode
|
||||
>
|
||||
MAX ATTACHMENTS
|
||||
</IntegerSetting>
|
||||
</li>
|
||||
<li>
|
||||
<h3>{{ $t('admin_dash.limits.users') }}</h3>
|
||||
</li>
|
||||
<li>
|
||||
<IntegerSetting
|
||||
source="admin"
|
||||
path=":pleroma.:instance.:user_bio_length"
|
||||
draft-mode
|
||||
>
|
||||
BIO LENGTH
|
||||
</IntegerSetting>
|
||||
</li>
|
||||
<li>
|
||||
<IntegerSetting
|
||||
source="admin"
|
||||
path=":pleroma.:instance.:user_name_length"
|
||||
draft-mode
|
||||
>
|
||||
NAME LENGTH
|
||||
</IntegerSetting>
|
||||
</li>
|
||||
<li>
|
||||
<h4>{{ $t('admin_dash.limits.profile_fields') }}</h4>
|
||||
</li>
|
||||
<li>
|
||||
<IntegerSetting
|
||||
source="admin"
|
||||
path=":pleroma.:instance.:max_account_fields"
|
||||
draft-mode
|
||||
>
|
||||
MAX ACCOUNT FIELDS
|
||||
</IntegerSetting>
|
||||
</li>
|
||||
<li>
|
||||
<IntegerSetting
|
||||
source="admin"
|
||||
path=":pleroma.:instance.:max_remote_account_fields"
|
||||
draft-mode
|
||||
>
|
||||
MAX ACCOUNT FIELDS (remote)
|
||||
</IntegerSetting>
|
||||
</li>
|
||||
<li>
|
||||
<IntegerSetting
|
||||
source="admin"
|
||||
path=":pleroma.:instance.:account_field_name_length"
|
||||
draft-mode
|
||||
>
|
||||
MAX ACCOUNT FIELD NAME
|
||||
</IntegerSetting>
|
||||
</li>
|
||||
<li>
|
||||
<IntegerSetting
|
||||
source="admin"
|
||||
path=":pleroma.:instance.:account_field_value_length"
|
||||
draft-mode
|
||||
>
|
||||
MAX ACCOUNT VALUE NAME
|
||||
</IntegerSetting>
|
||||
</li>
|
||||
<li>
|
||||
<h4>{{ $t('admin_dash.limits.user_uploads') }}</h4>
|
||||
</li>
|
||||
<li>
|
||||
<IntegerSetting
|
||||
source="admin"
|
||||
path=":pleroma.:instance.:avatar_upload_limit"
|
||||
draft-mode
|
||||
>
|
||||
MAX AVATAR SIZE KiB
|
||||
</IntegerSetting>
|
||||
</li>
|
||||
<li>
|
||||
<IntegerSetting
|
||||
source="admin"
|
||||
path=":pleroma.:instance.:banner_upload_limit"
|
||||
draft-mode
|
||||
>
|
||||
MAX BANNER SIZE KiB
|
||||
</IntegerSetting>
|
||||
</li>
|
||||
<li>
|
||||
<IntegerSetting
|
||||
source="admin"
|
||||
path=":pleroma.:instance.:max_pinned_statuses"
|
||||
draft-mode
|
||||
>
|
||||
MAX PINNED POSTS
|
||||
</IntegerSetting>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script src="./limits_tab.js"></script>
|
@ -12,7 +12,12 @@
|
||||
v-if="!!$slots.default"
|
||||
class="label"
|
||||
>
|
||||
<slot />
|
||||
<template v-if="backendDescription">
|
||||
{{ backendDescriptionLabel + ' ' }}
|
||||
</template>
|
||||
<template v-else>
|
||||
<slot />
|
||||
</template>
|
||||
</span>
|
||||
{{ ' ' }}
|
||||
<ModifiedIndicator
|
||||
@ -21,6 +26,12 @@
|
||||
/>
|
||||
<ProfileSettingIndicator :is-profile="isProfileSetting" />
|
||||
<DraftButtons />
|
||||
<p
|
||||
v-if="backendDescriptionDescription"
|
||||
class="setting-description"
|
||||
>
|
||||
{{ backendDescriptionDescription + ' ' }}
|
||||
</p>
|
||||
</Checkbox>
|
||||
</label>
|
||||
</template>
|
||||
|
@ -4,7 +4,12 @@
|
||||
class="IntegerSetting"
|
||||
>
|
||||
<label :for="path">
|
||||
<slot />
|
||||
<template v-if="backendDescription">
|
||||
{{ backendDescriptionLabel + ' ' }}
|
||||
</template>
|
||||
<template v-else>
|
||||
<slot />
|
||||
</template>
|
||||
</label>
|
||||
<input
|
||||
:id="path"
|
||||
@ -23,6 +28,12 @@
|
||||
/>
|
||||
<ProfileSettingIndicator :is-profile="isProfileSetting" />
|
||||
<DraftButtons />
|
||||
<p
|
||||
v-if="backendDescriptionDescription"
|
||||
class="setting-description"
|
||||
>
|
||||
{{ backendDescriptionDescription + ' ' }}
|
||||
</p>
|
||||
</span>
|
||||
</template>
|
||||
|
||||
|
@ -59,6 +59,16 @@ export default {
|
||||
return value
|
||||
}
|
||||
},
|
||||
backendDescription () {
|
||||
console.log(get(this.$store.state.adminSettings.descriptions, this.path))
|
||||
return get(this.$store.state.adminSettings.descriptions, this.path)
|
||||
},
|
||||
backendDescriptionLabel () {
|
||||
return this.backendDescription.label
|
||||
},
|
||||
backendDescriptionDescription () {
|
||||
return this.backendDescription.description
|
||||
},
|
||||
shouldBeDisabled () {
|
||||
const parentValue = this.parentPath !== undefined ? get(this.configSource, this.parentPath) : null
|
||||
return this.disabled || (parentValue !== null ? (this.parentInvert ? parentValue : !parentValue) : false)
|
||||
|
@ -4,7 +4,12 @@
|
||||
class="StringSetting"
|
||||
>
|
||||
<label :for="path">
|
||||
<slot />
|
||||
<template v-if="backendDescription">
|
||||
{{ backendDescriptionLabel + ' ' }}
|
||||
</template>
|
||||
<template v-else>
|
||||
<slot />
|
||||
</template>
|
||||
</label>
|
||||
<input
|
||||
:id="path"
|
||||
@ -21,6 +26,12 @@
|
||||
/>
|
||||
<ProfileSettingIndicator :is-profile="isProfileSetting" />
|
||||
<DraftButtons />
|
||||
<p
|
||||
v-if="backendDescriptionDescription"
|
||||
class="setting-description"
|
||||
>
|
||||
{{ backendDescriptionDescription + ' ' }}
|
||||
</p>
|
||||
</label>
|
||||
</template>
|
||||
|
||||
|
@ -17,6 +17,12 @@
|
||||
}
|
||||
}
|
||||
|
||||
.setting-description {
|
||||
margin-top: 0.2em;
|
||||
margin-bottom: 2em;
|
||||
font-size: 70%;
|
||||
}
|
||||
|
||||
.settings-modal-panel {
|
||||
overflow: hidden;
|
||||
transition: transform;
|
||||
|
@ -3,6 +3,7 @@ import TabSwitcher from 'src/components/tab_switcher/tab_switcher.jsx'
|
||||
import DataImportExportTab from './tabs/data_import_export_tab.vue'
|
||||
import MutesAndBlocksTab from './tabs/mutes_and_blocks_tab.vue'
|
||||
import InstanceTab from './admin_tabs/instance_tab.vue'
|
||||
import LimitsTab from './admin_tabs/limits_tab.vue'
|
||||
|
||||
import { library } from '@fortawesome/fontawesome-svg-core'
|
||||
import {
|
||||
@ -33,7 +34,8 @@ const SettingsModalAdminContent = {
|
||||
|
||||
DataImportExportTab,
|
||||
MutesAndBlocksTab,
|
||||
InstanceTab
|
||||
InstanceTab,
|
||||
LimitsTab
|
||||
},
|
||||
computed: {
|
||||
isLoggedIn () {
|
||||
|
@ -7,12 +7,19 @@
|
||||
:body-scroll-lock="bodyLock"
|
||||
>
|
||||
<div
|
||||
:label="$t('settings.general')"
|
||||
:label="$t('admin_dash.instance')"
|
||||
icon="wrench"
|
||||
data-tab-name="general"
|
||||
>
|
||||
<InstanceTab />
|
||||
</div>
|
||||
<div
|
||||
:label="$t('admin_dash.limits')"
|
||||
icon="wrench"
|
||||
data-tab-name="limits"
|
||||
>
|
||||
<LimitsTab />
|
||||
</div>
|
||||
</tab-switcher>
|
||||
</template>
|
||||
|
||||
|
@ -3,7 +3,8 @@ import { set, cloneDeep } from 'lodash'
|
||||
export const defaultState = {
|
||||
needsReboot: null,
|
||||
config: null,
|
||||
modifiedPaths: null
|
||||
modifiedPaths: null,
|
||||
descriptions: null
|
||||
}
|
||||
|
||||
export const newUserFlags = {
|
||||
@ -18,6 +19,9 @@ const adminSettingsStorage = {
|
||||
updateAdminSettings (state, { config, modifiedPaths }) {
|
||||
state.config = config
|
||||
state.modifiedPaths = modifiedPaths
|
||||
},
|
||||
updateAdminDescriptions (state, { descriptions }) {
|
||||
state.descriptions = descriptions
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
@ -40,8 +44,25 @@ const adminSettingsStorage = {
|
||||
}
|
||||
set(config, path, convert(c.value))
|
||||
})
|
||||
console.log(config[':pleroma'][':welcome'])
|
||||
commit('updateAdminSettings', { config, modifiedPaths })
|
||||
},
|
||||
setInstanceAdminDescriptions ({ state, commit, dispatch }, { backendDescriptions }) {
|
||||
const convert = ({ children, description, label, key = '<ROOT>', group, suggestions }, path, acc) => {
|
||||
const newPath = group ? group + '.' + key : key
|
||||
const obj = { description, label, suggestions }
|
||||
if (Array.isArray(children)) {
|
||||
children.forEach(c => {
|
||||
convert(c, '.' + newPath, obj)
|
||||
})
|
||||
}
|
||||
set(acc, newPath, obj)
|
||||
}
|
||||
|
||||
const descriptions = {}
|
||||
backendDescriptions.forEach(d => convert(d, '', descriptions))
|
||||
commit('updateAdminDescriptions', { descriptions })
|
||||
},
|
||||
pushAdminSetting ({ rootState, state, commit, dispatch }, { path, value }) {
|
||||
const [group, key, ...rest] = path.split(/\./g)
|
||||
const clone = {} // not actually cloning the entire thing to avoid excessive writes
|
||||
@ -71,7 +92,6 @@ const adminSettingsStorage = {
|
||||
.then(backendDbConfig => dispatch('setInstanceAdminSettings', { backendDbConfig }))
|
||||
},
|
||||
resetAdminSetting ({ rootState, state, commit, dispatch }, { path }) {
|
||||
console.log('ASS')
|
||||
const [group, key, subkey] = path.split(/\./g)
|
||||
|
||||
state.modifiedPaths.delete(path)
|
||||
|
@ -567,6 +567,8 @@ const users = {
|
||||
if (user.rights.admin) {
|
||||
store.rootState.api.backendInteractor.fetchInstanceDBConfig()
|
||||
.then(backendDbConfig => dispatch('setInstanceAdminSettings', { backendDbConfig }))
|
||||
store.rootState.api.backendInteractor.fetchInstanceConfigDescriptions()
|
||||
.then(backendDescriptions => dispatch('setInstanceAdminDescriptions', { backendDescriptions }))
|
||||
}
|
||||
commit('addNewUsers', [user])
|
||||
|
||||
|
@ -109,6 +109,7 @@ const PLEROMA_EDIT_ANNOUNCEMENT_URL = id => `/api/v1/pleroma/admin/announcements
|
||||
const PLEROMA_DELETE_ANNOUNCEMENT_URL = id => `/api/v1/pleroma/admin/announcements/${id}`
|
||||
|
||||
const PLEROMA_ADMIN_CONFIG_URL = '/api/pleroma/admin/config'
|
||||
const PLEROMA_ADMIN_DESCRIPTIONS_URL = '/api/pleroma/admin/config/descriptions'
|
||||
|
||||
const oldfetch = window.fetch
|
||||
|
||||
@ -1677,6 +1678,21 @@ const fetchInstanceDBConfig = ({ credentials }) => {
|
||||
})
|
||||
}
|
||||
|
||||
const fetchInstanceConfigDescriptions = ({ credentials }) => {
|
||||
return fetch(PLEROMA_ADMIN_DESCRIPTIONS_URL, {
|
||||
headers: authHeaders(credentials)
|
||||
})
|
||||
.then((response) => {
|
||||
if (response.ok) {
|
||||
return response.json()
|
||||
} else {
|
||||
return {
|
||||
error: response
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const pushInstanceDBConfig = ({ credentials, payload }) => {
|
||||
return fetch(PLEROMA_ADMIN_CONFIG_URL, {
|
||||
headers: {
|
||||
@ -1813,6 +1829,7 @@ const apiService = {
|
||||
deleteAnnouncement,
|
||||
adminFetchAnnouncements,
|
||||
fetchInstanceDBConfig,
|
||||
fetchInstanceConfigDescriptions,
|
||||
pushInstanceDBConfig
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user