summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVladimir Panteleev <github.private@thecybershadow.net>2018-04-08 18:08:19 +0200
committerDylan William Hardison <dylan@hardison.net>2018-04-08 18:08:19 +0200
commitf786d42447d8515d5fb2fdd821c2635f95cbe1bf (patch)
treeab76878be164064b73a6d4c52e271d927118e739
parent922c09396817fece1275365a474e5cbde6e1f99e (diff)
downloadbugzilla-f786d42447d8515d5fb2fdd821c2635f95cbe1bf.tar.gz
bugzilla-f786d42447d8515d5fb2fdd821c2635f95cbe1bf.tar.xz
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.
-rw-r--r--Bugzilla/Template.pm2
-rw-r--r--js/instant-search.js4
-rw-r--r--template/en/default/search/search-instant.html.tmpl8
3 files changed, 10 insertions, 4 deletions
diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm
index 3ace60cf8..20cdaa3ab 100644
--- a/Bugzilla/Template.pm
+++ b/Bugzilla/Template.pm
@@ -997,6 +997,8 @@ sub create {
'feature_enabled' => sub { return Bugzilla->feature(@_); },
+ 'has_extension' => sub { return Bugzilla->has_extension(@_); },
+
# field_descs can be somewhat slow to generate, so we generate
# it only once per-language no matter how many times
# $template->process() is called.
diff --git a/js/instant-search.js b/js/instant-search.js
index 6e8f104f2..183d5a3be 100644
--- a/js/instant-search.js
+++ b/js/instant-search.js
@@ -138,7 +138,7 @@ YAHOO.bugzilla.instantSearch = {
YAHOO.bugzilla.instantSearch.dataTable.showTableMessage(
'Searching...&nbsp;&nbsp;&nbsp;' +
- '<img src="extensions/GuidedBugEntry/web/images/throbber.gif"' +
+ '<img src="images/throbber.gif"' +
' width="16" height="11">',
YAHOO.widget.DataTable.CLASS_LOADING
);
@@ -191,7 +191,7 @@ YAHOO.bugzilla.instantSearch = {
var result = [];
var name = Dom.get('product').value;
result.push(name);
- if (products[name] && products[name].related) {
+ if (typeof products !== 'undefined' && products[name] && products[name].related) {
for (var i = 0, n = products[name].related.length; i < n; i++) {
result.push(products[name].related[i]);
}
diff --git a/template/en/default/search/search-instant.html.tmpl b/template/en/default/search/search-instant.html.tmpl
index d0cf078e7..ed3942166 100644
--- a/template/en/default/search/search-instant.html.tmpl
+++ b/template/en/default/search/search-instant.html.tmpl
@@ -8,11 +8,15 @@
[% PROCESS global/variables.none.tmpl %]
+[% javascript_urls = [ 'js/instant-search.js' ] %]
+[% IF has_extension('GuidedBugEntry') %]
+ [% javascript_urls.import(['extensions/GuidedBugEntry/web/js/products.js']); %]
+[% END %]
+
[% PROCESS global/header.html.tmpl
title = "Instant Search"
generate_api_token = 1
- javascript_urls = [ 'extensions/GuidedBugEntry/web/js/products.js',
- 'js/instant-search.js', ]
+ javascript_urls = javascript_urls
%]
[% UNLESS default.exists('product') && default.product.size %]