What happens to `atl.jira.view.issue.right.context` when Jira Issue Context Panel is released?

I’m currently using the atl.jira.view.issue.right.context web panel location for collecting analytics data on issue screens here.

This web panel location renders as an issue glance, so when the issue screen loads, the issue glance is closed, but an invisible iframe is still loaded where my logic happily sits.

When issue glances are replaced by the new issue context modules, I believe that nothing will load until the context panel is expanded, therefore my app will likely stop working when this feature is rolled out – as the iframe will not be loaded unless the context panel is expanded.

When issue glances were rolled out, the atl.jira.view.issue.right.context web panel location was said to be deprecated and you should move to issue glances. What actually happened is that the atl.jira.view.issue.right.context location seamlessly just became an issue glance.

Questions:

  • What will happen to the atl.jira.view.issue.right.context web panel location when issue context modules are rolled out?
  • Will my app still load the invisible iframe when the issue is loaded?

Cc: @AhmudAuleear

1 Like

Hi @david ,

I will try to get some help with this, but on the topic of relying on your code running when the issue is loaded, have you thought about using the Background Script module?

Regards,
Dugald

2 Likes

Thanks @dmorrow, I was unaware of that, so I’ll go and explore it further.

@dmorrow It looks like the background script module should work for me.

The documentation on jiraBackgroundScripts is very light on the ground, so here’s what I’ve learned…

In atlassian-connect.json, don’t add any request parameters on the URL as it will not load:

    "jiraBackgroundScripts": [
      {
        "url": "/background-script-bad?x=y", // ❌ with request parameters here, it won't load  
        "location": {
          "type": "issue_view",
          "shouldReloadOnRefresh": true
        },
        "key": "background-script-bad"
      },
	  
      {
        "url": "/background",    // ✅ no request parameters here, it will load  
        "location": {
          "type": "issue_view",
          "shouldReloadOnRefresh": true
        },
        "key": "background-script-good"
      }
    ],

You’ll need to add a route with no security/no JWT for the background script.

No security you say? That’s rather counterintuitive, but hey, lets go!

If you’re using Atlassian Connect Express (ACE):

  app.get("/background", 
  	[], // no security here - no JWT so that the page is "cachable"
	async (req, res) => {

	// ❌ cannot get at app settings, because no access to clientKey
    const appSettings = await addon.settings.get("appSettings", req.context.clientKey);

    res.render("background.hbs", {});
  });

Then in the background script, you can get the context and the JWT token

  AP.context.getContext((response) => {
    console.log("response", response);
    // { jira: { issue: ..., project: ... }, license: { active: true } }
  });
  AP.context.getToken((token) => {
    console.log("JWT token string", token);
  });

You’ll then need to add a route to collect any configuration from your app and secure is with addon.checkValidToken() (still using ACE) e.g.

// in /routes/index.js or similar

  app.get("/rest/settings", [addon.checkValidToken()], async (req, res) => {
    const appSettings = await addon.settings.get("appSettings", req.context.clientKey);
    res.json(appSettings);
  });

Now you’ll be able to access the config from your background page and perform some goodness

  AP.context.getToken((token) => {
    fetch(`/rest/settings?jwt=${token}`)
      .then((response) => response.json())
      .then(appSettings => {
        console.log("appSettings", appSettings);
        // your logic based on appSettings goes here 🙃
      });
  });
4 Likes

Hi @david,

  • The behaviour for the web panel module will stay the same, which means the atl.jira.view.issue.right.context location will still show up as a glance panel, and not a issue context panel. So 6 months after the release of the issue context panel, the atl.jira.view.issue.right.context web panel will be deprecated along with the glance panel.
  • Your app will only be loaded when the panel is expanded and it will stay loaded once it’s loaded. @dmorrow is right. The background script module can be used to preserve your app functionality.

Hope that helps.
Regards,
Tina

1 Like