diff options
author | Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com> | 2023-11-14 09:47:37 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-14 09:47:37 +0100 |
commit | bb82119a63d0a5da855417e72aa0adb7d91d46e8 (patch) | |
tree | a498be5bb7a95dac3732b766aef75517a8a0777b /apps | |
parent | 0e406d9d8bc2b114966c3b0a3122ebc2a19b0ec7 (diff) | |
parent | 8be988b645a9be818be37fa45e369924e779949e (diff) | |
download | nextcloud-server-bb82119a63d0a5da855417e72aa0adb7d91d46e8.tar.gz nextcloud-server-bb82119a63d0a5da855417e72aa0adb7d91d46e8.zip |
Merge pull request #41413 from nextcloud/fix/setting-app-order
Fix apps search provider order
Diffstat (limited to 'apps')
-rw-r--r-- | apps/settings/lib/Search/AppSearch.php | 44 |
1 files changed, 14 insertions, 30 deletions
diff --git a/apps/settings/lib/Search/AppSearch.php b/apps/settings/lib/Search/AppSearch.php index d4735f1c744..6ef0049954c 100644 --- a/apps/settings/lib/Search/AppSearch.php +++ b/apps/settings/lib/Search/AppSearch.php @@ -34,51 +34,38 @@ use OCP\Search\SearchResult; use OCP\Search\SearchResultEntry; class AppSearch implements IProvider { - - /** @var INavigationManager */ - protected $navigationManager; - - /** @var IL10N */ - protected $l; - - public function __construct(INavigationManager $navigationManager, - IL10N $l) { - $this->navigationManager = $navigationManager; - $this->l = $l; + public function __construct( + protected INavigationManager $navigationManager, + protected IL10N $l, + ) { } - /** - * @inheritDoc - */ public function getId(): string { return 'settings_apps'; } - /** - * @inheritDoc - */ public function getName(): string { return $this->l->t('Apps'); } - /** - * @inheritDoc - */ public function getOrder(string $route, array $routeParameters): int { - return -50; + return $route === 'settings.AppSettings.viewApps' ? -50 : 100; } - /** - * @inheritDoc - */ public function search(IUser $user, ISearchQuery $query): SearchResult { $entries = $this->navigationManager->getAll('all'); + $searchTitle = $this->l->t('Apps'); + $term = $query->getFilter('term')?->get(); + if (empty($term)) { + return SearchResult::complete($searchTitle, []); + } + $result = []; foreach ($entries as $entry) { if ( - stripos($entry['name'], $query->getTerm()) === false && - stripos($entry['id'], $query->getTerm()) === false + stripos($entry['name'], $term) === false && + stripos($entry['id'], $term) === false ) { continue; } @@ -102,9 +89,6 @@ class AppSearch implements IProvider { ); } - return SearchResult::complete( - $this->l->t('Apps'), - $result - ); + return SearchResult::complete($searchTitle, $result); } } |