Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to setting editor should trigger application dirty state #7774

Merged
merged 1 commit into from Jan 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/settingeditor-extension/package.json
Expand Up @@ -43,7 +43,8 @@
"@jupyterlab/settingeditor": "^2.0.0-beta.2",
"@jupyterlab/settingregistry": "^2.0.0-beta.2",
"@jupyterlab/statedb": "^2.0.0-beta.2",
"@jupyterlab/ui-components": "^2.0.0-beta.2"
"@jupyterlab/ui-components": "^2.0.0-beta.2",
"@lumino/disposable": "^1.3.4"
},
"devDependencies": {
"rimraf": "~3.0.0",
Expand Down
24 changes: 21 additions & 3 deletions packages/settingeditor-extension/src/index.ts
Expand Up @@ -6,7 +6,8 @@
import {
ILayoutRestorer,
JupyterFrontEnd,
JupyterFrontEndPlugin
JupyterFrontEndPlugin,
ILabStatus
} from '@jupyterlab/application';
import {
ICommandPalette,
Expand All @@ -22,6 +23,7 @@ import {
} from '@jupyterlab/settingeditor';
import { ISettingRegistry } from '@jupyterlab/settingregistry';
import { settingsIcon } from '@jupyterlab/ui-components';
import { IDisposable } from '@lumino/disposable';

/**
* The command IDs used by the setting editor.
Expand All @@ -45,7 +47,8 @@ const plugin: JupyterFrontEndPlugin<ISettingEditorTracker> = {
IEditorServices,
IStateDB,
IRenderMimeRegistry,
ICommandPalette
ICommandPalette,
ILabStatus
],
autoStart: true,
provides: ISettingEditorTracker,
Expand All @@ -62,7 +65,8 @@ function activate(
editorServices: IEditorServices,
state: IStateDB,
rendermime: IRenderMimeRegistry,
palette: ICommandPalette
palette: ICommandPalette,
status: ILabStatus
): ISettingEditorTracker {
const { commands, shell } = app;
const namespace = 'setting-editor';
Expand Down Expand Up @@ -104,13 +108,27 @@ function activate(
when
});

let disposable: IDisposable | null = null;
// Notify the command registry when the visibility status of the setting
// editor's commands change. The setting editor toolbar listens for this
// signal from the command registry.
editor.commandsChanged.connect((sender: any, args: string[]) => {
args.forEach(id => {
commands.notifyCommandChanged(id);
});
if (editor.canSaveRaw) {
if (!disposable) {
disposable = status.setDirty();
}
} else if (disposable) {
disposable.dispose();
disposable = null;
}
editor.disposed.connect(() => {
if (disposable) {
disposable.dispose();
}
});
});

editor.id = namespace;
Expand Down