Skip to content

Commit

Permalink
Add restorer to code snippet extension (#553)
Browse files Browse the repository at this point in the history
Adds behavior of reopening the code snippets extension on reloading
jupyter lab (if code snippets was already open). Fixes #432
  • Loading branch information
marthacryan committed May 20, 2020
1 parent 5fffc6c commit decf92c
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions packages/code-snippet/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ import { codeSnippetIcon } from '@elyra/application';

import {
JupyterFrontEnd,
JupyterFrontEndPlugin
JupyterFrontEndPlugin,
ILayoutRestorer
} from '@jupyterlab/application';
import { ICommandPalette } from '@jupyterlab/apputils';

Expand All @@ -36,8 +37,12 @@ const CODE_SNIPPET_EXTENSION_ID = 'elyra-code-snippet-extension';
export const code_snippet_extension: JupyterFrontEndPlugin<void> = {
id: CODE_SNIPPET_EXTENSION_ID,
autoStart: true,
requires: [ICommandPalette],
activate: (app: JupyterFrontEnd, palette: ICommandPalette) => {
requires: [ICommandPalette, ILayoutRestorer],
activate: (
app: JupyterFrontEnd,
palette: ICommandPalette,
restorer: ILayoutRestorer
) => {
console.log('Elyra - code-snippet extension is activated!');

const getCurrentWidget = (): Widget => {
Expand All @@ -49,6 +54,8 @@ export const code_snippet_extension: JupyterFrontEndPlugin<void> = {
codeSnippetWidget.title.icon = codeSnippetIcon;
codeSnippetWidget.title.caption = 'Code Snippet';

restorer.add(codeSnippetWidget, CODE_SNIPPET_EXTENSION_ID);

// Rank has been chosen somewhat arbitrarily to give priority to the running
// sessions widget in the sidebar.
app.shell.add(codeSnippetWidget, 'left', { rank: 900 });
Expand Down

0 comments on commit decf92c

Please sign in to comment.