Skip to content

Commit

Permalink
Fix following rebase.
Browse files Browse the repository at this point in the history
  • Loading branch information
HaudinFlorence committed Sep 8, 2023
1 parent 82e8ff8 commit 5f8c05d
Show file tree
Hide file tree
Showing 43 changed files with 1,265 additions and 1,019 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"build": "lerna run build",
"build:dev": "tsc --build",
"clean": "lerna run clean",
"prettier": "prettier --list-different --write \"**/*{.ts,.tsx,.js,.jsx,.css,.json,.md}\"",
"prettier:check": "prettier --check \"**/*{.ts,.tsx,.js,.jsx,.css,.json,.md}\"",
"prettier": "prettier --list-different --write \"**/*{.ts,.tsx,.js,.jsx,.css,.json,.md}\"",
"prettier:check": "prettier --check \"**/*{.ts,.tsx,.js,.jsx,.css,.json,.md}\"",
"publish": "npm run clean && npm run build && lerna publish --no-private -m \"Publish npm packages\"",
"test": "lerna run test",
"update:all": "update-dependency --lerna --minimal --regex .*",
Expand Down
50 changes: 24 additions & 26 deletions packages/labextension/src/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,12 @@ interface IApiResponse {
is_git: boolean;
}



export
function diffNotebook(args: {
readonly base: string,
readonly remote: string,
readonly rendermime: IRenderMimeRegistry,
readonly editorFactory: CodeEditor.Factory,
hideUnchanged?: boolean
export function diffNotebook(args: {
readonly base: string;
readonly remote: string;
readonly rendermime: IRenderMimeRegistry;
readonly editorFactory: CodeEditor.Factory;
hideUnchanged?: boolean;
}): Widget {
let { base, remote } = args;
let widget = new NbdimeWidget(args);
Expand All @@ -33,15 +30,13 @@ function diffNotebook(args: {
return widget;
}


export
function diffNotebookCheckpoint(args: {
readonly path: string,
readonly rendermime: IRenderMimeRegistry,
readonly editorFactory: CodeEditor.Factory,
hideUnchanged?: boolean
export function diffNotebookCheckpoint(args: {
readonly path: string;
readonly rendermime: IRenderMimeRegistry;
readonly editorFactory: CodeEditor.Factory;
hideUnchanged?: boolean;
}): Widget {
const {path, rendermime, hideUnchanged, editorFactory} = args;
const { path, rendermime, hideUnchanged, editorFactory } = args;
let nb_dir = PathExt.dirname(path);
let name = PathExt.basename(path, '.ipynb');
let base = PathExt.join(nb_dir, name + '.ipynb');
Expand All @@ -58,17 +53,20 @@ function diffNotebookCheckpoint(args: {
return widget;
}


export
function diffNotebookGit(args: {
readonly path: string,
readonly rendermime: IRenderMimeRegistry,
readonly editorFactory: CodeEditor.Factory,
hideUnchanged?: boolean
export function diffNotebookGit(args: {
readonly path: string;
readonly rendermime: IRenderMimeRegistry;
readonly editorFactory: CodeEditor.Factory;
hideUnchanged?: boolean;
}): Widget {
const {path, rendermime, hideUnchanged, editorFactory} = args;
const { path, rendermime, hideUnchanged, editorFactory } = args;
let name = PathExt.basename(path, '.ipynb');
let widget = new NbdimeWidget({base: path, editorFactory, rendermime, hideUnchanged});
let widget = new NbdimeWidget({
base: path,
editorFactory,
rendermime,
hideUnchanged,
});
widget.title.label = `Diff git: ${name}`;
widget.title.caption = `Local: git HEAD\nRemote: '${path}'`;
widget.title.iconClass = 'fa fa-git jp-fa-tabIcon';
Expand Down
26 changes: 15 additions & 11 deletions packages/labextension/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,9 @@ import type {

import { CommandToolbarButton } from '@jupyterlab/apputils';

import {
IEditorServices
} from '@jupyterlab/codeeditor'
import { IEditorServices } from '@jupyterlab/codeeditor';

import {
PathExt
} from '@jupyterlab/coreutils';
import { PathExt } from '@jupyterlab/coreutils';

import type { DocumentRegistry } from '@jupyterlab/docregistry';

Expand Down Expand Up @@ -119,10 +115,12 @@ function addCommands(
tracker: INotebookTracker,
rendermime: IRenderMimeRegistry,
settings: ISettingRegistry.ISettings,
editorServices: IEditorServices
editorServices: IEditorServices,
): void {
const { commands, shell } = app;
const editorFactory = editorServices.factoryService.newInlineEditor.bind(editorServices.factoryService);
const editorFactory = editorServices.factoryService.newInlineEditor.bind(
editorServices.factoryService,
);

// Whether we have our server extension available
let hasAPI = true;
Expand Down Expand Up @@ -201,7 +199,8 @@ function addCommands(
label: erroredGen('Notebook diff'),
caption: erroredGen('Display nbdiff between two notebooks'),
isEnabled: baseEnabled,
iconClass: 'jp-Icon jp-Icon-16 action-notebook-diff action-notebook-diff-notebooks',
iconClass:
'jp-Icon jp-Icon-16 action-notebook-diff action-notebook-diff-notebooks',
iconLabel: 'nbdiff',
});

Expand Down Expand Up @@ -263,7 +262,12 @@ function addCommands(
*/
const nbDiffProvider: JupyterFrontEndPlugin<void> = {
id: pluginId,
requires: [INotebookTracker, IRenderMimeRegistry, ISettingRegistry, IEditorServices],
requires: [
INotebookTracker,
IRenderMimeRegistry,
ISettingRegistry,
IEditorServices,
],
activate: activateWidgetExtension,
autoStart: true,
};
Expand All @@ -278,7 +282,7 @@ async function activateWidgetExtension(
tracker: INotebookTracker,
rendermime: IRenderMimeRegistry,
settingsRegistry: ISettingRegistry,
editorServices: IEditorServices
editorServices: IEditorServices,
): Promise<void> {
let { commands, docRegistry } = app;
let extension = new NBDiffExtension(commands);
Expand Down
16 changes: 8 additions & 8 deletions packages/labextension/src/widget.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import type * as nbformat from '@jupyterlab/nbformat';

import type {
CodeEditor
} from '@jupyterlab/codeeditor';
import type { CodeEditor } from '@jupyterlab/codeeditor';

import type {
IRenderMimeRegistry
} from '@jupyterlab/rendermime';
import type { IRenderMimeRegistry } from '@jupyterlab/rendermime';

import { ServerConnection } from '@jupyterlab/services';

Expand Down Expand Up @@ -120,7 +116,11 @@ export class NbdimeWidget extends Panel {
let base = data['base'] as nbformat.INotebookContent;
let diff = data['diff'] as any as IDiffEntry[];
let nbdModel = new NotebookDiffModel(base, diff);
let nbdWidget = new NotebookDiffWidget({model: nbdModel, rendermime: this.rendermime, editorFactory: this.editorFactory});
let nbdWidget = new NotebookDiffWidget({
model: nbdModel,
rendermime: this.rendermime,
editorFactory: this.editorFactory,
});

this.scroller.addWidget(nbdWidget);
let work = nbdWidget.init();
Expand Down Expand Up @@ -164,7 +164,7 @@ export namespace NbdimeWidget {
/**
* Code editor factory
*/
editorFactory: CodeEditor.Factory,
editorFactory: CodeEditor.Factory;

/**
* A rendermime instance to use to render markdown/outputs.
Expand Down
31 changes: 18 additions & 13 deletions packages/labextension/style/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
vertical-align: text-bottom;
}


/* Header syling */

.jp-fa-tabIcon {
Expand Down Expand Up @@ -84,17 +83,17 @@
vertical-align: top;
}



/* Hiding unchanged cells if told to */
.nbdime-root.jp-mod-hideUnchanged .jp-Cell-diff.jp-Diff-unchanged {
display: none;
}

/* Show a marker with the number of cells hidden before */
.nbdime-root.jp-mod-hideUnchanged .jp-Cell-diff[data-nbdime-NCellsHiddenBefore]::before,
.nbdime-root.jp-mod-hideUnchanged .jp-Diff-addremchunk[data-nbdime-NCellsHiddenBefore]::before {
content: attr(data-nbdime-NCellsHiddenBefore) " unchanged cell(s) hidden";
.nbdime-root.jp-mod-hideUnchanged
.jp-Cell-diff[data-nbdime-NCellsHiddenBefore]::before,
.nbdime-root.jp-mod-hideUnchanged
.jp-Diff-addremchunk[data-nbdime-NCellsHiddenBefore]::before {
content: attr(data-nbdime-NCellsHiddenBefore) ' unchanged cell(s) hidden';
position: absolute;
width: 100%;
top: 0;
Expand All @@ -105,9 +104,11 @@
}

/* Show a marker with the number of cells hidden after (for hidden cells at end) */
.nbdime-root.jp-mod-hideUnchanged .jp-Cell-diff[data-nbdime-NCellsHiddenAfter]::after,
.nbdime-root.jp-mod-hideUnchanged .jp-Diff-addremchunk[data-nbdime-NCellsHiddenAfter]::after {
content: attr(data-nbdime-NCellsHiddenAfter) " unchanged cell(s) hidden";
.nbdime-root.jp-mod-hideUnchanged
.jp-Cell-diff[data-nbdime-NCellsHiddenAfter]::after,
.nbdime-root.jp-mod-hideUnchanged
.jp-Diff-addremchunk[data-nbdime-NCellsHiddenAfter]::after {
content: attr(data-nbdime-NCellsHiddenAfter) ' unchanged cell(s) hidden';
position: absolute;
width: 100%;
bottom: 0;
Expand All @@ -118,18 +119,22 @@
}

.nbdime-root.jp-mod-hideUnchanged .jp-Cell-diff[data-nbdime-NCellsHiddenBefore],
.nbdime-root.jp-mod-hideUnchanged .jp-Diff-addremchunk[data-nbdime-NCellsHiddenBefore] {
.nbdime-root.jp-mod-hideUnchanged
.jp-Diff-addremchunk[data-nbdime-NCellsHiddenBefore] {
padding-top: 40px;
}

.nbdime-root.jp-mod-hideUnchanged .jp-Cell-diff[data-nbdime-NCellsHiddenAfter],
.nbdime-root.jp-mod-hideUnchanged .jp-Diff-addremchunk[data-nbdime-NCellsHiddenAfter] {
.nbdime-root.jp-mod-hideUnchanged
.jp-Diff-addremchunk[data-nbdime-NCellsHiddenAfter] {
padding-bottom: 40px;
}

/* Marker for when all cells are unchanged and hidden */
.nbdime-root.jp-mod-hideUnchanged .jp-Notebook-diff[data-nbdime-AllCellsHidden]::after {
content: "No changes, " attr(data-nbdime-AllCellsHidden) " unchanged cell(s) hidden";
.nbdime-root.jp-mod-hideUnchanged
.jp-Notebook-diff[data-nbdime-AllCellsHidden]::after {
content: 'No changes, ' attr(data-nbdime-AllCellsHidden)
' unchanged cell(s) hidden';
display: block;
width: 100%;
background-color: var(--jp-layout-color2);
Expand Down
8 changes: 4 additions & 4 deletions packages/nbdime/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const esModules = [
'vscode-ws-jsonrpc',
'y-protocols',
'y-websocket',
'yjs'
'yjs',
].join('|');

module.exports = {
Expand All @@ -22,10 +22,10 @@ module.exports = {
'^.+\\.tsx?$': [
'ts-jest/legacy',
{
tsconfig: `./tsconfig.test.json`
}
tsconfig: `./tsconfig.test.json`,
},
],
'^.+\\.jsx?$': 'babel-jest'
'^.+\\.jsx?$': 'babel-jest',
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
setupFiles: ['<rootDir>/test/jest-setup-files.js'],
Expand Down
57 changes: 29 additions & 28 deletions packages/nbdime/src/common/dragpanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,11 @@
// Distributed under the terms of the Modified BSD License.
'use strict';

import {
Panel, PanelLayout, Widget
} from '@lumino/widgets';
import { Panel, PanelLayout, Widget } from '@lumino/widgets';

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

import {
MimeData
} from '@lumino/coreutils';
import { MimeData } from '@lumino/coreutils';

import { Drag } from '@lumino/dragdrop';

Expand Down Expand Up @@ -143,20 +137,20 @@ export abstract class DropPanel extends Panel {
*/
handleEvent(event: Event): void {
switch (event.type) {
case 'p-dragenter':
this._evtDragEnter(event as Drag.Event);
break;
case 'p-dragleave':
this._evtDragLeave(event as Drag.Event);
break;
case 'p-dragover':
this._evtDragOver(event as Drag.Event);
break;
case 'p-drop':
this.evtDrop(event as Drag.Event);
break;
default:
break;
case 'p-dragenter':
this._evtDragEnter(event as Drag.Event);
break;
case 'p-dragleave':
this._evtDragLeave(event as Drag.Event);
break;
case 'p-dragover':
this._evtDragOver(event as Drag.Event);
break;
case 'p-drop':
this.evtDrop(event as Drag.Event);
break;
default:
break;
}
}

Expand All @@ -171,7 +165,10 @@ export abstract class DropPanel extends Panel {
* - That the `dropTarget` is a valid drop target
* - The value of `event.source` if `acceptDropsFromExternalSource` is false
*/
protected abstract processDrop(dropTarget: HTMLElement, event: Drag.Event): void;
protected abstract processDrop(
dropTarget: HTMLElement,
event: Drag.Event,
): void;

/**
* Find a drop target from a given drag event target.
Expand Down Expand Up @@ -739,8 +736,10 @@ export class DragDropPanel extends DragDropPanelBase {
* Override this if you need to handle other mime data than the default.
*/
protected processDrop(dropTarget: HTMLElement, event: Drag.Event): void {
if (!DropPanel.isValidAction(event.supportedActions, 'move') ||
event.proposedAction === 'none') {
if (
!DropPanel.isValidAction(event.supportedActions, 'move') ||
event.proposedAction === 'none'
) {
// The default implementation only handles move action
// OR Accept proposed none action, and perform no-op
event.dropAction = 'none';
Expand Down Expand Up @@ -788,8 +787,10 @@ export namespace DropPanel {
/**
* Validate a drop action against a SupportedActions type
*/
export
function isValidAction(supported: Drag.SupportedActions, action: Drag.DropAction): boolean {
export function isValidAction(
supported: Drag.SupportedActions,
action: Drag.DropAction,
): boolean {
switch (supported) {
case 'all':
return true;
Expand Down
Loading

0 comments on commit 5f8c05d

Please sign in to comment.