mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
refactor: migrate from vuex to pinia
Signed-off-by: fenn-cs <fenn25.fn@gmail.com>
This commit is contained in:
parent
d35a49caba
commit
647f4bc1c8
4 changed files with 25 additions and 45 deletions
|
|
@ -1,11 +0,0 @@
|
|||
import Vue from 'vue';
|
||||
import Vuex from 'vuex';
|
||||
import search from './unified-search-external-filters';
|
||||
|
||||
Vue.use(Vuex);
|
||||
|
||||
export default new Vuex.Store({
|
||||
modules: {
|
||||
search,
|
||||
},
|
||||
});
|
||||
|
|
@ -19,24 +19,18 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
const state = {
|
||||
externalFilters: [],
|
||||
}
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
const mutations = {
|
||||
registerExternalFilter(state, { id, label, callback, icon }) {
|
||||
state.externalFilters.push({ id, name: label, callback, icon, isPluginFilter: true })
|
||||
export const useSearchStore = defineStore({
|
||||
id: 'search',
|
||||
|
||||
state: () => ({
|
||||
externalFilters: [],
|
||||
}),
|
||||
|
||||
actions: {
|
||||
registerExternalFilter({ id, appId, label, callback, icon }) {
|
||||
this.externalFilters.push({ id, appId, name: label, callback, icon, isPluginFilter: true })
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
const actions = {
|
||||
registerExternalFilter({ commit }, { id, label, callback, icon }) {
|
||||
commit('registerExternalFilter', { id, label, callback, icon })
|
||||
},
|
||||
}
|
||||
|
||||
export default {
|
||||
state,
|
||||
mutations,
|
||||
actions,
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -23,10 +23,11 @@
|
|||
import { getLoggerBuilder } from '@nextcloud/logger'
|
||||
import { getRequestToken } from '@nextcloud/auth'
|
||||
import { translate as t, translatePlural as n } from '@nextcloud/l10n'
|
||||
import { createPinia, PiniaVuePlugin } from 'pinia'
|
||||
import Vue from 'vue'
|
||||
|
||||
import UnifiedSearch from './views/UnifiedSearch.vue'
|
||||
import store from '../src/store/index.js'
|
||||
import { useSearchStore } from '../src/store/unified-search-external-filters.js'
|
||||
|
||||
// eslint-disable-next-line camelcase
|
||||
__webpack_nonce__ = btoa(getRequestToken())
|
||||
|
|
@ -51,21 +52,19 @@ Vue.mixin({
|
|||
// Register the add/register filter action API globally
|
||||
window.OCA = window.OCA || {}
|
||||
window.OCA.UnifiedSearch = {
|
||||
registerFilterAction: ({ id, name, label, callback, icon }) => {
|
||||
store.dispatch('registerExternalFilter', {
|
||||
id,
|
||||
name,
|
||||
label,
|
||||
icon,
|
||||
callback,
|
||||
})
|
||||
registerFilterAction: ({ id, appId, label, callback, icon }) => {
|
||||
const searchStore = useSearchStore()
|
||||
searchStore.registerExternalFilter({ id, appId, label, callback, icon })
|
||||
},
|
||||
}
|
||||
|
||||
Vue.use(PiniaVuePlugin)
|
||||
const pinia = createPinia()
|
||||
|
||||
export default new Vue({
|
||||
el: '#unified-search',
|
||||
pinia,
|
||||
// eslint-disable-next-line vue/match-component-file-name
|
||||
name: 'UnifiedSearchRoot',
|
||||
store,
|
||||
render: h => h(UnifiedSearch),
|
||||
})
|
||||
|
|
|
|||
|
|
@ -154,8 +154,8 @@ import SearchResult from '../components/UnifiedSearch/SearchResult.vue'
|
|||
import debounce from 'debounce'
|
||||
import { emit, subscribe } from '@nextcloud/event-bus'
|
||||
import { useBrowserLocation } from '@vueuse/core'
|
||||
import { mapState } from 'vuex'
|
||||
import { getProviders, search as unifiedSearch, getContacts } from '../services/UnifiedSearchService.js'
|
||||
import { useSearchStore } from '../store/unified-search-external-filters.js'
|
||||
|
||||
export default {
|
||||
name: 'UnifiedSearchModal',
|
||||
|
|
@ -190,8 +190,10 @@ export default {
|
|||
* Reactive version of window.location
|
||||
*/
|
||||
const currentLocation = useBrowserLocation()
|
||||
const searchStore = useSearchStore()
|
||||
return {
|
||||
currentLocation,
|
||||
externalFilters: searchStore.externalFilters,
|
||||
}
|
||||
},
|
||||
data() {
|
||||
|
|
@ -220,9 +222,6 @@ export default {
|
|||
},
|
||||
|
||||
computed: {
|
||||
...mapState({
|
||||
externalFilters: state => state.search.externalFilters,
|
||||
}),
|
||||
userContacts() {
|
||||
return this.contacts
|
||||
},
|
||||
|
|
@ -577,7 +576,6 @@ export default {
|
|||
break
|
||||
}
|
||||
}
|
||||
console.debug('Search scope set to conversation', addFilterEvent)
|
||||
this.debouncedFind(this.searchQuery)
|
||||
},
|
||||
groupProvidersByApp(filters) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue