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

Fix file browser location in tree view. #7155

Merged
merged 2 commits into from Oct 10, 2019
Merged
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
24 changes: 15 additions & 9 deletions packages/application-extension/src/index.tsx
Expand Up @@ -262,26 +262,32 @@ const tree: JupyterFrontEndPlugin<void> = {
const treeMatch = args.path.match(treePattern);
const workspaceMatch = args.path.match(workspacePattern);
const match = treeMatch || workspaceMatch;
let path = decodeURI(match[1]);
// const { page, workspaces } = info.urls;
const path = decodeURI(match[1]);
const workspace = PathExt.basename(resolver.name);
const query = URLExt.queryStringToObject(args.search);
const fileBrowserPath = query['file-browser-path'];

// Remove the file browser path from the query string.
delete query['file-browser-path'];

// Remove the tree portion of the URL.
const url =
(workspaceMatch
? URLExt.join(paths.urls.workspaces, workspace)
: paths.urls.app) +
args.search +
URLExt.objectToQueryString(query) +
args.hash;

// 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 });

if (fileBrowserPath) {
await commands.execute('filebrowser:open-path', {
path: fileBrowserPath
});
}
} catch (error) {
console.warn('Tree routing failed.', error);
}
Expand Down