Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ import { JupyterFrontEndPlugin } from '@jupyterlab/application';
import {
driveFileBrowser,
openDriveDialogPlugin,
launcherPlugin
launcherPlugin,
sessionContextPatch
} from './plugins';

const plugins: JupyterFrontEndPlugin<any>[] = [
driveFileBrowser,
openDriveDialogPlugin,
launcherPlugin
launcherPlugin,
sessionContextPatch
];

export default plugins;
1 change: 1 addition & 0 deletions src/plugins/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './driveBrowserPlugin';
export * from './launcherPlugin';
export * from './driveDialogPlugin';
export * from './sessionContextPatch';
39 changes: 39 additions & 0 deletions src/plugins/sessionContextPatch.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import {
JupyterFrontEndPlugin,
JupyterFrontEnd
} from '@jupyterlab/application';
import { SessionContext } from '@jupyterlab/apputils';
import {
IDocumentManager,
IDocumentWidgetOpener
} from '@jupyterlab/docmanager';

/**
* A plugin to patch the session context path so it includes the drive name.
* associated with.
*/
export const sessionContextPatch: JupyterFrontEndPlugin<void> = {
id: '@jupyterlite/application-extension:session-context-patch',
autoStart: true,
requires: [IDocumentManager, IDocumentWidgetOpener],
activate: (
app: JupyterFrontEnd,
docManager: IDocumentManager,
widgetOpener: IDocumentWidgetOpener
) => {
const contents = app.serviceManager.contents;

widgetOpener.opened.connect((_, widget) => {
const context = docManager.contextForWidget(widget);
const driveName = contents.driveName(context?.path ?? '');
if (driveName === '') {
// do nothing if this is the default drive
return;
}
const sessionContext = widget.context.sessionContext as SessionContext;

// Path the session context to include the drive name
sessionContext['_path'] = context?.path;
});
}
};
Loading