aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornfebe <fenn25.fn@gmail.com>2025-01-11 00:07:19 +0100
committerF. E Noel Nfebe <fenn25.fn@gmail.com>2025-01-29 16:47:21 +0100
commitc680e74a82fb2a2b1544719490a3e60afae5727a (patch)
treec03cbd4f8325079f9865e67e09c77afea4524434
parent3290ec3abe6f3a8efb694bb708cf09e52a1173f2 (diff)
downloadnextcloud-server-c680e74a82fb2a2b1544719490a3e60afae5727a.tar.gz
nextcloud-server-c680e74a82fb2a2b1544719490a3e60afae5727a.zip
fix(unified-search): Use appId for searching
Each provider may search from a particular app so we should use that for searching. Before this commit, we used `provider.id` instead of `provider.appId` the problem with the previous approach is that it forces the provider id to be a valid search provider (an app that supports search) limiting the developers ability to use unique IDs to identify the different providers (especially plugin providers) inside the places filter. For example the Files search plugin "In folder" (search in folder plugin) was required to have id as `files` while the files provider itself already has id as `files`. Signed-off-by: nfebe <fenn25.fn@gmail.com>
-rw-r--r--apps/files/src/plugins/search/folderSearch.ts5
-rw-r--r--core/src/components/UnifiedSearch/UnifiedSearchModal.vue10
2 files changed, 11 insertions, 4 deletions
diff --git a/apps/files/src/plugins/search/folderSearch.ts b/apps/files/src/plugins/search/folderSearch.ts
index 2b29c7aec4d..4ba7e34a40e 100644
--- a/apps/files/src/plugins/search/folderSearch.ts
+++ b/apps/files/src/plugins/search/folderSearch.ts
@@ -21,7 +21,7 @@ function init() {
logger.info('Initializing unified search plugin: folder search from files app')
OCA.UnifiedSearch.registerFilterAction({
- id: 'files',
+ id: 'in-folder',
appId: 'files',
label: t('files', 'In folder'),
icon: imagePath('files', 'app.svg'),
@@ -35,7 +35,8 @@ function init() {
logger.info('Folder picked', { folder: nodes[0] })
const folder = nodes[0]
emit('nextcloud:unified-search:add-filter', {
- id: 'files',
+ id: 'in-folder',
+ appId: 'files',
payload: folder,
filterUpdateText: t('files', 'Search in folder: {folder}', { folder: folder.basename }),
filterParams: { path: folder.path },
diff --git a/core/src/components/UnifiedSearch/UnifiedSearchModal.vue b/core/src/components/UnifiedSearch/UnifiedSearchModal.vue
index 09d3db52835..d75d54756ac 100644
--- a/core/src/components/UnifiedSearch/UnifiedSearchModal.vue
+++ b/core/src/components/UnifiedSearch/UnifiedSearchModal.vue
@@ -374,7 +374,7 @@ export default defineComponent({
const providersToSearch = this.filteredProviders.length > 0 ? this.filteredProviders : this.providers
const searchProvider = (provider, filters) => {
const params = {
- type: provider.id,
+ type: provider.appId,
query,
cursor: null,
extraQueries: provider.extraParams,
@@ -397,6 +397,7 @@ export default defineComponent({
if (this.providerResultLimit > 5) {
params.limit = this.providerResultLimit
+ unifiedSearchLogger.debug('Limiting search to', params.limit)
}
const request = unifiedSearch(params).request
@@ -404,6 +405,7 @@ export default defineComponent({
request().then((response) => {
newResults.push({
id: provider.id,
+ appId: provider.appId,
provider: provider.name,
inAppSearch: provider.inAppSearch,
results: response.data.ocs.data.entries,
@@ -500,11 +502,13 @@ export default defineComponent({
},
loadMoreResultsForProvider(providerId) {
this.providerResultLimit += 5
- this.filters = this.filters.filter(filter => filter.type !== 'provider')
+ // If user wants more result for a particular filter remove other filters???
+ this.filters = this.filters.filter(filter => filter.id === providerId)
const provider = this.providers.find(provider => provider.id === providerId)
this.addProviderFilter(provider, true)
},
addProviderFilter(providerFilter, loadMoreResultsForProvider = false) {
+ unifiedSearchLogger.debug('Applying provider filter', { providerFilter, loadMoreResultsForProvider })
if (!providerFilter.id) return
if (providerFilter.isPluginFilter) {
providerFilter.callback()
@@ -521,6 +525,7 @@ export default defineComponent({
}
this.filteredProviders.push({
id: providerFilter.id,
+ appId: providerFilter.appId,
name: providerFilter.name,
icon: providerFilter.icon,
type: providerFilter.type || 'provider',
@@ -649,6 +654,7 @@ export default defineComponent({
this.updateDateFilter()
},
handlePluginFilter(addFilterEvent) {
+ unifiedSearchLogger.debug('Handling plugin filter', { addFilterEvent })
for (let i = 0; i < this.filteredProviders.length; i++) {
const provider = this.filteredProviders[i]
if (provider.id === addFilterEvent.id) {