Ensure @retrolab settings

Jeremy Tuloup 5 years ago
parent 8d92d7ff18
commit 0d22a5d786

1
.gitignore vendored

@ -116,6 +116,7 @@ junit.xml
retrolab/static/*
!retrolab/static/favicons
retrolab/labextension
retrolab/schemas
# playwright
app/test-results

@ -37,7 +37,8 @@ fs.copySync(cssImports, path.resolve(buildDir, 'extraStyle.js'));
const extras = Build.ensureAssets({
packageNames: names,
output: buildDir
output: buildDir,
schemaOutput: path.resolve(__dirname, '..', 'retrolab')
});
/**

@ -65,7 +65,8 @@
"access": "public"
},
"jupyterlab": {
"extension": true
"extension": true,
"schemaDir": "schema"
},
"styleModule": "style/index.js"
}

@ -0,0 +1,16 @@
{
"jupyter.lab.setting-icon": "retro-ui-components:retroSun",
"jupyter.lab.setting-icon-label": "RetroLab Top Area",
"title": "RetroLab Top Area",
"description": "RetroLab Top Area settings",
"properties": {
"visible": {
"type": "boolean",
"title": "Top Bar Visibility",
"description": "Whether to show the top bar or not",
"default": true
}
},
"additionalProperties": false,
"type": "object"
}

@ -38,6 +38,7 @@ import { PromiseDelegate } from '@lumino/coreutils';
import { DisposableDelegate, DisposableSet } from '@lumino/disposable';
import { Widget } from '@lumino/widgets';
import { ISettingRegistry } from '@jupyterlab/settingregistry';
/**
* The default notebook factory.
@ -451,20 +452,25 @@ const title: JupyterFrontEndPlugin<void> = {
const topVisibility: JupyterFrontEndPlugin<void> = {
id: '@retrolab/application-extension:top',
requires: [IRetroShell, ITranslator],
optional: [IMainMenu],
optional: [IMainMenu, ISettingRegistry],
activate: (
app: JupyterFrontEnd<JupyterFrontEnd.IShell>,
retroShell: IRetroShell,
translator: ITranslator,
menu: IMainMenu | null
menu: IMainMenu | null,
settingRegistry: ISettingRegistry | null
) => {
const trans = translator.load('retrolab');
const top = retroShell.top;
const pluginId = topVisibility.id;
app.commands.addCommand(CommandIDs.toggleTop, {
label: trans.__('Show Header'),
execute: () => {
top.setHidden(top.isVisible);
if (settingRegistry) {
void settingRegistry.set(pluginId, 'visible', top.isVisible);
}
},
isToggled: () => top.isVisible
});
@ -473,6 +479,25 @@ const topVisibility: JupyterFrontEndPlugin<void> = {
menu.viewMenu.addGroup([{ command: CommandIDs.toggleTop }], 2);
}
if (settingRegistry) {
const loadSettings = settingRegistry.load(pluginId);
const updateSettings = (settings: ISettingRegistry.ISettings): void => {
const visible = settings.get('visible').composite as boolean;
top.setHidden(!visible);
};
Promise.all([loadSettings, app.restored])
.then(([settings]) => {
updateSettings(settings);
settings.changed.connect(settings => {
updateSettings(settings);
});
})
.catch((reason: Error) => {
console.error(reason.message);
});
}
const onChanged = (): void => {
if (app.format === 'desktop') {
retroShell.expandTop();

@ -1,5 +1,5 @@
[build-system]
requires = ["jupyter_packaging~=0.10", "jupyterlab>=3.2.0rc0,==3.*"]
requires = ["jupyter_packaging~=0.10", "jupyterlab~=3.2"]
build-backend = "jupyter_packaging.build_api"
[license]

@ -28,7 +28,7 @@ include_package_data = True
packages = find:
python_requires = >=3.6
install_requires =
jupyterlab>=3.2.0rc0,==3.*
jupyterlab~=3.2
jupyterlab_server~=2.3
jupyter_server~=1.4
nbclassic~=0.2

@ -23,6 +23,7 @@ ensured_targets = [
data_files_spec = [
("share/jupyter/labextensions/%s" % labext_name, str(lab_extension_dest), "**"),
("share/jupyter/labextensions/%s" % labext_name, str(HERE), "install.json"),
('share/jupyter/lab/schemas', f'{NAME}/schemas', '@retrolab/**'),
(
"etc/jupyter/jupyter_server_config.d",
"jupyter-config/jupyter_server_config.d",

Loading…
Cancel
Save