Treat elements with "Ultimate Goal" label specially

Mainly restyle them to appear different from other techtree elements.
Also ignore any element status for these, because it is meaningless
(they can never be reached).
This commit is contained in:
Rahix 2026-01-23 14:48:49 +01:00
parent be7f305a6b
commit 8b0aef0599
2 changed files with 12 additions and 1 deletions

View file

@ -128,9 +128,15 @@ fn element_from_issue(issue: &forgejo_api::structs::Issue) -> anyhow::Result<cra
.iter() .iter()
.any(|l| l.name.as_deref() == Some("Completed")); .any(|l| l.name.as_deref() == Some("Completed"));
let has_ultimate_label = labels
.iter()
.any(|l| l.name.as_deref() == Some("Ultimate Goal"));
let status = match issue.state.context("Missing issue state")? { let status = match issue.state.context("Missing issue state")? {
forgejo_api::structs::StateType::Open => { forgejo_api::structs::StateType::Open => {
if has_completed_label { if has_ultimate_label {
crate::tree::ElementStatus::UltimateGoal
} else if has_completed_label {
crate::tree::ElementStatus::Completed crate::tree::ElementStatus::Completed
} else if issue.assignee.is_some() } else if issue.assignee.is_some()
|| issue.assignees.as_ref().is_some_and(|v| !v.is_empty()) || issue.assignees.as_ref().is_some_and(|v| !v.is_empty())

View file

@ -55,6 +55,7 @@ impl Element {
let (color, background) = match (subtree_role, status) { let (color, background) = match (subtree_role, status) {
(Some(SubtreeElementRole::ElementOfInterest), _) => ("black", "white"), (Some(SubtreeElementRole::ElementOfInterest), _) => ("black", "white"),
(Some(SubtreeElementRole::Dependant), _) => ("gray", "gray"), (Some(SubtreeElementRole::Dependant), _) => ("gray", "gray"),
(_, ElementStatus::UltimateGoal) => ("black", "white"),
(_, ElementStatus::Missing) => ( (_, ElementStatus::Missing) => (
"#800", "#800",
// Highlight root elements // Highlight root elements
@ -100,6 +101,7 @@ impl Element {
let class = match (role, status) { let class = match (role, status) {
(Some(SubtreeElementRole::ElementOfInterest), _) => "eoi", (Some(SubtreeElementRole::ElementOfInterest), _) => "eoi",
(Some(SubtreeElementRole::Dependant), _) => "dependant", (Some(SubtreeElementRole::Dependant), _) => "dependant",
(_, ElementStatus::UltimateGoal) => "ultimate",
(_, ElementStatus::Missing) => "dep_missing", (_, ElementStatus::Missing) => "dep_missing",
(_, ElementStatus::Assigned) => "dep_assigned", (_, ElementStatus::Assigned) => "dep_assigned",
(_, ElementStatus::Completed) => "dep_completed", (_, ElementStatus::Completed) => "dep_completed",
@ -116,6 +118,7 @@ fn mermaid_classes() -> String {
r##" r##"
classDef eoi fill:#fff, stroke:#000, color:#000; classDef eoi fill:#fff, stroke:#000, color:#000;
classDef dependant fill:#fff, stroke:#888, color:#888; classDef dependant fill:#fff, stroke:#888, color:#888;
classDef ultimate fill:#fff, stroke:#000, color:#000;
classDef dep_missing fill:#fcc, stroke:#800, color:#000; classDef dep_missing fill:#fcc, stroke:#800, color:#000;
classDef dep_assigned fill:#ffa, stroke:#a50, color:#000; classDef dep_assigned fill:#ffa, stroke:#a50, color:#000;
classDef dep_completed fill:#afa, stroke:#080, color:#000; classDef dep_completed fill:#afa, stroke:#080, color:#000;
@ -128,6 +131,7 @@ pub enum ElementStatus {
Missing, Missing,
Assigned, Assigned,
Completed, Completed,
UltimateGoal,
} }
impl std::fmt::Display for ElementStatus { impl std::fmt::Display for ElementStatus {
@ -136,6 +140,7 @@ impl std::fmt::Display for ElementStatus {
ElementStatus::Missing => "MISSING", ElementStatus::Missing => "MISSING",
ElementStatus::Assigned => "ASSIGNED", ElementStatus::Assigned => "ASSIGNED",
ElementStatus::Completed => "COMPLETED", ElementStatus::Completed => "COMPLETED",
ElementStatus::UltimateGoal => "ULTIMATE GOAL",
}) })
} }
} }