Author SHA1 Message Date
Romulus21andClaude Opus 5.5 63ddfd39d9 Ajoute l'URL du repo sur les projets
Colonne projects.repo_url (migration 0003), exposée par l'API
(repo_url à la création, "" ou null pour l'effacer) et éditable sur la
page clients ; une icône ouvre le repo dans un nouvel onglet. Seules les
URL http(s) sont acceptées.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 18:59:20 +01:00
Romulus21andClaude Opus 5.5 9e136bd208 Merge branch 'feat/favicon-enregistrement'
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 18:54:34 +01:00
Romulus21andClaude Opus 5.5 0c9b9c5823 Fait clignoter le favicon en rouge pendant un enregistrement
Favicon par défaut (static/favicon.svg) ; tant que /api/timer renvoie
une entrée en cours, il alterne chaque seconde entre un point rouge plein
et pâle, sur toutes les pages. État relu au chargement, après chaque
requête htmx, au retour sur l'onglet et toutes les 20 s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 18:54:34 +01:00
Romulus21andClaude Opus 5.5 aa4f5aeb0a Versionne les URL de app.css et app.js
Un hash du contenu est ajouté en ?v= : après un déploiement, le
navigateur recharge le CSS/JS au lieu de garder l'ancien en cache
(max-age=3600).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 18:39:05 +01:00
15 changed files with 190 additions and 16 deletions

No files matched your search

+2 -2
View File
@@ -31,8 +31,8 @@ Aucune authentification : le service est prévu pour tourner en local.
|--------------|----------------------------------------------------| |--------------|----------------------------------------------------|
| GET, POST | `/clients` (`?archived=true` pour inclure les archivés) — `{"name", "color"?}` | | GET, POST | `/clients` (`?archived=true` pour inclure les archivés) — `{"name", "color"?}` |
| PATCH, DELETE| `/clients/{id}` — `{"name"?, "archived"?, "color"?}` | | PATCH, DELETE| `/clients/{id}` — `{"name"?, "archived"?, "color"?}` |
| GET, POST | `/clients/{id}/projects` — `{"name", "color"?}` | | GET, POST | `/clients/{id}/projects` — `{"name", "color"?, "repo_url"?}` |
| PATCH, DELETE| `/projects/{id}` — `"color": null` pour reprendre celle du client | | PATCH, DELETE| `/projects/{id}` — `"color": null` pour reprendre celle du client, `"repo_url": ""` pour l'effacer |
| GET | `/timer` — entrée en cours ou `null` | | GET | `/timer` — entrée en cours ou `null` |
| POST | `/timer/start` `{"project_id", "note"?}` · `/timer/stop` | | POST | `/timer/start` `{"project_id", "note"?}` · `/timer/stop` |
| GET, POST | `/entries` (`?from&to&client_id&project_id`) | | GET, POST | `/entries` (`?from&to&client_id&project_id`) |
+2
View File
@@ -0,0 +1,2 @@
-- Optional link to the project's source repository (http(s) URL).
ALTER TABLE projects ADD COLUMN repo_url TEXT;
+8
View File
@@ -25,6 +25,8 @@ pub struct Project {
pub color: Option<String>, pub color: Option<String>,
/// `color`, or the client's color. /// `color`, or the client's color.
pub effective_color: String, pub effective_color: String,
/// Link to the source repository.
pub repo_url: Option<String>,
pub archived: bool, pub archived: bool,
pub created_at: DateTime<Utc>, pub created_at: DateTime<Utc>,
} }
@@ -97,6 +99,9 @@ pub struct NameInput {
/// `#rrggbb`. Clients get one from the palette, projects inherit their client's. /// `#rrggbb`. Clients get one from the palette, projects inherit their client's.
#[serde(default)] #[serde(default)]
pub color: Option<String>, pub color: Option<String>,
/// Projects only: `http(s)://` link to the source repository.
#[serde(default)]
pub repo_url: Option<String>,
} }
#[derive(Debug, Default, Deserialize)] #[derive(Debug, Default, Deserialize)]
@@ -106,6 +111,9 @@ pub struct UpdateInput {
/// Absent: unchanged. `null`: reset to the client's color (projects only). /// Absent: unchanged. `null`: reset to the client's color (projects only).
#[serde(default, deserialize_with = "present")] #[serde(default, deserialize_with = "present")]
pub color: Option<Option<String>>, pub color: Option<Option<String>>,
/// Projects only. Absent: unchanged. `null` or `""`: removed.
#[serde(default, deserialize_with = "present")]
pub repo_url: Option<Option<String>>,
} }
#[derive(Debug, Deserialize)] #[derive(Debug, Deserialize)]
+16
View File
@@ -33,6 +33,22 @@ fn clean_color(color: &str) -> AppResult<String> {
Ok(color.to_ascii_lowercase()) Ok(color.to_ascii_lowercase())
} }
/// Validates an optional repository URL; blank means none.
fn clean_repo_url(url: &str) -> AppResult<Option<String>> {
let url = url.trim();
if url.is_empty() {
return Ok(None);
}
let valid = (url.starts_with("https://") || url.starts_with("http://"))
&& !url.contains(char::is_whitespace);
if !valid {
return Err(AppError::Validation(format!(
"URL du repo invalide « {url} » (doit commencer par http:// ou https://)"
)));
}
Ok(Some(url.to_owned()))
}
/// Maps "zero rows affected" to `NotFound`. /// Maps "zero rows affected" to `NotFound`.
fn affected(result: sqlx::sqlite::SqliteQueryResult) -> AppResult<()> { fn affected(result: sqlx::sqlite::SqliteQueryResult) -> AppResult<()> {
if result.rows_affected() == 0 { if result.rows_affected() == 0 {
+16 -4
View File
@@ -1,12 +1,13 @@
use sqlx::SqlitePool; use sqlx::SqlitePool;
use super::{affected, clean_color, clean_name}; use super::{affected, clean_color, clean_name, clean_repo_url};
use crate::clock; use crate::clock;
use crate::error::{AppError, AppResult}; use crate::error::{AppError, AppResult};
use crate::models::{Project, UpdateInput}; use crate::models::{Project, UpdateInput};
const SELECT: &str = "SELECT p.id, p.client_id, c.name AS client_name, p.name, const SELECT: &str = "SELECT p.id, p.client_id, c.name AS client_name, p.name,
p.color, COALESCE(p.color, c.color) AS effective_color, p.archived, p.created_at p.color, COALESCE(p.color, c.color) AS effective_color, p.repo_url, p.archived,
p.created_at
FROM projects p JOIN clients c ON c.id = p.client_id"; FROM projects p JOIN clients c ON c.id = p.client_id";
/// Lists projects, optionally for one client. Archived projects (or projects of /// Lists projects, optionally for one client. Archived projects (or projects of
@@ -40,17 +41,21 @@ pub async fn create(
client_id: i64, client_id: i64,
name: &str, name: &str,
color: Option<&str>, color: Option<&str>,
repo_url: Option<&str>,
) -> AppResult<Project> { ) -> AppResult<Project> {
let name = clean_name(name)?; let name = clean_name(name)?;
let color = color.map(clean_color).transpose()?; let color = color.map(clean_color).transpose()?;
let repo_url = repo_url.map(clean_repo_url).transpose()?.flatten();
// Surface a missing client as 404 rather than a foreign key error. // Surface a missing client as 404 rather than a foreign key error.
super::clients::get(pool, client_id).await?; super::clients::get(pool, client_id).await?;
let id = sqlx::query( let id = sqlx::query(
"INSERT INTO projects (client_id, name, color, created_at) VALUES (?1, ?2, ?3, ?4)", "INSERT INTO projects (client_id, name, color, repo_url, created_at)
VALUES (?1, ?2, ?3, ?4, ?5)",
) )
.bind(client_id) .bind(client_id)
.bind(name) .bind(name)
.bind(color) .bind(color)
.bind(repo_url)
.bind(clock::ts(&clock::now())) .bind(clock::ts(&clock::now()))
.execute(pool) .execute(pool)
.await? .await?
@@ -64,10 +69,15 @@ pub async fn update(pool: &SqlitePool, id: i64, input: &UpdateInput) -> AppResul
Some(Some(c)) => Some(clean_color(c)?), Some(Some(c)) => Some(clean_color(c)?),
_ => None, _ => None,
}; };
let repo_url = match &input.repo_url {
Some(Some(u)) => clean_repo_url(u)?,
_ => None,
};
affected( affected(
sqlx::query( sqlx::query(
"UPDATE projects SET name = COALESCE(?2, name), archived = COALESCE(?3, archived), "UPDATE projects SET name = COALESCE(?2, name), archived = COALESCE(?3, archived),
color = CASE WHEN ?4 THEN ?5 ELSE color END color = CASE WHEN ?4 THEN ?5 ELSE color END,
repo_url = CASE WHEN ?6 THEN ?7 ELSE repo_url END
WHERE id = ?1", WHERE id = ?1",
) )
.bind(id) .bind(id)
@@ -75,6 +85,8 @@ pub async fn update(pool: &SqlitePool, id: i64, input: &UpdateInput) -> AppResul
.bind(input.archived) .bind(input.archived)
.bind(input.color.is_some()) .bind(input.color.is_some())
.bind(color) .bind(color)
.bind(input.repo_url.is_some())
.bind(repo_url)
.execute(pool) .execute(pool)
.await?, .await?,
)?; )?;
+10 -1
View File
@@ -90,7 +90,16 @@ async fn create_project(
) -> AppResult<(StatusCode, Json<Project>)> { ) -> AppResult<(StatusCode, Json<Project>)> {
Ok(( Ok((
StatusCode::CREATED, StatusCode::CREATED,
Json(projects::create(&pool, client_id, &input.name, input.color.as_deref()).await?), Json(
projects::create(
&pool,
client_id,
&input.name,
input.color.as_deref(),
input.repo_url.as_deref(),
)
.await?,
),
)) ))
} }
+19 -6
View File
@@ -44,18 +44,31 @@ pub fn app(pool: SqlitePool) -> Router {
) )
}), }),
) )
.route("/static/app.js", get(|| asset("text/javascript", APP_JS)))
.route("/static/app.css", get(|| asset("text/css", APP_CSS)))
.route( .route(
"/static/app.js", "/static/favicon.svg",
get(|| asset("text/javascript", include_str!("../../static/app.js"))), get(|| asset("image/svg+xml", include_str!("../../static/favicon.svg"))),
)
.route(
"/static/app.css",
get(|| asset("text/css", include_str!("../../static/app.css"))),
) )
.layer(TraceLayer::new_for_http()) .layer(TraceLayer::new_for_http())
.with_state(pool) .with_state(pool)
} }
const APP_CSS: &str = include_str!("../../static/app.css");
const APP_JS: &str = include_str!("../../static/app.js");
/// Hash of app.css + app.js, appended as `?v=` to their URLs so a deploy
/// bypasses the browser cache.
pub fn asset_version() -> &'static str {
static VERSION: std::sync::LazyLock<String> = std::sync::LazyLock::new(|| {
use std::hash::{Hash, Hasher};
let mut h = std::collections::hash_map::DefaultHasher::new();
(APP_CSS, APP_JS).hash(&mut h);
format!("{:x}", h.finish())
});
&VERSION
}
// En livereload, le CSS/JS doit être relu à chaque rechargement. // En livereload, le CSS/JS doit être relu à chaque rechargement.
const CACHE_CONTROL: &str = if cfg!(feature = "livereload") { const CACHE_CONTROL: &str = if cfg!(feature = "livereload") {
"no-cache" "no-cache"
+12 -1
View File
@@ -417,6 +417,9 @@ struct ItemForm {
/// Projects only: go back to the client's color. /// Projects only: go back to the client's color.
#[serde(default)] #[serde(default)]
inherit: bool, inherit: bool,
/// Projects only; blank removes it.
#[serde(default)]
repo_url: Option<String>,
} }
#[derive(Deserialize)] #[derive(Deserialize)]
@@ -476,7 +479,14 @@ async fn create_project(
// The color picker is prefilled with the client's color: keeping it means inheriting. // The color picker is prefilled with the client's color: keeping it means inheriting.
let client = clients::get(&pool, client_id).await?; let client = clients::get(&pool, client_id).await?;
let color = f.color.filter(|c| !c.eq_ignore_ascii_case(&client.color)); let color = f.color.filter(|c| !c.eq_ignore_ascii_case(&client.color));
projects::create(&pool, client_id, &f.name, color.as_deref()).await?; projects::create(
&pool,
client_id,
&f.name,
color.as_deref(),
f.repo_url.as_deref(),
)
.await?;
back_to_clients() back_to_clients()
} }
@@ -497,6 +507,7 @@ async fn save_project(
let input = UpdateInput { let input = UpdateInput {
name: Some(f.name), name: Some(f.name),
color, color,
repo_url: f.repo_url.map(Some),
..Default::default() ..Default::default()
}; };
projects::update(&pool, id, &input).await?; projects::update(&pool, id, &input).await?;
+2
View File
@@ -87,6 +87,7 @@ label { display: flex; align-items: center; gap: .35rem; color: var(--muted); }
border: 1px solid var(--border); background: var(--surface); border-radius: 8px; border: 1px solid var(--border); background: var(--surface); border-radius: 8px;
padding: .45rem .9rem; cursor: pointer; white-space: nowrap; padding: .45rem .9rem; cursor: pointer; white-space: nowrap;
} }
a.btn { color: var(--text); text-decoration: none; }
.btn:hover { border-color: var(--muted); } .btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; } .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn.danger { color: var(--danger); } .btn.danger { color: var(--danger); }
@@ -153,6 +154,7 @@ input[type="color"] {
padding: .4rem 0; border-bottom: 1px solid var(--border); padding: .4rem 0; border-bottom: 1px solid var(--border);
} }
.projects li.archived { opacity: .6; } .projects li.archived { opacity: .6; }
.row.grow input.repo-url { flex: 1.3; }
.projects li > form::before { content: "-"; color: var(--muted); flex: none; } .projects li > form::before { content: "-"; color: var(--muted); flex: none; }
/* Periods & reports */ /* Periods & reports */
+41
View File
@@ -61,3 +61,44 @@ function removeRow(button) {
for (const input of row.querySelectorAll("input")) input._flatpickr?.destroy(); for (const input of row.querySelectorAll("input")) input._flatpickr?.destroy();
row.remove(); row.remove();
} }
// Favicon : point rouge clignotant tant qu'un enregistrement est en cours,
// sur toutes les pages (état lu sur /api/timer).
const favicon = document.getElementById("favicon");
const IDLE_ICON = favicon.href;
const recIcon = (opacity) =>
"data:image/svg+xml," +
encodeURIComponent(
`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><circle cx="16" cy="16" r="13" fill="#e5322d" fill-opacity="${opacity}"/></svg>`,
);
const REC_ON = recIcon(1);
const REC_OFF = recIcon(0.2);
let recording = false;
let blinkOn = false;
function setRecording(value) {
if (value === recording) return;
recording = value;
blinkOn = true;
favicon.href = recording ? REC_ON : IDLE_ICON;
}
setInterval(() => {
if (!recording) return;
blinkOn = !blinkOn;
favicon.href = blinkOn ? REC_ON : REC_OFF;
}, 1000);
async function refreshRecording() {
try {
const res = await fetch("/api/timer", { headers: { accept: "application/json" } });
if (res.ok) setRecording((await res.json()) !== null);
} catch {
// Serveur injoignable : on garde l'état connu.
}
}
refreshRecording();
setInterval(refreshRecording, 20000);
document.addEventListener("visibilitychange", () => {
if (!document.hidden) refreshRecording();
});
document.body.addEventListener("htmx:afterRequest", refreshRecording);
+1
View File
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><circle cx="16" cy="16" r="12" fill="none" stroke="#2f6f5e" stroke-width="4"/><path d="M16 9v7l4 3" fill="none" stroke="#2f6f5e" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/></svg>

After

Width:  |  Height:  |  Size: 261 B

+1
View File
@@ -6,6 +6,7 @@
{%- else if name == "check" -%}<path d="M20 6 9 17l-5-5"/> {%- else if name == "check" -%}<path d="M20 6 9 17l-5-5"/>
{%- else if name == "plus" -%}<path d="M5 12h14"/><path d="M12 5v14"/> {%- else if name == "plus" -%}<path d="M5 12h14"/><path d="M12 5v14"/>
{%- else if name == "reset" -%}<path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/><path d="M3 3v5h5"/> {%- else if name == "reset" -%}<path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/><path d="M3 3v5h5"/>
{%- else if name == "link" -%}<path d="M15 3h6v6"/><path d="M10 14 21 3"/><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/>
{%- else if name == "archive" -%}<rect x="2" y="3" width="20" height="5" rx="1"/><path d="M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8"/><path d="M10 12h4"/> {%- else if name == "archive" -%}<rect x="2" y="3" width="20" height="5" rx="1"/><path d="M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8"/><path d="M10 12h4"/>
{%- else if name == "unarchive" -%}<rect x="2" y="3" width="20" height="5" rx="1"/><path d="M4 8v11a2 2 0 0 0 2 2h2"/><path d="M20 8v11a2 2 0 0 1-2 2h-2"/><path d="m9 15 3-3 3 3"/><path d="M12 12v9"/> {%- else if name == "unarchive" -%}<rect x="2" y="3" width="20" height="5" rx="1"/><path d="M4 8v11a2 2 0 0 0 2 2h2"/><path d="M20 8v11a2 2 0 0 1-2 2h-2"/><path d="m9 15 3-3 3 3"/><path d="M12 12v9"/>
{%- endif -%} {%- endif -%}
+3 -2
View File
@@ -4,12 +4,13 @@
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<title>{% block title %}Tempus{% endblock %} · Tempus</title> <title>{% block title %}Tempus{% endblock %} · Tempus</title>
<link rel="icon" id="favicon" type="image/svg+xml" href="/static/favicon.svg">
<link rel="stylesheet" href="/static/flatpickr/flatpickr.min.css"> <link rel="stylesheet" href="/static/flatpickr/flatpickr.min.css">
<link rel="stylesheet" href="/static/app.css"> <link rel="stylesheet" href="/static/app.css?v={{ crate::routes::asset_version() }}">
<script src="/static/htmx.min.js" defer></script> <script src="/static/htmx.min.js" defer></script>
<script src="/static/flatpickr/flatpickr.min.js" defer></script> <script src="/static/flatpickr/flatpickr.min.js" defer></script>
<script src="/static/flatpickr/fr.min.js" defer></script> <script src="/static/flatpickr/fr.min.js" defer></script>
<script src="/static/app.js" defer></script> <script src="/static/app.js?v={{ crate::routes::asset_version() }}" defer></script>
</head> </head>
<body> <body>
<header class="topbar"> <header class="topbar">
+5
View File
@@ -47,6 +47,7 @@
<input type="color" name="color" value="{{ p.effective_color }}" aria-label="Couleur du projet" <input type="color" name="color" value="{{ p.effective_color }}" aria-label="Couleur du projet"
title="{% if p.color.is_some() %}Couleur propre au projet{% else %}Couleur du client{% endif %}"> title="{% if p.color.is_some() %}Couleur propre au projet{% else %}Couleur du client{% endif %}">
<input name="name" value="{{ p.name }}" required aria-label="Nom du projet"> <input name="name" value="{{ p.name }}" required aria-label="Nom du projet">
<input type="url" name="repo_url" value="{% if let Some(u) = p.repo_url %}{{ u }}{% endif %}" placeholder="URL du repo" aria-label="URL du repo" class="repo-url">
<div class="btn-group"> <div class="btn-group">
<button class="btn small icon primary" title="Enregistrer" aria-label="Enregistrer">{% call icons::icon("check") %}{% endcall %}</button> <button class="btn small icon primary" title="Enregistrer" aria-label="Enregistrer">{% call icons::icon("check") %}{% endcall %}</button>
{% if p.color.is_some() %} {% if p.color.is_some() %}
@@ -61,6 +62,9 @@
</form> </form>
<form id="delete-project-{{ p.id }}" method="post" action="/ui/projects/{{ p.id }}/delete" data-confirm="Supprimer ce projet et tout le temps saisi dessus ?" hidden></form> <form id="delete-project-{{ p.id }}" method="post" action="/ui/projects/{{ p.id }}/delete" data-confirm="Supprimer ce projet et tout le temps saisi dessus ?" hidden></form>
<div class="btn-group"> <div class="btn-group">
{% if let Some(u) = p.repo_url %}
<a class="btn small icon" href="{{ u }}" target="_blank" rel="noopener noreferrer" title="Ouvrir le repo" aria-label="Ouvrir le repo">{% call icons::icon("link") %}{% endcall %}</a>
{% endif %}
{% if p.archived %} {% if p.archived %}
<button class="btn small icon" form="archive-project-{{ p.id }}" title="Réactiver" aria-label="Réactiver">{% call icons::icon("unarchive") %}{% endcall %}</button> <button class="btn small icon" form="archive-project-{{ p.id }}" title="Réactiver" aria-label="Réactiver">{% call icons::icon("unarchive") %}{% endcall %}</button>
{% else %} {% else %}
@@ -76,6 +80,7 @@
<form method="post" action="/ui/clients/{{ c.client.id }}/projects" class="row"> <form method="post" action="/ui/clients/{{ c.client.id }}/projects" class="row">
<input type="color" name="color" value="{{ c.client.color }}" aria-label="Couleur du projet" title="Garder la couleur du client ou en choisir une autre"> <input type="color" name="color" value="{{ c.client.color }}" aria-label="Couleur du projet" title="Garder la couleur du client ou en choisir une autre">
<input name="name" required placeholder="Nouveau projet" aria-label="Nouveau projet" class="grow"> <input name="name" required placeholder="Nouveau projet" aria-label="Nouveau projet" class="grow">
<input type="url" name="repo_url" placeholder="URL du repo (facultatif)" aria-label="URL du repo" class="grow">
<button class="btn icon primary" title="Ajouter le projet" aria-label="Ajouter le projet">{% call icons::icon("plus") %}{% endcall %}</button> <button class="btn icon primary" title="Ajouter le projet" aria-label="Ajouter le projet">{% call icons::icon("plus") %}{% endcall %}</button>
</form> </form>
</section> </section>
+52
View File
@@ -707,3 +707,55 @@ async fn move_timer_start() {
let (status, _) = send_form(&app, "/ui/timer/debut", &format!("started_at={future}")).await; let (status, _) = send_form(&app, "/ui/timer/debut", &format!("started_at={future}")).await;
assert_eq!(status, StatusCode::UNPROCESSABLE_ENTITY); assert_eq!(status, StatusCode::UNPROCESSABLE_ENTITY);
} }
#[tokio::test]
async fn project_repo_url() {
let app = app().await;
let (_, c) = send(
&app,
"POST",
"/api/clients",
Some(json!({ "name": "Acme" })),
)
.await;
let uri = format!("/api/clients/{}/projects", c["id"]);
let (status, p) = send(
&app,
"POST",
&uri,
Some(json!({ "name": "Site", "repo_url": " https://git.example.com/acme/site " })),
)
.await;
assert_eq!(status, StatusCode::CREATED);
assert_eq!(p["repo_url"], "https://git.example.com/acme/site");
let (status, _) = send(
&app,
"POST",
&uri,
Some(json!({ "name": "Bad", "repo_url": "git@example.com:acme/site.git" })),
)
.await;
assert_eq!(status, StatusCode::UNPROCESSABLE_ENTITY);
// Absent: unchanged; "" clears it.
let project = format!("/api/projects/{}", p["id"]);
let (_, p) = send(&app, "PATCH", &project, Some(json!({ "name": "Site web" }))).await;
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\""));
let (_, p) = send(&app, "PATCH", &project, Some(json!({ "repo_url": "" }))).await;
assert!(p["repo_url"].is_null());
// HTML form: the URL field is saved with the project.
let (status, _) = send_form(
&app,
&project.replace("/api/", "/ui/"),
"name=Site+web&repo_url=https%3A%2F%2Fgit.example.com%2Fx",
)
.await;
assert_eq!(status, StatusCode::SEE_OTHER);
let (_, p) = send(&app, "GET", &format!("{uri}?archived=true"), None).await;
assert_eq!(p[0]["repo_url"], "https://git.example.com/x");
}