Level 1 · Lesson 2
Cook from home
Level 1 · Lesson 2Rename the panel, then lay out a sample recipe 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.
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. Change it:
manifest.ymlThe title Jira shows above the panel.
resolver: |
function: resolver |
render: native |
Removed: title: Mise en place |
Added: title: Recipe card |
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 Pad thai ticket. The panel is now called Recipe card.
Stuck? I changed manifest.yml
Next step: next
Step 2: Start cooking from home
Locked until the step before it is done.
Lives on your laptop · Home kitchen
forge tunnel · cook from home
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.
In the kitchen The location keeps taking requests, but you cook them in your home kitchen and send them over.
forge tunnel running, Forge forwards the call to your laptop and runs your local code.With the tunnel open, the request goes to your home kitchen and you cook it there.Open a second terminal in the app folder and start the tunnel. Leave it running; you work in the first terminal and your editor.
forge tunnelEach time you save, the tunnel prints Reloading code... and the next reload in Jira uses your new code.
Stuck? The CLI says it is out of date, or forge tunnel mentions ngrok · The tunnel is running while I deploy or upgrade
Next step: next
Step 3: Lay out a sample card
Locked until the step before it is done.
Runs in the browser · Front of house
UI Kit · standard furniture
UI Kit is a set of React components from @forge/react, 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.
In the kitchen Furniture from the building’s own catalogue: it always fits and always matches.
Replace the template’s two lines with the shape of the finished card: a heading, a tag for the servings, and a line where the recipe 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.jsx- 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'; |
Added: import ForgeReconciler, { Heading, Inline, Lozenge, Stack, Text } from '@forge/react'; |
|
const App = () => { |
Removed: const [data, setData] = useState(null); |
Removed: useEffect(() => { |
Removed: invoke('getText', { example: 'my-invoke-variable' }).then(setData); |
Removed: }, []); |
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">Pad thai</Heading> |
Added: <Lozenge>2 servings</Lozenge> |
Added: </Inline> |
Added: <Text>The supplier’s recipe goes here.</Text> |
Added: </Stack> |
); |
}; |
|
Why: UI Kit
Save the file and reload the Pad thai ticket. Stack puts things under each other with a gap; Inline puts the heading and the tag side by side.
Recipe card
Pad thai 2 servings
The supplier’s recipe goes here.
Stuck? I changed code in src/
Next step: next
Step 4: Stop the tunnel and deploy
Locked until the step before it is done.
The tunnel only works while your laptop is on. Stop it with Ctrl + C in its terminal, then deploy, so the site serves the new layout by itself:
forge deployMake this a habit: stop the tunnel before every deploy, and start it again afterwards if you want it.
Stuck? The tunnel is running while I deploy or upgrade
Next step: next
Compare with yours: download the code after this lesson.