Skip to content

Commit 5d52f38

Browse files
bugclerkMrt134
andauthored
PD-2440 / 24.10 / PD-2440 - TrueNAS UI search redirect (by Mrt134) (#4297)
* PD-2440: Update search modal to catch incoming queries from the TrueNAS UI (cherry picked from commit ab0fe13) * PD-2440: update global search docs image Removed placeholder note in text (cherry picked from commit 2714a96) --------- Co-authored-by: Tim Moore <[email protected]>
1 parent 0cc2b11 commit 5d52f38

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed
117 KB
Loading

static/includes/UsingGlobalSearch.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ TrueNAS SCALE indicates the selected element with a glowing blue outline.
3535
Click **Search Documentation for <<*query*>>** to redirect the search to the TrueNAS Documentation Hub.
3636
TrueNAS SCALE opens a new browser tab to display documentation search results for the query.
3737

38-
<!-- Update image with results from the 24.10 branch, after branching for 24.10 has been completed and the redirect is updated away from master/nightlies-->
3938
{{< trueimage src="/images/SCALE/Dashboard/GlobalSearchDocs.png" alt="Search Documentation Results" id="Search Documentation Results" style="border:1px solid #0095d5" >}}
4039

4140
Use this option to search for tutorials and UI reference documentation for the feature, or to look for further information when the entered search term does not find any matching UI elements.

static/js/search-multi-site.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ class MultiSiteSearch {
102102
this.performSearch = this.performSearch.bind(this);
103103
this.loadMoreResults = this.loadMoreResults.bind(this);
104104
this.updateSearchIcon = this.updateSearchIcon.bind(this);
105+
this.checkUrlQueryParameter = this.checkUrlQueryParameter.bind(this);
105106

106107
this.init();
107108
}
@@ -238,6 +239,39 @@ class MultiSiteSearch {
238239
} catch (error) {
239240
// Could not pre-load docs index
240241
}
242+
243+
// Check for URL query parameter and auto-execute search
244+
this.checkUrlQueryParameter();
245+
}
246+
247+
checkUrlQueryParameter() {
248+
// Parse URL query parameters
249+
const urlParams = new URLSearchParams(window.location.search);
250+
const queryParam = urlParams.get('query');
251+
252+
if (queryParam && queryParam.trim() !== '') {
253+
// Check if we're on the /search/ path and redirect to homepage with query
254+
const currentPath = window.location.pathname;
255+
if (currentPath === '/search/' || currentPath === '/search') {
256+
// Redirect to homepage with query parameter preserved
257+
window.location.href = `/${window.location.search}`;
258+
return;
259+
}
260+
261+
// Open the modal
262+
this.openModal();
263+
264+
// Set the search input value
265+
const searchInput = document.getElementById('search-input-enhanced');
266+
if (searchInput) {
267+
searchInput.value = queryParam.trim();
268+
}
269+
270+
// Wait a short moment for modal to fully render, then perform search
271+
setTimeout(() => {
272+
this.performSearch();
273+
}, 200);
274+
}
241275
}
242276

243277
async loadIndex(siteKey) {

0 commit comments

Comments
 (0)