Skip to content

Commit f8db696

Browse files
committed
Bug 1446236 - Fix instant search without GuidedBugEntry (#38)
* instant-search.js: Don't fail if product map isn't loaded getProduct had a hard dependency on the 'products' object, which is provided by products.js from the GuidedBugEntry extension. Check if the products variable exists before attempting to use it. This can happen when loading products.js fails, which in turn can happen when the GuidedBugEntry extension isn't present. * Instant search: Don't load products.js without GuidedBugEntry Fixes a 404 if the GuidedBugEntry extension is not present. * instant-search.js: Use throbber.gif from core Fixes remaining dependency on GuidedBugEntry.
1 parent 43c1f45 commit f8db696

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

Bugzilla/Template.pm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,6 +1058,8 @@ sub create {
10581058

10591059
'feature_enabled' => sub { return Bugzilla->feature(@_); },
10601060

1061+
'has_extension' => sub { return Bugzilla->has_extension(@_); },
1062+
10611063
# field_descs can be somewhat slow to generate, so we generate
10621064
# it only once per-language no matter how many times
10631065
# $template->process() is called.

js/instant-search.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ YAHOO.bugzilla.instantSearch = {
108108

109109
YAHOO.bugzilla.instantSearch.dataTable.showTableMessage(
110110
'Searching...   ' +
111-
`<img src="${BUGZILLA.config.basepath}extensions/GuidedBugEntry/web/images/throbber.gif"` +
111+
'<img src="images/throbber.gif"' +
112112
' width="16" height="11">',
113113
YAHOO.widget.DataTable.CLASS_LOADING
114114
);
@@ -150,7 +150,7 @@ YAHOO.bugzilla.instantSearch = {
150150
var result = [];
151151
var name = Dom.get('product').value;
152152
result.push(name);
153-
if (products[name] && products[name].related) {
153+
if (typeof products !== 'undefined' && products[name] && products[name].related) {
154154
for (var i = 0, n = products[name].related.length; i < n; i++) {
155155
result.push(products[name].related[i]);
156156
}

template/en/default/search/search-instant.html.tmpl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,15 @@
88

99
[% PROCESS global/variables.none.tmpl %]
1010

11+
[% javascript_urls = [ 'js/instant-search.js' ] %]
12+
[% IF has_extension('GuidedBugEntry') %]
13+
[% javascript_urls.import(['extensions/GuidedBugEntry/web/js/products.js']); %]
14+
[% END %]
15+
1116
[% PROCESS global/header.html.tmpl
1217
title = "Instant Search"
1318
generate_api_token = 1
14-
javascript_urls = [ 'extensions/GuidedBugEntry/web/js/products.js',
15-
'js/instant-search.js', ]
19+
javascript_urls = javascript_urls
1620
%]
1721

1822
[% UNLESS default.exists('product') && default.product.size %]

0 commit comments

Comments
 (0)