Fix handling of default factory in the URL (#6873)

This commit is contained in:
Jeremy Tuloup 2023-05-16 10:46:47 +02:00 committed by GitHub
parent d51836480c
commit e976dfdc1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -24,6 +24,7 @@ const opener: JupyterFrontEndPlugin<IDocumentWidgetOpener> = {
provides: IDocumentWidgetOpener,
activate: (app: JupyterFrontEnd) => {
const baseUrl = PageConfig.getBaseUrl();
const docRegistry = app.docRegistry;
let id = 0;
return new (class {
open(widget: IDocumentWidget, options?: DocumentRegistry.IOpenOptions) {
@ -42,7 +43,8 @@ const opener: JupyterFrontEndPlugin<IDocumentWidgetOpener> = {
}
let url = `${baseUrl}${route}/${path}`;
// append ?factory only if it's not the default
if (widgetName !== 'default') {
const defaultFactory = docRegistry.defaultWidgetFactory(path);
if (widgetName !== defaultFactory.name) {
url = `${url}?factory=${widgetName}`;
}
window.open(url);