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

accept query parameter to optionally change file browser location #6875

Merged
merged 3 commits into from Aug 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions docs/source/user/urls.rst
Expand Up @@ -24,6 +24,16 @@ the nomenclature of the classic notebook; these URLs are ``/tree`` URLs:
Entering this URL will open the notebook in JupyterLab in
:ref:`single-document mode <tabs>`.

By default, the file browser will navigate to the directory containing the requested
file. This behavior can be changed with the optional ``file-browser-path`` query parameter:

.. code-block:: none

http(s)://<server:port>/<lab-location>/lab/tree/path/to/notebook.ipynb?file-browser-path=/

Entering the above URL will show the workspace root directory instead of the ``/path/to/``
directory in the file browser.


.. _url-workspaces-ui:

Expand Down
7 changes: 6 additions & 1 deletion packages/application-extension/src/index.tsx
Expand Up @@ -262,7 +262,7 @@ const tree: JupyterFrontEndPlugin<void> = {
const treeMatch = args.path.match(treePattern);
const workspaceMatch = args.path.match(workspacePattern);
const match = treeMatch || workspaceMatch;
const path = decodeURI(match[1]);
let path = decodeURI(match[1]);
// const { page, workspaces } = info.urls;
const workspace = PathExt.basename(resolver.name);
const url =
Expand All @@ -275,6 +275,11 @@ const tree: JupyterFrontEndPlugin<void> = {
// Remove the tree portion of the URL leaving the rest intact.
router.navigate(url);

const query = URLExt.queryStringToObject(args.search);
if (query['file-browser-path']) {
path = query['file-browser-path'];
}

try {
await commands.execute('filebrowser:open-path', { path });
} catch (error) {
Expand Down