Sfoglia il codice sorgente

Use resolver name instead of page config workspace. Update tree URL function to accept workspace parameter instead of storing it in page config.

Afshin Darian 6 anni fa
parent
commit
bb800d61d2

+ 4 - 4
packages/coreutils/src/pageconfig.ts

@@ -24,9 +24,9 @@ export namespace PageConfig {
    */
   export interface ITreeOptions {
     /**
-     * If `true`, the tree URL will include the current workspace, if any.
+     * If provided, the tree URL will include the current workspace, if any.
      */
-    workspace?: boolean;
+    workspace?: string;
   }
 
   /**
@@ -132,9 +132,9 @@ export namespace PageConfig {
     const tree = getOption('treeUrl');
     const defaultWorkspace = getOption('defaultWorkspace');
     const workspaces = getOption('workspacesUrl');
-    const workspace = getOption('workspace');
+    const workspace = options.workspace || '';
 
-    return !!options.workspace && workspace && workspace !== defaultWorkspace
+    return workspace && workspace !== defaultWorkspace
       ? URLExt.join(base, workspaces, PathExt.basename(workspace), 'tree')
       : URLExt.join(base, tree);
   }

+ 5 - 3
packages/filebrowser-extension/src/index.ts

@@ -11,6 +11,7 @@ import {
 import {
   Clipboard,
   InstanceTracker,
+  IWindowResolver,
   MainAreaWidget,
   ToolbarButton
 } from '@jupyterlab/apputils';
@@ -134,7 +135,7 @@ const factory: JupyterFrontEndPlugin<IFileBrowserFactory> = {
 const shareFile: JupyterFrontEndPlugin<void> = {
   activate: activateShareFile,
   id: '@jupyterlab/filebrowser-extension:share-file',
-  requires: [IFileBrowserFactory],
+  requires: [IFileBrowserFactory, IWindowResolver],
   autoStart: true
 };
 
@@ -309,7 +310,8 @@ function activateBrowser(
 
 function activateShareFile(
   app: JupyterFrontEnd,
-  factory: IFileBrowserFactory
+  factory: IFileBrowserFactory,
+  resolver: IWindowResolver
 ): void {
   const { commands } = app;
   const { tracker } = factory;
@@ -321,7 +323,7 @@ function activateShareFile(
         return;
       }
       const path = encodeURI(widget.selectedItems().next().path);
-      const tree = PageConfig.getTreeUrl({ workspace: true });
+      const tree = PageConfig.getTreeUrl({ workspace: resolver.name });
 
       Clipboard.copyToSystem(URLExt.join(tree, path));
     },