Browse Source

Clean up old unused code.

Jason Grout 6 years ago
parent
commit
b820fe7d3f

+ 0 - 26
packages/mainmenu-extension/src/index.ts

@@ -58,8 +58,6 @@ export namespace CommandIDs {
 
   export const closeAndCleanup = 'filemenu:close-and-cleanup';
 
-  export const saveWithOptions = 'filemenu:save-with-options';
-
   export const createConsole = 'filemenu:create-console';
 
   export const quit = 'filemenu:quit';
@@ -329,29 +327,6 @@ export function createFileMenu(
     )
   });
 
-  // Add a delegator command for saving with options.
-  commands.addCommand(CommandIDs.saveWithOptions, {
-    label: () => {
-      const action = Private.delegateLabel(app, menu.saveWithOptions, 'action');
-      const name = Private.delegateLabel(app, menu.saveWithOptions, 'name');
-      return `Save ${name} ${action || 'with Options'}`;
-    },
-    isEnabled: args => {
-      return (
-        Private.delegateEnabled(
-          app,
-          menu.saveWithOptions,
-          'saveWithOptions'
-        )() && commands.isEnabled('docmanager:save', args)
-      );
-    },
-    execute: Private.delegateExecute(
-      app,
-      menu.saveWithOptions,
-      'saveWithOptions'
-    )
-  });
-
   // Add a delegator command for creating a console for an activity.
   commands.addCommand(CommandIDs.createConsole, {
     label: () => {
@@ -429,7 +404,6 @@ export function createFileMenu(
   // Add save group.
   const saveGroup = [
     'docmanager:save',
-    'filemenu:save-with-options',
     'docmanager:save-as',
     'docmanager:save-all'
   ].map(command => {

+ 0 - 31
packages/mainmenu/src/file.ts

@@ -24,11 +24,6 @@ export interface IFileMenu extends IJupyterLabMenu {
    */
   readonly closeAndCleaners: Set<IFileMenu.ICloseAndCleaner<Widget>>;
 
-  /**
-   * The save with options extension point.
-   */
-  readonly saveWithOptions: Set<IFileMenu.ISaveWithOptions<Widget>>;
-
   /**
    * A set storing IConsoleCreators for the File menu.
    */
@@ -50,7 +45,6 @@ export class FileMenu extends JupyterLabMenu implements IFileMenu {
     this.newMenu = new JupyterLabMenu(options, false);
     this.newMenu.menu.title.label = 'New';
     this.closeAndCleaners = new Set<IFileMenu.ICloseAndCleaner<Widget>>();
-    this.saveWithOptions = new Set<IFileMenu.ISaveWithOptions<Widget>>();
     this.consoleCreators = new Set<IFileMenu.IConsoleCreator<Widget>>();
   }
 
@@ -64,11 +58,6 @@ export class FileMenu extends JupyterLabMenu implements IFileMenu {
    */
   readonly closeAndCleaners: Set<IFileMenu.ICloseAndCleaner<Widget>>;
 
-  /**
-   * The persist and save extension point.
-   */
-  readonly saveWithOptions: Set<IFileMenu.ISaveWithOptions<Widget>>;
-
   /**
    * A set storing IConsoleCreators for the Kernel menu.
    */
@@ -114,26 +103,6 @@ export namespace IFileMenu {
     closeAndCleanup: (widget: T) => Promise<void>;
   }
 
-  /**
-   * Interface for an activity that has some options for saving.
-   */
-  export interface ISaveWithOptions<T extends Widget> extends IMenuExtender<T> {
-    /**
-     * A label to use for the activity that is being saved.
-     */
-    name: string;
-
-    /**
-     * A label to describe what kinds of options are available.
-     */
-    action: string;
-
-    /**
-     * A function to perform the save (possibly getting user input on the options first).
-     */
-    saveWithOptions: (widget: T) => Promise<void>;
-  }
-
   /**
    * Interface for a command to create a console for an activity.
    */

+ 0 - 82
packages/notebook-extension/src/dialog.tsx

@@ -1,82 +0,0 @@
-// Copyright (c) Jupyter Development Team.
-// Distributed under the terms of the Modified BSD License.
-
-import { Dialog, showDialog, ReactWidget } from '@jupyterlab/apputils';
-import { Text } from '@jupyterlab/coreutils';
-
-import * as React from 'react';
-import { HTMLSelect, FormGroup, Checkbox } from '@jupyterlab/ui-components';
-
-type ISaveOption = any;
-type SaveAction = any;
-
-export type saveValues = { [key: string]: SaveAction };
-
-class BodyComponent extends ReactWidget {
-  constructor(options: ISaveOption[], values: Map<string, SaveAction>) {
-    super();
-    this.options = options;
-
-    let defaultActions = options.map<[string, SaveAction]>(k => [
-      k.name,
-      k.action
-    ]);
-    this.optionValues = new Map([...defaultActions, ...values]);
-  }
-
-  render() {
-    const checks = this.options.map((option, index) => (
-      <FormGroup
-        key={option.name}
-        label={option.label}
-        helperText={option.help}
-      >
-        <HTMLSelect
-          name={option.name}
-          options={['save', 'clear', 'previous'].map(Text.titleCase)}
-          value={Text.titleCase(this.optionValues.get(option.name))}
-          onChange={(event: any) => {
-            this.optionValues.set(
-              option.name,
-              event.target.value.toLowerCase()
-            );
-            this.update();
-          }}
-        />
-      </FormGroup>
-    ));
-    if (checks.length > 0) {
-      checks.push(
-        <div key="jupyterlab-remember-choices">
-          <Checkbox
-            label={'Remember my choices'}
-            onChange={(event: any) => {
-              this.remember = event.target.value;
-            }}
-          />
-        </div>
-      );
-    }
-    return (
-      <div>{checks.length ? checks : 'No options available for saving'}</div>
-    );
-  }
-
-  getValue() {
-    return { remember: this.remember, options: this.optionValues };
-  }
-  options: ISaveOption[];
-  optionValues: Map<string, SaveAction>;
-  remember: boolean;
-}
-
-export async function saveOptionsDialog(
-  options: ISaveOption[],
-  values: Map<string, SaveAction>
-) {
-  return showDialog({
-    title: 'Save Notebook with Options',
-    body: new BodyComponent(options, values),
-    buttons: [Dialog.cancelButton(), Dialog.okButton({ label: 'Save' })]
-  });
-}

+ 1 - 41
packages/notebook-extension/src/index.ts

@@ -204,8 +204,6 @@ namespace CommandIDs {
   export const enableOutputScrolling = 'notebook:enable-output-scrolling';
 
   export const disableOutputScrolling = 'notebook:disable-output-scrolling';
-
-  export const saveWithView = 'notebook:save-with-view';
 }
 
 /**
@@ -584,26 +582,6 @@ function activateNotebookHandler(
     });
     // Add the notebook panel to the tracker.
     tracker.add(widget);
-
-    /**
-     * TODO:
-     * * Add settings for each syncable cell attribute (collapse, scrolled, editable)
-     * * Have notebook-level widget settings for each syncable attribute
-     * * On the setting change, set each existing notebook accordingly
-     * * For each new notebook, set the attributes according to the setting
-     * * in a notebook, when a syncable attribute is set, set each cell appropriately and create new cells appropriately.
-     */
-
-    // // TODO: Add cell widget events for when the scrolled or collapse state
-    // // changes, so that we can sync metadata, then delete this save handler.
-    // widget.context.saveState.connect((sender, state) => {
-    //   if (state === 'started') {
-    //     // Always sync view state if we are the shell's current widget.
-    //     if (app.shell.currentWidget === widget) {
-    //       NotebookActions.persistCollapseScrollState(widget.content);
-    //     }
-    //   }
-    // });
   });
 
   /**
@@ -682,7 +660,7 @@ function activateNotebookHandler(
 
   // Add main menu notebook menu.
   if (mainMenu) {
-    populateMenus(app, mainMenu, tracker, services, palette, fetchSettings);
+    populateMenus(app, mainMenu, tracker, services, palette);
   }
 
   // Utility function to create a new notebook.
@@ -1806,23 +1784,6 @@ function addCommands(
     },
     isEnabled
   });
-  // commands.addCommand(CommandIDs.saveWithView, {
-  //   label: 'Save Notebook with View State',
-  //   execute: args => {
-  //     const current = getCurrent(args);
-
-  //     if (current) {
-  //       // Get registry of notebook persistence callbacks. Call each one with
-  //       // the notebook.
-
-  //       NotebookActions.persistViewState(current.content);
-  //       app.commands.execute('docmanager:save');
-  //     }
-  //   },
-  //   isEnabled: args => {
-  //     return isEnabled() && commands.isEnabled('docmanager:save', args);
-  //   }
-  // });
 }
 
 /**
@@ -1921,7 +1882,6 @@ function populateMenus(
   tracker: INotebookTracker,
   services: ServiceManager,
   palette: ICommandPalette | null,
-  fetchSettings: Promise<ISettingRegistry.ISettings>
 ): void {
   let { commands } = app;
 

+ 0 - 13
packages/notebook/src/model.ts

@@ -61,19 +61,6 @@ export interface INotebookModel extends DocumentRegistry.IModel {
   readonly deletedCells: string[];
 }
 
-/**
- * Save hook
- *
- * @param value - whether the user selected true or false for the save option.
- * @param model - the notebook model
- * @param savedJSON - the mutable model to transform.
- */
-export type SaveHook = (
-  value: boolean,
-  model: INotebookModel,
-  savedJSON: nbformat.INotebookContent
-) => void;
-
 /**
  * An implementation of a notebook Model.
  */

+ 0 - 17
tests/test-mainmenu/src/file.spec.ts

@@ -71,23 +71,6 @@ describe('@jupyterlab/mainmenu', () => {
       });
     });
 
-    describe('#saveWithOptions', () => {
-      it('should allow setting of an ISaveWithOptions', () => {
-        const saveWithOptions: IFileMenu.ISaveWithOptions<Wodget> = {
-          tracker,
-          name: 'Wodget',
-          action: 'with Save',
-          saveWithOptions: widget => {
-            widget.state = 'saved';
-            return Promise.resolve(void 0);
-          }
-        };
-        menu.saveWithOptions.add(saveWithOptions);
-        delegateExecute(wodget, menu.saveWithOptions, 'saveWithOptions');
-        expect(wodget.state).to.equal('saved');
-      });
-    });
-
     describe('#consoleCreators', () => {
       it('should allow setting of an IConsoleCreator', () => {
         const creator: IFileMenu.IConsoleCreator<Wodget> = {