aboutsummaryrefslogtreecommitdiffstats
path: root/core/src/unified-search.ts
blob: fd5f9cb1fdf0bc172bcd39295b679119c2bc50ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/**
 * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */

import { getLoggerBuilder } from '@nextcloud/logger'
import { getCSPNonce } 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 { useSearchStore } from '../src/store/unified-search-external-filters.js'

// eslint-disable-next-line camelcase
__webpack_nonce__ = getCSPNonce()

const logger = getLoggerBuilder()
	.setApp('unified-search')
	.detectUser()
	.build()

Vue.mixin({
	data() {
		return {
			logger,
		}
	},
	methods: {
		t,
		n,
	},
})

// Define type structure for unified searc action
interface UnifiedSearchAction {
    id: string;
    appId: string;
    label: string;
    icon: string;
    callback: () => void;
}

// Register the add/register filter action API globally
window.OCA = window.OCA || {}
window.OCA.UnifiedSearch = {
	registerFilterAction: ({ id, appId, label, callback, icon }: UnifiedSearchAction) => {
		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',
	render: h => h(UnifiedSearch),
})