aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFerdinand Thiessen <opensource@fthiessen.de>2025-07-04 16:34:41 +0200
committerFerdinand Thiessen <opensource@fthiessen.de>2025-07-07 10:52:21 +0200
commit1567d622dc04b0a7955340e2ab98b70c4780c46f (patch)
tree84f71cd10bd06b6bbaf5add5c757e92d2003689f
parent693bf9a475cc919b2b61b5ca3d16e4ef40e39e06 (diff)
downloadnextcloud-server-1567d622dc04b0a7955340e2ab98b70c4780c46f.tar.gz
nextcloud-server-1567d622dc04b0a7955340e2ab98b70c4780c46f.zip
refactor(files): remove "local search"
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
-rw-r--r--apps/files/src/components/FilesNavigationSearch.vue42
-rw-r--r--apps/files/src/services/Search.ts3
-rw-r--r--apps/files/src/store/search.ts36
-rw-r--r--apps/files/src/types.ts2
-rw-r--r--apps/files/src/views/SearchEmptyView.vue4
5 files changed, 15 insertions, 72 deletions
diff --git a/apps/files/src/components/FilesNavigationSearch.vue b/apps/files/src/components/FilesNavigationSearch.vue
index 85dc5534e5e..e34d4bf0971 100644
--- a/apps/files/src/components/FilesNavigationSearch.vue
+++ b/apps/files/src/components/FilesNavigationSearch.vue
@@ -13,15 +13,10 @@ import NcAppNavigationSearch from '@nextcloud/vue/components/NcAppNavigationSear
import NcIconSvgWrapper from '@nextcloud/vue/components/NcIconSvgWrapper'
import { onBeforeNavigation } from '../composables/useBeforeNavigation.ts'
import { useNavigation } from '../composables/useNavigation.ts'
-import { useRouteParameters } from '../composables/useRouteParameters.ts'
-import { useFilesStore } from '../store/files.ts'
import { useSearchStore } from '../store/search.ts'
import { VIEW_ID } from '../views/search.ts'
const { currentView } = useNavigation(true)
-const { directory } = useRouteParameters()
-
-const filesStore = useFilesStore()
const searchStore = useSearchStore()
/**
@@ -56,43 +51,18 @@ onBeforeNavigation((to, from, next) => {
const isSearchView = computed(() => currentView.value.id === VIEW_ID)
/**
- * Local search is only possible on real DAV resources within the files root
- */
-const canSearchLocally = computed(() => {
- if (searchStore.base) {
- return true
- }
-
- const folder = filesStore.getDirectoryByPath(currentView.value.id, directory.value)
- return folder?.isDavResource && folder?.root?.startsWith('/files/')
-})
-
-/**
* Different searchbox label depending if filtering or searching
*/
const searchLabel = computed(() => {
if (searchStore.scope === 'globally') {
return t('files', 'Search globally by filename …')
- } else if (searchStore.scope === 'locally') {
- return t('files', 'Search here by filename …')
}
- return t('files', 'Filter file names …')
+ return t('files', 'Search here by filename …')
})
-
-/**
- * Update the search value and set the base if needed
- * @param value - The new value
- */
-function onUpdateSearch(value: string) {
- if (searchStore.scope === 'locally' && currentView.value.id !== VIEW_ID) {
- searchStore.base = filesStore.getDirectoryByPath(currentView.value.id, directory.value)
- }
- searchStore.query = value
-}
</script>
<template>
- <NcAppNavigationSearch :label="searchLabel" :model-value="searchStore.query" @update:modelValue="onUpdateSearch">
+ <NcAppNavigationSearch v-model="searchStore.query" :label="searchLabel">
<template #actions>
<NcActions :aria-label="t('files', 'Search scope options')" :disabled="isSearchView">
<template #icon>
@@ -102,13 +72,7 @@ function onUpdateSearch(value: string) {
<template #icon>
<NcIconSvgWrapper :path="mdiMagnify" />
</template>
- {{ t('files', 'Filter in current view') }}
- </NcActionButton>
- <NcActionButton v-if="canSearchLocally" close-after-click @click="searchStore.scope = 'locally'">
- <template #icon>
- <NcIconSvgWrapper :path="mdiMagnify" />
- </template>
- {{ t('files', 'Search from this location') }}
+ {{ t('files', 'Filter and search from this location') }}
</NcActionButton>
<NcActionButton close-after-click @click="searchStore.scope = 'globally'">
<template #icon>
diff --git a/apps/files/src/services/Search.ts b/apps/files/src/services/Search.ts
index ae6f1ee50e0..f1d7c30a94e 100644
--- a/apps/files/src/services/Search.ts
+++ b/apps/files/src/services/Search.ts
@@ -21,12 +21,11 @@ export function getContents(): CancelablePromise<ContentsWithRoot> {
const controller = new AbortController()
const searchStore = useSearchStore(getPinia())
- const dir = searchStore.base?.path
return new CancelablePromise<ContentsWithRoot>(async (resolve, reject, cancel) => {
cancel(() => controller.abort())
try {
- const contents = await searchNodes(searchStore.query, { dir, signal: controller.signal })
+ const contents = await searchNodes(searchStore.query, { signal: controller.signal })
resolve({
contents,
folder: new Folder({
diff --git a/apps/files/src/store/search.ts b/apps/files/src/store/search.ts
index 417f662ca00..43e01f35b92 100644
--- a/apps/files/src/store/search.ts
+++ b/apps/files/src/store/search.ts
@@ -3,16 +3,16 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
-import type { INode, View } from '@nextcloud/files'
-import type RouterService from '../services/RouterService'
-import type { SearchScope } from '../types'
+import type { View } from '@nextcloud/files'
+import type RouterService from '../services/RouterService.ts'
+import type { SearchScope } from '../types.ts'
import { emit, subscribe } from '@nextcloud/event-bus'
+import debounce from 'debounce'
import { defineStore } from 'pinia'
import { ref, watch } from 'vue'
-import { VIEW_ID } from '../views/search'
-import logger from '../logger'
-import debounce from 'debounce'
+import { VIEW_ID } from '../views/search.ts'
+import logger from '../logger.ts'
export const useSearchStore = defineStore('search', () => {
/**
@@ -21,27 +21,15 @@ export const useSearchStore = defineStore('search', () => {
const query = ref('')
/**
- * Where to start the search
- */
- const base = ref<INode>()
-
- /**
* Scope of the search.
* Scopes:
* - filter: only filter current file list
- * - locally: search from current location recursivly
* - globally: search everywhere
*/
const scope = ref<SearchScope>('filter')
// reset the base if query is cleared
- watch(scope, () => {
- if (scope.value !== 'locally') {
- base.value = undefined
- }
-
- updateSearch()
- })
+ watch(scope, updateSearch)
watch(query, (old, current) => {
// skip if only whitespaces changed
@@ -59,13 +47,12 @@ export const useSearchStore = defineStore('search', () => {
* Debounced update of the current route
* @private
*/
- const updateRouter = debounce((isSearch: boolean, fileid?: number) => {
+ const updateRouter = debounce((isSearch: boolean) => {
const router = window.OCP.Files.Router as RouterService
router.goToRoute(
undefined,
{
view: VIEW_ID,
- ...(fileid === undefined ? {} : { fileid: String(fileid) }),
},
{
query: query.value,
@@ -106,12 +93,10 @@ export const useSearchStore = defineStore('search', () => {
return
}
- // we only use the directory if we search locally
- const fileid = scope.value === 'locally' ? base.value?.fileid : undefined
const isSearch = router.params.view === VIEW_ID
- logger.debug('Update route for updated search query', { query: query.value, fileid, isSearch })
- updateRouter(isSearch, fileid)
+ logger.debug('Update route for updated search query', { query: query.value, isSearch })
+ updateRouter(isSearch)
}
/**
@@ -162,7 +147,6 @@ export const useSearchStore = defineStore('search', () => {
}
return {
- base,
query,
scope,
}
diff --git a/apps/files/src/types.ts b/apps/files/src/types.ts
index 8ea1a8a6dbf..d2d1fe41648 100644
--- a/apps/files/src/types.ts
+++ b/apps/files/src/types.ts
@@ -116,7 +116,7 @@ export interface ActiveStore {
/**
* Search scope for the in-files-search
*/
-export type SearchScope = 'filter'|'locally'|'globally'
+export type SearchScope = 'filter'|'globally'
export interface TemplateFile {
app: string
diff --git a/apps/files/src/views/SearchEmptyView.vue b/apps/files/src/views/SearchEmptyView.vue
index 0553e416caf..904e1b0831d 100644
--- a/apps/files/src/views/SearchEmptyView.vue
+++ b/apps/files/src/views/SearchEmptyView.vue
@@ -7,7 +7,6 @@
import { mdiMagnifyClose } from '@mdi/js'
import { t } from '@nextcloud/l10n'
import debounce from 'debounce'
-import NcButton from '@nextcloud/vue/components/NcButton'
import NcEmptyContent from '@nextcloud/vue/components/NcEmptyContent'
import NcIconSvgWrapper from '@nextcloud/vue/components/NcIconSvgWrapper'
import NcInputField from '@nextcloud/vue/components/NcInputField'
@@ -32,9 +31,6 @@ const debouncedUpdate = debounce((value: string) => {
:model-value="searchStore.query"
type="search"
@update:model-value="debouncedUpdate" />
- <NcButton v-if="searchStore.scope === 'locally'" @click="searchStore.scope = 'globally'">
- {{ t('files', 'Search globally') }}
- </NcButton>
</div>
</template>
</NcEmptyContent>