Course menuForge Cloud

Level 2 · Lesson 1

Open the check-in desk

Goal of this lesson

Add a page of your own to Jira, built with Custom UI (your own web page code, instead of the ready-made screen parts Level 1 used), where the person at the front desk checks a car in with its notes and gets one repair task back.

About 35 min6 steps

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/after-07-hang-the-bell 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.

The car details card used UI Kit: Jira drew it from components you arranged. The check-in desk is a whole page in Jira, with its own HTML, CSS and JavaScript. By the end of this lesson the person at the front desk can name a car, paste the notes taken when it came in, and get one work item back, created as them.

Step 1: Unpack the check-in kit

Runs in the browser

Custom UI

Custom UI is your own web page inside a Forge app. You build it like any web page, point a resource in the manifest at the folder your build step produces, and Forge shows it in a sealed-off box inside Jira’s page (a sandboxed frame), so it cannot read or change the rest of Jira. It cannot reach Jira or the internet directly; it talks to your functions through the bridge. Choose it when UI Kit’s components are not enough; for a panel that looks like Jira, UI Kit is simpler.

Jira’s pageYour desk pagea sealed-off boxThe rest of JiraThe internetYour resolvera Forge functionthe bridgeinvoke()Jira’s API

Further reading, optional: Atlassian docs on Custom UI (opens in a new tab)

The desk’s page, its build script and a few helpers are ready-made, so this lesson can stay on Forge. They come as a zip file, the check-in kit, which you unpack into your app folder so its folders sit next to yours.

In a codespace, a container, on a Mac or on Linux, run this in the terminal, in the app folder (cd Workshop-helper first if you are not there). It downloads the kit, unpacks it, and removes the zip again:

RunTerminal
curl -sSLO https://forgecloud.si/downloads/level-2/check-in-kit.zip && unzip -o check-in-kit.zip && rm check-in-kit.zip

The line is three commands joined by &&, “then, if that worked”: curl downloads the file, unzip -o unpacks it (the -o lets it overwrite a half-unpacked earlier try without asking), and rm deletes the zip, which you no longer need.

On a Mac, use this command rather than double-clicking the zip. The kit has its own src folder, and if you drag it into your app folder in Finder, the Mac offers to replace your src folder, which would delete your app’s code. The command adds the kit’s files and leaves yours alone.

On Windows without the course workspace, download the check-in kit, right-click the zip, choose Extract All and pick the app folder.

Either way, the result is the same:

CodeWhat the kit adds
scripts/build-ui.mjs        builds the desk with esbuild
static/desk/src/            the desk’s HTML, CSS and JavaScript
src/lib/config.js           settings, limits and labels
src/lib/validate.js         checks what the desk sends, and what Forge LLM answers
src/lib/adf.js              turns text into Jira’s document format
src/lib/html.js             escapes text for Confluence pages
src/lib/llmText.js          reads Forge LLM’s answer
NOTICE.md                   the licences of the code this course adapts

Open static/desk/src/main.js. It is ordinary browser JavaScript, apart from one import:

Runs in the browser

Forge bridge

@forge/bridge is the only way out of a Custom UI page:

  • invoke() calls your resolver by name, as the car details card does.
  • router opens Jira pages.
  • view reads the context and applies Jira’s theme.

Anything the page sends is untrusted input, because whoever has the page open can change it.

Further reading, optional: Atlassian docs on Bridge API (opens in a new tab)

The desk sends the form with invoke('submitCheckIn', …) and shows what comes back. It puts every message on the page as plain text (developers say “text nodes”), never as HTML, the code a web page is made of. So if someone types something into the notes that looks like code, the page shows it as words and never runs it.

Step 2: Add the build step

The desk is written as several source files. Before Forge can serve it, a build step combines them into a few files the browser loads, in static/desk/build. A tool that does this is called a bundler; the kit uses one called esbuild. Install it:

RunTerminal
npm install --save-dev esbuild

npm adds esbuild to the devDependencies section for you: the list of tools you need only while building, which never become part of the app that runs on Forge. Add the build:ui line to the scripts section yourself, below the lint line the template put there. Put a comma at the end of the lint line: in this file, every line in a section except the last ends with a comma.

Editpackage.jsonChange 1 of 2

A script that builds the desk, and esbuild to do it.

"license": "MIT",
"private": true,
"scripts": {
Removed: "lint": "eslint src/**/*"
Added: "lint": "eslint src/**/*",
Added: "build:ui": "node scripts/build-ui.mjs"

A shortcut: npm run build:ui now runs the kit’s build script, which bundles the desk.

},
"devDependencies": {
"eslint": "^8.56.0",
Editpackage.jsonChange 2 of 2
},
"devDependencies": {
"eslint": "^8.56.0",
Removed: "eslint-plugin-react-hooks": "^4.6.0"
Added: "eslint-plugin-react-hooks": "^4.6.0",
Added: "esbuild": "^0.28.2"

npm wrote this line when you installed esbuild. The ^ means “this version or a newer compatible one”.

},
"dependencies": {
"@forge/api": "^8.2.0",

Why: Custom UI

Then build the desk:

RunTerminal
npm run build:ui

Run this before every deploy that changes the desk. Forget it, and Jira shows the old desk.

Stuck?2 common problems, and their fixes
  • I changed the check-in desk (Level 2)

    The desk is built from static/desk/src into static/desk/build, which is what Forge serves. Build, then deploy:

    RunTerminal
    npm run build:ui
    forge deploy
    Open in the FAQ
  • “Cannot find module @forge/…”

    The code imports a package that is not installed. Install the one named in the message, then deploy:

    RunTerminal
    npm install @forge/api
    forge deploy
    Open in the FAQ

Step 3: One repair task on your own login

The desk needs its own resolver, separate from the car details card’s. Create src/desk.js:

New filesrc/desk.js

A new resolver for the desk: check the input, then create one work item as the person asking.

Added: import Resolver from '@forge/resolver';
Added: import api, { route } from '@forge/api';
Added: import { LABELS, settings } from './lib/config';

Borrow the kit’s label names and settings, which reads the app’s variables.

Added: import { paragraphs } from './lib/adf';
Added: import { validateCheckIn } from './lib/validate';

Borrow the kit’s checker for what the desk sends.

Added:
Added: const resolver = new Resolver();
Added:
Added: // One repair task for the whole check-in, created on the login of the person asking.
Added: resolver.define('submitCheckIn', async ({ payload }) => {

The question the desk asks when someone presses Send. payload is what the desk sent: the form.

Added: const check = validateCheckIn(payload);

Check the form before using any of it.

Added: if (!check.ok) return { error: check.error };

Something in the form breaks a rule: send the desk the reason and stop.

Added: const { projectKey, issueType } = settings();

Which space and which work type to use, from the app’s variables, never from the page.

Added: const { car, notes } = check.checkIn;
Added: const response = await api.asUser().requestJira(route`/rest/api/3/issue`, {

Ask Jira to create a work item, as the person at the desk.

Added: method: 'POST',

POST means “create something”. A plain read, as in Level 1, is a GET.

Added: headers: { Accept: 'application/json', 'Content-Type': 'application/json' },
Added: body: JSON.stringify({

What to send Jira, written as JSON: the same fields you would fill in on the Create screen.

Added: fields: {
Added: project: { key: projectKey },
Added: issuetype: { name: issueType },
Added: summary: car,
Added: description: paragraphs(notes),

Jira wants the description in its own document format; the kit’s paragraphs turns the notes into it.

Added: labels: [LABELS.CHECK_IN],

Every repair task from the desk gets the label check-in.

Added: },
Added: }),
Added: });
Added: if (!response.ok) {
Added: return { error: `Jira answered ${response.status}: ${await response.text()}` };
Added: }
Added: const issue = await response.json();
Added: return { card: { key: issue.key, summary: car } };

Send the desk the new work item’s key and summary, so it can show and link it.

Added: });
Added:
Added: export const handler = resolver.getDefinitions();

Why: Resolver · asUser()

Three habits from here on:

  • validateCheckIn checks everything the desk sends before any of it is used, such as a car name that is too long or notes that are empty. It works like a validator on a workflow transition: if the input breaks a rule, nothing happens and the person gets a clear message.
  • The Jira space comes from settings(), which reads WORKSHOP_PROJECT_KEY, never from the page. Anyone with the page open can change what it sends, so if the page chose the space, someone could make the app create work items in a space it was never meant to touch.
  • The repair task is created with asUser(), so Jira checks the person at the desk may create work items there, and they are its reporter.
Stuck?One common problem, and its fix
  • I changed code in src/

    With forge tunnel running 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 deploy

    The site picks up the new version on its own. You do not need to install again.

    Open in the FAQ

Step 4: Add the check-in desk to the manifest

Runs in the browser

Global page (jira:globalPage)in the workshop: the check-in desk

jira:globalPage adds a full page to Jira, listed in the Apps menu. Like the issue panel, it names a resource to show and a resolver function to answer it; unlike the panel, it is not attached to any work item, so it has no work item in its context.

In the workshop Where a car’s notes are taken down when it is checked in.

See this on the Level 2 chart, in the step where the check-in desk calls its resolver.

Three additions: the page, the function behind it, and where the built desk lives. Step through them:

Editmanifest.ymlChange 1 of 3

A full page in Jira’s Apps menu, served from the built folder.

render: native
title: Car details
icon: https://developer.atlassian.com/platform/forge/images/icons/issue-panel-icon.svg
Added: jira:globalPage:

A new module: a full page in Jira’s Apps menu.

Added: - key: check-in-desk
Added: resource: desk

Show the files named desk, further down.

Added: resolver:
Added: function: desk-resolver

The function that answers the page’s questions.

Added: title: Check-in desk
trigger:
- key: new-repair-task-bell
function: bell
Editmanifest.ymlChange 2 of 3

The function that answers it.

handler: index.handler
- key: bell
handler: bell.run
Added: - key: desk-resolver
Added: handler: desk.handler

Its code: the handler export in src/desk.js.

resources:
- key: main
path: src/frontend/index.jsx
Editmanifest.ymlChange 3 of 3

Where the built desk lives.

resources:
- key: main
path: src/frontend/index.jsx
Added: - key: desk
Added: path: static/desk/build

Where the built desk lives. This is why you build before you deploy.

app:
runtime:
name: nodejs24.x

Why: Global page (jira:globalPage) · Custom UI

Stuck?2 common problems, and their fixes
  • I changed manifest.yml

    Check it, then deploy:

    RunTerminal
    forge lint
    forge deploy

    If the change adds a scope or an outside host, forge deploy stops and asks for approval. See Deploy stops after a permission change.

    Open in the FAQ
  • The check-in desk page is blank

    Forge serves static/desk/build, which only exists after a build. Run npm run build:ui, then forge deploy. If it is still blank, check that resources in the manifest points at static/desk/build.

    Open in the FAQ

Step 5: A permission to write work items

Creating work items needs a new scope. Let the linter add it:

RunTerminal
forge lint --fix
Editmanifest.yml

forge lint --fix adds this for you.

- address: api.api-ninjas.com
scopes:
- read:jira-work
Added: - write:jira-work

Permission to create and change work items.

Why: Scope · Major version

forge lint --fix may put the new line above read:jira-work instead of below it, as Forge CLI 15 does. The order of scopes doesn’t matter, so leave it as the linter wrote it. In later boxes the two scope lines may then be the other way round from your file; that is fine.

A new scope is a new major version, as in Level 1. Build the desk, deploy, approve, upgrade:

RunTerminal
npm run build:ui
forge deploy --approve MAJOR_VERSION_RULE
forge install --upgrade
Stuck?3 common problems, and their fixes
  • Deploy stops after a permission change

    That is expected, not an error. A new scope or outside host makes a new major version, which you approve. Then move each installation onto it. On your own developer site you are the admin, so you accept it yourself:

    RunTerminal
    forge deploy --approve MAJOR_VERSION_RULE
    forge install --upgrade
    Open in the FAQ
  • I added a scope or an outside host

    A permission change makes a new major version. Approve it, then move each installation onto it:

    RunTerminal
    forge deploy --approve MAJOR_VERSION_RULE
    forge install --upgrade

    If the app is installed on Jira and Confluence, run the upgrade for each; it asks which installation.

    Open in the FAQ
  • I changed the check-in desk (Level 2)

    The desk is built from static/desk/src into static/desk/build, which is what Forge serves. Build, then deploy:

    RunTerminal
    npm run build:ui
    forge deploy
    Open in the FAQ

Step 6: Check in the first car

In Jira’s left sidebar, select Apps, then Check-in desk. The first time, it asks you to allow access, as the car details card did. Fill in the form:

CodeCar
BMW 3 Series
CodeNotes
Grinding noise from the front when braking. Oil service is due. Battery light is on and the car won't start some mornings; customer wants a diagnosis before any electrical work.
CodeReported by
Customer

Select Send to the workshop. After a few seconds the desk shows one new repair task for the whole check-in. Open it:

  • Its reporter is you.
  • It has the label check-in.
  • Because its summary is the car’s make and model, the Level 1 car details card works on it: add the panel from the View app actions icon under the title, as on any new work item, and it shows the BMW 3 Series.

But it is one repair task for three faults. The next lessons fix that and one more thing: the button should not wait, and each fault should get its own repair task.

Stuck?4 common problems, and their fixes
  • The check-in desk page is blank

    Forge serves static/desk/build, which only exists after a build. Run npm run build:ui, then forge deploy. If it is still blank, check that resources in the manifest points at static/desk/build.

    Open in the FAQ
  • Creating a repair task fails with “Jira answered 400”

    Usually the issue type. The app creates a Task in the space set by WORKSHOP_PROJECT_KEY. If your space has no Task type, set another one and deploy:

    RunTerminal
    forge variables set WORKSHOP_ISSUE_TYPE Story
    forge deploy
    Open in the FAQ
  • The app asks me to “Allow access”

    Apps that call Jira or Confluence on your own login (asUser()) need your consent once per person. Select Allow access, accept, and reload.

    Open in the FAQ
  • My check-in stays “waiting” or ends “failed”

    The consumer ran into a problem. Read its log, which names the step that failed:

    RunTerminal
    forge logs --since 15m

    The usual causes are a missing WORKSHOP_PROJECT_KEY, a Jira space you cannot create work items in, or Forge LLM not being available on the site yet.

    Open in the FAQ

Compare with yours: download the code after this lesson.

Type at least two letters.