pub fn status_label(status: &str) -> &'static str {
match status {
"disabled" => "Disabled",
"satisfied" => "Satisfied",
"adjusted" | "adjusting" => "Adjusting",
"blocked" => "Blocked",
"pending" | "" => "Pending",
"duplicate" => "Duplicate",
"error" => "Error",
"incomplete" => "Incomplete",
"invalid-selection" => "Invalid selection",
"unsupported-selection" | "unimplemented" => "Unimplemented",
"pending-component" => "Pending component",
"fixed" => "Locked",
"noop" => "No change",
"apply-failed" => "Failed",
_ => "Pending",
}
}
pub fn status_color_rgb(status: &str) -> [u8; 3] {
match status {
"disabled" => [0x8e, 0x8e, 0x93],
"satisfied" => [0x30, 0xd1, 0x58],
"blocked" | "duplicate" | "error" | "invalid-selection" | "apply-failed" => {
[0xff, 0x3b, 0x30]
}
"unsupported-selection" | "unimplemented" => [0xff, 0x9f, 0x0a],
_ => [0xff, 0xd6, 0x0a],
}
}
pub fn status_color_hex(status: &str) -> String {
let [r, g, b] = status_color_rgb(status);
format!("#{r:02x}{g:02x}{b:02x}")
}
pub fn status_severity(status: &str) -> u8 {
match status {
"disabled" => 0,
"satisfied" => 1,
"blocked" | "duplicate" | "error" | "apply-failed" => 3,
_ => 2,
}
}