manager: Use Type/ labels instead of ty/ and don't force types

Allow arbitrary element types via the Type/# labels.
This commit is contained in:
Rahix 2025-05-22 10:09:59 +02:00
parent 81932d2ac1
commit 6d258f489f
2 changed files with 11 additions and 26 deletions

View file

@ -88,7 +88,7 @@ fn element_from_issue(issue: &forgejo_api::structs::Issue) -> anyhow::Result<cra
.context("Issue does not have any labels")? .context("Issue does not have any labels")?
.iter() .iter()
.filter_map(|l| l.name.as_deref()) .filter_map(|l| l.name.as_deref())
.filter(|l| l.starts_with("ty/")) .filter(|l| l.starts_with("Type/"))
.collect(); .collect();
if ty_labels.len() == 0 { if ty_labels.len() == 0 {
@ -98,12 +98,12 @@ fn element_from_issue(issue: &forgejo_api::structs::Issue) -> anyhow::Result<cra
anyhow::bail!("Issue #{issue_number} has more than one type label!"); anyhow::bail!("Issue #{issue_number} has more than one type label!");
} }
let ty = match *ty_labels.first().unwrap() { let ty = ty_labels
"ty/equipment" => crate::tree::ElementType::Equipment, .first()
"ty/process" => crate::tree::ElementType::Process, .unwrap()
"ty/knowledge" => crate::tree::ElementType::Knowledge, .strip_prefix("Type/")
t => anyhow::bail!("Unknown element type for issue #{issue_number}: {t:?}"), .unwrap()
}; .to_owned();
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 => {

View file

@ -10,7 +10,7 @@ pub struct Element {
/// Description of this element /// Description of this element
pub description: String, pub description: String,
/// Type of this element /// Type of this element
pub ty: ElementType, pub ty: String,
/// Completion status of this element. /// Completion status of this element.
pub status: ElementStatus, pub status: ElementStatus,
} }
@ -54,7 +54,9 @@ impl Element {
status, status,
} = self; } = self;
let label = format!(r##"<a href='/rahix/techtree-poc/issues/{issue_number}' target='_blank'>#{issue_number}</a> | {status}\n<i>{ty}</i>\n<b>{description}</b>"##); let label = format!(
r##"<a href='/rahix/techtree-poc/issues/{issue_number}' target='_blank'>#{issue_number}</a> | {status}\n<i>{ty}</i>\n<b>{description}</b>"##
);
let class = match (role, status) { let class = match (role, status) {
(Some(SubtreeElementRole::ElementOfInterest), _) => "eoi", (Some(SubtreeElementRole::ElementOfInterest), _) => "eoi",
@ -82,23 +84,6 @@ fn mermaid_classes() -> String {
.to_owned() .to_owned()
} }
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, serde::Serialize)]
pub enum ElementType {
Equipment,
Process,
Knowledge,
}
impl std::fmt::Display for ElementType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(match self {
ElementType::Equipment => "Equipment",
ElementType::Process => "Process",
ElementType::Knowledge => "Knowledge",
})
}
}
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, serde::Serialize)] #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, serde::Serialize)]
pub enum ElementStatus { pub enum ElementStatus {
Missing, Missing,