mirror of
https://github.com/nextcloud/server.git
synced 2026-04-21 22:27:31 -04:00
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>
This commit is contained in:
parent
78ce66766b
commit
eecda06f1a
2 changed files with 11 additions and 4 deletions
|
|
@ -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 },
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue