From bdb6f3ae887e4aae209c67ac2c8749498223ee58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Sevilla=20Mart=C3=ADn?= Date: Sun, 19 Aug 2018 17:43:49 -0400 Subject: [PATCH] Add a permission check to the Search sources (#1527) --- framework/core/js/src/forum/ForumApplication.js | 2 +- framework/core/js/src/forum/components/Search.js | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/framework/core/js/src/forum/ForumApplication.js b/framework/core/js/src/forum/ForumApplication.js index 34d685843..2e52abb1d 100644 --- a/framework/core/js/src/forum/ForumApplication.js +++ b/framework/core/js/src/forum/ForumApplication.js @@ -37,7 +37,7 @@ export default class ForumApplication extends Application { /** * The page's search component instance. * - * @type {SearchBox} + * @type {Search} */ search = new Search(); diff --git a/framework/core/js/src/forum/components/Search.js b/framework/core/js/src/forum/components/Search.js index 896c50e48..ea1fefb56 100644 --- a/framework/core/js/src/forum/components/Search.js +++ b/framework/core/js/src/forum/components/Search.js @@ -38,7 +38,7 @@ export default class Search extends Component { * * @type {SearchSource[]} */ - this.sources = this.sourceItems().toArray(); + this.sources = null; /** * The number of sources that are still loading results. @@ -74,6 +74,15 @@ export default class Search extends Component { this.value(currentSearch || ''); } + // Initialize search sources in the view rather than the constructor so + // that we have access to app.forum. + if (!this.sources) { + this.sources = this.sourceItems().toArray(); + } + + // Hide the search view if no sources were loaded + if (!this.sources.length) return
; + return (