Radish alpha
r
rad:zwTxygwuz5LDGBq255RA2CbNGrz8
Radicle CI broker
Radicle
Git
feat: on the front status page, tell result run if known
Merged liw opened 1 year ago

Previously we just said “finished”, now we say “finished, success” or the like.

Signed-off-by: Lars Wirzenius liw@liw.fi

1 file changed +38 -12 535b1592 513eb2c5
modified src/pages.rs
@@ -122,17 +122,20 @@ impl PageData {
        );

        for (alias, rid) in self.repos() {
-
            let (run_ids, status, info_url) = match self.latest_run(rid) {
-
                Some(run) => (
-
                    Self::run_ids(Some(run)),
-
                    run.state().to_string(),
-
                    Self::info_url(Some(run)),
-
                ),
-
                None => (
-
                    Self::run_ids(None),
-
                    "unknown".to_string(),
-
                    Self::info_url(None),
-
                ),
+
            let (run_ids, status, info_url) = {
+
                let run = self.latest_run(rid);
+
                match run {
+
                    Some(run) => (
+
                        Self::run_ids(Some(run)),
+
                        Self::run_state(run),
+
                        Self::info_url(Some(run)),
+
                    ),
+
                    None => (
+
                        Self::run_ids(None),
+
                        Self::run_state_unknown(),
+
                        Self::info_url(None),
+
                    ),
+
                }
            };

            table.push_child(
@@ -143,7 +146,7 @@ impl PageData {
                        Element::new(Tag::Td).with_child(
                            Element::new(Tag::Span)
                                .with_class("run-status")
-
                                .with_text(&status),
+
                                .with_child(status),
                        ),
                    )
                    .with_child(Element::new(Tag::Td).with_child(info_url)),
@@ -238,6 +241,29 @@ impl PageData {
        Ok(doc)
    }

+
    fn run_state(run: &Run) -> Element {
+
        let status = match run.state() {
+
            RunState::Finished => {
+
                if let Some(result) = run.result() {
+
                    format!("{}, {}", run.state(), result)
+
                } else {
+
                    format!("{} with unknown result", run.state())
+
                }
+
            }
+
            _ => run.state().to_string(),
+
        };
+

+
        Element::new(Tag::Span)
+
            .with_class(&status)
+
            .with_text(&status.to_string())
+
    }
+

+
    fn run_state_unknown() -> Element {
+
        Element::new(Tag::Span)
+
            .with_class("run-status")
+
            .with_text("unknown")
+
    }
+

    fn per_repo_page_as_html(&self, rid: RepoId, alias: &str, timestamp: &str) -> HtmlPage {
        let mut doc = HtmlPage::default();