Implement TUI init insert and generate workflows
This commit is contained in:
@@ -118,6 +118,18 @@ fn render_content(frame: &mut Frame, app: &App, area: Rect) {
|
||||
return;
|
||||
}
|
||||
|
||||
if app.mode() == Mode::Dialog
|
||||
&& let Some(workflow) = app.workflow()
|
||||
{
|
||||
frame.render_widget(
|
||||
Paragraph::new(workflow.rows().join("\n"))
|
||||
.block(Block::bordered().title(workflow.title()))
|
||||
.wrap(Wrap { trim: false }),
|
||||
area,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
let class = layout_class(frame.area());
|
||||
let (direction, constraints) = match class {
|
||||
LayoutClass::Narrow => (
|
||||
@@ -422,6 +434,9 @@ fn status_line(app: &App) -> Paragraph<'_> {
|
||||
}
|
||||
|
||||
fn context_line(app: &App) -> Paragraph<'static> {
|
||||
if app.mode() == Mode::Dialog && app.workflow().is_some() {
|
||||
return Paragraph::new("Tab/Shift-Tab focus Space toggle Ctrl-S submit Esc cancel");
|
||||
}
|
||||
let text = context_actions(app.mode())
|
||||
.map(|spec| format!("{} {}", spec.bindings[0].display, spec.label))
|
||||
.collect::<Vec<_>>()
|
||||
@@ -436,6 +451,9 @@ fn prompt_line(app: &App) -> Paragraph<'static> {
|
||||
Mode::Dialog if app.command_confirmation_message().is_some() => {
|
||||
Paragraph::new("confirm> y / n / Esc").style(Style::default().fg(Color::Yellow))
|
||||
}
|
||||
Mode::Dialog if app.workflow().is_some() => {
|
||||
Paragraph::new("form> ").style(Style::default().fg(Color::Yellow))
|
||||
}
|
||||
Mode::Dialog => Paragraph::new("dialog> ").style(Style::default().fg(Color::Yellow)),
|
||||
Mode::Editor if app.editor().is_some_and(EntryEditor::is_input_active) => {
|
||||
Paragraph::new("-- INSERT -- Esc stops input; Tab changes field; C-s saves")
|
||||
@@ -575,6 +593,38 @@ mod tests {
|
||||
assert!(confirmation.contains("confirm> y / n / Esc"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn workflow_dialog_is_keyboard_discoverable_and_masks_inserted_secrets() {
|
||||
let mut app = App::new();
|
||||
app.dispatch(crate::action::Action::InsertEntry);
|
||||
for character in "nested/account".chars() {
|
||||
app.handle_workflow_input(
|
||||
crossterm::event::KeyCode::Char(character),
|
||||
crossterm::event::KeyModifiers::NONE,
|
||||
);
|
||||
}
|
||||
app.handle_workflow_input(
|
||||
crossterm::event::KeyCode::Tab,
|
||||
crossterm::event::KeyModifiers::NONE,
|
||||
);
|
||||
app.handle_workflow_input(
|
||||
crossterm::event::KeyCode::Tab,
|
||||
crossterm::event::KeyModifiers::NONE,
|
||||
);
|
||||
for character in "never-render-this".chars() {
|
||||
app.handle_workflow_input(
|
||||
crossterm::event::KeyCode::Char(character),
|
||||
crossterm::event::KeyModifiers::NONE,
|
||||
);
|
||||
}
|
||||
let output = render(100, 24, &app);
|
||||
assert!(output.contains("Insert entry"));
|
||||
assert!(output.contains("nested/account"));
|
||||
assert!(output.contains("Ctrl-S submit"));
|
||||
assert!(output.contains("••••••••"));
|
||||
assert!(!output.contains("never-render-this"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hierarchy_selection_and_storage_indicators_have_stable_rendering() {
|
||||
let mut app = App::new();
|
||||
|
||||
Reference in New Issue
Block a user