Skip to content

Commit

Permalink
example implementation of target arg in execute of a command
Browse files Browse the repository at this point in the history
uses latest version of PR phosphorjs/phosphor#355
  • Loading branch information
telamonian committed Aug 19, 2018
1 parent 489d162 commit 23a64c9
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/docmanager-extension/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -596,8 +596,17 @@ function addCommands(
commands.addCommand(CommandIDs.showInFileBrowser, {
label: () => `Show in File Browser`,
isEnabled,
execute: args => {
execute: (args, target) => {
// give 1st precedence to explicitly passed path
let path = args['path'];
if (!path && target) {
// give 2nd precedence to path on the target node, if present
path = target.dataset['path'];
}
if (!path) {
// fall back to path of focused widget
path = docManager.contextForWidget(shell.currentWidget).path;
}
if (!path) {
return;
}
Expand Down Expand Up @@ -634,7 +643,6 @@ function addCommands(
});
app.contextMenu.addItem({
command: CommandIDs.showInFileBrowser,
passDataset: true,
selector: '[data-type="document-title"]',
rank: 3
});
Expand Down

0 comments on commit 23a64c9

Please sign in to comment.