Today I was playing around with a JSM Forge app.
At some point I decided that I wanted the jiraServiceManagement:portalHeader
only to show on the help_center
and the my_requests
page.
The help_center
is the “home page” where all the available portals are available, it can be accessed at https://<site>.atlassian.net/servicedesk/customer/portals
.
It looks like this:
The my_requests
page is the one that opens when clicking on the “Requests” button in the top right corner with the https://<site>.atlassian.net/servicedesk/customer/user/requests?page=1&statuses=open
URL.
How to show the module on certain pages only
The Jira Service Management portal header documentation explains that a pages
property in the manifest.yml
is available to restrict where the module is displayed.
And here is my example:
jiraServiceManagement:portalHeader:
- key: forge-jsm-portal-panel
function: main
pages:
- help_center
- my_requests
- portal
How to identify which page to use?
A good option to identify which page to specify in the manifest.yml file is to check the context when loading the app and check the output in the forge tunnel
when opening the various Jira Service Management pages:
const App = () => {
const context = useProductContext();
console.log(context);
The parameter to look for is the extensionContext.page
.
When opening the two pages above with a test app, you’ll find the following in the logs:
#help_center
extensionContext: { page: 'help_center', type: 'jiraServiceManagement:portalHeader' }
# my_requests case
extensionContext: { page: 'my_requests', type: 'jiraServiceManagement:portalHeader' }
I got an error
Last but not least, if you get an error saying saying should be array
make sure that each page is on its own line with a -
before it. This is because the pages
are expected to be defined as arrays.
At some point I had them defined as pages: help_center, my_requests
(don’t ask me why) and got this error:
error jiraServiceManagement:portalHeader property pages 'help_center, my_requests' should be array valid-document-required
Cheers,
Caterina