migrate adminSettings to pinia

This commit is contained in:
Henry Jameson 2026-06-09 13:11:21 +03:00
commit 50b356fc1d
15 changed files with 178 additions and 164 deletions

View file

@ -7,7 +7,7 @@ import { useAdminUsersStore } from 'src/stores/adminUsers.js'
const AdminCard = {
props: {
userId: {
type: String
type: String,
},
},
components: {
@ -43,7 +43,7 @@ const AdminCard = {
},
isConfirmed() {
return this.userAdminData.is_confirmed
}
},
},
}

View file

@ -9,6 +9,8 @@ import SharedComputedObject from '../helpers/shared_computed_object.js'
import StringSetting from '../helpers/string_setting.vue'
import TupleSetting from '../helpers/tuple_setting.vue'
import { useAdminSettingsStore } from 'src/stores/admin_settings.js'
const AuthTab = {
provide() {
return {
@ -30,9 +32,7 @@ const AuthTab = {
computed: {
...SharedComputedObject(),
LDAPEnabled() {
return this.$store.state.adminSettings.draft[':pleroma'][':ldap'][
':enabled'
]
return useAdminSettingsStore().draft[':pleroma'][':ldap'][':enabled']
},
},
}

View file

@ -7,6 +7,7 @@ import IntegerSetting from '../helpers/integer_setting.vue'
import SharedComputedObject from '../helpers/shared_computed_object.js'
import StringSetting from '../helpers/string_setting.vue'
import { useAdminSettingsStore } from 'src/stores/admin_settings.js'
import { useInterfaceStore } from 'src/stores/interface.js'
import { library } from '@fortawesome/fontawesome-svg-core'
@ -43,7 +44,7 @@ const FrontendsTab = {
computed: {
...SharedComputedObject(),
frontends() {
return this.$store.state.adminSettings.frontends
return useAdminSettingsStore().frontends
},
},
methods: {
@ -104,7 +105,7 @@ const FrontendsTab = {
const ref = suggestRef || this.getSuggestedRef(frontend)
const { name } = frontend
this.$store.commit('updateAdminDraft', {
useAdminSettingsStore.updateAdminDraft({
path: [':pleroma', ':frontends', ':primary'],
value: { name, ref },
})

View file

@ -12,6 +12,8 @@ import SharedComputedObject from '../helpers/shared_computed_object.js'
import StringSetting from '../helpers/string_setting.vue'
import TupleSetting from '../helpers/tuple_setting.vue'
import { useAdminSettingsStore } from 'src/stores/admin_settings.js'
const HTTPTab = {
provide() {
return {
@ -35,7 +37,7 @@ const HTTPTab = {
...SharedComputedObject(),
sslOptions() {
const desc = get(
this.$store.state.adminSettings.descriptions,
useAdminSettingsStore().descriptions,
':pleroma.:http.:adapter.:ssl_options.:versions',
)
return new Set(

View file

@ -12,6 +12,8 @@ import PWAManifestIconsSetting from '../helpers/pwa_manifest_icons_setting.vue'
import SharedComputedObject from '../helpers/shared_computed_object.js'
import StringSetting from '../helpers/string_setting.vue'
import { useAdminSettingsStore } from 'src/stores/admin_settings.js'
const InstanceTab = {
provide() {
return {
@ -34,7 +36,7 @@ const InstanceTab = {
computed: {
...SharedComputedObject(),
providersOptions() {
const desc = get(this.$store.state.adminSettings.descriptions, [
const desc = get(useAdminSettingsStore().descriptions, [
':pleroma',
'Pleroma.Web.Metadata',
':providers',
@ -47,7 +49,7 @@ const InstanceTab = {
)
},
limitLocalContentOptions() {
const desc = get(this.$store.state.adminSettings.descriptions, [
const desc = get(useAdminSettingsStore().descriptions, [
':pleroma',
':instance',
':limit_to_local_content',

View file

@ -10,6 +10,8 @@ import ListSetting from '../helpers/list_setting.vue'
import SharedComputedObject from '../helpers/shared_computed_object.js'
import StringSetting from '../helpers/string_setting.vue'
import { useAdminSettingsStore } from 'src/stores/admin_settings.js'
const LinksTab = {
provide() {
return {
@ -30,27 +32,27 @@ const LinksTab = {
computed: {
classIsPresent() {
return (
this.$store.state.adminSettings.draft[':pleroma']['Pleroma.Formatter'][
useAdminSettingsStore().draft[':pleroma']['Pleroma.Formatter'][
':class'
] !== false
)
},
relIsPresent() {
return (
this.$store.state.adminSettings.draft[':pleroma']['Pleroma.Formatter'][
useAdminSettingsStore().draft[':pleroma']['Pleroma.Formatter'][
':rel'
] !== false
)
},
truncateIsPresent() {
return (
this.$store.state.adminSettings.draft[':pleroma']['Pleroma.Formatter'][
useAdminSettingsStore().draft[':pleroma']['Pleroma.Formatter'][
':truncate'
] !== false
)
},
truncateDescription() {
return get(this.$store.state.adminSettings.descriptions, [
return get(useAdminSettingsStore().descriptions, [
':pleroma',
'Pleroma.Formatter',
':truncate',
@ -58,7 +60,7 @@ const LinksTab = {
},
ttlSettersOptions() {
const desc = get(
this.$store.state.adminSettings.descriptions,
useAdminSettingsStore().descriptions,
':pleroma.:rich_media.:ttl_setters',
)
return new Set(
@ -70,7 +72,7 @@ const LinksTab = {
},
parsersOptions() {
const desc = get(
this.$store.state.adminSettings.descriptions,
useAdminSettingsStore().descriptions,
':pleroma.:rich_media.:parsers',
)
return new Set(
@ -97,12 +99,12 @@ const LinksTab = {
]
},
mediaProxyEnabled() {
return this.$store.state.adminSettings.draft[':pleroma'][':media_proxy'][
return useAdminSettingsStore().draft[':pleroma'][':media_proxy'][
':enabled'
]
},
mediaInvalidationProvider() {
return this.$store.state.adminSettings.draft[':pleroma'][':media_proxy'][
return useAdminSettingsStore().draft[':pleroma'][':media_proxy'][
':invalidation'
][':provider']
},
@ -110,19 +112,19 @@ const LinksTab = {
},
methods: {
checkRel(e) {
this.$store.commit('updateAdminDraft', {
useAdminSettingsStore.updateAdminDraft({
path: [':pleroma', 'Pleroma.Formatter', ':rel'],
value: e ? '' : false,
})
},
checkClass(e) {
this.$store.commit('updateAdminDraft', {
useAdminSettingsStore.updateAdminDraft({
path: [':pleroma', 'Pleroma.Formatter', ':class'],
value: e ? '' : false,
})
},
checkTruncate(e) {
this.$store.commit('updateAdminDraft', {
useAdminSettingsStore.updateAdminDraft({
path: [':pleroma', 'Pleroma.Formatter', ':truncate'],
value: e ? 20 : false,
})

View file

@ -7,6 +7,8 @@ import IntegerSetting from '../helpers/integer_setting.vue'
import SharedComputedObject from '../helpers/shared_computed_object.js'
import StringSetting from '../helpers/string_setting.vue'
import { useAdminSettingsStore } from 'src/stores/admin_settings.js'
const MailerTab = {
provide() {
return {
@ -26,7 +28,7 @@ const MailerTab = {
computed: {
adaptersLabels() {
const prefix = 'Swoosh.Adapters.'
const descriptions = this.$store.state.adminSettings.descriptions
const descriptions = useAdminSettingsStore().descriptions
const options =
descriptions[':pleroma']['Pleroma.Emails.Mailer'][':adapter']
.suggestions
@ -46,20 +48,20 @@ const MailerTab = {
// ]))
},
adapter() {
return this.$store.state.adminSettings.draft[':pleroma'][
'Pleroma.Emails.Mailer'
][':adapter']
return useAdminSettingsStore().draft[':pleroma']['Pleroma.Emails.Mailer'][
':adapter'
]
},
mailerEnabled() {
return this.$store.state.adminSettings.draft[':pleroma'][
'Pleroma.Emails.Mailer'
][':enabled']
return useAdminSettingsStore().draft[':pleroma']['Pleroma.Emails.Mailer'][
':enabled'
]
},
...SharedComputedObject(),
},
methods: {
adapterHasKey(key) {
const descriptions = this.$store.state.adminSettings.descriptions
const descriptions = useAdminSettingsStore().descriptions
const mailerStuff = descriptions[':pleroma']['Pleroma.Emails.Mailer']
const adapterStuff = mailerStuff[':subgroup,' + this.adapter]
return Object.hasOwn(adapterStuff, key)

View file

@ -7,6 +7,8 @@ import ListSetting from '../helpers/list_setting.vue'
import SharedComputedObject from '../helpers/shared_computed_object.js'
import StringSetting from '../helpers/string_setting.vue'
import { useAdminSettingsStore } from 'src/stores/admin_settings.js'
const MediaProxyTab = {
provide() {
return {
@ -25,12 +27,12 @@ const MediaProxyTab = {
},
computed: {
mediaProxyEnabled() {
return this.$store.state.adminSettings.draft[':pleroma'][':media_proxy'][
return useAdminSettingsStore().draft[':pleroma'][':media_proxy'][
':enabled'
]
},
mediaInvalidationProvider() {
return this.$store.state.adminSettings.draft[':pleroma'][':media_proxy'][
return useAdminSettingsStore().draft[':pleroma'][':media_proxy'][
':invalidation'
][':provider']
},

View file

@ -4,6 +4,8 @@ import IntegerSetting from '../helpers/integer_setting.vue'
import SharedComputedObject from '../helpers/shared_computed_object.js'
import StringSetting from '../helpers/string_setting.vue'
import { useAdminSettingsStore } from 'src/stores/admin_settings.js'
const UploadsTab = {
provide() {
return {
@ -40,9 +42,9 @@ const UploadsTab = {
},
computed: {
uploader() {
return this.$store.state.adminSettings.draft[':pleroma'][
'Pleroma.Upload'
][':uploader']
return useAdminSettingsStore().draft[':pleroma']['Pleroma.Upload'][
':uploader'
]
},
...SharedComputedObject(),
},

View file

@ -115,7 +115,8 @@ const UsersTab = {
},
methods: {
fetchUsers(page) {
return useAdminUsersStore().fetchAdminUsers({
return useAdminUsersStore()
.fetchAdminUsers({
...this.fetchOptions,
page,
})

View file

@ -4,6 +4,7 @@ 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 { useInstanceStore } from 'src/stores/instance.js'
import { useInterfaceStore } from 'src/stores/interface.js'
import { useLocalConfigStore } from 'src/stores/local_config.js'
@ -125,14 +126,14 @@ export default {
draft: {
get() {
if (this.realSource === 'admin' || this.path == null) {
return get(this.$store.state.adminSettings.draft, this.canonPath)
return get(useAdminSettingsStore().draft, this.canonPath)
} else {
return this.localDraft
}
},
set(value) {
if (this.realSource === 'admin' || this.path == null) {
this.$store.commit('updateAdminDraft', {
useAdminSettingsStore.updateAdminDraft({
path: this.canonPath,
value,
})
@ -164,10 +165,7 @@ export default {
: this.draftMode
},
backendDescription() {
return get(
this.$store.state.adminSettings.descriptions,
this.descriptionPath,
)
return get(useAdminSettingsStore().descriptions, this.descriptionPath)
},
backendDescriptionLabel() {
if (this.realSource !== 'admin') return ''
@ -221,10 +219,7 @@ export default {
let parentValue = null
if (this.parentPath !== undefined && this.realSource === 'admin') {
if (this.realDraftMode) {
parentValue = get(
this.$store.state.adminSettings.draft,
this.parentPath,
)
parentValue = get(useAdminSettingsStore().draft, this.parentPath)
} else {
parentValue = get(this.configSource, this.parentPath)
}
@ -243,7 +238,7 @@ export default {
case 'profile':
return this.$store.state.profileConfig
case 'admin':
return this.$store.state.adminSettings.config
return useAdminSettingsStore().config
default:
return useMergedConfigStore().mergedConfig
}
@ -259,7 +254,7 @@ export default {
this.$store.dispatch('setProfileOption', { name: k, value: v })
case 'admin':
return (k, v) =>
this.$store.dispatch('pushAdminSetting', { path: k, value: v })
useAdminSettingsStore.pushAdminSetting({ path: k, value: v })
default:
return (readPath, value) => {
const writePath = `${readPath}`
@ -372,9 +367,7 @@ export default {
canHardReset() {
return (
this.realSource === 'admin' &&
this.$store.state.adminSettings.modifiedPaths?.has(
this.canonPath.join(' -> '),
)
useAdminSettingsStore().modifiedPaths?.has(this.canonPath.join(' -> '))
)
},
matchesExpertLevel() {

View file

@ -8,6 +8,7 @@ import Modal from 'src/components/modal/modal.vue'
import PanelLoading from 'src/components/panel_loading/panel_loading.vue'
import Popover from 'src/components/popover/popover.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'
@ -232,10 +233,10 @@ const SettingsModal = {
return clone
},
resetAdminDraft() {
this.$store.commit('resetAdminDraft')
useAdminSettingsStore.resetAdminDraft()
},
pushAdminDraft() {
this.$store.dispatch('pushAdminDraft')
useAdminSettingsStore.pushAdminDraft()
},
...mapActions(useInterfaceStore, [
'temporaryChangesRevert',
@ -265,8 +266,8 @@ const SettingsModal = {
},
adminDraftAny() {
return !isEqual(
this.$store.state.adminSettings.config,
this.$store.state.adminSettings.draft,
useAdminSettingsStore().config,
useAdminSettingsStore().draft,
)
},
},

View file

@ -19,6 +19,7 @@ import UploadsTab from './admin_tabs/uploads_tab.vue'
import UsersTab from './admin_tabs/users_tab.vue'
import VerticalTabSwitcher from './helpers/vertical_tab_switcher.jsx'
import { useAdminSettingsStore } from 'src/stores/admin_settings.js'
import { useInterfaceStore } from 'src/stores/interface.js'
import { library } from '@fortawesome/fontawesome-svg-core'
@ -109,18 +110,18 @@ const SettingsModalAdminContent = {
return useInterfaceStore().settingsModalState === 'visible'
},
adminDbLoaded() {
return this.$store.state.adminSettings.loaded
return useAdminSettingsStore().loaded
},
adminDescriptionsLoaded() {
return this.$store.state.adminSettings.descriptions !== null
return useAdminSettingsStore().descriptions !== null
},
noDb() {
return this.$store.state.adminSettings.dbConfigEnabled === false
return useAdminSettingsStore().dbConfigEnabled === false
},
},
created() {
if (this.user.rights.admin) {
this.$store.dispatch('loadAdminStuff')
useAdminSettingsStore().loadAdminStuff()
}
},
methods: {