Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Copy Download Link" in file browser #5072

Closed
jasongrout opened this issue Aug 8, 2018 · 0 comments · Fixed by #5089
Closed

"Copy Download Link" in file browser #5072

jasongrout opened this issue Aug 8, 2018 · 0 comments · Fixed by #5089
Labels
good first issue status:resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion.
Milestone

Comments

@jasongrout
Copy link
Contributor

Right now we have:

  • open in new tab, which gets the download URL and opens a new tab with it
  • copy sharable link, which gets a lab link and copies it to the clipboard

@johnkit pointed out that it would be nice to have a menu item that gets the download URL and copies it to the clipboard. Then you could get a link you could copy into a notebook, or a command line, etc., that would let you request a resource.

I think this would be an advanced "good first issue". I think you could piece together such a function by looking at the code for each of those menu items above:

open in new tab:

commands.addCommand(CommandIDs.openBrowserTab, {
execute: () => {
const widget = tracker.currentWidget;
if (!widget) {
return;
}
return Promise.all(
toArray(
map(widget.selectedItems(), item => {
return commands.execute('docmanager:open-browser-tab', {
path: item.path
});
})
)
);
},
iconClass: 'jp-MaterialIcon jp-AddIcon',
label: 'Open in New Browser Tab',
mnemonic: 0
});
which calls
commands.addCommand(CommandIDs.openBrowserTab, {
execute: args => {
const path =
typeof args['path'] === 'undefined' ? '' : (args['path'] as string);
if (!path) {
return;
}
return docManager.services.contents.getDownloadUrl(path).then(url => {
window.open(url, '_blank');
});
},
icon: args => (args['icon'] as string) || '',
label: () => 'Open in New Browser Tab'
});

copy sharable link:

commands.addCommand(CommandIDs.share, {
execute: () => {
const path = encodeURIComponent(browser.selectedItems().next().path);
const tree = PageConfig.getTreeUrl({ workspace: true });
Clipboard.copyToSystem(URLExt.join(tree, path));
},
isVisible: () => toArray(browser.selectedItems()).length === 1,
iconClass: 'jp-MaterialIcon jp-LinkIcon',
label: 'Copy Shareable Link'
});

CC @ian-r-rose

@jasongrout jasongrout added this to the Future milestone Aug 9, 2018
@jasongrout jasongrout modified the milestones: Future, 0.34 Aug 9, 2018
@lock lock bot added the status:resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion. label Aug 8, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Aug 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
good first issue status:resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion.
Projects
None yet
1 participant