Skip to content

Commit 89a42e3

Browse files
committed
refactor(webui): Move stub response link to trace view
1 parent b557b61 commit 89a42e3

3 files changed

Lines changed: 42 additions & 50 deletions

File tree

crates/webui/src/app.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,6 @@ impl Route {
191191
Route::ExecutionListNewerIncluding { cursor } => {
192192
html! { <ExecutionListPage filter={ExecutionFilter::Newer { cursor, including_cursor: true }} /> }
193193
}
194-
195194
Route::ExecutionListByFfqn { ffqn } => {
196195
html! { <ExecutionListPage filter={ExecutionFilter::Ffqn { ffqn } } /> }
197196
}

crates/webui/src/components/execution_detail_page.rs

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
1-
use crate::app::{AppState, Route};
21
use crate::components::debugger::debugger_view::EventsAndResponsesState;
32
use crate::components::execution_detail::utils::{compute_join_next_to_response, event_to_detail};
43
use crate::components::execution_header::{ExecutionHeader, ExecutionLink};
5-
use crate::grpc::ffqn::FunctionFqn;
6-
use crate::grpc::grpc_client::{
7-
self, ComponentType, ExecutionEvent, ExecutionId, JoinSetResponseEvent,
8-
};
4+
use crate::grpc::grpc_client::{self, ExecutionEvent, ExecutionId, JoinSetResponseEvent};
95
use assert_matches::assert_matches;
106
use chrono::DateTime;
117
use hashbrown::HashMap;
128
use std::ops::Deref;
139
use yew::prelude::*;
14-
use yew_router::prelude::Link;
1510

1611
#[derive(Properties, PartialEq)]
1712
pub struct ExecutionLogPageProps {
@@ -49,15 +44,8 @@ pub fn execution_log_page(ExecutionLogPageProps { execution_id }: &ExecutionLogP
4944
let responses = &events_and_responses_state.responses_state.0;
5045
let join_next_version_to_response = compute_join_next_to_response(events, responses);
5146

52-
let app_state =
53-
use_context::<AppState>().expect("AppState context is set when starting the App");
54-
55-
let details_html = render_execution_details(
56-
execution_id,
57-
events,
58-
&join_next_version_to_response,
59-
&app_state,
60-
);
47+
let details_html =
48+
render_execution_details(execution_id, events, &join_next_version_to_response);
6149

6250
html! {
6351
<>
@@ -75,7 +63,6 @@ fn render_execution_details(
7563
execution_id: &ExecutionId,
7664
events: &[ExecutionEvent],
7765
join_next_version_to_response: &HashMap<u32, &JoinSetResponseEvent>,
78-
app_state: &AppState,
7966
) -> Option<Html> {
8067
if events.is_empty() {
8168
return None;
@@ -99,18 +86,6 @@ fn render_execution_details(
9986
)
10087
};
10188

102-
let ffqn = FunctionFqn::from(create_event);
103-
let maybe_stub_link = if let Some((_, component_id)) = app_state.ffqns_to_details.get(&ffqn)
104-
&& let Some(found_component) = app_state.components_by_id.get(component_id)
105-
&& found_component.as_type() == ComponentType::ActivityStub
106-
{
107-
Some(html! {
108-
<Link<Route> to={Route::ExecutionStubResult { ffqn: ffqn.clone(), execution_id: execution_id.clone() }}>{"Submit stub response"}</Link<Route>>
109-
})
110-
} else {
111-
None
112-
};
113-
11489
let rows: Vec<_> = events
11590
.iter()
11691
.map(|event| {
@@ -140,7 +115,6 @@ fn render_execution_details(
140115
.collect();
141116
Some(html! {
142117
<div class="table-wrapper">
143-
{maybe_stub_link}
144118
<table>
145119
<thead>
146120
<tr>

crates/webui/src/components/trace/trace_view.rs

Lines changed: 39 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use super::data::{BusyIntervalStatus, TraceData};
22
use crate::{
3-
app::Route,
3+
app::{AppState, Route},
44
components::{
55
execution_detail::utils::{compute_join_next_to_response, event_to_detail},
66
execution_header::{ExecutionHeader, ExecutionLink},
@@ -13,8 +13,8 @@ use crate::{
1313
execution_id::{EXECUTION_ID_INFIX, ExecutionIdExt as _},
1414
ffqn::FunctionFqn,
1515
grpc_client::{
16-
self, ExecutionEvent, ExecutionId, JoinSetId, JoinSetResponseEvent, ResponseWithCursor,
17-
ResultDetail,
16+
self, ComponentType, ExecutionEvent, ExecutionId, JoinSetId, JoinSetResponseEvent,
17+
ResponseWithCursor, ResultDetail,
1818
execution_event::{
1919
self, Finished, TemporarilyFailed, TemporarilyTimedOut,
2020
history_event::{JoinSetRequest, join_set_request},
@@ -157,6 +157,9 @@ pub fn trace_view(TraceViewProps { execution_id }: &TraceViewProps) -> Html {
157157

158158
let trace_view = trace_view_state.deref();
159159

160+
let app_state =
161+
use_context::<AppState>().expect("AppState context is set when starting the App");
162+
160163
let root_trace = {
161164
let events_map = &trace_view.events;
162165
let responses_map = &trace_view.responses;
@@ -175,6 +178,7 @@ pub fn trace_view(TraceViewProps { execution_id }: &TraceViewProps) -> Html {
175178
trace_view_state.dispatch(TraceviewStateAction::AddExecutionId(execution_id));
176179
}
177180
},
181+
&app_state,
178182
)
179183
};
180184

@@ -313,6 +317,7 @@ fn compute_root_trace(
313317
responses_map: &HashMap<ExecutionId, HashMap<JoinSetId, Vec<JoinSetResponseEvent>>>,
314318
contains: impl Fn(&ExecutionId) -> bool + Clone,
315319
on_execution_load: impl Fn(ExecutionId) + Clone + 'static,
320+
app_state: &AppState,
316321
) -> Option<TraceDataRoot> {
317322
let events = match events_map.get(execution_id) {
318323
Some(events) if !events.is_empty() => events,
@@ -324,22 +329,33 @@ fn compute_root_trace(
324329
let responses = responses_map.get(execution_id);
325330
let mut last_event_at = compute_last_event_at(last_event, is_finished, responses);
326331

327-
let execution_scheduled_at = {
328-
let create_event = events
329-
.first()
330-
.expect("not found is sent as an error")
331-
.event
332-
.as_ref()
333-
.expect("`event` is sent by the server");
334-
let create_event = assert_matches!(
335-
create_event,
336-
grpc_client::execution_event::Event::Created(created) => created
337-
);
338-
DateTime::from(
339-
create_event
340-
.scheduled_at
341-
.expect("`scheduled_at` is sent by the server"),
342-
)
332+
let create_event = events
333+
.first()
334+
.expect("not found is sent as an error")
335+
.event
336+
.as_ref()
337+
.expect("`event` is sent by the server");
338+
let create_event = assert_matches!(
339+
create_event,
340+
grpc_client::execution_event::Event::Created(created) => created
341+
);
342+
let execution_scheduled_at = DateTime::from(
343+
create_event
344+
.scheduled_at
345+
.expect("`scheduled_at` is sent by the server"),
346+
);
347+
348+
let ffqn = FunctionFqn::from(create_event);
349+
let maybe_stub_link = if events.len() == 1 // stub execution can only contain Created and Finished events
350+
&& let Some((_, component_id)) = app_state.ffqns_to_details.get(&ffqn)
351+
&& let Some(found_component) = app_state.components_by_id.get(component_id)
352+
&& found_component.as_type() == ComponentType::ActivityStub
353+
{
354+
Some(html! {
355+
<Link<Route> to={Route::ExecutionStubResult { ffqn: ffqn.clone(), execution_id: execution_id.clone() }}>{"Submit stub response"}</Link<Route>>
356+
})
357+
} else {
358+
None
343359
};
344360

345361
let child_ids_to_results = compute_child_execution_id_to_child_execution_finished(responses);
@@ -431,7 +447,8 @@ fn compute_root_trace(
431447
events_map,
432448
responses_map,
433449
contains.clone(),
434-
on_execution_load.clone()
450+
on_execution_load.clone(),
451+
app_state
435452
) {
436453
last_event_at = last_event_at.max(child_root.last_event_at);
437454
Some(vec![TraceData::Root(child_root)])
@@ -572,6 +589,8 @@ fn compute_root_trace(
572589
<>
573590
{execution_id.render_execution_parts(true, ExecutionLink::Trace)}
574591
{" "}{&ffqn.function_name}
592+
{" "}
593+
{maybe_stub_link}
575594
</>
576595
};
577596
Some(TraceDataRoot {

0 commit comments

Comments
 (0)