diff --git a/src/models.rs b/src/models.rs index 740b8be..33e9851 100644 --- a/src/models.rs +++ b/src/models.rs @@ -41,6 +41,8 @@ pub struct Entry { /// The project's effective color. pub color: String, pub client_color: String, + /// The project's repository link. + pub repo_url: Option, pub started_at: DateTime, /// `None` while the timer is running. pub ended_at: Option>, diff --git a/src/repo/entries.rs b/src/repo/entries.rs index d20a88c..339d730 100644 --- a/src/repo/entries.rs +++ b/src/repo/entries.rs @@ -9,7 +9,7 @@ use crate::models::{Entry, EntryFilter, NewEntry, UpdateEntry}; /// `?1` is always "now", used to measure running entries. const SELECT: &str = "SELECT e.id, e.project_id, p.name AS project_name, p.client_id, c.name AS client_name, - COALESCE(p.color, c.color) AS color, c.color AS client_color, + COALESCE(p.color, c.color) AS color, c.color AS client_color, p.repo_url, e.started_at, e.ended_at, e.note, strftime('%s', COALESCE(e.ended_at, ?1)) - strftime('%s', e.started_at) AS seconds, EXISTS (SELECT 1 FROM time_entries o diff --git a/static/app.css b/static/app.css index 900d2cd..f3d2665 100644 --- a/static/app.css +++ b/static/app.css @@ -127,6 +127,8 @@ tr:last-child td { border-bottom: 0; } .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; } .time { white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--muted); } .client { color: var(--muted); } +.project-link { color: inherit; text-decoration: underline dotted var(--muted); text-underline-offset: 3px; } +.project-link:hover { color: var(--accent); text-decoration-color: currentColor; } tr.running { background: var(--running); } tr.day-head th { color: var(--text); font-weight: 600; font-size: .9rem; padding-top: 1.1rem; } tbody:first-of-type tr.day-head th { padding-top: .6rem; } diff --git a/templates/_entry_row.html b/templates/_entry_row.html index 22e1e7a..52efb75 100644 --- a/templates/_entry_row.html +++ b/templates/_entry_row.html @@ -4,7 +4,7 @@ {{ e.start_time() }} – {{ e.end_time() }} {% if e.overlaps %}⚠{% endif %} - {{ e.client_name }} / {{ e.project_name }} + {{ e.client_name }} / {% if let Some(u) = e.repo_url %}{{ e.project_name }}{% else %}{{ e.project_name }}{% endif %} {{ e.note }} {{ e.duration() }} diff --git a/tests/api.rs b/tests/api.rs index 8f58bb0..2fcd9e9 100644 --- a/tests/api.rs +++ b/tests/api.rs @@ -745,6 +745,17 @@ async fn project_repo_url() { assert_eq!(p["repo_url"], "https://git.example.com/acme/site"); let (_, html) = get_html(&app, "/clients").await; assert!(html.contains("href=\"https://git.example.com/acme/site\"")); + // Entry lists link the project name to its repository. + let (status, _) = add_entry( + &app, + p["id"].as_i64().unwrap(), + local(2026, 3, 10, 9, 0), + local(2026, 3, 10, 10, 0), + ) + .await; + assert_eq!(status, StatusCode::CREATED); + let (_, html) = get_html(&app, "/entries?from=2026-03-09&to=2026-03-15").await; + assert!(html.contains("class=\"project-link\" href=\"https://git.example.com/acme/site\"")); let (_, p) = send(&app, "PATCH", &project, Some(json!({ "repo_url": "" }))).await; assert!(p["repo_url"].is_null());