Page MenuHomePhorge

No OneTemporary

Size
17 KB
Referenced Files
None
Subscribers
None
diff --git a/src/components/settings_modal/admin_tabs/instance_tab.js b/src/components/settings_modal/admin_tabs/instance_tab.js
index 77a05d389a..7aaedbce8d 100644
--- a/src/components/settings_modal/admin_tabs/instance_tab.js
+++ b/src/components/settings_modal/admin_tabs/instance_tab.js
@@ -1,28 +1,34 @@
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 InstanceTab = {
+ provide () {
+ return {
+ defaultDraftMode: true,
+ defaultSource: 'admin'
+ }
+ },
components: {
BooleanSetting,
ChoiceSetting,
IntegerSetting,
StringSetting
},
computed: {
...SharedComputedObject()
}
}
export default InstanceTab
diff --git a/src/components/settings_modal/admin_tabs/instance_tab.vue b/src/components/settings_modal/admin_tabs/instance_tab.vue
index 411982cc9f..43ad4c8c98 100644
--- a/src/components/settings_modal/admin_tabs/instance_tab.vue
+++ b/src/components/settings_modal/admin_tabs/instance_tab.vue
@@ -1,170 +1,116 @@
<template>
<div :label="$t('admin_dash.tabs.instance')">
<div class="setting-item">
<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>
</ul>
</div>
<div class="setting-item">
<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>
</li>
</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>
<li>
<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>
</li>
</ul>
<ul
v-if="adminConfig[':pleroma']['Pleroma.Captcha'][':enabled'] && adminConfig[':pleroma']['Pleroma.Captcha'][':method'] === 'Pleroma.Captcha.Kocaptcha'"
class="setting-list suboptions"
>
<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>
</ul>
</li>
</ul>
</div>
</div>
</template>
<script src="./instance_tab.js"></script>
diff --git a/src/components/settings_modal/helpers/choice_setting.js b/src/components/settings_modal/helpers/choice_setting.js
index 3ff81bc904..bdeece7603 100644
--- a/src/components/settings_modal/helpers/choice_setting.js
+++ b/src/components/settings_modal/helpers/choice_setting.js
@@ -1,42 +1,41 @@
import Select from 'src/components/select/select.vue'
import Setting from './setting.js'
export default {
...Setting,
components: {
...Setting.components,
Select
},
props: {
...Setting.props,
options: {
type: Array,
required: false
},
optionLabelMap: {
type: Object,
required: false,
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,
label: this.optionLabelMap[x] || x
}))
}
return this.options
}
},
methods: {
...Setting.methods,
getValue (e) {
return e
}
}
}
diff --git a/src/components/settings_modal/helpers/choice_setting.vue b/src/components/settings_modal/helpers/choice_setting.vue
index 55f9a62ca9..8713acf567 100644
--- a/src/components/settings_modal/helpers/choice_setting.vue
+++ b/src/components/settings_modal/helpers/choice_setting.vue
@@ -1,42 +1,42 @@
<template>
<label
v-if="matchesExpertLevel"
class="ChoiceSetting"
>
<template v-if="backendDescription">
{{ backendDescriptionLabel }}
</template>
<template v-else>
<slot />
</template>
{{ ' ' }}
<Select
- :model-value="draftMode ? draft :state"
+ :model-value="realDraftMode ? draft :state"
:disabled="disabled"
@update:modelValue="update"
>
<option
v-for="option in realOptions"
:key="option.key"
:value="option.value"
>
{{ option.label }}
{{ option.value === defaultState ? $t('settings.instance_default_simple') : '' }}
</option>
</Select>
<ModifiedIndicator
:changed="isChanged"
:onclick="reset"
/>
<ProfileSettingIndicator :is-profile="isProfileSetting" />
<DraftButtons />
<p
v-if="backendDescriptionDescription"
class="setting-description"
>
{{ backendDescriptionDescription + ' ' }}
</p>
</label>
</template>
<script src="./choice_setting.js"></script>
diff --git a/src/components/settings_modal/helpers/number_setting.vue b/src/components/settings_modal/helpers/number_setting.vue
index 93a7a79ae8..f97d5cf2d0 100644
--- a/src/components/settings_modal/helpers/number_setting.vue
+++ b/src/components/settings_modal/helpers/number_setting.vue
@@ -1,40 +1,40 @@
<template>
<span
v-if="matchesExpertLevel"
class="NumberSetting"
>
<label :for="path">
<template v-if="backendDescription">
{{ backendDescriptionLabel + ' ' }}
</template>
<template v-else>
<slot />
</template>
</label>
<input
:id="path"
class="number-input"
type="number"
:step="step || 1"
:disabled="disabled"
:min="min || 0"
- :value="draftMode ? draft :state"
+ :value="realDraftMode ? draft :state"
@change="update"
>
{{ ' ' }}
<ModifiedIndicator
:changed="isChanged"
:onclick="reset"
/>
<ProfileSettingIndicator :is-profile="isProfileSetting" />
<DraftButtons />
<p
v-if="backendDescriptionDescription"
class="setting-description"
>
{{ backendDescriptionDescription + ' ' }}
</p>
</span>
</template>
<script src="./number_setting.js"></script>
diff --git a/src/components/settings_modal/helpers/setting.js b/src/components/settings_modal/helpers/setting.js
index fd730db930..7cad27b756 100644
--- a/src/components/settings_modal/helpers/setting.js
+++ b/src/components/settings_modal/helpers/setting.js
@@ -1,162 +1,177 @@
import ModifiedIndicator from './modified_indicator.vue'
import ProfileSettingIndicator from './profile_setting_indicator.vue'
import DraftButtons from './draft_buttons.vue'
import { get, set } from 'lodash'
export default {
components: {
ModifiedIndicator,
DraftButtons,
ProfileSettingIndicator
},
props: {
path: {
type: [String, Array],
required: true
},
disabled: {
type: Boolean,
default: false
},
parentPath: {
type: [String, Array]
},
parentInvert: {
type: Boolean,
default: false
},
expert: {
type: [Number, String],
default: 0
},
source: {
type: String,
- default: 'default'
+ default: undefined
},
draftMode: {
type: Boolean,
+ default: undefined
+ }
+ },
+ inject: {
+ defaultSource: {
+ default: 'default'
+ },
+ defaultDraftMode: {
default: false
}
},
data () {
return {
draft: null
}
},
created () {
- if (this.draftMode) {
+ if (this.realDraftMode) {
this.draft = this.state
}
},
computed: {
state () {
const value = get(this.configSource, this.path)
if (value === undefined) {
return this.defaultState
} else {
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)
},
backendDescriptionLabel () {
return this.backendDescription?.label
},
backendDescriptionDescription () {
return this.backendDescription?.description
},
backendDescriptionSuggestions () {
return this.backendDescription?.suggestions
},
shouldBeDisabled () {
const parentValue = this.parentPath !== undefined ? get(this.configSource, this.parentPath) : null
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':
return this.$store.state.adminSettings.config
default:
return this.$store.getters.mergedConfig
}
},
configSink () {
- switch (this.source) {
+ switch (this.realSource) {
case 'profile':
return (k, v) => this.$store.dispatch('setProfileOption', { name: k, value: v })
case 'admin':
return (k, v) => this.$store.dispatch('pushAdminSetting', { path: k, value: v })
default:
return (k, v) => this.$store.dispatch('setOption', { name: k, value: v })
}
},
defaultState () {
- switch (this.source) {
+ switch (this.realSource) {
case 'profile':
return {}
default:
return get(this.$store.getters.defaultConfig, this.path)
}
},
isProfileSetting () {
- return this.source === 'profile'
+ return this.realSource === 'profile'
},
isChanged () {
- switch (this.source) {
+ switch (this.realSource) {
case 'profile':
case 'admin':
return false
default:
return this.state !== this.defaultState
}
},
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
}
},
methods: {
getValue (e) {
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
} else {
set(this.$store.getters.mergedConfig, this.path, this.defaultState)
}
},
hardReset () {
- switch (this.source) {
+ switch (this.realSource) {
case 'admin':
return this.$store.dispatch('resetAdminSetting', { path: this.path })
.then(() => { this.draft = this.state })
default:
console.warn('Hard reset not implemented yet!')
}
}
}
}
diff --git a/src/components/settings_modal/helpers/string_setting.vue b/src/components/settings_modal/helpers/string_setting.vue
index 91a4afa455..fb91b5d970 100644
--- a/src/components/settings_modal/helpers/string_setting.vue
+++ b/src/components/settings_modal/helpers/string_setting.vue
@@ -1,38 +1,38 @@
<template>
<label
v-if="matchesExpertLevel"
class="StringSetting"
>
<label :for="path">
<template v-if="backendDescription">
{{ backendDescriptionLabel + ' ' }}
</template>
<template v-else>
<slot />
</template>
</label>
<input
:id="path"
class="string-input"
step="1"
:disabled="disabled"
- :value="draftMode ? draft :state"
+ :value="realDraftMode ? draft : state"
@change="update"
>
{{ ' ' }}
<ModifiedIndicator
:changed="isChanged"
:onclick="reset"
/>
<ProfileSettingIndicator :is-profile="isProfileSetting" />
<DraftButtons />
<p
v-if="backendDescriptionDescription"
class="setting-description"
>
{{ backendDescriptionDescription + ' ' }}
</p>
</label>
</template>
<script src="./string_setting.js"></script>

File Metadata

Mime Type
text/x-diff
Expires
Sun, Aug 9, 8:47 AM (1 d, 12 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1724367
Default Alt Text
(17 KB)

Event Timeline