logo

pleroma-fe

My custom branche(s) on git.pleroma.social/pleroma/pleroma-fe git clone https://hacktivis.me/git/pleroma-fe.git
commit: 2bf224e214d9b42333a2139a89c089ca9a544149
parent 6b40fc989575fd52b3b9bf3e8d78d7fb4a6c7696
Author: Henry Jameson <me@hjkos.com>
Date:   Tue, 21 Mar 2023 22:46:40 +0200

made draft-mode and source inject-able

Diffstat:

Msrc/components/settings_modal/admin_tabs/instance_tab.js6++++++
Msrc/components/settings_modal/admin_tabs/instance_tab.vue78++++++++++++------------------------------------------------------------------
Msrc/components/settings_modal/helpers/choice_setting.js3+--
Msrc/components/settings_modal/helpers/choice_setting.vue2+-
Msrc/components/settings_modal/helpers/number_setting.vue2+-
Msrc/components/settings_modal/helpers/setting.js41++++++++++++++++++++++++++++-------------
Msrc/components/settings_modal/helpers/string_setting.vue2+-
7 files changed, 50 insertions(+), 84 deletions(-)

diff --git a/src/components/settings_modal/admin_tabs/instance_tab.js b/src/components/settings_modal/admin_tabs/instance_tab.js @@ -14,6 +14,12 @@ library.add( ) const InstanceTab = { + provide () { + return { + defaultDraftMode: true, + defaultSource: 'admin' + } + }, components: { BooleanSetting, ChoiceSetting, diff --git a/src/components/settings_modal/admin_tabs/instance_tab.vue b/src/components/settings_modal/admin_tabs/instance_tab.vue @@ -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> diff --git a/src/components/settings_modal/helpers/choice_setting.js b/src/components/settings_modal/helpers/choice_setting.js @@ -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, diff --git a/src/components/settings_modal/helpers/choice_setting.vue b/src/components/settings_modal/helpers/choice_setting.vue @@ -11,7 +11,7 @@ </template> {{ ' ' }} <Select - :model-value="draftMode ? draft :state" + :model-value="realDraftMode ? draft :state" :disabled="disabled" @update:modelValue="update" > diff --git a/src/components/settings_modal/helpers/number_setting.vue b/src/components/settings_modal/helpers/number_setting.vue @@ -18,7 +18,7 @@ :step="step || 1" :disabled="disabled" :min="min || 0" - :value="draftMode ? draft :state" + :value="realDraftMode ? draft :state" @change="update" > {{ ' ' }} diff --git a/src/components/settings_modal/helpers/setting.js b/src/components/settings_modal/helpers/setting.js @@ -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 }) diff --git a/src/components/settings_modal/helpers/string_setting.vue b/src/components/settings_modal/helpers/string_setting.vue @@ -16,7 +16,7 @@ class="string-input" step="1" :disabled="disabled" - :value="draftMode ? draft :state" + :value="realDraftMode ? draft : state" @change="update" > {{ ' ' }}