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