archetype flows behave like the built-ins: switch off per archetype or per agent, board cards, duplicate
The document's disabled list takes archetype:<archetype>/<flow> (off for every member) and the same with @<agent> (off for one member); a key naming nothing is ignored. GET /api/notify/flows lists the archetype flows with their members, the board draws a card for each with a switch, a checkbox per agent and duplicate, and the dry run counts their hits. The flows keep following the archetype.
This commit is contained in:
parent
1efbb72fdd
commit
68c24643f6
1 changed files with 908 additions and 102 deletions
|
|
@ -41,6 +41,9 @@ pub enum Read {
|
|||
/// The flows in force, and which revision of the key they came from.
|
||||
pub struct Flows {
|
||||
pub active: Vec<Flow>,
|
||||
/// The document's `disabled_builtins`, which also switches off archetype
|
||||
/// flows ([`crate::archetype_flows::enabled`]).
|
||||
pub disabled: Vec<String>,
|
||||
/// The revision `active` was read from; `None` for the built-ins alone.
|
||||
revision: Option<u64>,
|
||||
/// The last problem logged, so a standing one is logged once.
|
||||
|
|
@ -53,6 +56,7 @@ impl Flows {
|
|||
pub fn builtins() -> Self {
|
||||
Self {
|
||||
active: Document::default().active().0,
|
||||
disabled: Vec::new(),
|
||||
revision: None,
|
||||
problem: None,
|
||||
checked: None,
|
||||
|
|
@ -70,6 +74,7 @@ impl Flows {
|
|||
);
|
||||
}
|
||||
self.active = Document::default().active().0;
|
||||
self.disabled.clear();
|
||||
self.problem = None;
|
||||
}
|
||||
Read::Document { revision, .. } if self.revision == Some(revision) => {}
|
||||
|
|
@ -92,6 +97,7 @@ impl Flows {
|
|||
"notify router: running the flows document"
|
||||
);
|
||||
self.active = active;
|
||||
self.disabled = doc.disabled_builtins;
|
||||
self.revision = Some(revision);
|
||||
self.problem = None;
|
||||
}
|
||||
|
|
@ -285,4 +291,22 @@ mod tests {
|
|||
});
|
||||
assert_eq!(ids(&f), BUILTIN_IDS);
|
||||
}
|
||||
|
||||
/// The document's disabled list is kept whole, archetype keys among the
|
||||
/// built-in ids, and goes with the document: a deleted one clears it.
|
||||
#[test]
|
||||
fn the_disabled_list_includes_archetype_keys_and_goes_with_the_document() {
|
||||
let mut f = Flows::builtins();
|
||||
assert!(f.disabled.is_empty());
|
||||
f.apply(at(1, doc(&["closed", "archetype:triage/new@alice"], &[])));
|
||||
assert_eq!(f.disabled, ["closed", "archetype:triage/new@alice"]);
|
||||
f.apply(junk(2, b"not json"));
|
||||
assert_eq!(
|
||||
f.disabled.len(),
|
||||
2,
|
||||
"a document it cannot read changes nothing"
|
||||
);
|
||||
f.apply(Read::Absent);
|
||||
assert!(f.disabled.is_empty());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue