Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/ResponseDefinitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
* name: string,
* icon: string,
* order: int,
* isExternalProvider: bool,
* triggers: list<string>,
* filters: array<string, string>,
* inAppSearch: bool,
Expand Down
4 changes: 4 additions & 0 deletions core/openapi-full.json
Original file line number Diff line number Diff line change
Expand Up @@ -1045,6 +1045,7 @@
"name",
"icon",
"order",
"isExternalProvider",
"triggers",
"filters",
"inAppSearch"
Expand All @@ -1066,6 +1067,9 @@
"type": "integer",
"format": "int64"
},
"isExternalProvider": {
"type": "boolean"
},
"triggers": {
"type": "array",
"items": {
Expand Down
4 changes: 4 additions & 0 deletions core/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1045,6 +1045,7 @@
"name",
"icon",
"order",
"isExternalProvider",
"triggers",
"filters",
"inAppSearch"
Expand All @@ -1066,6 +1067,9 @@
"type": "integer",
"format": "int64"
},
"isExternalProvider": {
"type": "boolean"
},
"triggers": {
"type": "array",
"items": {
Expand Down
43 changes: 43 additions & 0 deletions core/src/components/UnifiedSearch/UnifiedSearchModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@
<IconFilter :size="20" />
</template>
</NcButton>
<NcCheckboxRadioSwitch v-if="hasExternalResources"
v-model="searchExternalResources"
type="switch"
class="unified-search-modal__search-external-resources"
:class="{'unified-search-modal__search-external-resources--aligned': localSearch}">
{{ t('core', 'Search connected services') }}
</NcCheckboxRadioSwitch>
</div>
<div class="unified-search-modal__filters-applied">
<FilterChip v-for="filter in filters"
Expand Down Expand Up @@ -172,6 +179,7 @@ import NcButton from '@nextcloud/vue/components/NcButton'
import NcEmptyContent from '@nextcloud/vue/components/NcEmptyContent'
import NcInputField from '@nextcloud/vue/components/NcInputField'
import NcDialog from '@nextcloud/vue/components/NcDialog'
import NcCheckboxRadioSwitch from '@nextcloud/vue/components/NcCheckboxRadioSwitch'

import CustomDateRangeModal from './CustomDateRangeModal.vue'
import FilterChip from './SearchFilterChip.vue'
Expand All @@ -198,6 +206,7 @@ export default defineComponent({
NcEmptyContent,
NcDialog,
NcInputField,
NcCheckboxRadioSwitch,
SearchableList,
SearchResult,
},
Expand Down Expand Up @@ -264,6 +273,7 @@ export default defineComponent({
showDateRangeModal: false,
internalIsVisible: this.open,
initialized: false,
searchExternalResources: false,
}
},

Expand Down Expand Up @@ -301,6 +311,10 @@ export default defineComponent({
debouncedFilterContacts() {
return debounce(this.filterContacts, 300)
},

hasExternalResources() {
return this.providers.some(provider => provider.isExternalProvider)
},
},

watch: {
Expand Down Expand Up @@ -338,6 +352,12 @@ export default defineComponent({
this.$emit('update:query', this.searchQuery)
},
},

searchExternalResources() {
if (this.searchQuery) {
this.find(this.searchQuery)
}
},
},

mounted() {
Expand Down Expand Up @@ -418,6 +438,14 @@ export default defineComponent({
unifiedSearchLogger.debug('Limiting search to', params.limit)
}

const shouldSkipSearch = !this.searchExternalResources && provider.isExternalProvider
const wasManuallySelected = this.filteredProviders.some(filteredProvider => filteredProvider.id === provider.id)
// if the provider is an external resource and the user has not manually selected it, skip the search
if (shouldSkipSearch && !wasManuallySelected) {
this.searching = false
return
}

const request = unifiedSearch(params).request

request().then((response) => {
Expand Down Expand Up @@ -742,6 +770,21 @@ export default defineComponent({
padding-top: 4px;
}

&__search-external-resources {
:deep(span.checkbox-content) {
padding-top: 0;
padding-bottom: 0;
}

:deep(.checkbox-content__icon) {
margin: auto !important;
}

&--aligned {
margin-inline-start: auto;
}
}

&__filters-applied {
padding-top: 4px;
display: flex;
Expand Down
4 changes: 2 additions & 2 deletions dist/core-common.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-common.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/core-unified-search.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-unified-search.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions lib/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,7 @@
'OCP\\SabrePluginEvent' => $baseDir . '/lib/public/SabrePluginEvent.php',
'OCP\\SabrePluginException' => $baseDir . '/lib/public/SabrePluginException.php',
'OCP\\Search\\FilterDefinition' => $baseDir . '/lib/public/Search/FilterDefinition.php',
'OCP\\Search\\IExternalProvider' => $baseDir . '/lib/public/Search/IExternalProvider.php',
'OCP\\Search\\IFilter' => $baseDir . '/lib/public/Search/IFilter.php',
'OCP\\Search\\IFilterCollection' => $baseDir . '/lib/public/Search/IFilterCollection.php',
'OCP\\Search\\IFilteringProvider' => $baseDir . '/lib/public/Search/IFilteringProvider.php',
Expand Down
1 change: 1 addition & 0 deletions lib/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
'OCP\\SabrePluginEvent' => __DIR__ . '/../../..' . '/lib/public/SabrePluginEvent.php',
'OCP\\SabrePluginException' => __DIR__ . '/../../..' . '/lib/public/SabrePluginException.php',
'OCP\\Search\\FilterDefinition' => __DIR__ . '/../../..' . '/lib/public/Search/FilterDefinition.php',
'OCP\\Search\\IExternalProvider' => __DIR__ . '/../../..' . '/lib/public/Search/IExternalProvider.php',
'OCP\\Search\\IFilter' => __DIR__ . '/../../..' . '/lib/public/Search/IFilter.php',
'OCP\\Search\\IFilterCollection' => __DIR__ . '/../../..' . '/lib/public/Search/IFilterCollection.php',
'OCP\\Search\\IFilteringProvider' => __DIR__ . '/../../..' . '/lib/public/Search/IFilteringProvider.php',
Expand Down
3 changes: 3 additions & 0 deletions lib/private/Search/SearchComposer.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use OCP\IURLGenerator;
use OCP\IUser;
use OCP\Search\FilterDefinition;
use OCP\Search\IExternalProvider;
use OCP\Search\IFilter;
use OCP\Search\IFilteringProvider;
use OCP\Search\IInAppSearch;
Expand Down Expand Up @@ -178,6 +179,7 @@ function (array $providerData) use ($route, $routeParameters) {
if ($order === null) {
return;
}
$isExternalProvider = $provider instanceof IExternalProvider ? $provider->isExternalProvider() : false;
$triggers = [$provider->getId()];
if ($provider instanceof IFilteringProvider) {
$triggers += $provider->getAlternateIds();
Expand All @@ -192,6 +194,7 @@ function (array $providerData) use ($route, $routeParameters) {
'name' => $provider->getName(),
'icon' => $this->fetchIcon($appId, $provider->getId()),
'order' => $order,
'isExternalProvider' => $isExternalProvider,
'triggers' => array_values($triggers),
'filters' => $this->getFiltersType($filters, $provider->getId()),
'inAppSearch' => $provider instanceof IInAppSearch,
Expand Down
25 changes: 25 additions & 0 deletions lib/public/Search/IExternalProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCP\Search;

/**
* Interface for search providers that forward user queries to external services.
*
* @since 32.0.0
*/
interface IExternalProvider extends IProvider {
/**
* Indicates whether this search provider queries external (3rd-party) resources.
* This is used by the Unified Search modal filter (toggle switch). By default, searching through external providers is disabled.
*
* @return bool default false
*
* @since 32.0.0
*/
public function isExternalProvider(): bool;
}
4 changes: 4 additions & 0 deletions openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1083,6 +1083,7 @@
"name",
"icon",
"order",
"isExternalProvider",
"triggers",
"filters",
"inAppSearch"
Expand All @@ -1104,6 +1105,9 @@
"type": "integer",
"format": "int64"
},
"isExternalProvider": {
"type": "boolean"
},
"triggers": {
"type": "array",
"items": {
Expand Down
Loading