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:
parent
faca128304
commit
79f3cb1225
12 changed files with 308 additions and 204 deletions
|
@ -233,31 +233,25 @@ pub fn deploy_context_menu(
|
|||
.action("Copy and Trim", Box::new(CopyAndTrim))
|
||||
.action("Paste", Box::new(Paste))
|
||||
.separator()
|
||||
.map(|builder| {
|
||||
let reveal_in_finder_label = if cfg!(target_os = "macos") {
|
||||
.action_disabled_when(
|
||||
!has_reveal_target,
|
||||
if cfg!(target_os = "macos") {
|
||||
"Reveal in Finder"
|
||||
} else {
|
||||
"Reveal in File Manager"
|
||||
};
|
||||
const OPEN_IN_TERMINAL_LABEL: &str = "Open in Terminal";
|
||||
if has_reveal_target {
|
||||
builder
|
||||
.action(reveal_in_finder_label, Box::new(RevealInFileManager))
|
||||
.action(OPEN_IN_TERMINAL_LABEL, Box::new(OpenInTerminal))
|
||||
} else {
|
||||
builder
|
||||
.disabled_action(reveal_in_finder_label, Box::new(RevealInFileManager))
|
||||
.disabled_action(OPEN_IN_TERMINAL_LABEL, Box::new(OpenInTerminal))
|
||||
}
|
||||
})
|
||||
.map(|builder| {
|
||||
const COPY_PERMALINK_LABEL: &str = "Copy Permalink";
|
||||
if has_git_repo {
|
||||
builder.action(COPY_PERMALINK_LABEL, Box::new(CopyPermalinkToLine))
|
||||
} else {
|
||||
builder.disabled_action(COPY_PERMALINK_LABEL, Box::new(CopyPermalinkToLine))
|
||||
}
|
||||
});
|
||||
},
|
||||
Box::new(RevealInFileManager),
|
||||
)
|
||||
.action_disabled_when(
|
||||
!has_reveal_target,
|
||||
"Open in Terminal",
|
||||
Box::new(OpenInTerminal),
|
||||
)
|
||||
.action_disabled_when(
|
||||
!has_git_repo,
|
||||
"Copy Permalink",
|
||||
Box::new(CopyPermalinkToLine),
|
||||
);
|
||||
match focus {
|
||||
Some(focus) => builder.context(focus),
|
||||
None => builder,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue