Skip to content

Commit

Permalink
Remove send_request keybinding
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasPickering committed Apr 7, 2024
1 parent dd57280 commit 4e6e906
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 18 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

- All variants of the `Chain.source` field are now maps
- This is to support the next request auto-execution feature, as well as future proofing for additional chain configuration
- Remove `send_request` keybinding
- The `submit` keybinding is now used to send requests from all panes (except the profile pane)
- This is only a breaking change if you have `send_request` remapped in your config file

Follow this mapping to update:

Expand Down
1 change: 0 additions & 1 deletion docs/src/api/configuration/input_bindings.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ input_bindings:
| `end` | `end` |
| `submit` | `enter` |
| `cancel` | `esc` |
| `send_request` | `f2` |
| `search` | `/` |
| `reload_collection` | `f5` |
| `fullscreen` | `f` |
Expand Down
7 changes: 2 additions & 5 deletions src/tui/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ impl Default for InputEngine {
Action::OpenActions => KeyCode::Char('x').into(),
Action::OpenHelp => KeyCode::Char('?').into(),
Action::Fullscreen => KeyCode::Char('f').into(),
Action::SendRequest => KeyCode::F(2).into(),
Action::ReloadCollection => KeyCode::F(5).into(),
Action::Search => KeyCode::Char('/').into(),
Action::PreviousPane => KeyCode::BackTab.into(),
Expand Down Expand Up @@ -195,13 +194,11 @@ pub enum Action {
Home,
End,

/// Do a thing. E.g. select an item in a list
/// Do a thing, e.g. submit a modal. Alternatively, send a request
#[display("Send Request/Submit")]
Submit,
/// Close the current modal/dialog/etc.
Cancel,
/// Send the active request from *any* context
#[display("Send Request")]
SendRequest,
/// Start a search/filter operation
#[display("Search/Filter")]
Search,
Expand Down
2 changes: 1 addition & 1 deletion src/tui/view/component/primary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ impl EventHandler for PrimaryView {
Action::NextPane if self.fullscreen_mode.is_none() => {
self.selected_pane.next(context);
}
Action::SendRequest => {
Action::Submit => {
// Send a request from anywhere
context.queue_event(Event::HttpSendRequest);
}
Expand Down
15 changes: 14 additions & 1 deletion src/tui/view/component/profile_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{
view::{
common::{list::List, Pane},
draw::{Draw, Generate},
event::{Event, EventHandler, UpdateContext},
event::{Event, EventHandler, Update, UpdateContext},
state::{
persistence::{Persistable, Persistent, PersistentKey},
select::{Dynamic, SelectState},
Expand Down Expand Up @@ -53,6 +53,19 @@ impl ProfileListPane {
}

impl EventHandler for ProfileListPane {
fn update(&mut self, _context: &mut UpdateContext, event: Event) -> Update {
match event {
// Sending requests from the profile pane is unintuitive, so eat
// submission events here
Event::Input {
action: Some(Action::Submit),
..
} => Update::Consumed,

_ => Update::Propagate(event),
}
}

fn children(&mut self) -> Vec<Component<&mut dyn EventHandler>> {
vec![self.profiles.as_child()]
}
Expand Down
11 changes: 1 addition & 10 deletions src/tui/view/component/recipe_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,10 @@ impl RecipeListPane {
context.queue_event(Event::HttpLoadRequest);
}

// Trigger a request on submit
fn on_submit(context: &mut UpdateContext, _: &mut Recipe) {
// Parent has to be responsible for actually sending the request
// because it also needs access to the profile list state
context.queue_event(Event::HttpSendRequest);
}

Self {
recipes: Persistent::new(
PersistentKey::RecipeId,
SelectState::new(recipes)
.on_select(on_select)
.on_submit(on_submit),
SelectState::new(recipes).on_select(on_select),
)
.into(),
}
Expand Down

0 comments on commit 4e6e906

Please sign in to comment.