Skip to content

Commit

Permalink
TODO fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
vidartf committed Dec 20, 2019
1 parent 3898f1c commit 879c914
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 24 deletions.
7 changes: 1 addition & 6 deletions packages/application/src/router.ts
Expand Up @@ -7,12 +7,7 @@ import { URLExt } from '@jupyterlab/coreutils';

import { CommandRegistry } from '@lumino/commands';

import {
PromiseDelegate,
Token,
ReadonlyPartialJSONObject,
PartialJSONObject
} from '@lumino/coreutils';
import { PromiseDelegate, Token } from '@lumino/coreutils';

import { DisposableDelegate, IDisposable } from '@lumino/disposable';

Expand Down
42 changes: 27 additions & 15 deletions packages/notebook/src/notebooktools.ts
Expand Up @@ -3,7 +3,10 @@

import { ArrayExt, each, chain } from '@lumino/algorithm';

import { PartialJSONValue, PartialJSONObject } from '@lumino/coreutils';
import {
ReadonlyPartialJSONValue,
ReadonlyPartialJSONObject
} from '@lumino/coreutils';

import { ConflatableMessage, Message, MessageLoop } from '@lumino/messaging';

Expand Down Expand Up @@ -209,8 +212,8 @@ export class NotebookTools extends Widget implements INotebookTools {
* Handle a change in the active cell metadata.
*/
private _onActiveNotebookPanelMetadataChanged(
sender: IObservableMap<PartialJSONValue | undefined>,
args: IObservableMap.IChangedArgs<PartialJSONValue>
sender: IObservableMap<ReadonlyPartialJSONValue | undefined>,
args: IObservableMap.IChangedArgs<ReadonlyPartialJSONValue>
): void {
let message = new ObservableJSON.ChangeMessage(
'activenotebookpanel-metadata-changed',
Expand All @@ -225,8 +228,8 @@ export class NotebookTools extends Widget implements INotebookTools {
* Handle a change in the notebook model metadata.
*/
private _onActiveCellMetadataChanged(
sender: IObservableMap<PartialJSONValue | undefined>,
args: IObservableMap.IChangedArgs<PartialJSONValue>
sender: IObservableMap<ReadonlyPartialJSONValue | undefined>,
args: IObservableMap.IChangedArgs<ReadonlyPartialJSONValue>
): void {
let message = new ObservableJSON.ChangeMessage(
'activecell-metadata-changed',
Expand Down Expand Up @@ -742,7 +745,10 @@ export namespace NotebookTools {
/**
* Set the value for the data.
*/
private _setValue = (cell: Cell, value: PartialJSONValue | undefined) => {
private _setValue = (
cell: Cell,
value: ReadonlyPartialJSONValue | undefined
) => {
if (value === this._default) {
cell.model.metadata.delete(this.key);
} else {
Expand All @@ -752,9 +758,12 @@ export namespace NotebookTools {

private _changeGuard = false;
private _validCellTypes: string[];
private _getter: (cell: Cell) => PartialJSONValue | undefined;
private _setter: (cell: Cell, value: PartialJSONValue | undefined) => void;
private _default: PartialJSONValue | undefined;
private _getter: (cell: Cell) => ReadonlyPartialJSONValue | undefined;
private _setter: (
cell: Cell,
value: ReadonlyPartialJSONValue | undefined
) => void;
private _default: ReadonlyPartialJSONValue | undefined;
}

/**
Expand All @@ -777,7 +786,7 @@ export namespace NotebookTools {
* If a value equals the default, choosing it may erase the key from the
* metadata.
*/
optionsMap: PartialJSONObject;
optionsMap: ReadonlyPartialJSONObject;

/**
* The optional title of the selector - defaults to capitalized `key`.
Expand All @@ -796,7 +805,7 @@ export namespace NotebookTools {
*
* @returns The appropriate value for the selector.
*/
getter?: (cell: Cell) => PartialJSONValue | undefined;
getter?: (cell: Cell) => ReadonlyPartialJSONValue | undefined;

/**
* An optional value setter for the selector.
Expand All @@ -809,12 +818,15 @@ export namespace NotebookTools {
* The setter should set the appropriate metadata value given the value of
* the selector.
*/
setter?: (cell: Cell, value: PartialJSONValue | undefined) => void;
setter?: (
cell: Cell,
value: ReadonlyPartialJSONValue | undefined
) => void;

/**
* Default value for default setters and getters if value is not found.
*/
default?: PartialJSONValue;
default?: ReadonlyPartialJSONValue;
}
}

Expand All @@ -835,7 +847,7 @@ export namespace NotebookTools {
},
getter: cell => {
let value = cell.model.metadata.get('slideshow') as
| PartialJSONObject
| ReadonlyPartialJSONObject
| undefined;
return value && value['slide_type'];
},
Expand All @@ -862,7 +874,7 @@ export namespace NotebookTools {
* Create an nbconvert selector.
*/
export function createNBConvertSelector(
optionsMap: PartialJSONObject
optionsMap: ReadonlyPartialJSONObject
): KeySelector {
return new KeySelector({
key: 'raw_mimetype',
Expand Down
6 changes: 3 additions & 3 deletions packages/notebook/src/widget.ts
Expand Up @@ -3,7 +3,7 @@

import { ArrayExt, each } from '@lumino/algorithm';

import { PartialJSONValue } from '@lumino/coreutils';
import { ReadonlyPartialJSONValue } from '@lumino/coreutils';

import { Message } from '@lumino/messaging';

Expand Down Expand Up @@ -319,8 +319,8 @@ export class StaticNotebook extends Widget {
* when the `language_info` metadata changes.
*/
protected onMetadataChanged(
sender: IObservableMap<PartialJSONValue | undefined>,
args: IObservableMap.IChangedArgs<PartialJSONValue>
sender: IObservableMap<ReadonlyPartialJSONValue | undefined>,
args: IObservableMap.IChangedArgs<ReadonlyPartialJSONValue>
): void {
switch (args.key) {
case 'language_info':
Expand Down

0 comments on commit 879c914

Please sign in to comment.