- Replace direct `useStore` usage with composable helpers
(useActions, useState, useGetters)
- Add `setPopupShow` action to wrap `popupShow` mutation
and eliminate mutations in favor of `setPopupShow` action
- Remove `usePbx` and `useUser` composables
- Update documentation
This prepares the codebase for eventual Pinia migration by:
- Avoiding mutations (Pinia has no mutations)
- Centralizing store access through helpers
- Enabling future migration with minimal component changes
Change-Id: Iddc63b8c3c39fe1a06bb6a78ef322f01fe77a9af
(cherry picked from commit e64887e492)
mr26.0
parent
8760189634
commit
4233c0432c
@ -1,52 +0,0 @@
|
||||
import { useStore } from 'src/composables/useStore'
|
||||
import { computed } from 'vue'
|
||||
|
||||
export function usePbx () {
|
||||
const store = useStore()
|
||||
|
||||
// State
|
||||
const numbers = computed(() => store.getters['pbx/numbers'])
|
||||
const seatList = computed(() => store.state.pbx.seatList)
|
||||
const groupList = computed(() => store.state.pbx.groupList)
|
||||
const deviceProfileList = computed(() => store.state.pbx.deviceProfileList)
|
||||
|
||||
// Getters
|
||||
const numberOptions = computed(() => store.getters['pbx/getNumberOptions'])
|
||||
const seatOptions = computed(() => store.getters['pbx/getSeatOptions'])
|
||||
const groupOptions = computed(() => store.getters['pbx/getGroupOptions'])
|
||||
const subscriberOptions = computed(() => store.getters['pbx/getSubscriberOptions'])
|
||||
|
||||
// Loading states
|
||||
const isNumbersRequesting = computed(() => store.getters['pbx/isNumbersRequesting'])
|
||||
const isSubscribersRequesting = computed(() => store.getters['pbx/isSubscribersRequesting'])
|
||||
|
||||
// Actions
|
||||
const loadNumbers = () => store.dispatch('pbx/loadNumbers')
|
||||
const loadSubscribers = () => store.dispatch('pbx/loadSubscribers')
|
||||
const loadProfiles = () => store.dispatch('pbx/loadProfiles')
|
||||
const loadDeviceModel = (payload) => store.dispatch('pbx/loadDeviceModel', payload)
|
||||
|
||||
return {
|
||||
// State
|
||||
numbers,
|
||||
seatList,
|
||||
groupList,
|
||||
deviceProfileList,
|
||||
|
||||
// Getters
|
||||
numberOptions,
|
||||
seatOptions,
|
||||
groupOptions,
|
||||
subscriberOptions,
|
||||
|
||||
// Loading states
|
||||
isNumbersRequesting,
|
||||
isSubscribersRequesting,
|
||||
|
||||
// Actions
|
||||
loadNumbers,
|
||||
loadSubscribers,
|
||||
loadProfiles,
|
||||
loadDeviceModel
|
||||
}
|
||||
}
|
||||
@ -1,61 +0,0 @@
|
||||
import { useStore } from 'src/composables/useStore'
|
||||
import { computed } from 'vue'
|
||||
|
||||
export function useUser () {
|
||||
const store = useStore()
|
||||
|
||||
// State
|
||||
const subscriber = computed(() => store.state.user.subscriber)
|
||||
const platformInfo = computed(() => store.state.user.platformInfo)
|
||||
|
||||
// Getters
|
||||
const isLogged = computed(() => store.getters['user/isLogged'])
|
||||
const username = computed(() => store.getters['user/getUsername'])
|
||||
const isAdmin = computed(() => store.getters['user/isAdmin'])
|
||||
const isPbxAdmin = computed(() => store.getters['user/isPbxAdmin'])
|
||||
const isPbxEnabled = computed(() => store.getters['user/isPbxEnabled'])
|
||||
const isSpCe = computed(() => store.getters['user/isSpCe'])
|
||||
const loginRequesting = computed(() => store.getters['user/loginRequesting'])
|
||||
const isPasswordChanging = computed(() => store.getters['user/isPasswordChanging'])
|
||||
|
||||
// Actions
|
||||
const login = (credentials) => store.dispatch('user/login', credentials)
|
||||
const logout = () => store.dispatch('user/logout')
|
||||
const changePassword = (newPassword) => store.dispatch('user/changePassword', newPassword)
|
||||
const changeSIPPassword = (newPassword) => store.dispatch('user/changeSIPPassword', newPassword)
|
||||
const initUser = () => store.dispatch('user/initUser')
|
||||
|
||||
// Getters with parameters
|
||||
const hasCapability = (capability) => store.getters['user/hasCapability'](capability)
|
||||
const hasPlatformFeature = (feature) => store.getters['user/hasPlatformFeature'](feature)
|
||||
const hasSubscriberProfileAttribute = (attribute) =>
|
||||
store.getters['user/hasSubscriberProfileAttribute'](attribute)
|
||||
|
||||
return {
|
||||
// State
|
||||
subscriber,
|
||||
platformInfo,
|
||||
|
||||
// Getters
|
||||
isLogged,
|
||||
username,
|
||||
isAdmin,
|
||||
isPbxAdmin,
|
||||
isPbxEnabled,
|
||||
isSpCe,
|
||||
loginRequesting,
|
||||
isPasswordChanging,
|
||||
|
||||
// Actions
|
||||
login,
|
||||
logout,
|
||||
changePassword,
|
||||
changeSIPPassword,
|
||||
initUser,
|
||||
|
||||
// Getters with parameters
|
||||
hasCapability,
|
||||
hasPlatformFeature,
|
||||
hasSubscriberProfileAttribute
|
||||
}
|
||||
}
|
||||
Loading…
Reference in new issue