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:
parent
81932d2ac1
commit
6d258f489f
|
@ -88,7 +88,7 @@ fn element_from_issue(issue: &forgejo_api::structs::Issue) -> anyhow::Result<cra
|
|||
.context("Issue does not have any labels")?
|
||||
.iter()
|
||||
.filter_map(|l| l.name.as_deref())
|
||||
.filter(|l| l.starts_with("ty/"))
|
||||
.filter(|l| l.starts_with("Type/"))
|
||||
.collect();
|
||||
|
||||
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!");
|
||||
}
|
||||
|
||||
let ty = match *ty_labels.first().unwrap() {
|
||||
"ty/equipment" => crate::tree::ElementType::Equipment,
|
||||
"ty/process" => crate::tree::ElementType::Process,
|
||||
"ty/knowledge" => crate::tree::ElementType::Knowledge,
|
||||
t => anyhow::bail!("Unknown element type for issue #{issue_number}: {t:?}"),
|
||||
};
|
||||
let ty = ty_labels
|
||||
.first()
|
||||
.unwrap()
|
||||
.strip_prefix("Type/")
|
||||
.unwrap()
|
||||
.to_owned();
|
||||
|
||||
let status = match issue.state.context("Missing issue state")? {
|
||||
forgejo_api::structs::StateType::Open => {
|
||||
|
|
|
@ -10,7 +10,7 @@ pub struct Element {
|
|||
/// Description of this element
|
||||
pub description: String,
|
||||
/// Type of this element
|
||||
pub ty: ElementType,
|
||||
pub ty: String,
|
||||
/// Completion status of this element.
|
||||
pub status: ElementStatus,
|
||||
}
|
||||
|
@ -54,7 +54,9 @@ impl Element {
|
|||
status,
|
||||
} = 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) {
|
||||
(Some(SubtreeElementRole::ElementOfInterest), _) => "eoi",
|
||||
|
@ -82,23 +84,6 @@ fn mermaid_classes() -> String {
|
|||
.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)]
|
||||
pub enum ElementStatus {
|
||||
Missing,
|
||||
|
|
Loading…
Reference in a new issue