Rate this page:
This section describes how to use tools in the UI kit, including UI kit components.
You'll use these components to build dynamic and interactive interfaces for your app's front end. When your app is complete, you'll learn
how to continue monitoring the Forge environment using the forge logs
command.
This is part 3 of 3 in this tutorial. Complete Part 2: Call a Jira Service Management API before working on this page.
The hello world app contains a single Text
component that displays 'Hello world!' in a Jira Service Management QueuePage app. In the UI kit,
this is represented by <Text>Hello world!</Text>
.
You’ll update the component to display the number of queues on a service desk project.
When using multiple UI kit components, you must wrap them in a
Fragment block because a function can
only return one top-level component. In the example below Fragment
acts as a wrapper
for the other UI kit components.
Start the tunnel by running:
1 2forge tunnel
Navigate to the src
directory and open the index.jsx
file.
Inside the Fragment
tag, add the following code after the first Text
component:
1 2<Text> Number of queues : {queues.length} </Text>
Refresh the Jira Service Management queues view.
Your index.jsx
file should look like the following:
1 2import ForgeUI, { render, Fragment, QueuePage, Text, useProductContext, useState } from "@forge/ui"; import api, {route} from "@forge/api"; /** * This fetches the list of queues from the jsm */ const getJsmQueues = async (serviceDeskId) => { const res = await api .asUser() .requestJira( route`/rest/servicedeskapi/servicedesk/${serviceDeskId}/queue` ); const data = await res.json(); return data.values; }; const App = () => { console.log(JSON.stringify(useProductContext())); const context = useProductContext(); const [queues] = useState(async () => await getJsmQueues(context.extensionContext.project.key)); return ( <Fragment> <Text> Hello World! </Text> <Text> Number of queues : {queues.length} </Text> </Fragment> ); }; export const run = render(<QueuePage><App/></QueuePage>);
The app displays the number of queues in the queue page app in Jira Service Management. Add more queues and refresh the page to count them in your app. Your queue page app should look like the following:
After confirming the app works locally, deploy the app so that it continues to work when you close the tunnel.
Close your tunnel by pressing Ctrl+C.
Deploy your app by running:
1 2forge deploy
Refresh the page where your app is installed.
After you deploy your app, run the forge logs
command to view app events. Logs are processed after deployment, so you may need to wait a moment before running the command.
To view the new logs in your development environment, run:
1 2forge logs
Your logs should look something like the following:
1 2INFO 2020-03-19T04:32:29.689Z 91be7233-f758-40f6-ae9d-478bfb9a12e2 Number of queues : 4
Your logs are an important tool when debugging Forge apps. Learn more about debugging.
Once your app is deployed, it will appear in the developer console. From the console, you can manage and distribute your apps. You can also see how your app is performing, view your app logs and installations, and manage app alerts.
You now know enough to develop your own Forge apps. Learn more from our tutorials, guides, example apps or reference pages.
Rate this page: