Level 1 · Lesson 2
Work from your laptop
Level 1 · Lesson 2Goal of this lesson
Rename the panel, then lay out a sample car details card with UI Kit while forge tunnel shows every save on the site, without a deploy.
Behind, or starting here? Download the code as it should be before this lesson, or in the course workspace run course-catch-up level-1/start in the folder above your app. It offers to bring your own app folder to this point and keeps its app id (the id: line in manifest.yml, which links the code to your app on the site), so it stays the same app. Your old files are kept in a copy next to it.
Deploying after every small change is slow. This lesson sets up the faster loop you use for the rest of the course: the site keeps calling your app, but your laptop runs the code, so a save and a reload are enough. Changes to the manifest are the exception, and the first step shows why.
Step 1: Name the card
Locked until the step before it is done.
The heading Jira draws above the panel is the module’s title in the manifest. The View app actions menu under a work item’s title uses the same name, so after this change you find the panel there as Car details.
Change the title:
manifest.ymlThe title Jira shows above the panel.
resolver: | |||
function: resolver | |||
render: native | |||
Removed: title: Workshop helper | |||
Added: title: Car details | |||
The heading Jira draws above your panel. The spaces in front matter: they show this line belongs to the panel above it. | |||
icon: https://developer.atlassian.com/platform/forge/images/icons/issue-panel-icon.svg | |||
function: | |||
- key: resolver | |||
The manifest is read when you deploy, not while the code runs. Any change to it needs a deploy:
forge deployReload the BMW 3 Series repair task. The panel is now called Car details.
Stuck?3 common problems, and their fixes
I changed manifest.yml
Open in the FAQCheck it, then deploy:
RunTerminal forge lint forge deployIf the change adds a scope or an outside host,
forge deploystops and asks for approval. See Deploy stops after a permission change.After changing manifest.yml,
forge lintorforge deployreports an error in the manifestOpen in the FAQMost often the spaces at the start of the lines are off. In
manifest.ymlthose spaces matter: they show what belongs inside what, the way an outline does. Every line you add must start with exactly as many spaces as the line it sits next to in the lesson’s change, and it must use spaces, not tabs. Compare your file with the change, line up the new lines, save, and run:RunTerminal forge lintIf you are still stuck, download the code after the lesson (the link at the end of each lesson) and compare its
manifest.ymlwith yours.“Make sure you’re in the top-level directory of your app” or “Command failed due to validation error”
Open in the FAQThe terminal is not in your app folder, so the command can’t find
manifest.yml. This happens most often in a codespace: every new terminal, and the codespace after it restarts, opens in the workspace folder (/workspaces/forge-cloud-workspace), one level above your app. The end of the error line,manifest-file-required, says the same thing.Move into the app folder and run the command again:
RunTerminal cd Workshop-helper forge deployThe prompt in the terminal shows where you are: it should end in
Workshop-helper. If you gave your app another name, use that folder’s name instead.
Step 2: Start the tunnel
Locked until the step before it is done.
Lives on your laptop
forge tunnel
forge tunnel connects the deployed app to your laptop. While it runs, Forge sends the app’s function calls to your machine and runs your local code, and UI changes are served from your folder too. Save a file, reload Jira, and you see the change. It works only for code: the manifest still comes from the last deploy.
Further reading, optional: Atlassian docs on Tunneling (opens in a new tab)
See this on the home chart, in the step where forge tunnel runs the function from your laptop.
Open a second terminal (in VS Code or a codespace, select + in the terminal panel; elsewhere, open a new terminal window). A new terminal starts in the workspace folder, not in your app, so move into the app folder first, then start the tunnel:
cd Workshop-helper
forge tunnelThe tunnel is ready when it prints a line starting Listening for requests. Leave that terminal alone from then on: you work in the first terminal and your editor. Each time you save a file, the tunnel prints Reloading code... and the next reload in Jira uses your new code.
VS Code may pop up messages saying an application is running on a port. A port is a numbered door on a computer that one program listens at, so several programs can receive connections on the same computer without mixing them up. The messages come with buttons to open the port in a browser. They are about the tunnel’s own connections; close them, you don’t need them. Never choose Make Public: that would let anyone with the address open what the tunnel serves. If you did, open the Ports tab next to the terminal, right-click the port, and set Port Visibility back to Private.
13resources:
14 - key: main
15 path: src/frontend/index.jsx
16app:
/workspaces/forge-cloud-workspace $ cd Workshop-helper
…/Workshop-helper $ forge tunnel
Tunnel redirects requests you make to your local machine.
Press Ctrl+C to cancel.
=== Bundling code...
Listening for requests...
- bash
- node
ⓘ Your application running on port 4000 is available.✕
Open in BrowserMake Public
Stuck?3 common problems, and their fixes
The CLI says it is out of date, or forge tunnel mentions ngrok
Open in the FAQOlder CLI versions used a separate tool called ngrok for the tunnel; current versions do not need it. Update the CLI and check the version:
RunTerminal npm install -g @forge/cli@latest forge --versionThe tunnel says Reloading code, but Jira still shows the old version
Open in the FAQJira only uses the tunnel when your browser runs on the same computer as
forge tunnel. When you open Jira, your browser looks for the tunnel on your own computer. If it cannot find it, Jira shows your last deploy without any error.- You build in a codespace in your browser. The codespace runs on GitHub’s computer, so your browser never finds the tunnel. Stop the tunnel with Ctrl+C, then after each change deploy and reload:
RunTerminal forge deploy- You changed
manifest.yml. The tunnel only runs code. Stop it, deploy, then start it again. - Your browser blocks it. The tunnel works in Chrome and Firefox. Ad blockers, Brave Shields and some extensions block the connection to your own computer; turn them off for your Atlassian site. If Chrome asks whether the site may reach apps and devices on your network or this device, allow it.
The tunnel is running while I deploy or upgrade
Open in the FAQStop it with Ctrl+C first, then deploy or upgrade, then start it again. While the tunnel runs, Jira runs the code on your laptop instead of your last deploy, so if you deploy with it running you cannot tell which version you are testing. Changes to the manifest only reach the site through a deploy, never through the tunnel.
Step 3: Lay out a sample card
Locked until the step before it is done.
Runs in the browser
UI Kit
UI Kit is a set of React components from @forge/react. React is a popular JavaScript library for building screens out of components, reusable pieces such as Heading, Stack, Inline, Lozenge and List. Forge draws them with Jira’s own design system, so the card looks like part of Jira and follows its light and dark themes. You arrange the components; you never write CSS (the styling language of web pages).
Further reading, optional: Atlassian docs on UI Kit overview (opens in a new tab)
Replace the template’s two lines with the shape of the finished card:
- a heading for the make and model
- a tag for the fuel types
- a line where the car data goes
For now it is sample text, and the panel no longer asks the resolver for anything. Lesson 4 brings that back.
src/frontend/index.jsxChange 1 of 3- Import the UI Kit components the card uses.
- Replace the template text with a sample card.
Removed: import React, { useEffect, useState } from 'react'; | |||
Removed: import ForgeReconciler, { Text } from '@forge/react'; | |||
Removed: import { invoke } from '@forge/bridge'; | |||
Added: import React from 'react'; | |||
Borrow React, the library UI Kit is built on. Every card file starts with it. | |||
Added: import ForgeReconciler, { Heading, Inline, Lozenge, Stack, Text } from '@forge/react'; | |||
Borrow the UI Kit pieces this card uses, by name, from Forge’s | |||
| |||
const App = () => { | |||
src/frontend/index.jsxChange 2 of 3 |
const App = () => { |
Removed: const [data, setData] = useState(null); |
Removed: useEffect(() => { |
Removed: invoke('getText', { example: 'my-invoke-variable' }).then(setData); |
Removed: }, []); |
return ( |
src/frontend/index.jsxChange 3 of 3 return ( | |||
Removed: <> | |||
Removed: <Text>Hello world!</Text> | |||
Removed: <Text>{data ? data : 'Loading...'}</Text> | |||
Removed: </> | |||
Added: <Stack space="space.200"> | |||
| |||
Added: <Inline space="space.100" alignBlock="center"> | |||
| |||
Added: <Heading size="medium">BMW 3 Series</Heading> | |||
A heading. Each piece opens with its name in angle brackets and closes with the same name after a slash. | |||
Added: <Lozenge>Petrol · Diesel</Lozenge> | |||
A lozenge is Jira’s small rounded tag, the same kind a status uses. | |||
Added: </Inline> | |||
Added: <Text>What the car data service knows goes here.</Text> | |||
A line of plain text. Lesson 4 replaces this sample with real data. | |||
Added: </Stack> | |||
); | |||
}; | |||
| |||
Why: UI Kit
Save the file. If you don’t use the tunnel, run forge deploy now. Then reload the BMW 3 Series repair task. Stack puts things under each other with a gap; Inline puts the heading and the tag side by side.
Car details
BMW 3 Series Petrol · Diesel
What the car data service knows goes here.
Stuck?2 common problems, and their fixes
I changed code in src/
Open in the FAQWith
forge tunnelrunning on your own computer, save the file and reload the Jira page: the tunnel serves your laptop’s code. Without the tunnel, or in a codespace in your browser, deploy:RunTerminal forge deployThe site picks up the new version on its own. You do not need to install again.
The tunnel says Reloading code, but Jira still shows the old version
Open in the FAQJira only uses the tunnel when your browser runs on the same computer as
forge tunnel. When you open Jira, your browser looks for the tunnel on your own computer. If it cannot find it, Jira shows your last deploy without any error.- You build in a codespace in your browser. The codespace runs on GitHub’s computer, so your browser never finds the tunnel. Stop the tunnel with Ctrl+C, then after each change deploy and reload:
RunTerminal forge deploy- You changed
manifest.yml. The tunnel only runs code. Stop it, deploy, then start it again. - Your browser blocks it. The tunnel works in Chrome and Firefox. Ad blockers, Brave Shields and some extensions block the connection to your own computer; turn them off for your Atlassian site. If Chrome asks whether the site may reach apps and devices on your network or this device, allow it.
Step 4: Stop the tunnel and deploy
Locked until the step before it is done.
If you skipped the tunnel, your last deploy already shows the new layout: tick this step.
The tunnel only works while your laptop is on. Stop it: click into its terminal and press Ctrl + C. It prints Stopping tunnel... and takes a few seconds; it has stopped when the terminal shows its prompt again, the line where you can type.
Listening for requests...
^C
Stopping tunnel...
…/Workshop-helper ❯
Then deploy, from the app folder, so the site serves the new layout by itself:
forge deployDo this every time: stop the tunnel before you deploy, and start it again afterwards if you want it. Then you always know what the site is running. While the tunnel runs, it is the code on your laptop; once you stop it, it is your last deploy.
Stuck?One common problem, and its fix
The tunnel is running while I deploy or upgrade
Open in the FAQStop it with Ctrl+C first, then deploy or upgrade, then start it again. While the tunnel runs, Jira runs the code on your laptop instead of your last deploy, so if you deploy with it running you cannot tell which version you are testing. Changes to the manifest only reach the site through a deploy, never through the tunnel.
Compare with yours: download the code after this lesson.