1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
// Job detail view rendering
use crate::app::App;
use ratatui::{
backend::CrosstermBackend,
layout::{Constraint, Direction, Layout, Rect},
style::{Color, Modifier, Style},
text::{Line, Span},
widgets::{Block, BorderType, Borders, Paragraph, Row, Table},
Frame,
};
use std::io;
// Render the job detail view
pub fn render_job_detail_view(
f: &mut Frame<CrosstermBackend<io::Stdout>>,
app: &mut App,
area: Rect,
) {
// Get the workflow index either from current_execution or selected workflow
let current_workflow_idx = app
.current_execution
.or_else(|| app.workflow_list_state.selected())
.filter(|&idx| idx < app.workflows.len());
if let Some(workflow_idx) = current_workflow_idx {
// Only proceed if we have execution details
if let Some(execution) = &app.workflows[workflow_idx].execution_details {
// Only proceed if we have a valid job selection
if let Some(job_idx) = app.job_list_state.selected() {
if job_idx < execution.jobs.len() {
let job = &execution.jobs[job_idx];
// Split the area into sections
let chunks = Layout::default()
.direction(Direction::Vertical)
.constraints(
[
Constraint::Length(3), // Job title
Constraint::Min(5), // Steps table
Constraint::Length(8), // Step details
]
.as_ref(),
)
.margin(1)
.split(area);
// Job title section
let status_text = match job.status {
wrkflw_executor::JobStatus::Success => "Success",
wrkflw_executor::JobStatus::Failure => "Failed",
wrkflw_executor::JobStatus::Skipped => "Skipped",
};
let status_style = match job.status {
wrkflw_executor::JobStatus::Success => Style::default().fg(Color::Green),
wrkflw_executor::JobStatus::Failure => Style::default().fg(Color::Red),
wrkflw_executor::JobStatus::Skipped => Style::default().fg(Color::Yellow),
};
let job_title = Paragraph::new(vec![
Line::from(vec![
Span::styled("Job: ", Style::default().fg(Color::Blue)),
Span::styled(
job.name.clone(),
Style::default()
.fg(Color::White)
.add_modifier(Modifier::BOLD),
),
Span::raw(" ("),
Span::styled(status_text, status_style),
Span::raw(")"),
]),
Line::from(vec![
Span::styled("Steps: ", Style::default().fg(Color::Blue)),
Span::styled(
format!("{}", job.steps.len()),
Style::default().fg(Color::White),
),
]),
])
.block(
Block::default()
.borders(Borders::ALL)
.border_type(BorderType::Rounded)
.title(Span::styled(
" Job Details ",
Style::default().fg(Color::Yellow),
)),
);
f.render_widget(job_title, chunks[0]);
// Steps section
let header_cells = ["Status", "Step Name"].iter().map(|h| {
ratatui::widgets::Cell::from(*h).style(Style::default().fg(Color::Yellow))
});
let header = Row::new(header_cells)
.style(Style::default().add_modifier(Modifier::BOLD))
.height(1);
let rows = job.steps.iter().map(|step| {
let status_symbol = match step.status {
wrkflw_executor::StepStatus::Success => "✅",
wrkflw_executor::StepStatus::Failure => "❌",
wrkflw_executor::StepStatus::Skipped => "⏭",
};
let status_style = match step.status {
wrkflw_executor::StepStatus::Success => {
Style::default().fg(Color::Green)
}
wrkflw_executor::StepStatus::Failure => Style::default().fg(Color::Red),
wrkflw_executor::StepStatus::Skipped => {
Style::default().fg(Color::Gray)
}
};
Row::new(vec![
ratatui::widgets::Cell::from(status_symbol).style(status_style),
ratatui::widgets::Cell::from(step.name.clone()),
])
});
let steps_table = Table::new(rows)
.header(header)
.block(
Block::default()
.borders(Borders::ALL)
.border_type(BorderType::Rounded)
.title(Span::styled(" Steps ", Style::default().fg(Color::Yellow))),
)
.highlight_style(
Style::default()
.bg(Color::DarkGray)
.add_modifier(Modifier::BOLD),
)
.highlight_symbol("» ")
.widths(&[
Constraint::Length(8), // Status icon column
Constraint::Percentage(92), // Name column
]);
// We need to use the table state from the app
f.render_stateful_widget(steps_table, chunks[1], &mut app.step_table_state);
// Step detail section
if let Some(step_idx) = app.step_table_state.selected() {
if step_idx < job.steps.len() {
let step = &job.steps[step_idx];
// Show step output with proper styling
let status_text = match step.status {
wrkflw_executor::StepStatus::Success => "Success",
wrkflw_executor::StepStatus::Failure => "Failed",
wrkflw_executor::StepStatus::Skipped => "Skipped",
};
let status_style = match step.status {
wrkflw_executor::StepStatus::Success => {
Style::default().fg(Color::Green)
}
wrkflw_executor::StepStatus::Failure => {
Style::default().fg(Color::Red)
}
wrkflw_executor::StepStatus::Skipped => {
Style::default().fg(Color::Yellow)
}
};
let mut output_text = step.output.clone();
// Truncate if too long
if output_text.len() > 1000 {
output_text = format!("{}... [truncated]", &output_text[..1000]);
}
let step_detail = Paragraph::new(vec![
Line::from(vec![
Span::styled("Step: ", Style::default().fg(Color::Blue)),
Span::styled(
step.name.clone(),
Style::default()
.fg(Color::White)
.add_modifier(Modifier::BOLD),
),
Span::raw(" ("),
Span::styled(status_text, status_style),
Span::raw(")"),
]),
Line::from(""),
Line::from(output_text),
])
.block(
Block::default()
.borders(Borders::ALL)
.border_type(BorderType::Rounded)
.title(Span::styled(
" Step Output ",
Style::default().fg(Color::Yellow),
)),
)
.wrap(ratatui::widgets::Wrap { trim: false });
f.render_widget(step_detail, chunks[2]);
}
}
}
}
}
}
}