Fix user settings overrides

This commit is contained in:
Jeremy Tuloup 2021-11-22 15:15:40 +01:00
parent 4002f2154b
commit 6c96c80c8c
10 changed files with 49 additions and 10 deletions

View File

@ -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])
@ -547,6 +552,9 @@ const topVisibility: JupyterFrontEndPlugin<void> = {
}
const onChanged = (): void => {
if (settingsOverride) {
return;
}
if (app.format === 'desktop') {
retroShell.expandTop();
} else {
@ -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
};

View File

@ -37,7 +37,7 @@ export class RetroApp extends JupyterFrontEnd<IRetroShell> {
this.registerPlugin(plugin);
}
}
void this._formatter.invoke();
this.restored.then(() => this._formatter.invoke());
}
/**

View File

@ -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 });
@ -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 () => {

View File

@ -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

View File

@ -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');
});
@ -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');
});

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

View File

@ -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');
});