patch: Adjust available operations

This commit is contained in:
Erik Kundt
2024-03-06 00:00:34 +01:00
parent 15142a41e3
commit 6ee251af09
2 changed files with 8 additions and 42 deletions
+6 -14
View File
@@ -17,30 +17,22 @@ pub enum Mode {
/// selection widget.
#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
pub enum PatchOperation {
Show,
Checkout,
Delete,
Edit,
Comment,
Diff,
Show,
}
impl Display for PatchOperation {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
PatchOperation::Show => {
write!(f, "show")
}
PatchOperation::Checkout => {
write!(f, "checkout")
}
PatchOperation::Delete => {
write!(f, "delete")
PatchOperation::Diff => {
write!(f, "diff")
}
PatchOperation::Edit => {
write!(f, "edit")
}
PatchOperation::Comment => {
write!(f, "comment")
PatchOperation::Show => {
write!(f, "show")
}
}
}
+2 -28
View File
@@ -115,34 +115,10 @@ impl Widget<PatchesState, Action> for ListPage {
});
}
}
Key::Char('m') => {
if let Some(selected) = &self.props.selected {
let selection = Selection {
operation: Some(PatchOperation::Comment.to_string()),
ids: vec![selected.id],
args: vec![],
};
let _ = self.action_tx.send(Action::Exit {
selection: Some(selection),
});
}
}
Key::Char('e') => {
if let Some(selected) = &self.props.selected {
let selection = Selection {
operation: Some(PatchOperation::Edit.to_string()),
ids: vec![selected.id],
args: vec![],
};
let _ = self.action_tx.send(Action::Exit {
selection: Some(selection),
});
}
}
Key::Char('d') => {
if let Some(selected) = &self.props.selected {
let selection = Selection {
operation: Some(PatchOperation::Delete.to_string()),
operation: Some(PatchOperation::Diff.to_string()),
ids: vec![selected.id],
args: vec![],
};
@@ -168,9 +144,7 @@ impl Render<()> for ListPage {
Mode::Operation => vec![
Shortcut::new("enter", "show"),
Shortcut::new("c", "checkout"),
Shortcut::new("m", "comment"),
Shortcut::new("e", "edit"),
Shortcut::new("d", "delete"),
Shortcut::new("d", "diff"),
],
};