Radish alpha
r
Radicle CI broker
Radicle
Git (anonymous pull)
Log in to clone via SSH
refactor: use .with_class instead of .with_attribute to set class
Lars Wirzenius committed 2 years ago
commit d8a1035da0996f1cc98511072cc47c99ed65087f
parent 9085ada0db9fa277230ba306f7ee1c750b1f9497
1 file changed +19 -27
modified src/pages.rs
@@ -151,7 +151,7 @@ impl PageData {

        doc.push_to_body(Element::new(Tag::P).with_text("Latest CI run for each repository."));

-
        let mut list = Element::new(Tag::Ul).with_attribute("class", "repolist");
+
        let mut list = Element::new(Tag::Ul).with_class("repolist");
        for (alias, rid) in self.repos() {
            let mut item = Element::new(Tag::Li);

@@ -163,13 +163,13 @@ impl PageData {
                        .with_text("Repository ")
                        .with_child(
                            Element::new(Tag::Span)
-
                                .with_attribute("class", "alias")
+
                                .with_class("alias)")
                                .with_text(&alias),
                        )
                        .with_text(" (")
                        .with_child(
                            Element::new(Tag::Code)
-
                                .with_attribute("class", "repoid")
+
                                .with_class("repoid)")
                                .with_text(&rid.to_string()),
                        )
                        .with_text(&format!("), {} runs", runs.len())),
@@ -188,11 +188,7 @@ impl PageData {
                item.push_child(Element::new(Tag::Br));

                let state = run.state().to_string();
-
                item.push_child(
-
                    Element::new(Tag::Span)
-
                        .with_attribute("class", &state)
-
                        .with_text(&state),
-
                );
+
                item.push_child(Element::new(Tag::Span).with_class(&state).with_text(&state));

                let result = match run.result() {
                    None => Element::new(Tag::Span)
@@ -229,13 +225,13 @@ impl PageData {
                .with_text("branch ")
                .with_child(
                    Element::new(Tag::Code)
-
                        .with_attribute("class", "branch")
+
                        .with_class("branch)")
                        .with_text(name),
                )
                .with_text(", commit  ")
                .with_child(
                    Element::new(Tag::Code)
-
                        .with_attribute("class", "commit")
+
                        .with_class("commit)")
                        .with_text(&commit.to_string()),
                )
                .with_child(Element::new(Tag::Br))
@@ -254,27 +250,23 @@ impl PageData {
                .with_text("patch ")
                .with_child(
                    Element::new(Tag::Code)
-
                        .with_attribute("class", "branch")
+
                        .with_class("branch")
                        .with_text(&patch.to_string()),
                )
                .with_child(Element::new(Tag::Br))
                .with_text("revision ")
-
                .with_child(
-
                    Element::new(Tag::Code)
-
                        .with_attribute("class", "revision")
-
                        .with_text(&{
-
                            if let Some(rev) = &revision {
-
                                rev.to_string()
-
                            } else {
-
                                "<unknown patch revision>".to_string()
-
                            }
-
                        }),
-
                )
+
                .with_child(Element::new(Tag::Code).with_class("revision)").with_text(&{
+
                    if let Some(rev) = &revision {
+
                        rev.to_string()
+
                    } else {
+
                        "<unknown patch revision>".to_string()
+
                    }
+
                }))
                .with_child(Element::new(Tag::Br))
                .with_text("commit ")
                .with_child(
                    Element::new(Tag::Code)
-
                        .with_attribute("class", "commit")
+
                        .with_class("commit)")
                        .with_text(&commit.to_string()),
                )
                .with_child(Element::new(Tag::Br))
@@ -319,14 +311,14 @@ impl PageData {
        let mut runs = self.runs(rid);
        runs.sort_by_cached_key(|run| run.timestamp());
        runs.reverse();
-
        let mut list = Element::new(Tag::Ol).with_attribute("class", "runlist");
+
        let mut list = Element::new(Tag::Ol).with_class("runlist");
        for run in runs {
            let current = match run.state() {
                RunState::Triggered => Element::new(Tag::Span)
                    .with_attribute("state", "triggered")
                    .with_text("triggered"),
                RunState::Running => Element::new(Tag::Span)
-
                    .with_attribute("class", "running")
+
                    .with_class("running)")
                    .with_text("running"),
                RunState::Finished => {
                    let result = if let Some(result) = run.result() {
@@ -335,7 +327,7 @@ impl PageData {
                        "unknown".into()
                    };
                    Element::new(Tag::Span)
-
                        .with_attribute("class", &result)
+
                        .with_class(&result)
                        .with_text(&result)
                }
            };
@@ -346,7 +338,7 @@ impl PageData {
                    .with_text("log")
            } else {
                Element::new(Tag::Span)
-
                    .with_attribute("class", "missing_log")
+
                    .with_class("missing_log")
                    .with_text("no log yet")
            };