Uploaded image for project: 'Jira Cloud'
  1. Jira Cloud
  2. JRACLOUD-60715

issue collector script wont run as embedded javascript in "strict" mode

    XMLWordPrintable

Details

    Description

      NOTE: This bug report is for JIRA Cloud. Using JIRA Server? See the corresponding bug report.

      I was trying to use the issue collector with a custom trigger as embedded javascript (not html).
      However it failed to Pop Up the bug reporter dialogue form.

      It did work as HTML added to my page.

      On investigation I found out that the script downloaded was not in "strict" mode. Because the javascript file I was embedding it in was in strict mode it failed. (my build system uses webpack to bundle all my js). The problem was the the script downloaded to my page referenced a variable called "hideDialog" and this variable is not prefixed by the "var" keyword which failed strict mode.

      I fixed it locally by manually downloading the javascript referred to in the embeddable snippet ie
      https://avocadoconsulting.atlassian.net/s/e8998266a22de47600f7a8650aafb214-T/hdpdpv/72002/b6b48b2829824b869586ac216d119363/2.0.13/_/download/batch/com.atlassian.jira.collector.plugin.jira-issue-collector-plugin:issuecollector-embededjs/com.atlassian.jira.collector.plugin.jira-issue-collector-plugin:issuecollector-embededjs.js?locale=en-UK&collectorId=f4742d98

      I added the "var" keyword in front of the "hideDialog" variable at that URL where it is defining a function, it at the declaration of "hideDialog" not at its usages.

      I then modified the "url" reference in the JQuery ajax call given in the embeddable JavaScript (see below) to call my file rather than your URL... it then worked fine

      I assume that the fix for you is to place "use strict;" in your source file and put "var" in front of "hideDialog" in its declaration.

      Cheers

      Karl Roberts
      karl.roberts@owtelse.com
      karl.roberts@avocadoconsulting.com.au

      FYI the embedded javascript code I received from Jira's issue collector page is below.

      // Requires jQuery!
      jQuery.ajax({
      url: "https://avocadoconsulting.atlassian.net/s/e8998266a22de47600f7a8650aafb214-T/hdpdpv/72002/b6b48b2829824b869586ac216d119363/2.0.13/_/download/batch/com.atlassian.jira.collector.plugin.jira-issue-collector-plugin:issuecollector-embededjs/com.atlassian.jira.collector.plugin.jira-issue-collector-plugin:issuecollector-embededjs.js?locale=en-UK&collectorId=f4742d98",
      type: "get",
      cache: true,
      dataType: "script"
      });

      window.ATL_JQ_PAGE_PROPS = {
      "triggerFunction": function(showCollectorDialog) {
      //Requires that jQuery is available!
      jQuery("#myCustomTrigger").click(function(e)

      { e.preventDefault(); showCollectorDialog(); }

      );
      }};

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              6cd2822cd670 Karl Roberts
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - 0.5h
                  0.5h
                  Remaining:
                  Remaining Estimate - 0.5h
                  0.5h
                  Logged:
                  Time Spent - Not Specified
                  Not Specified