Skip to content

Commit

Permalink
Add command to reset application state. Insert command into the help …
Browse files Browse the repository at this point in the history
…menu.
  • Loading branch information
afshin committed Feb 18, 2018
1 parent 864cacc commit f65e9ac
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
25 changes: 12 additions & 13 deletions packages/apputils-extension/src/index.ts
Expand Up @@ -62,15 +62,15 @@ namespace CommandIDs {
export
const changeTheme = 'apputils:change-theme';

export
const clearState = 'apputils:clear-statedb';

export
const loadState = 'apputils:load-statedb';

export
const recoverState = 'apputils:recover-statedb';

export
const reset = 'apputils:reset';

export
const resetOnLoad = 'apputils:reset-on-load';

Expand Down Expand Up @@ -236,11 +236,7 @@ const splash: JupyterLabPlugin<ISplashScreen> = {
return {
show: () => {
const { commands, restored } = app;
const recovery = () => {
commands.execute(CommandIDs.recoverState)
.then(() => { document.location.reload(); })
.catch(() => { document.location.reload(); });
};
const recovery = () => { commands.execute(CommandIDs.reset); };

return Private.showSplash(restored, recovery);
}
Expand Down Expand Up @@ -269,11 +265,6 @@ const state: JupyterLabPlugin<IStateDB> = {
transform: transform.promise
});

commands.addCommand(CommandIDs.clearState, {
label: 'Clear Application Restore State',
execute: () => state.clear()
});

commands.addCommand(CommandIDs.recoverState, {
execute: () => {
const immediate = true;
Expand Down Expand Up @@ -373,6 +364,14 @@ const state: JupyterLabPlugin<IStateDB> = {
pattern: Patterns.loadState
});

commands.addCommand(CommandIDs.reset, {
label: 'Reset Application State',
execute: () => {
commands.execute(CommandIDs.recoverState)
.then(() => { document.location.reload(); })
.catch(() => { document.location.reload(); });
}
});

commands.addCommand(CommandIDs.resetOnLoad, {
execute: (args: IRouter.ILocation) => {
Expand Down
3 changes: 2 additions & 1 deletion packages/help-extension/src/index.ts
Expand Up @@ -201,6 +201,7 @@ function activate(app: JupyterLab, mainMenu: IMainMenu, palette: ICommandPalette
const resourcesGroup = RESOURCES
.map(args => ({ args, command: CommandIDs.open }));
helpMenu.addGroup(resourcesGroup, 10);
helpMenu.addGroup([{ command: 'apputils:reset' }], 20);

// Generate a cache of the kernel help links.
const kernelInfoCache = new Map<string, KernelMessage.IInfoReply>();
Expand Down Expand Up @@ -388,7 +389,7 @@ function activate(app: JupyterLab, mainMenu: IMainMenu, palette: ICommandPalette
RESOURCES.forEach(args => {
palette.addItem({ args, command: CommandIDs.open, category });
});
palette.addItem({ command: 'apputils:clear-statedb', category });
palette.addItem({ command: 'apputils:reset', category });
palette.addItem({ command: CommandIDs.launchClassic, category });

}

0 comments on commit f65e9ac

Please sign in to comment.