SPDX-License-Identifier: MIT SPDX-License-Identifier: ISC SPDX-License-Identifier: GPL-3.0-or-later SPDX-License-Identifier: CC-BY-4.0 SPDX-License-Identifier: BSD-3-Clause SPDX-License-Identifier: AGPL-3.0-or-later SPDX-License-Identifier: (MPL-2.0 OR Apache-2.0) SPDX-FileCopyrightText: escape-html developers SPDX-FileCopyrightText: Tobias Koppers @sokra SPDX-FileCopyrightText: T. Jameson Little SPDX-FileCopyrightText: Sergey Rubanov SPDX-FileCopyrightText: Roman Shtylman SPDX-FileCopyrightText: Rob Cresswell SPDX-FileCopyrightText: Nextcloud GmbH and Nextcloud contributors SPDX-FileCopyrightText: Kilian Valkhof SPDX-FileCopyrightText: John Molakvoæ (skjnldsv) SPDX-FileCopyrightText: GitHub Inc. SPDX-FileCopyrightText: Feross Aboukhadijeh SPDX-FileCopyrightText: Evan You SPDX-FileCopyrightText: Dr.-Ing. Mario Heiderich, Cure53 (https://cure53.de/) SPDX-FileCopyrightText: Dmitry Soshnikov SPDX-FileCopyrightText: Christoph Wurst SPDX-FileCopyrightText: Ben Briggs SPDX-FileCopyrightText: Andrey Sitnik This file is generated from multiple sources. Included packages: - @nextcloud/auth - version: 2.4.0 - license: GPL-3.0-or-later - @nextcloud/browser-storage - version: 0.4.0 - license: GPL-3.0-or-later - @nextcloud/browserslist-config - version: 3.0.1 - license: GPL-3.0-or-later - semver - version: 7.6.3 - license: ISC - @nextcloud/event-bus - version: 3.3.1 - license: GPL-3.0-or-later - @nextcloud/l10n - version: 3.1.0 - license: GPL-3.0-or-later - @nextcloud/logger - version: 3.0.2 - license: GPL-3.0-or-later - @nextcloud/router - version: 3.0.1 - license: GPL-3.0-or-later - @nextcloud/vue - version: 8.20.0 - license: AGPL-3.0-or-later - base64-js - version: 1.5.1 - license: MIT - browserslist - version: 4.23.3 - license: MIT - caniuse-lite - version: 1.0.30001647 - license: CC-BY-4.0 - css-loader - version: 7.1.2 - license: MIT - dompurify - version: 3.1.7 - license: (MPL-2.0 OR Apache-2.0) - electron-to-chromium - version: 1.5.4 - license: ISC - escape-html - version: 1.0.3 - license: MIT - ieee754 - version: 1.2.1 - license: BSD-3-Clause - buffer - version: 6.0.3 - license: MIT - node-releases - version: 2.0.18 - license: MIT - process - version: 0.11.10 - license: MIT - regexp-tree - version: 0.1.27 - license: MIT - style-loader - version: 4.0.0 - license: MIT - vue-loader - version: 15.11.1 - license: MIT - vue-material-design-icons - version: 5.3.1 - license: MIT - vue - version: 2.7.16 - license: MIT - webpack - version: 5.94.0 - license: MIT - nextcloud - version: 1.0.0 - license: AGPL-3.0-or-later quest-timeout-const Nextcloud server, a safe home for all your data: https://github.com/nextcloud/serverwww-data
aboutsummaryrefslogtreecommitdiffstats
blob: 2b29c7aec4daea012ccca796af44284b6d0ad0d2 (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: 2024 Nextcloud GmbH and Nextcloud contributors
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */

import type { Node } from '@nextcloud/files'
import { emit } from '@nextcloud/event-bus'
import { getFilePickerBuilder } from '@nextcloud/dialogs'
import { imagePath } from '@nextcloud/router'
import { translate as t } from '@nextcloud/l10n'
import logger from '../../logger'

/**
 * Initialize the unified search plugin.
 */
function init() {
	const OCA = window.OCA
	if (!OCA.UnifiedSearch) {
		return
	}

	logger.info('Initializing unified search plugin: folder search from files app')
	OCA.UnifiedSearch.registerFilterAction({
		id: 'files',
		appId: 'files',
		label: t('files', 'In folder'),
		icon: imagePath('files', 'app.svg'),
		callback: () => {
			const filepicker = getFilePickerBuilder('Pick plain text files')
				.addMimeTypeFilter('httpd/unix-directory')
				.allowDirectories(true)
				.addButton({
					label: 'Pick',
					callback: (nodes: Node[]) => {
						logger.info('Folder picked', { folder: nodes[0] })
						const folder = nodes[0]
						emit('nextcloud:unified-search:add-filter', {
							id: 'files',
							payload: folder,
							filterUpdateText: t('files', 'Search in folder: {folder}', { folder: folder.basename }),
							filterParams: { path: folder.path },
						})
					},
				})
				.build()
			filepicker.pick()
		},
	})
}

document.addEventListener('DOMContentLoaded', init)