mirror of
https://seed.radicle.dev/rad:z39mP9rQAaGmERfUMPULfPUi473tY.git
synced 2026-11-21 10:30:48 +08:00
patch: Adjust available operations
This commit is contained in:
@@ -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")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"),
|
||||
],
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user