summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorBenjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>2023-11-22 09:49:46 +0100
committerGitHub <noreply@github.com>2023-11-22 09:49:46 +0100
commitba1af2b22e5409c62ea2bdf7eb0e13c282ed70e8 (patch)
tree6e2826a26cee6632d2178b5cba9cd4a102056274 /lib
parentf79398c55d74a8ea2fbd95ac3dbd00ad90dfb218 (diff)
parent0d8aa6894afa13e053e6a4c9e283b80d04a26ebd (diff)
downloadnextcloud-server-ba1af2b22e5409c62ea2bdf7eb0e13c282ed70e8.tar.gz
nextcloud-server-ba1af2b22e5409c62ea2bdf7eb0e13c282ed70e8.zip
Merge pull request #41646 from nextcloud/feat/hide-search-provider
feat(search): hide search provider from list
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Search/SearchComposer.php7
-rw-r--r--lib/public/Search/IProvider.php6
2 files changed, 10 insertions, 3 deletions
diff --git a/lib/private/Search/SearchComposer.php b/lib/private/Search/SearchComposer.php
index b20d47aa94e..22da362bf40 100644
--- a/lib/private/Search/SearchComposer.php
+++ b/lib/private/Search/SearchComposer.php
@@ -184,6 +184,10 @@ class SearchComposer {
function (array $providerData) use ($route, $routeParameters) {
$appId = $providerData['appId'];
$provider = $providerData['provider'];
+ $order = $provider->getOrder($route, $routeParameters);
+ if ($order === null) {
+ return;
+ }
$triggers = [$provider->getId()];
if ($provider instanceof IFilteringProvider) {
$triggers += $provider->getAlternateIds();
@@ -197,7 +201,7 @@ class SearchComposer {
'appId' => $appId,
'name' => $provider->getName(),
'icon' => $this->fetchIcon($appId, $provider->getId()),
- 'order' => $provider->getOrder($route, $routeParameters),
+ 'order' => $order,
'triggers' => $triggers,
'filters' => $this->getFiltersType($filters, $provider->getId()),
'inAppSearch' => $provider instanceof IInAppSearch,
@@ -205,6 +209,7 @@ class SearchComposer {
},
$this->providers,
);
+ $providers = array_filter($providers);
// Sort providers by order and strip associative keys
usort($providers, function ($provider1, $provider2) {
diff --git a/lib/public/Search/IProvider.php b/lib/public/Search/IProvider.php
index 61655c47367..95d7a1b163a 100644
--- a/lib/public/Search/IProvider.php
+++ b/lib/public/Search/IProvider.php
@@ -68,15 +68,17 @@ interface IProvider {
/**
* Get the search provider order
* The lower the int, the higher it will be sorted (0 will be before 10)
+ * If null, the search provider will be hidden in the UI and the API not called
*
* @param string $route the route the user is currently at, e.g. files.view.index
* @param array $routeParameters the parameters of the route the user is currently at, e.g. [fileId = 982, dir = "/"]
*
- * @return int
+ * @return int|null
*
* @since 20.0.0
+ * @since 28.0.0 Can return null
*/
- public function getOrder(string $route, array $routeParameters): int;
+ public function getOrder(string $route, array $routeParameters): ?int;
/**
* Find matching search entries in an app