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

Commit

Permalink
Fix user settings overrides
Browse files Browse the repository at this point in the history
  • Loading branch information
jtpio committed Nov 29, 2021
1 parent 4002f21 commit 6c96c80
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 10 deletions.
13 changes: 10 additions & 3 deletions packages/application-extension/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -527,11 +527,16 @@ const topVisibility: JupyterFrontEndPlugin<void> = {
menu.viewMenu.addGroup([{ command: CommandIDs.toggleTop }], 2);
}

let settingsOverride = false;

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 (settings.user.visible !== undefined) {
settingsOverride = true;
top.setHidden(!visible);
}
};

Promise.all([loadSettings, app.restored])
Expand All @@ -547,6 +552,9 @@ const topVisibility: JupyterFrontEndPlugin<void> = {
}

const onChanged = (): void => {
if (settingsOverride) {
return;
}
if (app.format === 'desktop') {
retroShell.expandTop();
} else {
Expand All @@ -556,7 +564,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
2 changes: 1 addition & 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
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
7 changes: 6 additions & 1 deletion ui-tests/test/jupyter_server_config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
from tempfile import mkdtemp

c.ServerApp.port = 8888
c.ServerApp.port_retries = 0
c.ServerApp.open_browser = False

c.ServerApp.root_dir = mkdtemp(prefix="galata-test-")
c.ServerApp.token = ""
c.ServerApp.password = ""
c.ServerApp.disable_check_xsrf = True
c.ServerApp.open_browser = False
c.RetroApp.expose_app_in_browser = True
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.
6 changes: 4 additions & 2 deletions ui-tests/test/settings.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@ test.describe('Settings', () => {

await page.goto(`tree/${tmpPath}`);

await page.waitForSelector('#top-panel', { state: 'visible' });
await page.menu.clickMenuItem(showHeaderPath);
await page.waitForSelector('#top-panel', { state: 'hidden' });
await page.reload({ waitUntil: 'networkidle' });

await page.menu.getMenuItem(showHeaderPath);
expect(await page.screenshot()).toMatchSnapshot('top-hidden.png');

await page.waitForSelector('#top-panel', { state: 'hidden' });
await page.menu.clickMenuItem(showHeaderPath);
await page.waitForSelector('#top-panel', { state: 'visible' });
await page.reload({ waitUntil: 'networkidle' });

await page.menu.getMenuItem(showHeaderPath);
expect(await page.screenshot()).toMatchSnapshot('top-visible.png');
});
Expand Down

0 comments on commit 6c96c80

Please sign in to comment.