setting-sync (#175)
Co-authored-by: FloatingGhost <hannah@coffee-and-dreams.uk> Reviewed-on: https://akkoma.dev/AkkomaGang/pleroma-fe/pulls/175
This commit is contained in:
parent
eaf2bd05a0
commit
4f837f75ea
15 changed files with 314 additions and 16 deletions
|
@ -12,7 +12,8 @@ export default {
|
|||
'path',
|
||||
'disabled',
|
||||
'options',
|
||||
'expert'
|
||||
'expert',
|
||||
'hideDefaultLabel'
|
||||
],
|
||||
computed: {
|
||||
pathDefault () {
|
||||
|
|
|
@ -16,7 +16,11 @@
|
|||
:value="option.value"
|
||||
>
|
||||
{{ option.label }}
|
||||
{{ option.value === defaultState ? $t('settings.instance_default_simple') : '' }}
|
||||
<template
|
||||
v-if="hideDefaultLabel !== true"
|
||||
>
|
||||
{{ option.value === defaultState ? $t('settings.instance_default_simple') : '' }}
|
||||
</template>
|
||||
</option>
|
||||
</Select>
|
||||
<ModifiedIndicator :changed="isChanged" />
|
||||
|
|
|
@ -19,7 +19,7 @@ const SharedComputedObject = () => ({
|
|||
.map(key => [key, {
|
||||
get () { return this.$store.getters.mergedConfig[key] },
|
||||
set (value) {
|
||||
this.$store.dispatch('setOption', { name: key, value })
|
||||
this.$store.dispatch('setOption', { name: key, value, manual: true })
|
||||
}
|
||||
}])
|
||||
.reduce((acc, [key, value]) => ({ ...acc, [key]: value }), {}),
|
||||
|
@ -27,7 +27,7 @@ const SharedComputedObject = () => ({
|
|||
.map(key => ['serverSide_' + key, {
|
||||
get () { return this.$store.state.serverSideConfig[key] },
|
||||
set (value) {
|
||||
this.$store.dispatch('setServerSideOption', { name: key, value })
|
||||
this.$store.dispatch('setServerSideOption', { name: key, value, manual: true })
|
||||
}
|
||||
}])
|
||||
.reduce((acc, [key, value]) => ({ ...acc, [key]: value }), {}),
|
||||
|
|
|
@ -8,11 +8,12 @@ import SharedComputedObject from '../helpers/shared_computed_object.js'
|
|||
import ServerSideIndicator from '../helpers/server_side_indicator.vue'
|
||||
import { library } from '@fortawesome/fontawesome-svg-core'
|
||||
import {
|
||||
faGlobe
|
||||
faGlobe, faSync
|
||||
} from '@fortawesome/free-solid-svg-icons'
|
||||
|
||||
library.add(
|
||||
faGlobe
|
||||
faGlobe,
|
||||
faSync
|
||||
)
|
||||
|
||||
const GeneralTab = {
|
||||
|
@ -48,6 +49,8 @@ const GeneralTab = {
|
|||
value: tab,
|
||||
label: this.$t(`user_card.${tab}`)
|
||||
})),
|
||||
profilesExpanded: false,
|
||||
newProfileName: '',
|
||||
loopSilentAvailable:
|
||||
// Firefox
|
||||
Object.getOwnPropertyDescriptor(HTMLVideoElement.prototype, 'mozHasAudio') ||
|
||||
|
@ -88,8 +91,22 @@ const GeneralTab = {
|
|||
this.$store.dispatch('setOption', { name: 'interfaceLanguage', value: val })
|
||||
}
|
||||
},
|
||||
settingsProfiles () {
|
||||
return (this.$store.state.instance.settingsProfiles || [])
|
||||
},
|
||||
settingsProfile: {
|
||||
get: function () { return this.$store.getters.mergedConfig.profile },
|
||||
set: function (val) {
|
||||
this.$store.dispatch('setOption', { name: 'profile', value: val })
|
||||
this.$store.dispatch('getSettingsProfile')
|
||||
}
|
||||
},
|
||||
settingsVersion () {
|
||||
return this.$store.getters.mergedConfig.profileVersion
|
||||
},
|
||||
translationLanguages () {
|
||||
return (this.$store.getters.mergedConfig.supportedTranslationLanguages.target || []).map(lang => ({ key: lang.code, value: lang.code, label: lang.name }))
|
||||
const langs = this.$store.state.instance.translationLanguages || []
|
||||
return (langs || []).map(lang => ({ key: lang.code, value: lang.code, label: lang.name }))
|
||||
},
|
||||
translationLanguage: {
|
||||
get: function () { return this.$store.getters.mergedConfig.translationLanguage },
|
||||
|
@ -105,6 +122,30 @@ const GeneralTab = {
|
|||
},
|
||||
setTranslationLanguage (value) {
|
||||
this.$store.dispatch('setOption', { name: 'translationLanguage', value })
|
||||
},
|
||||
toggleExpandedSettings () {
|
||||
this.profilesExpanded = !this.profilesExpanded
|
||||
},
|
||||
loadSettingsProfile (name) {
|
||||
this.$store.commit('setOption', { name: 'profile', value: name })
|
||||
this.$store.dispatch('getSettingsProfile', true)
|
||||
},
|
||||
createSettingsProfile () {
|
||||
this.$store.dispatch('setOption', { name: 'profile', value: this.newProfileName })
|
||||
this.$store.dispatch('setOption', { name: 'profileVersion', value: 1 })
|
||||
this.$store.dispatch('syncSettings')
|
||||
this.newProfileName = ''
|
||||
},
|
||||
forceSync () {
|
||||
this.$store.dispatch('getSettingsProfile')
|
||||
},
|
||||
refreshProfiles () {
|
||||
this.$store.dispatch('listSettingsProfiles')
|
||||
},
|
||||
deleteSettingsProfile (name) {
|
||||
if (confirm(this.$t('settings.settings_profile_delete_confirm'))) {
|
||||
this.$store.dispatch('deleteSettingsProfile', name)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
<template>
|
||||
<div :label="$t('settings.general')">
|
||||
<div class="setting-item">
|
||||
<h2>{{ $t('settings.interface') }}</h2>
|
||||
<ul class="setting-list">
|
||||
<li>
|
||||
<interface-language-switcher
|
||||
|
@ -10,6 +9,94 @@
|
|||
:set-language="val => language = val"
|
||||
/>
|
||||
</li>
|
||||
<li
|
||||
v-if="user && (settingsProfiles.length > 0)"
|
||||
>
|
||||
<h2>{{ $t('settings.settings_profile') }}</h2>
|
||||
<p>
|
||||
{{ $t('settings.settings_profile_currently', { name: settingsProfile, version: settingsVersion }) }}
|
||||
<button
|
||||
class="btn button-default"
|
||||
@click="forceSync()"
|
||||
>
|
||||
{{ $t('settings.settings_profile_force_sync') }}
|
||||
</button>
|
||||
|
||||
</p>
|
||||
<div
|
||||
@click="toggleExpandedSettings"
|
||||
>
|
||||
<template
|
||||
v-if="profilesExpanded"
|
||||
>
|
||||
<button class="btn button-default">
|
||||
{{ $t('settings.settings_profiles_unshow') }}
|
||||
</button>
|
||||
</template>
|
||||
<template
|
||||
v-else
|
||||
>
|
||||
<button class="btn button-default">
|
||||
{{ $t('settings.settings_profiles_show') }}
|
||||
</button>
|
||||
</template>
|
||||
</div>
|
||||
<br>
|
||||
<template
|
||||
v-if="profilesExpanded"
|
||||
>
|
||||
|
||||
<div
|
||||
v-for="profile in settingsProfiles"
|
||||
:key="profile.id"
|
||||
class="settings-profile"
|
||||
>
|
||||
<h4>{{ profile.name }} ({{ profile.version }})</h4>
|
||||
<template
|
||||
v-if="settingsProfile === profile.name"
|
||||
>
|
||||
{{ $t('settings.settings_profile_in_use') }}
|
||||
</template>
|
||||
<template
|
||||
v-else
|
||||
>
|
||||
<button
|
||||
class="btn button-default"
|
||||
@click="loadSettingsProfile(profile.name)"
|
||||
>
|
||||
{{ $t('settings.settings_profile_use') }}
|
||||
</button>
|
||||
<button
|
||||
class="btn button-default"
|
||||
@click="deleteSettingsProfile(profile.name)"
|
||||
>
|
||||
{{ $t('settings.settings_profile_delete') }}
|
||||
</button>
|
||||
</template>
|
||||
</div>
|
||||
<button class="btn button-default" @click="refreshProfiles()">
|
||||
{{ $t('settings.settings_profiles_refresh') }}
|
||||
<FAIcon icon="sync" @click="refreshProfiles()" />
|
||||
</button>
|
||||
<h3>{{ $t('settings.settings_profile_creation') }}</h3>
|
||||
<label for="settings-profile-new-name">
|
||||
{{ $t('settings.settings_profile_creation_new_name_label') }}
|
||||
</label>
|
||||
<input v-model="newProfileName" id="settings-profile-new-name">
|
||||
<button
|
||||
class="btn button-default"
|
||||
@click="createSettingsProfile"
|
||||
>
|
||||
{{ $t('settings.settings_profile_creation_submit') }}
|
||||
</button>
|
||||
</template>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="setting-item">
|
||||
<h2>{{ $t('settings.interface') }}</h2>
|
||||
<ul class="setting-list">
|
||||
<li v-if="instanceSpecificPanelPresent">
|
||||
<BooleanSetting path="hideISP">
|
||||
{{ $t('settings.hide_isp') }}
|
||||
|
@ -463,7 +550,6 @@
|
|||
</BooleanSetting>
|
||||
</li>
|
||||
<li>
|
||||
<!-- <BooleanSetting path="serverSide_defaultNSFW"> -->
|
||||
<BooleanSetting path="sensitiveByDefault">
|
||||
{{ $t('settings.sensitive_by_default') }}
|
||||
</BooleanSetting>
|
||||
|
@ -546,3 +632,13 @@
|
|||
</template>
|
||||
|
||||
<script src="./general_tab.js"></script>
|
||||
<style lang="scss">
|
||||
.settings-profile {
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
#settings-profile-new-name {
|
||||
margin-left: 1em;
|
||||
margin-right: 1em;
|
||||
}
|
||||
</style>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue