mirror of
https://github.com/nextcloud/server.git
synced 2026-06-09 00:32:29 -04:00
Fix application search provider order
Signed-off-by: Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
This commit is contained in:
parent
eaaf954753
commit
8be988b645
1 changed files with 14 additions and 30 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue