Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F85951413
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
Unknown
Size
64 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/src/components/settings_modal/helpers/attachment_setting.vue b/src/components/settings_modal/helpers/attachment_setting.vue
index c8e0e4ea02..87306a02ae 100644
--- a/src/components/settings_modal/helpers/attachment_setting.vue
+++ b/src/components/settings_modal/helpers/attachment_setting.vue
@@ -1,123 +1,123 @@
<template>
<span
v-if="matchesExpertLevel"
class="AttachmentSetting setting-item"
:class="{ '-compact': compact }"
>
<label
class="setting-label"
:for="path"
:class="{ 'faint': shouldBeDisabled }"
>
- <template v-if="backendDescriptionLabel">
- {{ backendDescriptionLabel + ' ' }}
+ <template v-if="realLabel">
+ {{ realLabel + ' ' }}
</template>
<template v-else-if="source === 'admin'">
MISSING LABEL FOR {{ path }}
</template>
<slot v-else />
</label>
<p
- v-if="backendDescriptionDescription"
+ v-if="realDescription"
class="setting-description"
:class="{ 'faint': shouldBeDisabled }"
>
- {{ backendDescriptionDescription + ' ' }}
+ {{ realDescription + ' ' }}
</p>
<div class="attachment-input">
<div class="controls control-field">
<label for="path">{{ $t('settings.url') }}</label>
<input
:id="path"
class="input string-input"
:disabled="shouldBeDisabled"
:value="realDraftMode ? draft : state"
@change="update"
>
{{ ' ' }}
<ModifiedIndicator
:changed="isChanged"
:onclick="reset"
/>
<LocalSettingIndicator :is-local="isLocalSetting" />
</div>
<div v-if="!compact">{{ $t('settings.preview') }}</div>
<Attachment
class="attachment"
:compact="compact"
:attachment="attachment"
size="small"
hide-description
/>
<div class="controls control-upload">
<MediaUpload
ref="mediaUpload"
class="media-upload-icon"
normal-button
:accept-types="acceptTypes"
@uploaded="setMediaFile"
/>
</div>
</div>
<DraftButtons />
</span>
</template>
<script src="./attachment_setting.js"></script>
<style lang="scss">
.AttachmentSetting {
.attachment {
display: block;
width: 100%;
height: 15em;
margin-bottom: 0.5em;
}
.attachment-input {
margin-left: 1em;
display: flex;
flex-direction: column;
width: 20em;
}
&.-compact {
.attachment-input {
flex-direction: row;
align-items: flex-end;
}
.attachment {
flex: 0;
order: 0;
display: block;
min-width: 4em;
height: 4em;
align-self: center;
margin-bottom: 0;
}
.control-field {
order: 1;
min-width: 12em;
margin-left: 0.5em;
}
.control-upload {
order: 2;
min-width: 12em;
padding: 0 0.5em;
}
}
.controls {
margin-bottom: 0.5em;
input,
button {
width: 100%;
}
}
}
</style>
diff --git a/src/components/settings_modal/helpers/boolean_setting.vue b/src/components/settings_modal/helpers/boolean_setting.vue
index 5367966911..6864aa4a59 100644
--- a/src/components/settings_modal/helpers/boolean_setting.vue
+++ b/src/components/settings_modal/helpers/boolean_setting.vue
@@ -1,47 +1,46 @@
<template>
<div
v-if="matchesExpertLevel"
class="BooleanSetting setting-item"
>
<span
class="setting-label"
:class="{ 'faint': shouldBeDisabled }"
>
<ModifiedIndicator
:changed="isChanged"
:onclick="reset"
/>
<LocalSettingIndicator :is-local="isLocalSetting" />
{{ ' ' }}
<label :for="idPrefix + 'checkbox'">
- <template v-if="backendDescriptionLabel">
- {{ backendDescriptionLabel }}
+ <template v-if="realLabel">
+ {{ realLabel }}
</template>
<template v-else-if="source === 'admin'">
MISSING LABEL FOR {{ path }}
</template>
<slot v-else />
</label>
</span>
<Checkbox
:id="idPrefix + 'checkbox'"
class="setting-control"
- :model-value="visibleState"
- :disabled="shouldBeDisabled"
+ v-model="visibleState"
:indeterminate="isIndeterminate"
- @update:model-value="update"
+ :disabled="shouldBeDisabled"
/>
<p
- v-if="backendDescriptionDescription || showDescription"
+ v-if="realDescription"
class="setting-description"
:class="{ 'faint': shouldBeDisabled }"
>
<slot name="description">
- {{ backendDescriptionDescription + ' ' }}
+ {{ realDescription + ' ' }}
</slot>
</p>
<DraftButtons />
</div>
</template>
<script src="./boolean_setting.js"></script>
diff --git a/src/components/settings_modal/helpers/choice_setting.js b/src/components/settings_modal/helpers/choice_setting.js
index e5bc8420e3..aad1e63caa 100644
--- a/src/components/settings_modal/helpers/choice_setting.js
+++ b/src/components/settings_modal/helpers/choice_setting.js
@@ -1,54 +1,54 @@
import Select from 'src/components/select/select.vue'
import Setting from './setting.js'
export default {
...Setting,
components: {
...Setting.components,
Select,
},
props: {
...Setting.props,
overrideOptions: {
type: Boolean,
required: false,
},
options: {
type: Array,
required: false,
},
optionLabelMap: {
type: Object,
required: false,
default: {},
},
},
computed: {
...Setting.computed,
realOptions() {
if (this.overrideOptions) {
return this.options
}
if (this.realSource === 'admin') {
if (
- !this.backendDescriptionSuggestions?.length ||
- this.backendDescriptionSuggestions?.length === 0
+ !this.realSuggestions?.length ||
+ this.realSuggestions?.length === 0
) {
return this.options
}
- return this.backendDescriptionSuggestions.map((x) => ({
+ return this.realSuggestions.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 67c56cebdf..ef1aa24855 100644
--- a/src/components/settings_modal/helpers/choice_setting.vue
+++ b/src/components/settings_modal/helpers/choice_setting.vue
@@ -1,67 +1,67 @@
<template>
<div
v-if="matchesExpertLevel"
class="ChoiceSetting setting-item"
:class="{ 'faint': shouldBeDisabled }"
>
<div
class="setting-label"
>
<ModifiedIndicator
:changed="isChanged"
:onclick="reset"
/>
<LocalSettingIndicator :is-local="isLocalSetting" />
{{ ' ' }}
<label
:for="idPrefix + 'select'"
:id="idPrefix + 'label'"
>
- <template v-if="backendDescriptionLabel">
- {{ backendDescriptionLabel }}
+ <template v-if="realLabel">
+ {{ realLabel }}
</template>
<template v-else>
<slot />
</template>
</label>
</div>
<Select
class="setting-control"
:id="idPrefix + 'select'"
:model-value="realDraftMode ? draft : state"
:disabled="shouldBeDisabled"
@update:model-value="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>
<DraftButtons />
<p
- v-if="backendDescriptionDescription"
+ v-if="realDescription"
class="setting-description"
>
- {{ backendDescriptionDescription + ' ' }}
+ {{ realDescription + ' ' }}
</p>
</div>
</template>
<script src="./choice_setting.js"></script>
<style lang="scss">
.ChoiceSetting.setting-item {
.-mobile & {
display: block;
.setting-label {
display: block;
margin-bottom: 0.5em
}
}
}
</style>
diff --git a/src/components/settings_modal/helpers/color_setting.vue b/src/components/settings_modal/helpers/color_setting.vue
index f8f3b9427f..6e0f137653 100644
--- a/src/components/settings_modal/helpers/color_setting.vue
+++ b/src/components/settings_modal/helpers/color_setting.vue
@@ -1,72 +1,72 @@
<template>
<label
v-if="matchesExpertLevel"
class="ColorSetting setting-item"
>
<label
v-if="!hideLabel"
:for="path"
class="setting-label"
:class="{ 'faint': shouldBeDisabled }"
>
- <template v-if="backendDescriptionLabel">
- {{ backendDescriptionLabel + ' ' }}
+ <template v-if="realLabel">
+ {{ realLabel + ' ' }}
</template>
<template v-else-if="source === 'admin'">
MISSING LABEL FOR {{ path }}
</template>
<slot v-else />
</label>
{{ ' ' }}
<ColorInput
:id="path"
:name="path"
class="setting-control color-setting-input"
:class="{ disabled: shouldBeDisabled }"
:disabled="shouldBeDisabled"
- :placeholder="backendDescriptionSuggestions"
+ :placeholder="realSuggestions"
:model-value="realDraftMode ? draft : state"
@update:model-value="update"
/>
{{ ' ' }}
<ModifiedIndicator
:changed="isChanged"
:onclick="reset"
/>
<LocalSettingIndicator :is-local="isLocalSetting" />
<DraftButtons v-if="!hideDraftButtons" />
<p
- v-if="backendDescriptionDescription"
+ v-if="realDescription"
class="setting-description"
:class="{ 'faint': shouldBeDisabled }"
>
- {{ backendDescriptionDescription + ' ' }}
+ {{ realDescription + ' ' }}
</p>
</label>
</template>
<script src="./color_setting.js"></script>
<style lang="scss">
.ColorSetting {
&.setting-item {
display: grid;
grid-template-areas:
"label control"
". desc"
". draft";
.setting-label {
text-align: right;
align-self: center;
}
.setting-control {
align-self: end;
}
}
.color-setting-input {
align-self: baseline;
}
}
</style>
diff --git a/src/components/settings_modal/helpers/list_setting.js b/src/components/settings_modal/helpers/list_setting.js
index ecbdb3669a..8e2ea0e512 100644
--- a/src/components/settings_modal/helpers/list_setting.js
+++ b/src/components/settings_modal/helpers/list_setting.js
@@ -1,135 +1,135 @@
import Checkbox from 'src/components/checkbox/checkbox.vue'
import Setting from './setting.js'
import { useMergedConfigStore } from 'src/stores/merged_config.js'
export default {
...Setting,
data() {
return {
newValue: '',
}
},
components: {
...Setting.components,
Checkbox,
},
props: {
...Setting.props,
ignoreSuggestions: {
required: false,
type: Boolean,
},
overrideAvailableOptions: {
required: false,
type: Boolean,
},
options: {
required: false,
type: Set,
},
allowNew: {
required: false,
type: Boolean,
default: true,
},
forceNew: {
required: false,
type: Boolean,
default: false,
},
},
computed: {
...Setting.computed,
showNew() {
if (this.forceNew) return true
if (!this.allowNew) return false
const isExpert = useMergedConfigStore().mergedConfig.expertLevel > 0
const hasBuiltins = this.builtinEntries.length > 0
if (hasBuiltins) {
return isExpert
} else {
return true
}
},
valueSet() {
return new Set(this.visibleState)
},
suggestionsSet() {
- const suggestions = this.backendDescriptionSuggestions
+ const suggestions = this.realSuggestions
if (suggestions) {
return new Set(suggestions)
} else {
return new Set()
}
},
extraEntries() {
if (this.ignoreSuggestions) return [...this.valueSet.values()]
if (!this.suggestionsSet) return []
return [...this.valueSet.values()].filter((x) => {
return !this.builtinEntriesValueSet.has(x)
})
},
builtinEntries() {
if (this.ignoreSuggestions) return []
if (this.overrideAvailableOptions) {
return [...this.options]
}
if (!this.suggestionsSet) return []
const builtins = [...this.suggestionsSet.values()]
return builtins.map((option) => ({
label: option,
value: option,
}))
},
builtinEntriesValueSet() {
return new Set(this.builtinEntries.map((x) => x.value))
},
},
methods: {
...Setting.methods,
optionPresent(option) {
return this.valueSet.has(option)
},
getValue({ event, value, index, eventType }) {
switch (eventType) {
case 'toggle': {
this.newValue = ''
const newSet = new Set(this.valueSet.values())
if (event) {
newSet.add(value)
} else {
newSet.delete(value)
}
return [...newSet.values()]
}
case 'add': {
if (!this.newValue) return this.valueSet.values()
const res = [...this.valueSet.values(), this.newValue]
this.newValue = ''
return res
}
case 'remove': {
const pre = [...this.valueSet.values()].slice(0, index)
const post = [...this.valueSet.values()].slice(index + 1)
return [...pre, ...post]
}
case 'edit': {
const pre = [...this.valueSet.values()].slice(0, index)
const post = [...this.valueSet.values()].slice(index + 1)
const string = event.target.value
if (!string) return [...this.valueSet.values()]
return [...pre, string, ...post]
}
}
},
},
}
diff --git a/src/components/settings_modal/helpers/list_setting.vue b/src/components/settings_modal/helpers/list_setting.vue
index 93b0cd454f..96fb880023 100644
--- a/src/components/settings_modal/helpers/list_setting.vue
+++ b/src/components/settings_modal/helpers/list_setting.vue
@@ -1,100 +1,100 @@
<template>
<fieldset
v-if="matchesExpertLevel"
class="ListSetting setting-item"
>
<legend
class="setting-label"
:class="{ 'faint': shouldBeDisabled }"
>
- <template v-if="backendDescriptionLabel">
- {{ backendDescriptionLabel + ' ' }}
+ <template v-if="realLabel">
+ {{ realLabel + ' ' }}
</template>
<template v-else-if="source === 'admin'">
MISSING LABEL FOR {{ path }}
</template>
<slot v-else />
</legend>
<p
- v-if="backendDescriptionDescription"
+ v-if="realDescription"
class="setting-description"
:class="{ 'faint': shouldBeDisabled }"
>
- {{ backendDescriptionDescription + ' ' }}
+ {{ realDescription + ' ' }}
</p>
<ul class="setting-list">
<li
v-for="(item, i) in builtinEntries"
:key="i"
>
<Checkbox
:disabled="shouldBeDisabled"
:model-value="optionPresent(item.value)"
@update:model-value="event => update({ event, value: item.value, eventType: 'toggle' })"
>
{{ item.label }}
</Checkbox>
</li>
<li
v-for="(item, index) in extraEntries"
:key="index"
>
<div class="btn-group">
<input
class="input string-input"
:class="{ disabled: shouldBeDisabled }"
:value="item"
@change="e => update({ event: e, index, eventType: 'edit' })"
>
<button
class="button-default"
@click="e => update({ index, eventType: 'remove' })"
>
<FAIcon icon="times" />
</button>
</div>
</li>
<li v-if="showNew">
<div class="btn-group">
<input
v-model="newValue"
class="input string-input"
:class="{ disabled: shouldBeDisabled }"
:disabled="shouldBeDisabled"
>
<button
class="button-default"
@click="e => update({ eventType: 'add' })"
>
<FAIcon icon="plus" />
</button>
</div>
</li>
</ul>
<ModifiedIndicator
:changed="isChanged"
:onclick="reset"
/>
<LocalSettingIndicator :is-local="isLocalSetting" />
<DraftButtons />
</fieldset>
</template>
<script src="./list_setting.js"></script>
<style lang="scss">
.ListSetting {
border: none;
margin: 0;
legend {
float: left;
}
.setting-list {
align-self: center;
display: flex;
flex-direction: column;
gap: 0.5em;
}
}
</style>
diff --git a/src/components/settings_modal/helpers/list_tuple_setting.vue b/src/components/settings_modal/helpers/list_tuple_setting.vue
index 41ff2e5bf2..41403997b5 100644
--- a/src/components/settings_modal/helpers/list_tuple_setting.vue
+++ b/src/components/settings_modal/helpers/list_tuple_setting.vue
@@ -1,116 +1,116 @@
<template>
<fieldset
v-if="matchesExpertLevel"
class="ListTupleSetting"
>
<legend
class="setting-label"
:class="{ 'faint': shouldBeDisabled }"
>
- <template v-if="backendDescriptionLabel">
- {{ backendDescriptionLabel + ' ' }}
+ <template v-if="realLabel">
+ {{ realLabel + ' ' }}
</template>
<template v-else-if="source === 'admin'">
MISSING LABEL FOR {{ path }}
</template>
<slot v-else />
</legend>
<p
- v-if="backendDescriptionDescription"
+ v-if="realDescription"
class="setting-description"
:class="{ 'faint': shouldBeDisabled }"
>
- {{ backendDescriptionDescription + ' ' }}
+ {{ realDescription + ' ' }}
</p>
<ul class="setting-list">
<li
v-for="(item, index) in visibleState"
:key="index"
>
<div class="btn-group">
<input
class="input string-input"
:class="{ disabled: shouldBeDisabled }"
:value="item.tuple[0]"
- :title="backendDescriptionSuggestions[0][0]"
+ :title="realSuggestions[0][0]"
@change="e => update({ event: e, index, eventType: 'edit', tuple: 0 })"
>
<input
class="input string-input"
:class="{ disabled: shouldBeDisabled }"
:value="item.tuple[1]"
- :title="backendDescriptionSuggestions[0][1]"
+ :title="realSuggestions[0][1]"
@change="e => update({ event: e, index, eventType: 'edit', tuple: 1 })"
>
<button
class="button-default"
@click="e => update({ index, eventType: 'remove' })"
>
<FAIcon icon="times" />
</button>
</div>
</li>
<li>
<div class="btn-group">
<input
v-model="newValue[0]"
class="input string-input"
:class="{ disabled: shouldBeDisabled }"
:disabled="shouldBeDisabled"
- :placeholder="backendDescriptionSuggestions[0][0]"
- :title="backendDescriptionSuggestions[0][0]"
+ :placeholder="realSuggestions[0][0]"
+ :title="realSuggestions[0][0]"
>
<input
v-model="newValue[1]"
class="input string-input"
:class="{ disabled: shouldBeDisabled }"
:disabled="shouldBeDisabled"
- :placeholder="backendDescriptionSuggestions[0][1]"
- :title="backendDescriptionSuggestions[0][1]"
+ :placeholder="realSuggestions[0][1]"
+ :title="realSuggestions[0][1]"
>
<button
class="button-default"
@click="e => update({ eventType: 'add' })"
>
<FAIcon icon="plus" />
</button>
</div>
</li>
</ul>
<ModifiedIndicator
:changed="isChanged"
:onclick="reset"
/>
<DraftButtons />
</fieldset>
</template>
<script src="./list_tuple_setting.js"></script>
<style lang="scss">
.ListTupleSetting {
.btn-group {
display: flex
}
dl {
display: inline-grid;
grid-template-columns: auto auto;
gap: 0.5em;
align-items: baseline;
dt {
display: inline;
font-weight: 800;
&::after {
content: ':'
}
}
dd {
display: inline;
margin: 0
}
}
}
</style>
diff --git a/src/components/settings_modal/helpers/map_setting.vue b/src/components/settings_modal/helpers/map_setting.vue
index df77a1a724..092e588575 100644
--- a/src/components/settings_modal/helpers/map_setting.vue
+++ b/src/components/settings_modal/helpers/map_setting.vue
@@ -1,116 +1,116 @@
<template>
<fieldset
v-if="matchesExpertLevel"
class="MapSetting setting-item"
>
<legend
class="setting-label"
:class="{ 'faint': shouldBeDisabled }"
>
- <template v-if="backendDescriptionLabel">
- {{ backendDescriptionLabel + ' ' }}
+ <template v-if="realLabel">
+ {{ realLabel + ' ' }}
</template>
<template v-else-if="source === 'admin'">
MISSING LABEL FOR {{ path }}
</template>
<slot v-else />
</legend>
<p
- v-if="backendDescriptionDescription"
+ v-if="realDescription"
class="setting-description"
:class="{ 'faint': shouldBeDisabled }"
>
- {{ backendDescriptionDescription + ' ' }}
+ {{ realDescription + ' ' }}
</p>
<ul class="setting-list">
<li
v-for="(item, i) in displayState"
:key="i"
>
<div class="btn-group">
<input
class="input string-input"
:class="{ disabled: shouldBeDisabled }"
:value="item[0]"
- :title="backendDescriptionSuggestions[0][0]"
+ :title="realSuggestions[0][0]"
@change="e => update({ event: e, key: item[0], eventType: 'edit', isKey: true })"
>
<input
class="input string-input"
:class="{ disabled: shouldBeDisabled }"
:value="item[1]"
- :title="backendDescriptionSuggestions[0][1]"
+ :title="realSuggestions[0][1]"
@change="e => update({ event: e, key: item[0], eventType: 'edit', isKey: false })"
>
<button
class="button-default"
@click="e => update({ key: item[0], eventType: 'remove' })"
>
<FAIcon icon="times" />
</button>
</div>
</li>
<li v-if="allowNew">
<div class="btn-group">
<input
v-model="newValue[0]"
class="input string-input"
:class="{ disabled: shouldBeDisabled }"
:disabled="shouldBeDisabled"
- :placeholder="backendDescriptionSuggestions[0][0]"
- :title="backendDescriptionSuggestions[0][0]"
+ :placeholder="realSuggestions[0][0]"
+ :title="realSuggestions[0][0]"
>
<input
v-model="newValue[1]"
class="input string-input"
:class="{ disabled: shouldBeDisabled }"
:disabled="shouldBeDisabled"
- :placeholder="backendDescriptionSuggestions[0][1]"
- :title="backendDescriptionSuggestions[0][1]"
+ :placeholder="realSuggestions[0][1]"
+ :title="realSuggestions[0][1]"
>
<button
class="button-default"
@click="e => update({ eventType: 'add' })"
>
<FAIcon icon="plus" />
</button>
</div>
</li>
</ul>
<ModifiedIndicator
:changed="isChanged"
:onclick="reset"
/>
<LocalSettingIndicator :is-local="isLocalSetting" />
<DraftButtons />
</fieldset>
</template>
<script src="./map_setting.js"></script>
<style lang="scss">
.MapSetting {
.btn-group {
display: flex
}
dl {
display: inline-grid;
grid-template-columns: auto auto;
gap: 0.5em;
dt {
display: inline;
font-weight: 800;
&::after {
content: ':'
}
}
dd {
display: inline;
margin: 0
}
}
}
</style>
diff --git a/src/components/settings_modal/helpers/number_setting.vue b/src/components/settings_modal/helpers/number_setting.vue
index a53be93c3f..5c1737460b 100644
--- a/src/components/settings_modal/helpers/number_setting.vue
+++ b/src/components/settings_modal/helpers/number_setting.vue
@@ -1,49 +1,49 @@
<template>
<span
v-if="matchesExpertLevel"
class="NumberSetting setting-item"
>
<label
v-if="!hideLabel"
:for="path"
class="setting-label"
:class="{ 'faint': shouldBeDisabled }"
>
<ModifiedIndicator
:changed="isChanged"
:onclick="reset"
/>
<LocalSettingIndicator :is-local="isLocalSetting" />
{{ ' ' }}
<DraftButtons v-if="!hideDraftButtons" />
- <template v-if="backendDescriptionLabel">
- {{ backendDescriptionLabel + ' ' }}
+ <template v-if="realLabel">
+ {{ realLabel + ' ' }}
</template>
<template v-else-if="source === 'admin'">
MISSING LABEL FOR {{ path }}
</template>
<slot v-else />
</label>
{{ ' ' }}
<input
:id="path"
class="input number-input setting-control"
type="number"
:step="step || 1"
:disabled="shouldBeDisabled"
- :placeholder="backendDescriptionSuggestions"
+ :placeholder="realSuggestions"
:min="min || 0"
:value="realDraftMode ? draft :state"
@change="update"
>
<p
- v-if="backendDescriptionDescription"
+ v-if="realDescription"
class="setting-description"
:class="{ 'faint': shouldBeDisabled }"
>
- {{ backendDescriptionDescription + ' ' }}
+ {{ realDescription + ' ' }}
</p>
</span>
</template>
<script src="./number_setting.js"></script>
diff --git a/src/components/settings_modal/helpers/proxy_setting.vue b/src/components/settings_modal/helpers/proxy_setting.vue
index e7b69f008d..8ba23d68de 100644
--- a/src/components/settings_modal/helpers/proxy_setting.vue
+++ b/src/components/settings_modal/helpers/proxy_setting.vue
@@ -1,60 +1,60 @@
<template>
<label
v-if="matchesExpertLevel"
class="ProxySetting setting-item"
>
<label
v-if="!hideLabel"
:for="idPrefix + 'input'"
:id="idPrefix + 'label'"
class="setting-label"
:class="{ 'faint': shouldBeDisabled }"
>
- <template v-if="backendDescriptionLabel">
- {{ backendDescriptionLabel + ' ' }}
+ <template v-if="realLabel">
+ {{ realLabel + ' ' }}
</template>
<template v-else-if="source === 'admin'">
MISSING LABEL FOR {{ path }}
</template>
<slot v-else />
</label>
{{ ' ' }}
<div class="setting-control">
<input
:id="idPrefix + 'input'"
class="input string-input"
:class="{ disabled: shouldBeDisabled }"
:disabled="shouldBeDisabled"
- :placeholder="backendDescriptionSuggestions[0]"
+ :placeholder="realSuggestions[0]"
:value="displayState"
@change="event => update({ event })"
>
{{ ' ' }}
<Checkbox
:model-value="socksState"
:disabled="shouldBeDisabled"
:indeterminate="isIndeterminate"
style="margin-left: 1em"
@update:model-value="event => update({ event, isProxy: true})"
>
SOCKS5
{{ ' ' }}
</Checkbox>
</div>
{{ ' ' }}
<ModifiedIndicator
:changed="isChanged"
:onclick="reset"
/>
<DraftButtons v-if="!hideDraftButtons" />
<p
- v-if="backendDescriptionDescription"
+ v-if="realDescription"
class="setting-description"
:class="{ 'faint': shouldBeDisabled }"
>
- {{ backendDescriptionDescription + ' ' }}
+ {{ realDescription + ' ' }}
</p>
</label>
</template>
<script src="./proxy_setting.js"></script>
diff --git a/src/components/settings_modal/helpers/pwa_manifest_icons_setting.vue b/src/components/settings_modal/helpers/pwa_manifest_icons_setting.vue
index 692adc0249..1b80b7ec81 100644
--- a/src/components/settings_modal/helpers/pwa_manifest_icons_setting.vue
+++ b/src/components/settings_modal/helpers/pwa_manifest_icons_setting.vue
@@ -1,236 +1,236 @@
<template>
<fieldset
v-if="matchesExpertLevel"
class="PWAManifestIconsSetting setting-item"
>
<legend
class="pwa-label setting-label"
:class="{ 'faint': shouldBeDisabled }"
>
<ModifiedIndicator
:changed="isChanged"
:onclick="reset"
/>
{{ ' ' }}
- <template v-if="backendDescriptionLabel">
- {{ backendDescriptionLabel + ' ' }}
+ <template v-if="realLabel">
+ {{ realLabel + ' ' }}
</template>
<template v-else-if="source === 'admin'">
MISSING LABEL FOR {{ path }}
</template>
<slot v-else />
</legend>
<p
- v-if="backendDescriptionDescription"
+ v-if="realDescription"
class="setting-description"
:class="{ 'faint': shouldBeDisabled }"
>
- {{ backendDescriptionDescription + ' ' }}
+ {{ realDescription + ' ' }}
</p>
<div class="setting-control">
<ul class="item-list">
<li
v-if="visibleState.length === 0"
class="no_items"
>
{{ $t('admin_dash.instance.pwa.no_icons') }}
<button
v-if="visibleState.length === 0"
class="button-default add-button"
@click="e => update({ eventType: 'add' })"
>
<FAIcon icon="plus" />
</button>
</li>
<li
v-for="(item, index) in visibleState"
:key="index"
>
<div class="icon-element">
<div class="src-field">
<Attachment
class="src-attachment"
:compact="true"
:attachment="attachment(item)"
size="small"
hide-description
/>
<div class="src-url">
<label :for="idPrefix + 'url' + index">{{ $t('settings.url') }}</label>
<input
:id="idPrefix + 'url' + index"
class="input string-input"
:disabled="shouldBeDisabled"
:value="item[':src']"
@change="event => update({ event, index, eventType: 'edit', field: ':src' })"
>
</div>
<MediaUpload
ref="mediaUpload"
class="src-upload media-upload-icon"
:class="{ disabled: shouldBeDisabled }"
normal-button
accept-types="image"
@uploaded="event => setMediaFile({ event, index })"
/>
</div>
<dl>
<dt>{{ $t('admin_dash.instance.pwa.icon.purpose') }}</dt>
<dd>
<Select
:id="idPrefix + 'purpose' + index"
:class="{ disabled: shouldBeDisabled }"
:disabled="shouldBeDisabled"
:model-value="item[':purpose']"
@update:model-value="event => setPurpose({ event, index })"
>
<option
v-for="(purpose, index2) in purposeOptions"
:key="index2"
:value="purpose.value"
>
{{ purpose.label }}
</option>
</Select>
</dd>
<dt>
<label :for="idPrefix + 'sizes' + index">
<code>sizes</code>{{ $t('admin_dash.instance.pwa.optional') }}
</label>
</dt>
<dd>
<input
:id="idPrefix + 'sizes' + index"
class="input string-input"
:class="{ disabled: shouldBeDisabled }"
:value="item[':sizes']"
@change="e => update({ event: e, index, eventType: 'edit', field: ':sizes' })"
>
</dd>
<dt>
<label :for="idPrefix + 'type' + index">
<code>type</code>{{ $t('admin_dash.instance.pwa.optional') }}
</label>
</dt>
<dd>
<input
:id="idPrefix + 'type' + index"
class="input string-input"
:class="{ disabled: shouldBeDisabled }"
:value="item[':type']"
@change="e => update({ event: e, index, eventType: 'edit', field: ':type' })"
>
</dd>
</dl>
<div class="buttons">
<button
v-if="index === visibleState.length - 1"
class="button-default add-button"
@click="e => update({ eventType: 'add' })"
>
<FAIcon icon="plus" />
</button>
<button
class="button-default delete-button"
@click="e => update({ index, eventType: 'remove' })"
>
<FAIcon icon="times" />
</button>
</div>
</div>
</li>
</ul>
</div>
</fieldset>
</template>
<script src="./pwa_manifest_icons_setting.js"></script>
<style lang="scss">
fieldset.PWAManifestIconsSetting {
margin-left: 3em;
&.setting-item {
display: grid;
grid-template-areas:
"label"
"desc"
"control"
"draft";
grid-template-rows: 2em auto 1fr;
grid-template-columns: 1fr;
}
.pwa-label.setting-label {
align-self: end;
text-align: left;
}
.buttons {
display: flex;
gap: 0.5em;
justify-content: right;
margin-top: 0.5em;
button {
line-height: 2;
}
}
ul {
list-style: none;
display: grid;
grid-template-columns: repeat(auto-fit, 12em);
gap: 2em;
}
dl {
display: grid;
grid-template-columns: 1fr;
margin-top: 0.5em;
gap: 0.25em;
align-items: baseline;
dt {
font-weight: 800;
&::after {
content: ':'
}
}
dd {
margin: 0
}
}
.src-field {
display: grid;
grid-template-columns: auto;
justify-items: center;
gap: 0.5em;
.src-attachment {
width: 10em;
height: 10em;
display: block;
margin-bottom: 0.5em;
}
.src-upload {
display: block;
width: 100%;
}
.src-url {
display: flex;
flex-direction: column;
gap: 0.25em;
width: 100%;
label {
display: block;
}
}
}
}
</style>
diff --git a/src/components/settings_modal/helpers/rate_setting.vue b/src/components/settings_modal/helpers/rate_setting.vue
index add623cf10..76dbb8ec73 100644
--- a/src/components/settings_modal/helpers/rate_setting.vue
+++ b/src/components/settings_modal/helpers/rate_setting.vue
@@ -1,154 +1,154 @@
<template>
<fieldset
v-if="matchesExpertLevel"
class="RateSetting setting-item"
>
<legend
class="setting-label"
:class="{ 'faint': shouldBeDisabled }"
>
<ModifiedIndicator
:changed="isChanged"
:onclick="reset"
/>
<LocalSettingIndicator :is-local="isLocalSetting" />
{{ ' ' }}
- <template v-if="backendDescriptionLabel">
- {{ backendDescriptionLabel + ' ' }}
+ <template v-if="realLabel">
+ {{ realLabel + ' ' }}
</template>
<template v-else-if="source === 'admin'">
MISSING LABEL FOR {{ path }}
</template>
<slot v-else />
</legend>
<p
- v-if="backendDescriptionDescription"
+ v-if="realDescription"
class="setting-description"
:class="{ 'faint': shouldBeDisabled }"
>
- {{ backendDescriptionDescription + ' ' }}
+ {{ realDescription + ' ' }}
</p>
<div class="setting-control">
<table>
<thead>
<tr>
<td> </td>
<th :id="idPrefix + 'header-period'">
{{ $t('admin_dash.rate_limit.period') }}
</th>
<th :id="idPrefix + 'header-amount'">
{{ $t('admin_dash.rate_limit.amount') }}
</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">
{{ isSeparate ? $t('admin_dash.rate_limit.unauthenticated') : $t('admin_dash.rate_limit.all') }}
</th>
<td>
<input
:id="idPrefix + 'period'"
:aria-labelledby="idPrefix + 'header-period'"
class="input string-input"
type="number"
:value="normalizedState[0][0]"
@change="e => update({ event: e, index: 0, side: 0, eventType: 'edit' })"
>
</td>
<td>
<input
:id="idPrefix + 'amount'"
:aria-labelledby="idPrefix + 'header-amount'"
class="input string-input"
type="number"
:value="normalizedState[0][1]"
@change="e => update({ event: e, index: 1, side: 0, eventType: 'edit' })"
>
</td>
</tr>
<tr v-if="isSeparate">
<th scope="row">
{{ $t('admin_dash.rate_limit.authenticated') }}
</th>
<td>
<input
:id="idPrefix + 'period2'"
:aria-labelledby="idPrefix + 'header-period'"
class="input string-input"
type="number"
:value="normalizedState[1][0]"
@change="e => update({ event: e, index: 0, side: 1, eventType: 'edit' })"
>
</td>
<td>
<input
:id="idPrefix + 'amount2'"
:aria-labelledby="idPrefix + 'header-amount'"
class="input string-input"
type="number"
:value="normalizedState[1][1]"
@change="e => update({ event: e, index: 1, side: 1, eventType: 'edit' })"
>
</td>
</tr>
</tbody>
</table>
<Checkbox
:model-value="isSeparate"
@update:model-value="event => update({ event: event ? 'split' : 'join', eventType: 'toggleMode' })"
>
{{ $t('admin_dash.rate_limit.separate') }}
</Checkbox>
</div>
<DraftButtons />
</fieldset>
</template>
<script src="./rate_setting.js"></script>
<style lang="scss">
.RateSetting {
&.setting-item {
display: grid;
grid-template-areas:
"label control"
"desc control"
". draft";
.setting-label {
text-align: right;
align-self: center;
}
.setting-description {
text-align: right;
}
.setting-control {
align-self: end;
flex-direction: column;
align-items: start;
}
}
table {
margin-top: 0.5em;
}
th {
font-weight: normal;
}
tbody th {
text-align: right;
}
td {
input {
width: 15ch;
}
}
margin-bottom: 2em;
}
</style>
diff --git a/src/components/settings_modal/helpers/setting.js b/src/components/settings_modal/helpers/setting.js
index 432d5a8fc1..88c7c1ad51 100644
--- a/src/components/settings_modal/helpers/setting.js
+++ b/src/components/settings_modal/helpers/setting.js
@@ -1,435 +1,463 @@
import { cloneDeep, get, isEqual, set } from 'lodash-es'
import { useId } from 'vue'
import DraftButtons from './draft_buttons.vue'
import LocalSettingIndicator from './local_setting_indicator.vue'
import ModifiedIndicator from './modified_indicator.vue'
import { useAdminSettingsStore } from 'src/stores/admin_settings.js'
import { useInterfaceStore } from 'src/stores/interface.js'
import { useLocalConfigStore } from 'src/stores/local_config.js'
import { useMergedConfigStore } from 'src/stores/merged_config.js'
import { useProfileConfigStore } from 'src/stores/profile_config.js'
import { useSyncConfigStore } from 'src/stores/sync_config.js'
export default {
components: {
ModifiedIndicator,
DraftButtons,
LocalSettingIndicator,
},
props: {
- modelValue: {
- type: String,
- default: null,
- },
- description: {
- type: String,
- default: null,
- },
+ // # Main props.
+ // Path to a setting
path: {
type: [String, Array],
required: false,
},
- showDescription: {
- type: Boolean,
- required: false,
- },
- descriptionPathOverride: {
- type: [String, Array],
- required: false,
+ // What store setting resides in
+ source: {
+ type: String,
+ default: undefined,
},
- suggestions: {
- type: [String, Array],
- required: false,
+ // Whether setting is meant to be an "expert" one
+ expert: {
+ type: [Number, String],
+ default: 0,
},
+ // Backend admin thing
subgroup: {
type: String,
required: false,
},
- disabled: {
+ // Local-only setting
+ localOnly: {
type: Boolean,
default: false,
},
- local: {
+ // Whether to use draft mode, i.e. writing to a draft first instead of real storage
+ draftMode: {
+ type: Boolean,
+ default: undefined,
+ },
+ // When changing setting, apply it temporarily and let user confirm the change
+ // or revert after a timeout. Only supported in sync/local sources
+ timedApplyMode: {
type: Boolean,
default: false,
},
+
+ // ## Option dependency
+ // Path of a "parent" setting
parentPath: {
type: [String, Array],
},
+ // Whether to disable setting when parent is true instead of false
parentInvert: {
type: Boolean,
default: false,
},
- expert: {
- type: [Number, String],
- default: 0,
- },
- source: {
+
+ // # Direct mode
+ // using local state instead of storage when path=null
+ modelValue: {
type: String,
- default: undefined,
+ default: null,
},
- hideDraftButtons: {
- // this is for the weird backend hybrid (Boolean|String or Boolean|Number) settings
- required: false,
+ disabled: {
type: Boolean,
+ default: false,
},
- hideLabel: {
- type: Boolean,
+
+ // # Admin settings labels/descriptions
+ suggestions: {
+ type: [String, Array],
+ required: false,
},
- hideDescription: {
- type: Boolean,
+ description: {
+ type: String,
+ default: null,
},
- swapDescriptionAndLabel: {
- type: Boolean,
+ label: {
+ type: String,
+ default: null,
},
- backendDescriptionPath: {
+ descriptionPathOverride: {
type: [String, Array],
+ required: false,
+ },
+ swapDescriptionAndLabel: {
+ type: Boolean,
},
+
+ // Override labels, for cases where they are incorrect or confusing
overrideBackendDescription: {
type: Boolean,
},
overrideBackendDescriptionLabel: {
type: [Boolean, String],
},
- draftMode: {
+
+ // # Text and supporting components
+ hideDraftButtons: {
+ // this is for the weird backend hybrid (Boolean|String or Boolean|Number) settings
+ required: false,
type: Boolean,
- default: undefined,
},
- timedApplyMode: {
+ hideLabel: {
+ type: Boolean,
+ },
+ hideDescription: {
type: Boolean,
- default: false,
},
},
inject: {
defaultSource: {
- default: 'default',
+ default: 'sync',
},
defaultDraftMode: {
default: false,
},
},
setup() {
const uniqueId = useId()
return { uniqueId }
},
data() {
return {
localDraft: null,
}
},
emits: ['update:modelValue'],
created() {
- if (
- this.realDraftMode &&
- (this.realSource !== 'admin' || this.path == null)
- ) {
+ if (!this.realDraftMode) return
+ if (this.realSource !== 'admin' || this.path == null) {
this.draft = cloneDeep(this.state)
}
},
computed: {
- idPrefix() {
- return `setting-${this.uniqueId}-`
+ // Normalized props
+ canonPath() {
+ if (this.path == null) return null
+ return Array.isArray(this.path) ? this.path : this.path.split('.')
+ },
+ descriptionPath() {
+ if (this.path == null) return null
+ const data = this.descriptionPathOverride ?? this.path
+ const path = Array.isArray(data) ? data : data.split('.')
+ if (this.subgroup) {
+ return [
+ ...path.slice(0, path.length - 1),
+ ':subgroup,' + this.subgroup,
+ ...path.slice(path.length - 1),
+ ]
+ }
+ return path
+ },
+ realSource() {
+ return this.source || this.defaultSource
},
+ realDraftMode() {
+ return this.draftMode ?? this.defaultDraftMode
+ },
+
+ // Main state
draft: {
get() {
- if (this.realSource === 'admin' || this.path == null) {
+ if (this.realSource === 'admin') {
return get(useAdminSettingsStore().draft, this.canonPath)
} else {
return this.localDraft
}
},
set(value) {
- if (this.realSource === 'admin' || this.path == null) {
+ if (this.realSource === 'admin') {
useAdminSettingsStore().updateAdminDraft({
path: this.canonPath,
value,
})
} else {
this.localDraft = value
}
},
},
- state() {
- if (this.path == null) {
- return this.modelValue
- }
- const value = get(this.configSource, this.canonPath)
- if (value === undefined) {
- return this.defaultState
- } else {
- return value
- }
- },
- visibleState() {
- return this.realDraftMode ? this.draft : this.state
- },
- realSource() {
- return this.source || this.defaultSource
- },
- realDraftMode() {
- return this.draftMode === undefined
- ? this.defaultDraftMode
- : this.draftMode
- },
- backendDescription() {
- return get(useAdminSettingsStore().descriptions, this.descriptionPath)
- },
- backendDescriptionLabel() {
- if (this.realSource !== 'admin') return ''
- if (
- this.overrideBackendDescriptionLabel !== '' &&
- typeof this.overrideBackendDescriptionLabel === 'string'
- ) {
- return this.overrideBackendDescriptionLabel
- }
- if (!this.backendDescription || this.overrideBackendDescriptionLabel) {
- return this.$t(
- [
- 'admin_dash',
- 'temp_overrides',
- ...this.canonPath.map((p) => p.replaceAll('.', '_DOT_')),
- 'label',
- ].join('.'),
- )
- } else {
- return this.swapDescriptionAndLabel
- ? this.backendDescription?.description
- : this.backendDescription?.label
- }
- },
- backendDescriptionDescription() {
- if (this.description) return this.description
- if (this.realSource !== 'admin') return ''
- if (this.hideDescription) return null
- if (!this.backendDescription || this.overrideBackendDescription) {
- return this.$t(
- [
- 'admin_dash',
- 'temp_overrides',
- ...this.canonPath.map((p) => p.replaceAll('.', '_DOT_')),
- 'description',
- ].join('.'),
- )
- } else {
- return this.swapDescriptionAndLabel
- ? this.backendDescription?.label
- : this.backendDescription?.description
+ state: {
+ get() {
+ if (this.path == null) return this.modelValue
+
+ const value = get(this.configSource, this.canonPath)
+ if (value === undefined) {
+ return this.defaultState
+ } else {
+ return value
+ }
+ },
+ set(value) {
+ this.$emit('update:modelValue', )
+ this.configSink(this.path, value)
}
},
- backendDescriptionSuggestions() {
- return this.backendDescription?.suggestions || this.suggestions
- },
- shouldBeDisabled() {
- if (this.path == null) {
- return this.disabled
- }
- let parentValue = null
- if (this.parentPath !== undefined && this.realSource === 'admin') {
+ visibleState: {
+ get() {
+ if (this.realDraftMode) {
+ return this.draft
+ } else {
+ return this.state
+ }
+ },
+ set(value) {
if (this.realDraftMode) {
- parentValue = get(useAdminSettingsStore().draft, this.parentPath)
+ this.draft = this.getValue(value)
} else {
- parentValue = get(this.configSource, this.parentPath)
+ this.state = this.getValue(value)
}
}
- return (
- this.disabled ||
- (parentValue !== null
- ? this.parentInvert
- ? parentValue
- : !parentValue
- : false)
- )
},
+
+ // Data access
configSource() {
switch (this.realSource) {
case 'profile':
return useProfileConfigStore().config
case 'admin':
return useAdminSettingsStore().config
+ case 'fe-admin':
+ throw Error('Not implemented')
default:
- return useMergedConfigStore().mergedConfig
+ if (this.realSource === 'local' || this.localOnly) {
+ return useLocalConfigStore().prefsStorage
+ } else {
+ return useMergedConfigStore().mergedConfig
+ }
}
},
configSink() {
if (this.path == null) {
return () => {
/* no-op */
}
}
switch (this.realSource) {
case 'profile':
- return (k, v) =>
- useProfileConfigStore().setProfileOption({ name: k, value: v })
+ return (path, value) =>
+ useProfileConfigStore().setProfileOption({ name, value })
case 'admin':
- return (k, v) =>
- useAdminSettingsStore().pushAdminSetting({ path: k, value: v })
+ return (path, value) =>
+ useAdminSettingsStore().pushAdminSetting({ path, value })
default:
- return (readPath, value) => {
- const writePath = `${readPath}`
-
+ return (path, value) => {
if (!this.timedApplyMode) {
- if (this.local) {
+ if (this.realSource === 'local' || this.localOnly) {
useLocalConfigStore().set({
- path: writePath,
+ path,
value,
})
} else {
useSyncConfigStore().setSimplePrefAndSave({
- path: writePath,
+ path,
value,
})
}
} else {
if (useInterfaceStore().temporaryChangesTimeoutId !== null) {
console.error("Can't track more than one temporary change")
return
}
- const oldValue = get(this.configSource, readPath)
-
- if (this.local) {
- useLocalConfigStore().setTemporarily({ path: writePath, value })
- } else {
- useSyncConfigStore().setPreference({ path: writePath, value })
- }
+ useLocalConfigStore().setTemporarily({ path, value })
const confirm = () => {
- if (this.local) {
- useLocalConfigStore().set({ path: writePath, value })
+ if (this.realSource === 'local' || this.localOnly) {
+ useLocalConfigStore().set({ path, value })
} else {
- useSyncConfigStore().pushSyncConfig()
+ useSyncConfigStore().setSimplePrefAndSave({
+ path,
+ value,
+ })
}
+ useLocalConfigStore().unsetTemporarily({ path })
useInterfaceStore().clearTemporaryChanges()
}
const revert = () => {
- if (this.local) {
- useLocalConfigStore().unsetTemporarily({
- path: writePath,
- value,
- })
- } else {
- useSyncConfigStore().setPreference({
- path: writePath,
- value: oldValue,
- })
- }
+ useLocalConfigStore().unsetTemporarily({ path })
useInterfaceStore().clearTemporaryChanges()
}
useInterfaceStore().setTemporaryChanges({ confirm, revert })
}
}
}
},
defaultState() {
switch (this.realSource) {
case 'profile':
return {}
+ case 'admin':
+ return {}
+ case 'local':
+ return {}
+ case 'fe-admin':
+ return {}
default: {
- return get(useMergedConfigStore().mergedConfigDefault, this.path)
+ return get(useMergedConfigStore().mergedConfigDefault, this.canonPath)
}
}
},
+
+ // Labels & Descriptions
+ backendDescription() {
+ return get(useAdminSettingsStore().descriptions, this.descriptionPath)
+ },
+ realLabel() {
+ if (this.label) return this.label
+ if (this.realSource !== 'admin') return ''
+ if (!this.backendDescription || this.overrideBackendDescriptionLabel) {
+ return this.$t(
+ [
+ 'admin_dash',
+ 'temp_overrides',
+ ...this.canonPath.map((p) => p.replaceAll('.', '_DOT_')),
+ 'label',
+ ].join('.'),
+ )
+ } else {
+ return this.swapDescriptionAndLabel
+ ? this.backendDescription?.description
+ : this.backendDescription?.label
+ }
+ },
+ realDescription() {
+ if (this.description) return this.description
+ if (this.realSource !== 'admin') return ''
+ if (this.hideDescription) return null
+ if (!this.backendDescription || this.overrideBackendDescription) {
+ return this.$t(
+ [
+ 'admin_dash',
+ 'temp_overrides',
+ ...this.canonPath.map((p) => p.replaceAll('.', '_DOT_')),
+ 'description',
+ ].join('.'),
+ )
+ } else {
+ return this.swapDescriptionAndLabel
+ ? this.backendDescription?.label
+ : this.backendDescription?.description
+ }
+ },
+ realSuggestions() {
+ return this.suggestions || this.backendDescription?.suggestions
+ },
+
+ // Supporting misc states
+ shouldBeDisabled() {
+ if (this.path == null) return this.disabled
+
+ const parentValue = (() => {
+ if (this.parentPath === undefined) return undefined
+ if (this.realSource === 'admin') {
+ return get(useAdminSettingsStore().draft, this.parentPath)
+ } else {
+ return get(this.configSource, this.parentPath)
+ }
+ })()
+
+ if (parentValue === undefined) return this.disabled
+
+ return this.parentInvert ? parentValue : !parentValue
+ },
isProfileSetting() {
return this.realSource === 'profile'
},
isLocalSetting() {
- return this.local
+ return this.localOnly
},
isChanged() {
if (this.path == null) return false
switch (this.realSource) {
case 'profile':
case 'admin':
return false
default:
return this.state !== this.defaultState
}
},
- canonPath() {
- if (this.path == null) return null
- return Array.isArray(this.path) ? this.path : this.path.split('.')
- },
- descriptionPath() {
- if (this.path == null) return null
- if (this.descriptionPathOverride) return this.descriptionPathOverride
- const path = Array.isArray(this.path) ? this.path : this.path.split('.')
- if (this.subgroup) {
- return [
- ...path.slice(0, path.length - 1),
- ':subgroup,' + this.subgroup,
- ...path.slice(path.length - 1),
- ]
- }
- return path
- },
isDirty() {
- if (this.path == null) return false
+ if (!this.realDraftMode) return false
if (this.realSource === 'admin' && this.canonPath.length > 3) {
return false // should not show draft buttons for "grouped" values
- } else {
- return this.realDraftMode && !isEqual(this.draft, this.state)
}
+ return !isEqual(this.draft, this.state)
},
canHardReset() {
- return (
- this.realSource === 'admin' &&
- useAdminSettingsStore().modifiedPaths?.has(this.canonPath.join(' -> '))
- )
+ switch (this.realSource) {
+ case 'admin':
+ return useAdminSettingsStore().modifiedPaths?.has(this.canonPath.join(' -> '))
+ case 'local':
+ case 'fe-admin':
+ return this.state !== undefined
+ default:
+ return false
+ }
},
matchesExpertLevel() {
const settingExpertLevel = this.expert || 0
const userToggleExpert =
useMergedConfigStore().mergedConfig.expertLevel || 0
return settingExpertLevel <= userToggleExpert
},
+ idPrefix() {
+ return `setting-${this.uniqueId}-`
+ },
},
methods: {
+ // Function that meant to be overriden by consumers to output
+ // correct value given the model-value update event
getValue(e) {
return e.target.value
},
- update(e) {
- if (this.realDraftMode) {
- this.draft = this.getValue(e)
- } else {
- this.$emit('update:modelValue', this.getValue(e))
- this.configSink(this.path, this.getValue(e))
- }
- },
commitDraft() {
if (this.realDraftMode) {
this.$emit('update:modelValue', this.draft)
this.configSink(this.path, this.draft)
}
},
reset() {
if (this.realDraftMode) {
this.draft = cloneDeep(this.state)
} else {
set(
useMergedConfigStore().mergedConfig,
this.path,
cloneDeep(this.defaultState),
)
}
},
hardReset() {
switch (this.realSource) {
case 'admin':
return useAdminSettingsStore()
.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 511a3d90d8..261fdfbe1d 100644
--- a/src/components/settings_modal/helpers/string_setting.vue
+++ b/src/components/settings_modal/helpers/string_setting.vue
@@ -1,47 +1,47 @@
<template>
<span
v-if="matchesExpertLevel"
class="StringSetting setting-item"
>
<label
v-if="!hideLabel"
:for="idPrefix + 'label'"
class="setting-label"
:class="{ 'faint': shouldBeDisabled }"
>
<ModifiedIndicator
:changed="isChanged"
:onclick="reset"
/>
<LocalSettingIndicator :is-local="isLocalSetting" />
{{ ' ' }}
- <template v-if="backendDescriptionLabel">
- {{ backendDescriptionLabel + ' ' }}
+ <template v-if="realLabel">
+ {{ realLabel + ' ' }}
</template>
<template v-else-if="source === 'admin'">
MISSING LABEL FOR {{ path }}
</template>
<slot v-else />
</label>
<input
:id="idPrefix + 'label'"
class="setting-control input string-input"
:class="{ disabled: shouldBeDisabled }"
:disabled="shouldBeDisabled"
- :placeholder="backendDescriptionSuggestions"
+ :placeholder="realSuggestions"
:value="realDraftMode ? draft : state"
@change="update"
>
{{ ' ' }}
<DraftButtons v-if="!hideDraftButtons" />
<p
- v-if="backendDescriptionDescription"
+ v-if="realDescription"
class="setting-description"
:class="{ 'faint': shouldBeDisabled }"
>
- {{ backendDescriptionDescription + ' ' }}
+ {{ realDescription + ' ' }}
</p>
</span>
</template>
<script src="./string_setting.js"></script>
diff --git a/src/components/settings_modal/helpers/tuple_setting.vue b/src/components/settings_modal/helpers/tuple_setting.vue
index 0286b9ebde..661ca09b34 100644
--- a/src/components/settings_modal/helpers/tuple_setting.vue
+++ b/src/components/settings_modal/helpers/tuple_setting.vue
@@ -1,56 +1,56 @@
<template>
<fieldset
v-if="matchesExpertLevel"
class="setting-item"
>
<legend
v-if="!hideLabel"
class="setting-label"
:class="{ 'faint': shouldBeDisabled }"
>
<ModifiedIndicator
:changed="isChanged"
:onclick="reset"
/>
<LocalSettingIndicator :is-local="isLocalSetting" />
{{ ' ' }}
- <template v-if="backendDescriptionLabel">
- {{ backendDescriptionLabel + ' ' }}
+ <template v-if="realLabel">
+ {{ realLabel + ' ' }}
</template>
<template v-else-if="source === 'admin'">
MISSING LABEL FOR {{ path }}
</template>
<slot v-else />
</legend>
<span class="setting-control">
<input
class="input string-input" :class="{ disabled: shouldBeDisabled }"
:disabled="shouldBeDisabled"
- :placeholder="backendDescriptionSuggestions?.[0]?.[0]"
- :title="backendDescriptionSuggestions?.[0]?.[0]"
+ :placeholder="realSuggestions?.[0]?.[0]"
+ :title="realSuggestions?.[0]?.[0]"
:value="visibleState?.tuple?.[0]"
@change="e => update({ e, side: 0 })"
>
{{ ' ' }}
<input
class="input string-input"
:class="{ disabled: shouldBeDisabled }"
:disabled="shouldBeDisabled"
- :placeholder="backendDescriptionSuggestions?.[0]?.[1]"
- :title="backendDescriptionSuggestions?.[0]?.[1]"
+ :placeholder="realSuggestions?.[0]?.[1]"
+ :title="realSuggestions?.[0]?.[1]"
:value="visibleState?.tuple?.[1]"
@change="e => update({ e, side: 1 })"
>
</span>
<DraftButtons v-if="!hideDraftButtons" />
<p
- v-if="backendDescriptionDescription"
+ v-if="realDescription"
class="setting-description"
:class="{ 'faint': shouldBeDisabled }"
>
- {{ backendDescriptionDescription + ' ' }}
+ {{ realDescription + ' ' }}
</p>
</fieldset>
</template>
<script src="./tuple_setting.js"></script>
diff --git a/src/stores/local_config.js b/src/stores/local_config.js
index 4c859ab21c..fa41699ce4 100644
--- a/src/stores/local_config.js
+++ b/src/stores/local_config.js
@@ -1,64 +1,64 @@
import { cloneDeep, set } from 'lodash-es'
import { defineStore } from 'pinia'
import {
LOCAL_DEFAULT_CONFIG,
LOCAL_DEFAULT_CONFIG_DEFINITIONS,
makeUndefined,
validateSetting,
} from 'src/stores/default_state/default_config_state.js'
export const defaultState = {
prefsStorage: {
...makeUndefined(LOCAL_DEFAULT_CONFIG),
},
tempStorage: {
...makeUndefined(LOCAL_DEFAULT_CONFIG),
},
}
export const useLocalConfigStore = defineStore('local_config', {
state() {
return cloneDeep(defaultState)
},
actions: {
set({ path, value }) {
const definition = LOCAL_DEFAULT_CONFIG_DEFINITIONS[path]
const finalValue = validateSetting({
path,
value,
definition,
throwError: false,
defaultState: LOCAL_DEFAULT_CONFIG,
})
set(this.prefsStorage, path, finalValue)
},
setTemporarily({ path, value }) {
set(this.tempStorage, path, value)
},
- unsetTemporarily({ path, value }) {
+ unsetTemporarily({ path }) {
set(this.tempStorage, path, undefined)
},
unset({ path, value }) {
set(this.prefsStorage, path, undefined)
},
clearLocalConfig() {
Object.keys(this).forEach((k) => {
this.prefsStorage[k] = undefined
this.tempStorage[k] = undefined
})
},
},
persist: {
afterLoad(state) {
return {
prefsStorage: state.prefsStorage ?? {
...makeUndefined(LOCAL_DEFAULT_CONFIG),
},
tempStorage: { ...makeUndefined(LOCAL_DEFAULT_CONFIG) },
}
},
},
})
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Thu, Nov 19, 11:42 AM (1 d, 23 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1841228
Default Alt Text
(64 KB)
Attached To
Mode
rPUFE pleroma-fe-upstream
Attached
Detach File
Event Timeline