From cd24eac5b0b4eadb9420c903fc958d4e01ee975f Mon Sep 17 00:00:00 2001 From: fenn-cs Date: Thu, 9 Nov 2023 17:46:37 +0100 Subject: [PATCH] Add unified search toggle in config The new global search UI is new and might be unstable, hence we are giving users the option to use the old unified search UI, if the encounter signficant bottlenecks. Signed-off-by: fenn-cs Signed-off-by: nextcloud-command --- config/config.sample.php | 7 +++++++ lib/private/TemplateLayout.php | 18 ++++++++++++------ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/config/config.sample.php b/config/config.sample.php index 9043dbd00aa35..ab86feedb8520 100644 --- a/config/config.sample.php +++ b/config/config.sample.php @@ -2395,4 +2395,11 @@ * Defaults to ``true`` */ 'reference_opengraph' => true, + +/** + * Enable use of old unified search + * + * Defaults to ``false`` + */ +'unified_search.enabled' => false, ]; diff --git a/lib/private/TemplateLayout.php b/lib/private/TemplateLayout.php index 90ca935974074..011597e6c29c5 100644 --- a/lib/private/TemplateLayout.php +++ b/lib/private/TemplateLayout.php @@ -106,12 +106,18 @@ public function __construct($renderAs, $appId = '') { $this->initialState->provideInitialState('core', 'active-app', $this->navigationManager->getActiveEntry()); $this->initialState->provideInitialState('core', 'apps', $this->navigationManager->getAll()); - $this->initialState->provideInitialState('unified-search', 'limit-default', (int)$this->config->getAppValue('core', 'unified-search.limit-default', (string)SearchQuery::LIMIT_DEFAULT)); - $this->initialState->provideInitialState('unified-search', 'min-search-length', (int)$this->config->getAppValue('core', 'unified-search.min-search-length', (string)1)); - $this->initialState->provideInitialState('unified-search', 'live-search', $this->config->getAppValue('core', 'unified-search.live-search', 'yes') === 'yes'); - Util::addScript('core', 'unified-search', 'core'); - Util::addScript('core', 'global-search', 'core'); - + /* + * NB : Unified search enabled, defaults to true since new advanced search is + * unstable. Once we think otherwise, the default should be false. + */ + if ($this->config->getSystemValueBool('unified_search.enabled', true)) { + $this->initialState->provideInitialState('unified-search', 'limit-default', (int)$this->config->getAppValue('core', 'unified-search.limit-default', (string)SearchQuery::LIMIT_DEFAULT)); + $this->initialState->provideInitialState('unified-search', 'min-search-length', (int)$this->config->getAppValue('core', 'unified-search.min-search-length', (string)1)); + $this->initialState->provideInitialState('unified-search', 'live-search', $this->config->getAppValue('core', 'unified-search.live-search', 'yes') === 'yes'); + Util::addScript('core', 'unified-search', 'core'); + } else { + Util::addScript('core', 'global-search', 'core'); + } // Set body data-theme $this->assign('enabledThemes', []); if (\OC::$server->getAppManager()->isEnabledForUser('theming') && class_exists('\OCA\Theming\Service\ThemesService')) {