From 2a4465dc1bdce99f3628b14761741cb4cd9bd3b2 Mon Sep 17 00:00:00 2001 From: Benjamin Gaussorgues Date: Fri, 24 Nov 2023 17:00:50 +0100 Subject: [PATCH] feat(dav): hide search providers if their respective app is not activated Signed-off-by: Benjamin Gaussorgues --- apps/dav/lib/Search/ContactsSearchProvider.php | 9 +++++---- apps/dav/lib/Search/EventsSearchProvider.php | 9 +++++---- apps/dav/lib/Search/TasksSearchProvider.php | 9 +++++---- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/apps/dav/lib/Search/ContactsSearchProvider.php b/apps/dav/lib/Search/ContactsSearchProvider.php index 265f4958efb..2a0e70bf045 100644 --- a/apps/dav/lib/Search/ContactsSearchProvider.php +++ b/apps/dav/lib/Search/ContactsSearchProvider.php @@ -83,11 +83,12 @@ class ContactsSearchProvider implements IFilteringProvider { return $this->l10n->t('Contacts'); } - public function getOrder(string $route, array $routeParameters): int { - if ($route === 'contacts.Page.index') { - return -1; + public function getOrder(string $route, array $routeParameters): ?int { + if ($this->appManager->isEnabledForUser('contacts')) { + return $route === 'contacts.Page.index' ? -1 : 25; } - return 25; + + return null; } public function search(IUser $user, ISearchQuery $query): SearchResult { diff --git a/apps/dav/lib/Search/EventsSearchProvider.php b/apps/dav/lib/Search/EventsSearchProvider.php index 0cf01742672..dd87f486a1d 100644 --- a/apps/dav/lib/Search/EventsSearchProvider.php +++ b/apps/dav/lib/Search/EventsSearchProvider.php @@ -89,11 +89,12 @@ class EventsSearchProvider extends ACalendarSearchProvider implements IFiltering /** * @inheritDoc */ - public function getOrder(string $route, array $routeParameters): int { - if ($route === 'calendar.View.index') { - return -1; + public function getOrder(string $route, array $routeParameters): ?int { + if ($this->appManager->isEnabledForUser('calendar')) { + return $route === 'calendar.View.index' ? -1 : 30; } - return 30; + + return null; } /** diff --git a/apps/dav/lib/Search/TasksSearchProvider.php b/apps/dav/lib/Search/TasksSearchProvider.php index 91692ea1c2a..5cb64556457 100644 --- a/apps/dav/lib/Search/TasksSearchProvider.php +++ b/apps/dav/lib/Search/TasksSearchProvider.php @@ -77,11 +77,12 @@ class TasksSearchProvider extends ACalendarSearchProvider { /** * @inheritDoc */ - public function getOrder(string $route, array $routeParameters): int { - if ($route === 'tasks.Page.index') { - return -1; + public function getOrder(string $route, array $routeParameters): ?int { + if ($this->appManager->isEnabledForUser('tasks')) { + return $route === 'tasks.Page.index' ? -1 : 35; } - return 35; + + return null; } /** -- 2.39.5