Skip to content

Commit 6222ca1

Browse files
committed
add ui docs
1 parent 0818cac commit 6222ca1

3 files changed

Lines changed: 143 additions & 0 deletions

File tree

docs/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ It includes:
2929
## Documentation Map
3030

3131
- [Getting Started](getting-started.md)
32+
- [UI Guide](ui-guide.md)
3233
- [API Reference](api-reference.md)
3334
- [Split-Host Deployment](split-host-deployment.md)
3435
- [Docker Deployment](docker.md)

docs/ui-guide.md

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
# UI Guide
2+
3+
## Signing In
4+
5+
The sign-in page only appears when `FRONTEND_AUTH_ENABLED=true` is set on the backend. If your deployment uses nginx-level auth (Basic Auth or OIDC) instead, you will not see it; access is handled before the page loads.
6+
7+
When the sign-in page is shown:
8+
9+
1. Navigate to `/ui/config-builder` (or any `/ui/*` path). You will be redirected to `/auth/login` if you are not already authenticated.
10+
2. Enter the username and password set in `FRONTEND_AUTH_USERNAME` and `FRONTEND_AUTH_PASSWORD`.
11+
3. Click **Sign In**. On success you are redirected to the original destination. On failure the page shows "Invalid credentials. Try again."
12+
13+
To sign out, click the **Logout** button in the top navigation bar. This clears the session cookie.
14+
15+
---
16+
17+
## Template Builder
18+
19+
Templates are the egress payload blueprints. Every route config references exactly one template. You must create at least one template before you can build a route config.
20+
21+
Navigate to **Templates** in the top nav.
22+
23+
### Creating A Template
24+
25+
1. Click **New Template** to clear the form.
26+
27+
2. **Template Name** (required): a unique name used to reference the template from route configs. Example: `pagerduty-alert`.
28+
29+
3. **Needs Documentation Rules**: set to `true` if this template has a field that should be populated with a documentation URL at runtime. When set to `true`, a **Documentation Target Field** input appears. Defaults to `false`.
30+
31+
4. **Documentation Target Field**: visible only when Needs Documentation Rules is `true`. Enter the name of the field in the template that will receive the resolved documentation URL. This must match a key in the fields JSON. Example: `alertDocumentation`.
32+
33+
5. **Template Fields (JSON Object)** (required): a JSON object where each key is a field name and each value is the default value for that field. Keys become the editable fields that the config builder will let you map ingress data into.
34+
35+
Example:
36+
```json
37+
{
38+
"alertTitle": "",
39+
"alertSummary": "",
40+
"alertDocumentation": ""
41+
}
42+
```
43+
44+
- Every key you define here appears as a mappable field in the config builder.
45+
- Values are the defaults; if a route config provides no mapping for a field, this value is used.
46+
47+
6. Click **Save Template**.
48+
49+
### Editing A Template
50+
51+
Select a template from the **Saved Templates** dropdown and click **Load Template**. Make changes and click **Save Template**. The page will warn you if you try to navigate away with unsaved changes.
52+
53+
### Deleting A Template
54+
55+
Load the template, then click **Delete Template**. This is permanent. Route configs referencing a deleted template will fail validation on the next app restart.
56+
57+
---
58+
59+
## Config Builder
60+
61+
Route configs define how an inbound webhook gets transformed and forwarded. Navigate to **Route Configuration** in the top nav.
62+
63+
### Route Settings
64+
65+
**Route Name** (required): a human-readable identifier for this route. Used as part of the generated webhook path. Example: `github-to-pagerduty`.
66+
67+
**Method**: the HTTP method the route accepts. Defaults to `POST`. Options: `POST`, `PUT`, `PATCH`.
68+
69+
**Route Path**: read-only. Auto-generated as `/webhook/{routeName}/{ULID}`. The ULID makes the path effectively unguessable. Click **Generate New Route ULID** to regenerate the random suffix if needed.
70+
71+
**Enabled**: when unchecked the route exists in the database but the app will not route incoming requests to it.
72+
73+
**Outbound Headers**: headers added to every forwarded request. Each row has:
74+
- **Header name**: the HTTP header name, e.g. `X-API-KEY`.
75+
- **Value type**: `Environment Variable` or `Literal`.
76+
- `Environment Variable`: enter just the variable name, e.g. `API_TOKEN`. The app resolves it to `process.env.API_TOKEN` at runtime. Use this for secrets so they are never stored in the database.
77+
- `Literal`: the exact string is stored and sent as-is.
78+
79+
**Target URL(s)** (required): one or more URLs the transformed payload is forwarded to. Add multiple targets to fan out a single inbound webhook to several endpoints.
80+
81+
### Template Selection
82+
83+
Select the template that defines the egress payload structure for this route. Once selected, the **Field Discovery** and **Field Mapping** panels appear. The status line shows the editable fields the template exposes.
84+
85+
### Field Discovery
86+
87+
Paste a sample JSON payload from your webhook provider and click **Extract Fields From Sample**. The builder flattens every leaf path in the payload — including nested objects and array items — and stores them as autocomplete suggestions for the mapping step.
88+
89+
You do not need to extract fields before mapping. It just makes it easier to avoid typos when referencing nested paths.
90+
91+
### Field Mapping
92+
93+
One row appears per editable field in the selected template. Each row shows the target field name and a mapping expression input.
94+
95+
**How expressions work:**
96+
97+
- `$path.to.field`: resolves the value at that dot-separated path in the inbound payload. `$event.title` looks up `payload.event.title`.
98+
- Array indexing uses bracket notation: `$items[0].name`.
99+
- Everything not preceded by `$` is literal text. `Alert: $event.title``Alert: Server Down`.
100+
- Multiple tokens and literals can be mixed: `$service.name ($event.severity)``Payments Service (critical)`.
101+
- To include a literal dollar sign, write `$$`.
102+
- If a `$path` reference does not resolve (key missing or null in the payload), that path contributes nothing to the output. If the entire expression resolves to nothing, the template default value is used.
103+
104+
**Autocomplete:** type `$` and the builder shows matching paths from the extracted sample. Use arrow keys to navigate, `Enter` or `Tab` to accept, `Escape` to dismiss.
105+
106+
**Preview:** below each input, a rendered preview shows path references as highlighted tokens and literal text as plain text.
107+
108+
**Clear:** removes the mapping for that field, reverting it to the template default at runtime.
109+
110+
### Documentation Rules
111+
112+
This panel only appears when the selected template has **Needs Documentation Rules** set to `true`.
113+
114+
Documentation rules automatically populate the template's documentation target field with a URL based on the resolved value of another field. This is useful for linking alert routes to the relevant runbook or wiki page.
115+
116+
Each rule has three fields:
117+
118+
- **Field to match**: the template field whose resolved value is inspected.
119+
- **Match value**: a case-insensitive substring to look for in that field's resolved value.
120+
- **Documentation URL**: the URL written into the documentation target field when the match is found.
121+
122+
Rules are evaluated in order. The first match wins. If no rule matches, the documentation target field uses its template default.
123+
124+
**Example:** field to match = `alertTitle`, match value = `Server Down`, URL = `https://wiki.example.com/runbooks/server-down`. Any webhook whose `alertTitle` mapping resolves to a string containing "server down" will have that URL written into the documentation target field of the egress payload.
125+
126+
Click **Add Documentation Rule** to add a row. Click **Remove** to delete a row.
127+
128+
### Saving A Config
129+
130+
Click **Save Current Config** to persist the route to the database. The app picks up the new config immediately without a restart.
131+
132+
To preview the raw JSON before saving, click **Generate Config JSON**.
133+
134+
### Loading And Editing An Existing Config
135+
136+
Select a config from the **Config Records** dropdown (shown as `{path} [{method}]`) and click **Load Config**. Edit as needed and click **Save Current Config**.
137+
138+
### Deleting A Config
139+
140+
Load the config and click **Delete Selected Config**. The route stops accepting webhooks immediately.

scripts/build-docs-pages.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const outputStylesPath = path.join(outputDir, 'ui', 'dist', 'styles.css');
1414
const preferredOrder = [
1515
'index',
1616
'getting-started',
17+
'ui-guide',
1718
'api-reference',
1819
'split-host-deployment',
1920
'docker',
@@ -23,6 +24,7 @@ const preferredOrder = [
2324
];
2425

2526
const titleOverrides = {
27+
'ui-guide': 'UI Guide',
2628
'api-reference': 'API Reference',
2729
'split-host-deployment': 'Split-Host Deployment',
2830
'docker': 'Docker Deployment',

0 commit comments

Comments
 (0)