Skip to content

Commit 011aac9

Browse files
authored
feat(tracking) :: accept links (#1576)
Fixes #900 Assisted-By :: Claude Opus 5.5
1 parent 011ba8a commit 011aac9

6 files changed

Lines changed: 45 additions & 1 deletion

File tree

‎CHANGELOG.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
- The modal component accepts `close_label` as another name for `close`, which is a reserved word on SQL Server. ([#1070](https://github.com/sqlpage/SQLPage/issues/1070))
1414

15+
- Each item of the tracking component accepts a `link`. ([#900](https://github.com/sqlpage/SQLPage/issues/900))
16+
1517
## v0.47.0 (2026-10-15)
1618
- Redesigned the official website homepage with live SQLPage examples, an interactive database sculpture, flowing section transitions, responsive layouts, and direct links to documentation and deployment guides.
1719
- For sites that store their pages in a database, checking for page updates no longer makes other pages wait when the database is busy. In a test, another page loaded in under 1 ms instead of about 250 ms.

‎examples/official-site/sqlpage/migrations/28_tracking_component.sql‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,14 @@ VALUES (
7878
FALSE,
7979
FALSE
8080
),
81+
(
82+
'tracking',
83+
'link',
84+
'A URL to open when the user clicks on the tracked item.',
85+
'URL',
86+
FALSE,
87+
TRUE
88+
),
8189
(
8290
'tracking',
8391
'center',

‎sqlpage/templates/tracking.handlebars‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@
1818
<div class="mt-2">
1919
<div class="tracking">
2020
{{#each_row}}
21-
<div class="tracking-block{{#if color}} bg-{{color}}{{/if}}" data-bs-toggle="tooltip" data-bs-placement="{{default ../placement "top"}}" title="{{title}}"></div>
21+
{{#if link}}
22+
<a href="{{link}}" class="tracking-block{{#if color}} bg-{{color}}{{/if}}" data-bs-toggle="tooltip" data-bs-placement="{{default ../placement "top"}}" title="{{title}}"></a>
23+
{{else}}
24+
<div class="tracking-block{{#if color}} bg-{{color}}{{/if}}" data-bs-toggle="tooltip" data-bs-placement="{{default ../placement "top"}}" title="{{title}}"></div>
25+
{{/if}}
2226
{{/each_row}}
2327
</div>
2428
</div>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SELECT 'text' AS component, 'Details for ' || $day AS contents;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
SELECT 'tracking' AS component, 'Server uptime' AS title;
2+
SELECT 'Monday: up' AS title, 'success' AS color, 'day.sql?day=Monday' AS link;
3+
SELECT 'Tuesday: down' AS title, 'danger' AS color;
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { expect, test } from "../../fixture.ts";
2+
3+
test("tracking block with a link opens it", async ({ page }) => {
4+
await page.locator(".tracking-block").first().click();
5+
await expect(page).toHaveURL(/\/tracking\/day\.sql\?day=Monday$/);
6+
await expect(page.getByText("Details for Monday")).toBeVisible();
7+
});
8+
9+
test("tracking block without a link is not a link", async ({ page }) => {
10+
await expect(page.locator(".tracking-block").nth(1)).not.toHaveAttribute(
11+
"href",
12+
);
13+
});
14+
15+
test("tracking block with a link looks like one without", async ({ page }) => {
16+
const blocks = page.locator(".tracking-block");
17+
const linked = await blocks.nth(0).boundingBox();
18+
const plain = await blocks.nth(1).boundingBox();
19+
expect(linked?.width).toBe(plain?.width);
20+
expect(linked?.height).toBe(plain?.height);
21+
});
22+
23+
test("tracking block with a link keeps its tooltip", async ({ page }) => {
24+
await page.locator(".tracking-block").first().hover();
25+
await expect(page.getByRole("tooltip")).toHaveText("Monday: up");
26+
});

0 commit comments

Comments
 (0)