Improve scenario tool feedback and keep draft actions visible

This commit is contained in:
2026-09-06 05:32:34 +03:00
parent b2d713e774
commit c6c07cc3a3
5 changed files with 114 additions and 67 deletions
+24 -4
View File
@@ -878,11 +878,14 @@ impl Scene {
MessageKind::Timer { .. } => "timer · ",
}
};
let message_label = if let MessageKind::Timer { expression } = message_kind
{
expression.as_str()
let message_label = if !scenario {
r.map(|r| r.name.clone()).unwrap_or_else(|| e.name.clone())
} else if let MessageKind::Timer { expression } = message_kind {
format!("{} · {expression}", e.name)
} else if let Some(exchange) = r.filter(|r| r.name != e.name) {
format!("{} · {}", e.name, exchange.name)
} else {
r.map(|r| r.name.as_str()).unwrap_or(&e.name)
e.name.clone()
};
self.lines.push(Line {
id: *id,
@@ -1603,6 +1606,23 @@ mod direct_canvas_tests {
})
}
#[test]
fn reused_exchange_messages_display_their_distinct_occurrence_names() {
let mut f = scenario::direct_tests::fixture();
f.project.elements.get_mut(&f.call).unwrap().name = "Route request".into();
f.project.elements.get_mut(&f.reply).unwrap().name = "Route response".into();
let scene = Scene::sequence(&f.project, f.owner, f.call);
let call = scene.lines.iter().find(|line| line.id == f.call).unwrap();
let reply = scene.lines.iter().find(|line| line.id == f.reply).unwrap();
assert!(call.label.starts_with("1. call · Route request"));
assert!(reply.label.starts_with("2. reply · Route response"));
assert!(call.label.ends_with(&f.project.relations[&f.exchange].name));
assert!(
reply
.label
.ends_with(&f.project.relations[&f.exchange].name)
);
}
#[test]
fn direct_drag_and_click_click_use_ordered_sources_and_publish_once() {
for drag in [false, true] {
let (f, scene) = scene();
+38 -22
View File
@@ -1254,10 +1254,16 @@ pub fn view<'a>(app: &'a App, owner: Id, mut out: Column<'a, Message>) -> Elemen
if !pending {
out = out.push(
row![
button("Select / reorder").on_press(Message::ScenarioCanvas(CanvasEvent::Choose(
context,
CanvasTool::Select
))),
button("Select / reorder")
.on_press(Message::ScenarioCanvas(CanvasEvent::Choose(
context,
CanvasTool::Select
)))
.style(if tool == CanvasTool::Select {
style::selected
} else {
style::nav
}),
pick_list(
vec![
MessageStyle::Asynchronous,
@@ -1277,10 +1283,16 @@ pub fn view<'a>(app: &'a App, owner: Id, mut out: Column<'a, Message>) -> Elemen
.text_size(12)
.padding(8)
.width(Fill),
button("Draw message").on_press(Message::ScenarioCanvas(CanvasEvent::Choose(
context,
CanvasTool::Message(style)
))),
button("Draw message")
.on_press(Message::ScenarioCanvas(CanvasEvent::Choose(
context,
CanvasTool::Message(style)
)))
.style(if matches!(tool, CanvasTool::Message(_)) {
style::selected
} else {
style::nav
}),
]
.spacing(6),
);
@@ -1314,7 +1326,7 @@ pub fn view<'a>(app: &'a App, owner: Id, mut out: Column<'a, Message>) -> Elemen
horizontal: scrollable::Scrollbar::default(),
})
.height(if pending {
(app.window_size.height - 500.).clamp(160., 260.)
(app.window_size.height - 660.).clamp(110., 190.)
} else {
(app.window_size.height - 410.).clamp(180., 340.)
}),
@@ -1524,24 +1536,28 @@ pub fn view<'a>(app: &'a App, owner: Id, mut out: Column<'a, Message>) -> Elemen
if let Err(error) = &readiness {
form = form.push(label(error.clone()));
}
form = form.push(
row![
button("Create")
.padding(9)
.on_press_maybe(readiness.is_ok().then_some(event(Event::Submit))),
action("Cancel", event(Event::Cancel))
]
.spacing(7),
);
let footer = row![
button("Create")
.padding(9)
.on_press_maybe(readiness.is_ok().then_some(event(Event::Submit))),
action("Cancel", event(Event::Cancel))
]
.spacing(7);
out = out.push(
container(scrollable(form).height((app.window_size.height - 470.).clamp(190., 280.)))
.padding(14)
.style(style::card),
container(
column![
scrollable(form).height((app.window_size.height - 650.).clamp(110., 240.)),
footer
]
.spacing(9),
)
.padding(14)
.style(style::card),
);
}
if lines(p, owner).is_empty() && p.elements[&owner].steps().is_none_or(Vec::is_empty) {
out = out.push(container(label("Add lifelines for the participating work or actors, then create messages between them.")).padding(16).width(Fill).style(style::card));
} else {
} else if !pending {
out = sequence_rows(p, owner, out);
}
super::scenario_scroll::observe(context, ScrollArea::Page, scrollable(out.padding(24)))