blob: a30f732163ca70c16870fc55c1d52c0749cdf1a8 (
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
|
/**
* SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import type { ComponentPublicInstanceConstructor } from 'vue/types/v3-component-public-instance'
import { View, getNavigation } from '@nextcloud/files'
import { t } from '@nextcloud/l10n'
import { getContents } from '../services/Search.ts'
import { VIEW_ID as FILES_VIEW_ID } from './files.ts'
import MagnifySvg from '@mdi/svg/svg/magnify.svg?raw'
import Vue from 'vue'
export const VIEW_ID = 'search'
/**
* Register the search-in-files view
*/
export function registerSearchView() {
let instance: Vue
let view: ComponentPublicInstanceConstructor
const Navigation = getNavigation()
Navigation.register(new View({
id: VIEW_ID,
name: t('files', 'Search'),
caption: t('files', 'Search results within your files.'),
async emptyView(el) {
if (!view) {
view = (await import('./SearchEmptyView.vue')).default
} else {
instance.$destroy()
}
instance = new Vue(view)
instance.$mount(el)
},
icon: MagnifySvg,
order: 10,
parent: FILES_VIEW_ID,
// it should be shown expanded
expanded: true,
// this view is hidden by default and only shown when active
hidden: true,
getContents,
}))
}
|