Skip to content

Commit

Permalink
gator not displayed in jupyterlab after updating or re-installing
Browse files Browse the repository at this point in the history
Fixes #139
  • Loading branch information
fcollonval committed Apr 24, 2021
1 parent 6e2f029 commit 6003118
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions packages/labextension/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ async function activateCondaEnv(
const tracker = new WidgetTracker<MainAreaWidget<CondaEnvWidget>>({
namespace: pluginNamespace
});
let content: CondaEnvWidget;
let condaWidget: MainAreaWidget<CondaEnvWidget>;

commands.addCommand(command, {
label: 'Conda Packages Manager',
Expand All @@ -62,7 +62,7 @@ async function activateCondaEnv(
const delayTour = (): void => {
setTimeout(() => {
timeout += TOUR_DELAY;
if (content.isVisible && tour) {
if (condaWidget?.isVisible && tour) {
commands.execute('jupyterlab-tour:launch', {
id: tour.id,
force: false
Expand All @@ -88,21 +88,26 @@ async function activateCondaEnv(
}
});

if (tracker.currentWidget) {
shell.activateById(tracker.currentWidget.id);
return;
if (!condaWidget || condaWidget.isDisposed) {
condaWidget = new MainAreaWidget({
content: new CondaEnvWidget(model)
});
condaWidget.addClass(CONDA_WIDGET_CLASS);
condaWidget.id = pluginNamespace;
condaWidget.title.label = 'Packages';
condaWidget.title.caption = 'Conda Packages Manager';
condaWidget.title.icon = condaIcon;
}

content = new CondaEnvWidget(model);
content.addClass(CONDA_WIDGET_CLASS);
content.id = pluginNamespace;
content.title.label = 'Packages';
content.title.caption = 'Conda Packages Manager';
content.title.icon = condaIcon;
const widget = new MainAreaWidget({ content });

void tracker.add(widget);
shell.add(widget, 'main');
if (!tracker.has(condaWidget)) {
// Track the state of the widget for later restoration
tracker.add(condaWidget);
}
if (!condaWidget.isAttached) {
// Attach the widget to the main work area if it's not there
app.shell.add(condaWidget, 'main');
}
app.shell.activateById(condaWidget.id);
}
});

Expand Down

0 comments on commit 6003118

Please sign in to comment.