diff options
author | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2020-08-03 12:54:37 +0200 |
---|---|---|
committer | npmbuildbot[bot] <npmbuildbot[bot]@users.noreply.github.com> | 2020-08-03 11:26:03 +0000 |
commit | 1a1b3e20e470a945dd9f5fab1d99174b10cbb141 (patch) | |
tree | aacff8872bcfd47685e9a9fb3e5e3a423e498f59 /lib | |
parent | 4987fe9a51f0b889d2b99428c967014d95bb13ae (diff) | |
download | nextcloud-server-1a1b3e20e470a945dd9f5fab1d99174b10cbb141.tar.gz nextcloud-server-1a1b3e20e470a945dd9f5fab1d99174b10cbb141.zip |
Fix unified search
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Signed-off-by: npmbuildbot[bot] <npmbuildbot[bot]@users.noreply.github.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Search/SearchComposer.php | 9 | ||||
-rw-r--r-- | lib/private/Search/SearchQuery.php | 2 | ||||
-rw-r--r-- | lib/private/TemplateLayout.php | 31 | ||||
-rw-r--r-- | lib/public/Search/ASearchResultEntry.php | 22 | ||||
-rw-r--r-- | lib/public/Search/IProvider.php | 11 |
5 files changed, 58 insertions, 17 deletions
diff --git a/lib/private/Search/SearchComposer.php b/lib/private/Search/SearchComposer.php index 61bbbbc969b..dd4edfc5f40 100644 --- a/lib/private/Search/SearchComposer.php +++ b/lib/private/Search/SearchComposer.php @@ -106,9 +106,9 @@ class SearchComposer { } /** - * Get a list of all provider IDs for the consecutive calls to `search` + * Get a list of all provider IDs & Names for the consecutive calls to `search` * - * @return string[] + * @return array */ public function getProviders(): array { $this->loadLazyProviders(); @@ -118,7 +118,10 @@ class SearchComposer { */ return array_values( array_map(function (IProvider $provider) { - return $provider->getId(); + return [ + 'id' => $provider->getId(), + 'name' => $provider->getName() + ]; }, $this->providers)); } diff --git a/lib/private/Search/SearchQuery.php b/lib/private/Search/SearchQuery.php index 2ed31fed441..186b4ccf18f 100644 --- a/lib/private/Search/SearchQuery.php +++ b/lib/private/Search/SearchQuery.php @@ -28,7 +28,7 @@ namespace OC\Search; use OCP\Search\ISearchQuery; class SearchQuery implements ISearchQuery { - public const LIMIT_DEFAULT = 20; + public const LIMIT_DEFAULT = 5; /** @var string */ private $term; diff --git a/lib/private/TemplateLayout.php b/lib/private/TemplateLayout.php index 69eb26ab8b2..87a4d7badc1 100644 --- a/lib/private/TemplateLayout.php +++ b/lib/private/TemplateLayout.php @@ -44,34 +44,40 @@ namespace OC; -use OC\AppFramework\Http\Request; +use OC\Search\SearchQuery; use OC\Template\JSCombiner; use OC\Template\JSConfigHelper; use OC\Template\SCSSCacher; use OCP\AppFramework\Http\TemplateResponse; use OCP\Defaults; +use OCP\IConfig; use OCP\IInitialStateService; use OCP\Support\Subscription\IRegistry; +use OCP\Util; class TemplateLayout extends \OC_Template { private static $versionHash = ''; - /** - * @var \OCP\IConfig - */ + /** @var IConfig */ private $config; + /** @var IInitialStateService */ + private $initialState; + /** * @param string $renderAs * @param string $appId application id */ public function __construct($renderAs, $appId = '') { - // yes - should be injected .... - $this->config = \OC::$server->getConfig(); + /** @var IConfig */ + $this->config = \OC::$server->get(IConfig::class); - if (\OCP\Util::isIE()) { - \OC_Util::addStyle('ie'); + /** @var IInitialStateService */ + $this->initialState = \OC::$server->get(InitialStateService::class); + + if (Util::isIE()) { + Util::addStyle('ie'); } // Decide which page we show @@ -83,6 +89,9 @@ class TemplateLayout extends \OC_Template { $this->assign('bodyid', 'body-user'); } + $this->initialState->provideInitialState('unified-search', 'limit-default', SearchQuery::LIMIT_DEFAULT); + Util::addScript('dist/unified-search', null, true); + // Add navigation entry $this->assign('application', ''); $this->assign('appid', $appId); @@ -240,10 +249,8 @@ class TemplateLayout extends \OC_Template { } } } - - /** @var InitialStateService $initialState */ - $initialState = \OC::$server->query(InitialStateService::class); - $this->assign('initialStates', $initialState->getInitialStates()); + + $this->assign('initialStates', $this->initialState->getInitialStates()); } /** diff --git a/lib/public/Search/ASearchResultEntry.php b/lib/public/Search/ASearchResultEntry.php index 45d62525abd..584ae79de4d 100644 --- a/lib/public/Search/ASearchResultEntry.php +++ b/lib/public/Search/ASearchResultEntry.php @@ -69,21 +69,39 @@ abstract class ASearchResultEntry implements JsonSerializable { protected $resourceUrl; /** + * @var string + * @since 20.0.0 + */ + protected $iconClass; + + /** + * @var boolean + * @since 20.0.0 + */ + protected $rounded; + + /** * @param string $thumbnailUrl a relative or absolute URL to the thumbnail or icon of the entry * @param string $title a main title of the entry * @param string $subline the secondary line of the entry * @param string $resourceUrl the URL where the user can find the detail, like a deep link inside the app + * @param string $iconClass the icon class fallback + * @param boolean $rounded is the thumbnail rounded * * @since 20.0.0 */ public function __construct(string $thumbnailUrl, string $title, string $subline, - string $resourceUrl) { + string $resourceUrl, + string $iconClass = '', + bool $rounded = false) { $this->thumbnailUrl = $thumbnailUrl; $this->title = $title; $this->subline = $subline; $this->resourceUrl = $resourceUrl; + $this->iconClass = $iconClass; + $this->rounded = $rounded; } /** @@ -97,6 +115,8 @@ abstract class ASearchResultEntry implements JsonSerializable { 'title' => $this->title, 'subline' => $this->subline, 'resourceUrl' => $this->resourceUrl, + 'iconClass' => $this->iconClass, + 'rounded' => $this->rounded, ]; } } diff --git a/lib/public/Search/IProvider.php b/lib/public/Search/IProvider.php index 080f5089f1f..bdff0a66e0e 100644 --- a/lib/public/Search/IProvider.php +++ b/lib/public/Search/IProvider.php @@ -54,6 +54,17 @@ interface IProvider { public function getId(): string; /** + * Get the translated name of this search provider + * + * Example: 'Mail', 'Contacts'... + * + * @return string + * + * @since 20.0.0 + */ + public function getName(): string; + + /** * Find matching search entries in an app * * Search results can either be a complete list of all the matches the app can |