Port commit page to Page

This commit is contained in:
Joscha 2024-05-13 00:32:47 +02:00
parent 537419c251
commit 8047814894

View file

@ -12,8 +12,8 @@ use crate::{
server::{ server::{
util, util,
web::{ web::{
base::{Base, Tab},
components, components,
page::{Page, Tab},
paths::{PathAdminQueueAdd, PathCommitByHash}, paths::{PathAdminQueueAdd, PathCommitByHash},
server_config_ext::ServerConfigExt, server_config_ext::ServerConfigExt,
}, },
@ -26,8 +26,6 @@ pub async fn get_commit_by_hash(
State(config): State<&'static ServerConfig>, State(config): State<&'static ServerConfig>,
State(db): State<SqlitePool>, State(db): State<SqlitePool>,
) -> somehow::Result<Response> { ) -> somehow::Result<Response> {
let base = Base::new(config, Tab::None);
let Some(commit) = sqlx::query!( let Some(commit) = sqlx::query!(
"\ "\
SELECT \ SELECT \
@ -93,60 +91,61 @@ pub async fn get_commit_by_hash(
let (class, title) = components::commit_class_and_title(commit.reachable); let (class, title) = components::commit_class_and_title(commit.reachable);
Ok(base let html = Page::new(config)
.html( .title(util::format_commit_summary(&commit.message))
&util::format_commit_summary(&commit.message), .nav(Tab::None)
html! {}, .body(html! {
html! { h2 { "Commit" }
h2 { "Commit" } div .commit-like .commit {
div .commit-like .commit { span .title { "commit " (commit.hash) }
span .title { "commit " (commit.hash) } dl {
dl { dt { "Author:" }
dt { "Author:" } dd { (commit.author) }
dd { (commit.author) }
dt { "AuthorDate:" } dt { "AuthorDate:" }
dd { (util::format_time(commit.author_date)) } dd { (util::format_time(commit.author_date)) }
dt { "Commit:" } dt { "Commit:" }
dd { (commit.committer) } dd { (commit.committer) }
dt { "CommitDate:" } dt { "CommitDate:" }
dd { (util::format_time(commit.committer_date)) } dd { (util::format_time(commit.committer_date)) }
@for commit in parents { @for commit in parents {
dt { "Parent:" } dt { "Parent:" }
dd { (commit) } dd { (commit) }
}
@for commit in children {
dt { "Child:" }
dd { (commit) }
}
} }
pre .(class) title=(title) {
(commit.message.trim_end()) @for commit in children {
dt { "Child:" }
dd { (commit) }
} }
} }
pre .(class) title=(title) {
h2 { "Runs" } (commit.message.trim_end())
@if runs.is_empty() { }
p { "There aren't any runs yet." } }
} @else { })
ul { .body(html!{
@for run in runs { h2 { "Runs" }
li { (run) } @if runs.is_empty() {
} p { "There aren't any runs yet." }
} @else {
ul {
@for run in runs {
li { (run) }
} }
} }
form method="post" action=(config.path(PathAdminQueueAdd {})) { }
input type="hidden" name="hash" value=(commit.hash); form method="post" action=(config.path(PathAdminQueueAdd {})) {
button { "Add to queue" } " with a " input type="hidden" name="hash" value=(commit.hash);
label for="priority" { "priority" } " of " button { "Add to queue" } " with a "
input id="priority" name="priority" type="number" value="10" min="-2147483648" max="2147483647"; label for="priority" { "priority" } " of "
"." input id="priority" name="priority" type="number" value="10" min="-2147483648" max="2147483647";
} "."
}, }
) })
.into_response()) .build();
Ok(html.into_response())
} }