Search code examples
jiraevent-listenerjira-rest-apiatlassian-forgejira-forge

How to update Forge UI Issue Panel with JIRA Issue update event listener function?


We have created an Issue panel on JIRA issue view screen. What we need to render is a list of issue keys (which fetched by an API call).

This is how we define the Forge library manifest.yml file:

modules:
jira:issuePanel:
- key: dylan-hello-world-app-hello-world-panel
function: main
title: Forge App by Dylan
icon: https://developer.atlassian.com/platform/forge/images/icons/issue-panel-icon.svg
trigger:
- key: issue-updated-trigger
events:
- avi:jira:updated:issue
function: issue-trigger-func
function:
- key: main
handler: index.run
- key: issue-trigger-func
handler: index.issueUpdatedTrigger
app:
id: our cloud app id
name: dylan-hello-world-app
permissions:
scopes:
- read:jira-work

My run() function does the the rendering part of the panel (initial render).

The issueUpdateTrigger(event, context) function will be triggered when issue updated event happens. By default, this function will automatically received event and context parameters from JIRA.

In the issueUpdateTrigger, we would like to call API again by passing in context to retrieve new issue keys list and also update the context of our existing panel. May I know how can we perform the regarding actions?

(I think It is a must to expose both run() and issueUpdatedTrigger() functions in the index file, cause this is how Forge reads the function, and therefore these two functions might not be able to share a common ancestor function.)

Appreciate your help and do let me know if more information is needed :D


Solution

  • Based on your jira:issuePanel module having a function key and value, my answer assumes that you are using Forge's UI Kit and not Custom UI.

    With UI Kit, there is not a way to force a refresh of the UI component without a user click. The work around is to add a "Refresh" button that, when clicks, refreshes the component.

    You could use Custom UI to handle this situation, but that is a much more involved solution as you'd be responsible for building the UI (as opposed to using the components provided by Forge).

    You may also find other feedback and advice in the Atlassian Developer Community category specifically for Forge: https://community.developer.atlassian.com/c/forge/45