Skip to content

Commit 5d536dd

Browse files
authored
Merge pull request #599 from btel/jlab-2.0-rebased
compatibility with jupyterlab >= 2.0
2 parents a921bca + 81b9de2 commit 5d536dd

24 files changed

+1986
-2000
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ cache:
77
- /home/travis/.yarn-cache/
88
before_install:
99
- nvm install 10
10-
install: pip install pytest pytest-asyncio "jupyterlab~=1.1"
10+
install: pip install --upgrade --upgrade-strategy=eager pytest pytest-asyncio "jupyterlab~=2.0"
1111
script:
1212
# Build the sdist (identical to what will be uploaded to eg pypi on release)
1313
- python setup.py sdist

package.json

+19-16
Original file line numberDiff line numberDiff line change
@@ -49,30 +49,33 @@
4949
"schemaDir": "schema"
5050
},
5151
"dependencies": {
52-
"@jupyterlab/application": "^1.1.0",
53-
"@jupyterlab/apputils": "^1.1.0",
54-
"@jupyterlab/codemirror": "^1.1.0",
55-
"@jupyterlab/console": "^1.1.0",
56-
"@jupyterlab/coreutils": "^3.1.0",
57-
"@jupyterlab/filebrowser": "^1.1.0",
58-
"@jupyterlab/mainmenu": "^1.1.0",
59-
"@jupyterlab/services": "^4.1.0",
60-
"@jupyterlab/terminal": "^1.1.0",
61-
"@jupyterlab/ui-components": "^1.1.0",
52+
"@jupyterlab/application": "^2.0.0",
53+
"@jupyterlab/apputils": "^2.0.0",
54+
"@jupyterlab/codemirror": "^2.0.0",
55+
"@jupyterlab/console": "^2.0.0",
56+
"@jupyterlab/coreutils": "^4.0.0",
57+
"@jupyterlab/filebrowser": "^2.0.0",
58+
"@jupyterlab/mainmenu": "^2.0.0",
59+
"@jupyterlab/nbformat": "^2.0.0",
60+
"@jupyterlab/services": "^5.0.0",
61+
"@jupyterlab/settingregistry": "^2.0.0",
62+
"@jupyterlab/terminal": "^2.0.0",
63+
"@jupyterlab/ui-components": "^2.0.0",
64+
"@lumino/polling": "^1.0.4",
65+
"@lumino/widgets": "^1.11.1",
6266
"@material-ui/core": "^4.8.2",
6367
"@material-ui/icons": "^4.5.1",
64-
"@phosphor/widgets": "^1.8.0",
6568
"diff-match-patch": "^1.0.4",
66-
"nbdime": "~5.0.1",
67-
"react": "~16.8.4",
68-
"react-dom": "~16.8.4",
69+
"nbdime": "^6.0.0",
70+
"react": "~16.9.0",
71+
"react-dom": "~16.9.0",
6972
"react-textarea-autosize": "^7.1.2",
7073
"typestyle": "^2.0.1"
7174
},
7275
"devDependencies": {
7376
"@babel/core": "^7.5.0",
7477
"@babel/preset-env": "^7.5.0",
75-
"@jupyterlab/testutils": "^1.1.0",
78+
"@jupyterlab/testutils": "^2.0.0",
7679
"@types/codemirror": "^0.0.79",
7780
"@types/diff-match-patch": "^1.0.32",
7881
"@types/enzyme": "3.1.15",
@@ -96,7 +99,7 @@
9699
"tslint": "^5.11.0",
97100
"tslint-config-prettier": "1.18.0",
98101
"tslint-plugin-prettier": "^2.0.0",
99-
"typescript": "~3.5.1",
102+
"typescript": "~3.7.1",
100103
"typescript-tslint-plugin": "^0.5.4"
101104
},
102105
"peerDependencies": {

setup.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,14 @@ def runPackLabextension():
7171
],
7272
install_requires = [
7373
'notebook',
74-
'nbdime >= 1.1.0, < 2.0.0',
74+
'nbdime ~=2.0',
7575
'pexpect'
7676
],
7777
extras_require = {
7878
'test': [
7979
'pytest',
8080
'pytest-asyncio',
81-
'jupyterlab~=1.1',
81+
'jupyterlab~=2.0',
8282
],
8383
},
8484
)

src/components/ActionButton.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from 'react';
2-
import { DefaultIconReact } from '@jupyterlab/ui-components';
32
import { classes } from 'typestyle';
3+
import { LabIcon } from '@jupyterlab/ui-components';
44
import { actionButtonStyle } from '../style/ActionButtonStyle';
55

66
/**
@@ -44,7 +44,7 @@ export const ActionButton: React.FunctionComponent<IActionButtonProps> = (
4444
title={props.title}
4545
onClick={props.onClick}
4646
>
47-
<DefaultIconReact tag="span" name={props.iconName} />
47+
<LabIcon.resolveReact icon={props.iconName} />
4848
</button>
4949
);
5050
};

src/components/FileList.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import * as React from 'react';
22
import { Dialog, showDialog, showErrorMessage } from '@jupyterlab/apputils';
3-
import { ISettingRegistry } from '@jupyterlab/coreutils';
43
import { IRenderMimeRegistry } from '@jupyterlab/rendermime';
5-
import { Menu } from '@phosphor/widgets';
4+
import { ISettingRegistry } from '@jupyterlab/settingregistry';
5+
import { Menu } from '@lumino/widgets';
66
import { GitExtension } from '../model';
77
import { hiddenButtonStyle } from '../style/ActionButtonStyle';
88
import { fileListWrapperClass } from '../style/FileListStyle';

src/components/GitPanel.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import * as React from 'react';
22
import Tabs from '@material-ui/core/Tabs';
33
import Tab from '@material-ui/core/Tab';
44
import { showErrorMessage, showDialog } from '@jupyterlab/apputils';
5-
import { ISettingRegistry } from '@jupyterlab/coreutils';
5+
import { ISettingRegistry } from '@jupyterlab/settingregistry';
66
import { IRenderMimeRegistry } from '@jupyterlab/rendermime';
7-
import { JSONObject } from '@phosphor/coreutils';
7+
import { JSONObject } from '@lumino/coreutils';
88
import { GitExtension } from '../model';
99
import {
1010
panelWrapperClass,

src/components/SinglePastCommitInfo.tsx

+17-10
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import * as React from 'react';
22
import { IRenderMimeRegistry } from '@jupyterlab/rendermime';
3-
import { DefaultIconReact } from '@jupyterlab/ui-components';
4-
import { classes } from 'typestyle';
3+
import { fileIcon } from '@jupyterlab/ui-components';
4+
import { insertionsMadeIcon, deletionsMadeIcon } from '../style/icons';
5+
import { classes } from 'typestyle/';
56
import { GitExtension } from '../model';
67
import { Git } from '../tokens';
78
import {
@@ -159,21 +160,27 @@ export class SinglePastCommitInfo extends React.Component<
159160
<div>
160161
<div className={commitClass}>
161162
<div className={commitOverviewNumbersClass}>
162-
<span title="# Files Changed">
163-
<DefaultIconReact name="file" className={iconClass} />
163+
<span>
164+
<fileIcon.react
165+
className={iconClass}
166+
tag="span"
167+
title="# Files Changed"
168+
/>
164169
{this.state.numFiles}
165170
</span>
166-
<span title="# Insertions">
167-
<DefaultIconReact
168-
name="git-insertionsMade"
171+
<span>
172+
<insertionsMadeIcon.react
169173
className={classes(iconClass, insertionsIconClass)}
174+
tag="div"
175+
title="# Insertions"
170176
/>
171177
{this.state.insertions}
172178
</span>
173-
<span title="# Deletions">
174-
<DefaultIconReact
175-
name="git-deletionsMade"
179+
<span>
180+
<deletionsMadeIcon.react
176181
className={classes(iconClass, deletionsIconClass)}
182+
tag="div"
183+
title="# Deletions"
177184
/>
178185
{this.state.deletions}
179186
</span>

src/components/diff/NbDiff.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { nbformat, PathExt } from '@jupyterlab/coreutils';
1+
import { PathExt } from '@jupyterlab/coreutils';
2+
import * as nbformat from '@jupyterlab/nbformat';
23
import { IRenderMimeRegistry } from '@jupyterlab/rendermime';
34
import { ServerConnection } from '@jupyterlab/services/lib/serverconnection';
45
import { IDiffEntry } from 'nbdime/lib/diff/diffentries';

src/gitMenuCommands.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import {
66
showDialog,
77
showErrorMessage
88
} from '@jupyterlab/apputils';
9-
import { ISettingRegistry } from '@jupyterlab/coreutils';
109
import { FileBrowser } from '@jupyterlab/filebrowser';
10+
import { ISettingRegistry } from '@jupyterlab/settingregistry';
1111
import { ITerminal } from '@jupyterlab/terminal';
1212
import { IGitExtension } from './tokens';
1313
import { doGitClone } from './widgets/gitClone';

src/index.ts

+5-8
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@ import {
33
JupyterFrontEnd,
44
JupyterFrontEndPlugin
55
} from '@jupyterlab/application';
6-
import { IChangedArgs, ISettingRegistry } from '@jupyterlab/coreutils';
6+
import { IChangedArgs } from '@jupyterlab/coreutils';
7+
import { ISettingRegistry } from '@jupyterlab/settingregistry';
78
import {
89
FileBrowser,
910
FileBrowserModel,
1011
IFileBrowserFactory
1112
} from '@jupyterlab/filebrowser';
1213
import { IMainMenu } from '@jupyterlab/mainmenu';
1314
import { IRenderMimeRegistry } from '@jupyterlab/rendermime';
14-
import { defaultIconRegistry } from '@jupyterlab/ui-components';
15-
import { Menu } from '@phosphor/widgets';
15+
import { Menu } from '@lumino/widgets';
1616
import { addCommands, CommandIDs } from './gitMenuCommands';
1717
import { GitExtension } from './model';
18-
import { registerGitIcons } from './style/icons';
1918
import { IGitExtension } from './tokens';
2019
import { addCloneButton } from './widgets/gitClone';
2120
import { GitWidget } from './widgets/GitWidget';
21+
import { gitIcon } from './style/icons';
2222

2323
export { Git, IGitExtension } from './tokens';
2424

@@ -68,9 +68,6 @@ async function activate(
6868
): Promise<IGitExtension> {
6969
let settings: ISettingRegistry.ISettings;
7070

71-
// Register Git icons with the icon registry
72-
registerGitIcons(defaultIconRegistry);
73-
7471
// Get a reference to the default file browser extension
7572
const filebrowser = factory.defaultBrowser;
7673

@@ -102,7 +99,7 @@ async function activate(
10299
// Create the Git widget sidebar
103100
const gitPlugin = new GitWidget(gitExtension, settings, renderMime);
104101
gitPlugin.id = 'jp-git-sessions';
105-
gitPlugin.title.iconClass = 'jp-SideBar-tabIcon jp-GitIcon';
102+
gitPlugin.title.icon = gitIcon;
106103
gitPlugin.title.caption = 'Git';
107104

108105
// Let the application restorer track the running panel for restoration of

src/model.ts

+6-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
import { JupyterFrontEnd } from '@jupyterlab/application';
2-
import {
3-
IChangedArgs,
4-
PathExt,
5-
Poll,
6-
ISettingRegistry
7-
} from '@jupyterlab/coreutils';
2+
import { IChangedArgs, PathExt } from '@jupyterlab/coreutils';
83
import { ServerConnection } from '@jupyterlab/services';
9-
import { CommandRegistry } from '@phosphor/commands';
10-
import { JSONObject } from '@phosphor/coreutils';
11-
import { ISignal, Signal } from '@phosphor/signaling';
4+
import { ISettingRegistry } from '@jupyterlab/settingregistry';
5+
import { CommandRegistry } from '@lumino/commands';
6+
import { JSONObject } from '@lumino/coreutils';
7+
import { Poll } from '@lumino/polling';
8+
import { ISignal, Signal } from '@lumino/signaling';
129
import { httpGitRequest } from './git';
1310
import { IGitExtension, Git } from './tokens';
1411
import { decodeStage } from './utils';

src/style/GitStageStyle.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export const changeStageButtonStyle = style({
5454
backgroundColor: 'transparent',
5555
backgroundPosition: 'center',
5656
backgroundRepeat: 'no-repeat',
57-
backgroundSize: '14px',
57+
backgroundSize: '20px',
5858
transition: 'background-color 0.1s ease',
5959
height: '13px',
6060
width: '12px',
@@ -63,9 +63,9 @@ export const changeStageButtonStyle = style({
6363
});
6464

6565
export const caretdownImageStyle = style({
66-
backgroundImage: 'var(--jp-image-caretdown)'
66+
backgroundImage: 'var(--jp-icon-caret-down)'
6767
});
6868

6969
export const caretrightImageStyle = style({
70-
backgroundImage: 'var(--jp-image-caretright)'
70+
backgroundImage: 'var(--jp-icon-caret-right)'
7171
});

src/style/PastCommitNode.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,14 @@ export const iconButtonClass = style({
7777
});
7878

7979
export const expandIconButtonClass = style({
80-
backgroundImage: 'var(--jp-icon-caretdown)',
80+
backgroundImage: 'var(--jp-icon-caret-down)',
8181
backgroundSize: '20px',
8282
backgroundRepeat: 'no-repeat',
8383
backgroundPosition: 'center'
8484
});
8585

8686
export const collapseIconButtonClass = style({
87-
backgroundImage: 'var(--jp-icon-caretup)',
87+
backgroundImage: 'var(--jp-icon-caret-up)',
8888
backgroundSize: '20px',
8989
backgroundRepeat: 'no-repeat',
9090
backgroundPosition: 'center'

src/style/Toolbar.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,14 @@ export const branchIconClass = style({
153153
});
154154

155155
export const openMenuIconClass = style({
156-
backgroundImage: 'var(--jp-icon-caretdown)',
156+
backgroundImage: 'var(--jp-icon-caret-down)',
157157
backgroundSize: '20px',
158158
backgroundRepeat: 'no-repeat',
159159
backgroundPosition: 'center'
160160
});
161161

162162
export const closeMenuIconClass = style({
163-
backgroundImage: 'var(--jp-icon-caretup)',
163+
backgroundImage: 'var(--jp-icon-caret-up)',
164164
backgroundSize: '20px',
165165
backgroundRepeat: 'no-repeat',
166166
backgroundPosition: 'center'

src/style/icons.ts

+31-37
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { IIconRegistry } from '@jupyterlab/ui-components';
1+
import { LabIcon } from '@jupyterlab/ui-components';
22

33
// icon svg import statements
44
import gitSvg from '../../style/images/git-icon.svg';
@@ -10,39 +10,33 @@ import addSvg from '../../style/images/move-file-up.svg';
1010
import removeSvg from '../../style/images/move-file-down.svg';
1111
import rewindSvg from '../../style/images/rewind.svg';
1212

13-
export function registerGitIcons(iconRegistry: IIconRegistry) {
14-
iconRegistry.addIcon(
15-
{
16-
name: 'git',
17-
svg: gitSvg
18-
},
19-
{
20-
name: 'git-add',
21-
svg: addSvg
22-
},
23-
{
24-
name: 'git-deletionsMade',
25-
svg: deletionsMadeSvg
26-
},
27-
{
28-
name: 'git-diff',
29-
svg: diffSvg
30-
},
31-
{
32-
name: 'git-discard',
33-
svg: discardSvg
34-
},
35-
{
36-
name: 'git-insertionsMade',
37-
svg: insertionsMadeSvg
38-
},
39-
{
40-
name: 'git-remove',
41-
svg: removeSvg
42-
},
43-
{
44-
name: 'git-rewind',
45-
svg: rewindSvg
46-
}
47-
);
48-
}
13+
export const gitIcon = new LabIcon({ name: 'git', svgstr: gitSvg });
14+
export const deletionsMadeIcon = new LabIcon({
15+
name: 'git-deletionsMade',
16+
svgstr: deletionsMadeSvg
17+
});
18+
export const insertionsMadeIcon = new LabIcon({
19+
name: 'git-insertionsMade',
20+
svgstr: insertionsMadeSvg
21+
});
22+
export const addIcon = new LabIcon({
23+
name: 'git-add',
24+
svgstr: addSvg
25+
});
26+
27+
export const diffIcon = new LabIcon({
28+
name: 'git-diff',
29+
svgstr: diffSvg
30+
});
31+
export const discardIcon = new LabIcon({
32+
name: 'git-discard',
33+
svgstr: discardSvg
34+
});
35+
export const removeIcon = new LabIcon({
36+
name: 'git-remove',
37+
svgstr: removeSvg
38+
});
39+
export const rewindIcon = new LabIcon({
40+
name: 'git-rewind',
41+
svgstr: rewindSvg
42+
});

src/tokens.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { IChangedArgs } from '@jupyterlab/coreutils';
2-
import { Token, JSONObject } from '@phosphor/coreutils';
3-
import { IDisposable } from '@phosphor/disposable';
4-
import { ISignal } from '@phosphor/signaling';
2+
import { Token, JSONObject } from '@lumino/coreutils';
3+
import { IDisposable } from '@lumino/disposable';
4+
import { ISignal } from '@lumino/signaling';
55

66
export const EXTENSION_ID = 'jupyter.extensions.git_plugin';
77

0 commit comments

Comments
 (0)