made draft-mode and source inject-able
This commit is contained in:
parent
6b40fc9895
commit
2bf224e214
@ -14,6 +14,12 @@ library.add(
|
||||
)
|
||||
|
||||
const InstanceTab = {
|
||||
provide () {
|
||||
return {
|
||||
defaultDraftMode: true,
|
||||
defaultSource: 'admin'
|
||||
}
|
||||
},
|
||||
components: {
|
||||
BooleanSetting,
|
||||
ChoiceSetting,
|
||||
|
@ -4,65 +4,37 @@
|
||||
<h2>{{ $t('admin_dash.instance.instance') }}</h2>
|
||||
<ul class="setting-list">
|
||||
<li>
|
||||
<StringSetting
|
||||
source="admin"
|
||||
path=":pleroma.:instance.:name"
|
||||
draft-mode
|
||||
>
|
||||
<StringSetting path=":pleroma.:instance.:name">
|
||||
NAME
|
||||
</StringSetting>
|
||||
</li>
|
||||
<li>
|
||||
<StringSetting
|
||||
source="admin"
|
||||
path=":pleroma.:instance.:email"
|
||||
draft-mode
|
||||
>
|
||||
<StringSetting path=":pleroma.:instance.:email">
|
||||
ADMIN EMAIL
|
||||
</StringSetting>
|
||||
</li>
|
||||
<li>
|
||||
<StringSetting
|
||||
source="admin"
|
||||
path=":pleroma.:instance.:description"
|
||||
draft-mode
|
||||
>
|
||||
<StringSetting path=":pleroma.:instance.:description">
|
||||
DESCRIPTION
|
||||
</StringSetting>
|
||||
</li>
|
||||
<li>
|
||||
<StringSetting
|
||||
source="admin"
|
||||
path=":pleroma.:instance.:short_description"
|
||||
draft-mode
|
||||
>
|
||||
<StringSetting path=":pleroma.:instance.:short_description">
|
||||
SHORT DESCRIPTION
|
||||
</StringSetting>
|
||||
</li>
|
||||
<li>
|
||||
<StringSetting
|
||||
source="admin"
|
||||
path=":pleroma.:instance.:instance_thumbnail"
|
||||
draft-mode
|
||||
>
|
||||
<StringSetting path=":pleroma.:instance.:instance_thumbnail">
|
||||
INSTANCE THUMBNAIL
|
||||
</StringSetting>
|
||||
</li>
|
||||
<li>
|
||||
<StringSetting
|
||||
source="admin"
|
||||
path=":pleroma.:instance.:background_image"
|
||||
draft-mode
|
||||
>
|
||||
<StringSetting path=":pleroma.:instance.:background_image">
|
||||
BACKGROUND IMAGE
|
||||
</StringSetting>
|
||||
</li>
|
||||
<li>
|
||||
<BooleanSetting
|
||||
source="admin"
|
||||
path=":pleroma.:instance.:public"
|
||||
draft-mode
|
||||
>
|
||||
<BooleanSetting path=":pleroma.:instance.:public">
|
||||
PUBLIC
|
||||
</BooleanSetting>
|
||||
</li>
|
||||
@ -72,21 +44,15 @@
|
||||
<h2>{{ $t('admin_dash.instance.registrations') }}</h2>
|
||||
<ul class="setting-list">
|
||||
<li>
|
||||
<BooleanSetting
|
||||
source="admin"
|
||||
path=":pleroma.:instance.:registrations_open"
|
||||
draft-mode
|
||||
>
|
||||
<BooleanSetting path=":pleroma.:instance.:registrations_open">
|
||||
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>
|
||||
@ -94,20 +60,12 @@
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<BooleanSetting
|
||||
source="admin"
|
||||
path=":pleroma.:instance.:account_activation_required"
|
||||
draft-mode
|
||||
>
|
||||
<BooleanSetting path=":pleroma.:instance.:account_activation_required">
|
||||
ACTIVATION REQUIRED
|
||||
</BooleanSetting>
|
||||
</li>
|
||||
<li>
|
||||
<BooleanSetting
|
||||
source="admin"
|
||||
path=":pleroma.:instance.:account_approval_required"
|
||||
draft-mode
|
||||
>
|
||||
<BooleanSetting path=":pleroma.:instance.:account_approval_required">
|
||||
APPROVAL REQUIRED
|
||||
</BooleanSetting>
|
||||
</li>
|
||||
@ -115,32 +73,24 @@
|
||||
<h3>{{ $t('admin_dash.instance.captcha_header') }}</h3>
|
||||
</li>
|
||||
<li>
|
||||
<BooleanSetting
|
||||
source="admin"
|
||||
:path="[':pleroma', 'Pleroma.Captcha', ':enabled']"
|
||||
draft-mode
|
||||
>
|
||||
<BooleanSetting :path="[':pleroma', 'Pleroma.Captcha', ':enabled']">
|
||||
CAPTCHA
|
||||
</BooleanSetting>
|
||||
<ul class="setting-list suboptions">
|
||||
<li>
|
||||
<ChoiceSetting
|
||||
source="admin"
|
||||
:path="[':pleroma', 'Pleroma.Captcha', ':method']"
|
||||
:parent-path="[':pleroma', 'Pleroma.Captcha', ':enabled']"
|
||||
:option-label-map="{
|
||||
'Pleroma.Captcha.Native': $t('admin_dash.captcha.native'),
|
||||
'Pleroma.Captcha.Kocaptcha': $t('admin_dash.captcha.kocaptcha')
|
||||
}"
|
||||
draft-mode
|
||||
>
|
||||
CAPTCHA TYPE
|
||||
</ChoiceSetting>
|
||||
<IntegerSetting
|
||||
source="admin"
|
||||
:path="[':pleroma', 'Pleroma.Captcha', ':seconds_valid']"
|
||||
:parent-path="[':pleroma', 'Pleroma.Captcha', ':enabled']"
|
||||
draft-mode
|
||||
>
|
||||
VALID
|
||||
</IntegerSetting>
|
||||
@ -152,11 +102,7 @@
|
||||
>
|
||||
<h4>{{ $t('admin_dash.instance.kocaptcha') }}</h4>
|
||||
<li>
|
||||
<StringSetting
|
||||
source="admin"
|
||||
:path="[':pleroma', 'Pleroma.Captcha.Kocaptcha', ':endpoint']"
|
||||
draft-mode
|
||||
>
|
||||
<StringSetting :path="[':pleroma', 'Pleroma.Captcha.Kocaptcha', ':endpoint']">
|
||||
cockAPTCHA ENDPOINT
|
||||
</StringSetting>
|
||||
</li>
|
||||
|
@ -22,8 +22,7 @@ export default {
|
||||
computed: {
|
||||
...Setting.computed,
|
||||
realOptions () {
|
||||
if (this.source === 'admin') {
|
||||
console.log(this.backendDescriptionSuggestions)
|
||||
if (this.realSource === 'admin') {
|
||||
return this.backendDescriptionSuggestions.map(x => ({
|
||||
key: x,
|
||||
value: x,
|
||||
|
@ -11,7 +11,7 @@
|
||||
</template>
|
||||
{{ ' ' }}
|
||||
<Select
|
||||
:model-value="draftMode ? draft :state"
|
||||
:model-value="realDraftMode ? draft :state"
|
||||
:disabled="disabled"
|
||||
@update:modelValue="update"
|
||||
>
|
||||
|
@ -18,7 +18,7 @@
|
||||
:step="step || 1"
|
||||
:disabled="disabled"
|
||||
:min="min || 0"
|
||||
:value="draftMode ? draft :state"
|
||||
:value="realDraftMode ? draft :state"
|
||||
@change="update"
|
||||
>
|
||||
{{ ' ' }}
|
||||
|
@ -31,10 +31,18 @@ export default {
|
||||
},
|
||||
source: {
|
||||
type: String,
|
||||
default: 'default'
|
||||
default: undefined
|
||||
},
|
||||
draftMode: {
|
||||
type: Boolean,
|
||||
default: undefined
|
||||
}
|
||||
},
|
||||
inject: {
|
||||
defaultSource: {
|
||||
default: 'default'
|
||||
},
|
||||
defaultDraftMode: {
|
||||
default: false
|
||||
}
|
||||
},
|
||||
@ -44,7 +52,7 @@ export default {
|
||||
}
|
||||
},
|
||||
created () {
|
||||
if (this.draftMode) {
|
||||
if (this.realDraftMode) {
|
||||
this.draft = this.state
|
||||
}
|
||||
},
|
||||
@ -57,6 +65,12 @@ export default {
|
||||
return value
|
||||
}
|
||||
},
|
||||
realSource () {
|
||||
return this.source || this.defaultSource
|
||||
},
|
||||
realDraftMode () {
|
||||
return typeof this.draftMode === 'undefined' ? this.defaultDraftMode : this.draftMode
|
||||
},
|
||||
backendDescription () {
|
||||
return get(this.$store.state.adminSettings.descriptions, this.path)
|
||||
},
|
||||
@ -74,7 +88,8 @@ export default {
|
||||
return this.disabled || (parentValue !== null ? (this.parentInvert ? parentValue : !parentValue) : false)
|
||||
},
|
||||
configSource () {
|
||||
switch (this.source) {
|
||||
console.log('SRC', this.realSource)
|
||||
switch (this.realSource) {
|
||||
case 'profile':
|
||||
return this.$store.state.profileConfig
|
||||
case 'admin':
|
||||
@ -84,7 +99,7 @@ export default {
|
||||
}
|
||||
},
|
||||
configSink () {
|
||||
switch (this.source) {
|
||||
switch (this.realSource) {
|
||||
case 'profile':
|
||||
return (k, v) => this.$store.dispatch('setProfileOption', { name: k, value: v })
|
||||
case 'admin':
|
||||
@ -94,7 +109,7 @@ export default {
|
||||
}
|
||||
},
|
||||
defaultState () {
|
||||
switch (this.source) {
|
||||
switch (this.realSource) {
|
||||
case 'profile':
|
||||
return {}
|
||||
default:
|
||||
@ -102,10 +117,10 @@ export default {
|
||||
}
|
||||
},
|
||||
isProfileSetting () {
|
||||
return this.source === 'profile'
|
||||
return this.realSource === 'profile'
|
||||
},
|
||||
isChanged () {
|
||||
switch (this.source) {
|
||||
switch (this.realSource) {
|
||||
case 'profile':
|
||||
case 'admin':
|
||||
return false
|
||||
@ -114,10 +129,10 @@ export default {
|
||||
}
|
||||
},
|
||||
isDirty () {
|
||||
return this.draftMode && this.draft !== this.state
|
||||
return this.realDraftMode && this.draft !== this.state
|
||||
},
|
||||
canHardReset () {
|
||||
return this.source === 'admin' && this.$store.state.adminSettings.modifiedPaths.has(this.path)
|
||||
return this.realSource === 'admin' && this.$store.state.adminSettings.modifiedPaths.has(this.path)
|
||||
},
|
||||
matchesExpertLevel () {
|
||||
return (this.expert || 0) <= this.$store.state.config.expertLevel > 0
|
||||
@ -128,20 +143,20 @@ export default {
|
||||
return e.target.value
|
||||
},
|
||||
update (e) {
|
||||
if (this.draftMode) {
|
||||
if (this.realDraftMode) {
|
||||
this.draft = this.getValue(e)
|
||||
} else {
|
||||
this.configSink(this.path, this.getValue(e))
|
||||
}
|
||||
},
|
||||
commitDraft () {
|
||||
if (this.draftMode) {
|
||||
if (this.realDraftMode) {
|
||||
this.configSink(this.path, this.draft)
|
||||
}
|
||||
},
|
||||
reset () {
|
||||
console.log('reset')
|
||||
if (this.draftMode) {
|
||||
if (this.realDraftMode) {
|
||||
console.log(this.draft)
|
||||
console.log(this.state)
|
||||
this.draft = this.state
|
||||
@ -150,7 +165,7 @@ export default {
|
||||
}
|
||||
},
|
||||
hardReset () {
|
||||
switch (this.source) {
|
||||
switch (this.realSource) {
|
||||
case 'admin':
|
||||
return this.$store.dispatch('resetAdminSetting', { path: this.path })
|
||||
.then(() => { this.draft = this.state })
|
||||
|
@ -16,7 +16,7 @@
|
||||
class="string-input"
|
||||
step="1"
|
||||
:disabled="disabled"
|
||||
:value="draftMode ? draft :state"
|
||||
:value="realDraftMode ? draft : state"
|
||||
@change="update"
|
||||
>
|
||||
{{ ' ' }}
|
||||
|
Loading…
Reference in New Issue
Block a user