Skip to content
This repository has been archived by the owner on Feb 16, 2023. It is now read-only.

Commit

Permalink
Fix startup events
Browse files Browse the repository at this point in the history
  • Loading branch information
jtpio committed Nov 29, 2021
1 parent 4002f21 commit 79a300c
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 7 deletions.
7 changes: 4 additions & 3 deletions packages/application-extension/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -530,8 +530,10 @@ const topVisibility: JupyterFrontEndPlugin<void> = {
if (settingRegistry) {
const loadSettings = settingRegistry.load(pluginId);
const updateSettings = (settings: ISettingRegistry.ISettings): void => {
const visible = settings.get('visible').composite as boolean;
top.setHidden(!visible);
const visible = settings.get('visible').composite;
if (visible !== undefined) {
top.setHidden(!visible);
}
};

Promise.all([loadSettings, app.restored])
Expand All @@ -556,7 +558,6 @@ const topVisibility: JupyterFrontEndPlugin<void> = {

// listen on format change (mobile and desktop) to make the view more compact
app.formatChanged.connect(onChanged);
onChanged();
},
autoStart: true
};
Expand Down
4 changes: 3 additions & 1 deletion packages/application/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class RetroApp extends JupyterFrontEnd<IRetroShell> {
this.registerPlugin(plugin);
}
}
void this._formatter.invoke();
this.restored.then(() => this._formatter.invoke());
}

/**
Expand Down Expand Up @@ -193,5 +193,7 @@ namespace Private {
*/
export function setFormat(app: RetroApp): void {
app.format = window.matchMedia(MOBILE_QUERY).matches ? 'mobile' : 'desktop';
console.log('width', window.innerWidth);
console.log('set format', app.format);
}
}
11 changes: 8 additions & 3 deletions packages/notebook-extension/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,13 @@ const kernelLogo: JupyterFrontEndPlugin<void> = {
const kernelStatus: JupyterFrontEndPlugin<void> = {
id: '@retrolab/notebook-extension:kernel-status',
autoStart: true,
requires: [IRetroShell],
activate: (app: JupyterFrontEnd, shell: IRetroShell) => {
requires: [IRetroShell, ITranslator],
activate: (
app: JupyterFrontEnd,
shell: IRetroShell,
translator: ITranslator
) => {
const trans = translator.load('retrolab');
const widget = new Widget();
widget.addClass('jp-RetroKernelStatus');
app.shell.add(widget, 'menu', { rank: 10_010 });
Expand Down Expand Up @@ -193,7 +198,7 @@ const kernelStatus: JupyterFrontEndPlugin<void> = {
widget.addClass(KERNEL_STATUS_FADE_OUT_CLASS);
break;
}
widget.node.textContent = text;
widget.node.textContent = trans.__(text);
};

const onChange = async () => {
Expand Down
20 changes: 20 additions & 0 deletions ui-tests/test/mobile.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ test.describe('Mobile', () => {
tmpPath
}) => {
await page.goto(`tree/${tmpPath}`);
await page.waitForSelector('#top-panel-wrapper', { state: 'hidden' });
expect(await page.screenshot()).toMatchSnapshot('tree.png');
});

Expand All @@ -28,6 +29,25 @@ test.describe('Mobile', () => {
`${tmpPath}/${notebook}`
);
await page.goto(`notebooks/${tmpPath}/${notebook}`);
// TODO: investigate why this does not run the cells in RetroLab
// await page.notebook.run();

// wait for the kernel status animations to be finished
await page.waitForSelector('.jp-RetroKernelStatus-fade');
await page.waitForFunction(() => {
const status = window.document.getElementsByClassName(
'jp-RetroKernelStatus'
)[0];

if (!status) {
return false;
}

const finished = status?.getAnimations().reduce((prev, curr) => {
return prev && curr.playState === 'finished';
}, true);
return finished;
});

expect(await page.screenshot()).toMatchSnapshot('notebook.png');
});
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 79a300c

Please sign in to comment.