js: Don't attempt to set bug, PDF links without configuration
Generating both the bug link and PDF download link requires some configuration in 'conf.py': specifically, the 'openstack_bug_project' and 'openstack_pdf_link' config options must be set. If these are not present, the template doesn't include the relevant tags, which means attempts to look these up via 'getElementById' will return 'null', causing ugly tracebacks like so in the console. Uncaught ReferenceError: bugProject is not defined <anonymous> http://localhost:8000/search.html?q=usage:395 Simply surround these blocks with the same conditionals as the template, avoiding the issue entirely. Change-Id: I08ef0fc6c7ebd2c0e7ba89bc42cc92176fec8ab8 Signed-off-by: Stephen Finucane <sfinucan@redhat.com> Closes-Bug: #1896607
This commit is contained in:
parent
6876b7276b
commit
8e6b9c5244
|
@ -34,6 +34,7 @@
|
|||
build time and the project's launchpad bug tag. Set the HREF of the bug
|
||||
buttons */
|
||||
|
||||
{%- if bug_project %}
|
||||
var lineFeed = "%0A";
|
||||
var gitURL = "Source: Can't derive source file URL";
|
||||
|
||||
|
@ -52,9 +53,7 @@
|
|||
/* gitsha, project and bug_tag rely on variables in conf.py */
|
||||
var gitSha = "SHA: {{ gitsha }}";
|
||||
var repositoryName = "{{ repository_name }}";
|
||||
{%- if bug_project %}
|
||||
var bugProject = "{{ bug_project }}";
|
||||
{%- endif %}
|
||||
var bugProject = "{{ bug_project }}";
|
||||
{%- if bug_title %}
|
||||
var bugTitle = "{{ bug_title }}";
|
||||
{%- else %}
|
||||
|
@ -78,8 +77,11 @@
|
|||
lineFeed + encodeURI(gitURL) ;
|
||||
|
||||
logABug(bugTitle, bugProject, fieldComment, fieldTags, repositoryName, useStoryboard);
|
||||
{%- endif %}
|
||||
|
||||
{%- if pdf_link %}
|
||||
var currentSourceFile = "{{ pagename }}";
|
||||
var pdfFileName = "{{ pdf_filename }}";
|
||||
pdfLink(currentSourceFile, pdfFileName);
|
||||
{%- endif %}
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue