Skip to content

Commit

Permalink
Merge pull request #6875 from dmarth/feature-filebrowser-location-par…
Browse files Browse the repository at this point in the history
…ameter

accept query parameter to optionally change file browser location
  • Loading branch information
blink1073 committed Aug 22, 2019
2 parents f1bc02c + 0caf4ed commit cd2fb6a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
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

0 comments on commit cd2fb6a

Please sign in to comment.