keymap_ui: Add context menu for table rows (#33747)
Closes #ISSUE Adds a right click context menu to table rows, refactoring the table API to support more general row rendering in the process, and creating actions for the couple of operations available in the context menu. Additionally includes an only partially related change to the context menu API, which makes it easier to have actions that are disabled based on a boolean value. Release Notes: - N/A *or* Added/Fixed/Improved ...
This commit is contained in:
@@ -122,40 +122,29 @@ fn git_panel_context_menu(
|
||||
ContextMenu::build(window, cx, move |context_menu, _, _| {
|
||||
context_menu
|
||||
.context(focus_handle)
|
||||
.map(|menu| {
|
||||
if state.has_unstaged_changes {
|
||||
menu.action("Stage All", StageAll.boxed_clone())
|
||||
} else {
|
||||
menu.disabled_action("Stage All", StageAll.boxed_clone())
|
||||
}
|
||||
})
|
||||
.map(|menu| {
|
||||
if state.has_staged_changes {
|
||||
menu.action("Unstage All", UnstageAll.boxed_clone())
|
||||
} else {
|
||||
menu.disabled_action("Unstage All", UnstageAll.boxed_clone())
|
||||
}
|
||||
})
|
||||
.action_disabled_when(
|
||||
!state.has_unstaged_changes,
|
||||
"Stage All",
|
||||
StageAll.boxed_clone(),
|
||||
)
|
||||
.action_disabled_when(
|
||||
!state.has_staged_changes,
|
||||
"Unstage All",
|
||||
UnstageAll.boxed_clone(),
|
||||
)
|
||||
.separator()
|
||||
.action("Open Diff", project_diff::Diff.boxed_clone())
|
||||
.separator()
|
||||
.map(|menu| {
|
||||
if state.has_tracked_changes {
|
||||
menu.action("Discard Tracked Changes", RestoreTrackedFiles.boxed_clone())
|
||||
} else {
|
||||
menu.disabled_action(
|
||||
"Discard Tracked Changes",
|
||||
RestoreTrackedFiles.boxed_clone(),
|
||||
)
|
||||
}
|
||||
})
|
||||
.map(|menu| {
|
||||
if state.has_new_changes {
|
||||
menu.action("Trash Untracked Files", TrashUntrackedFiles.boxed_clone())
|
||||
} else {
|
||||
menu.disabled_action("Trash Untracked Files", TrashUntrackedFiles.boxed_clone())
|
||||
}
|
||||
})
|
||||
.action_disabled_when(
|
||||
!state.has_tracked_changes,
|
||||
"Discard Tracked Changes",
|
||||
RestoreTrackedFiles.boxed_clone(),
|
||||
)
|
||||
.action_disabled_when(
|
||||
!state.has_new_changes,
|
||||
"Trash Untracked Files",
|
||||
TrashUntrackedFiles.boxed_clone(),
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user