Skip to content

[WIP] Update for JupyterLab 2.0 #520

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
2854f5f
changes for jlab 2.0 beta
Jan 9, 2020
caa4f7c
remove skiplibcheck
Jan 9, 2020
d192a67
cleaned up/added some vscode stuff to .gitignore
telamonian Feb 5, 2020
5d2976a
bumped deps to jlab 2.0.0 final
telamonian Feb 28, 2020
b314457
trying out using resolutions to fix nbdime dep
telamonian Mar 3, 2020
be68b92
updated LabIcon/lumino stuff to latest; now builds
telamonian Mar 3, 2020
ec933eb
added auto-enable to pip dev install
telamonian Mar 4, 2020
d2d6d31
post-rebase integrity
telamonian Mar 4, 2020
bf3840f
updated to jlab 2.0 in infrastructure
telamonian Mar 4, 2020
b00da65
began cleanup of icon stuff
telamonian Mar 4, 2020
e414308
export all LabIcon at top level of package
telamonian Mar 4, 2020
9bf681e
fixed some icon paths/names
telamonian Mar 4, 2020
40c8043
moved style/images => style/icons
telamonian Mar 4, 2020
66170cd
unified filetype handling with jlab core, use LabIcon for ft icons
telamonian Mar 4, 2020
c323a95
fixed appearance of selected LabIcons, made filetype lookup more robust
telamonian Mar 4, 2020
bfcd2fe
bugfix for filetype lookup of changed files in history view
telamonian Mar 4, 2020
b193a3b
fixed up class of svg paths for deletionsIcon/insertionsIcon
telamonian Mar 4, 2020
6cdd329
burning down icons in variables.css; removed unused arrow/checkmark i…
telamonian Mar 4, 2020
d3b7fdd
added styling classes to svg of diffIcon
telamonian Mar 4, 2020
0731c77
fixed name of diffIcon svg
telamonian Mar 4, 2020
5501a28
migrated diffIcon from css-background to LabIcon
telamonian Mar 4, 2020
6ec2e34
Update nbdime version that supports lab 2.x
lresende Mar 22, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 20 additions & 12 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,30 +1,39 @@
# os junk
.DS_Store

# yarn/typescript build junk
package-lock.json
*.tsbuildinfo

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
.pytest_cache/

# C extensions
*.so

# Distribution / packaging
*.egg
*.egg-info/
.eggs/
.installed.cfg
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
jupyterlab_git/labextension/*.tgz
lib/
lib64/
MANIFEST
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
Expand Down Expand Up @@ -102,12 +111,11 @@ ENV/
.mypy_cache/
node_modules/

#editors
.vscode/
# jetbrains ide stuff
*.iml
.idea/

package-lock.json
MANIFEST
jupyterlab_git/labextension/*.tgz
.pytest_cache/
*.tsbuildinfo
.pytest_cache/
# vscode ide stuff
*.code-workspace
.history
.vscode
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ cache:
- /home/travis/.yarn-cache/
before_install:
- nvm install 10
install: pip install pytest pytest-asyncio "jupyterlab~=1.1"
install: pip install pytest pytest-asyncio "jupyterlab~=2.0"
script:
# Build the sdist (identical to what will be uploaded to eg pypi on release)
- python setup.py sdist
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jupyter labextension list

- Be sure to be in a Git repository in the filebrowser tab

- Check the server log. If you see a warning with a 404 code similar to:
- Check the server log. If you see a warning with a 404 code similar to:
`[W 00:27:41.800 LabApp] 404 GET /git/server_root?1576081660665`

Explicitly enable the server extension by running:
Expand Down Expand Up @@ -106,7 +106,6 @@ cd jupyterlab-git

# Install the server extension in development mode and enable it
pip install -e .[test]
jupyter serverextension enable --py jupyterlab_git

# Build the labextension and dev-mode link it to jlab
jlpm build
Expand Down
66 changes: 34 additions & 32 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
"build": "jlpm install && tsc",
"build:labextension": "jlpm build && jlpm clean:labextension && mkdirp jupyterlab_git/labextension && cd jupyterlab_git/labextension && npm pack ../..",
"clean": "rimraf lib tsconfig.tsbuildinfo",
"clean:more": "jlpm clean && rimraf build dist MANIFEST",
"clean:labextension": "rimraf jupyterlab_git/labextension",
"clean:more": "jlpm clean && rimraf build dist MANIFEST",
"clean:slate": "jlpm clean:more && jlpm clean:labextension && rimraf node_modules",
"watch": "tsc -w",
"test": "jest",
"deduplicate": "jlpm yarn-deduplicate -s fewer",
"lint": "tslint --project .",
"tslint-check": "tslint-config-prettier-check ./tslint.json"
"test": "jest",
"tslint-check": "tslint-config-prettier-check ./tslint.json",
"watch": "tsc -w"
},
"files": [
"lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}",
Expand All @@ -48,36 +49,40 @@
"schemaDir": "schema"
},
"dependencies": {
"@jupyterlab/application": "^1.1.0",
"@jupyterlab/apputils": "^1.1.0",
"@jupyterlab/codemirror": "^1.1.0",
"@jupyterlab/console": "^1.1.0",
"@jupyterlab/coreutils": "^3.1.0",
"@jupyterlab/filebrowser": "^1.1.0",
"@jupyterlab/mainmenu": "^1.1.0",
"@jupyterlab/services": "^4.1.0",
"@jupyterlab/terminal": "^1.1.0",
"@jupyterlab/ui-components": "^1.1.0",
"@jupyterlab/application": "^2.0.0",
"@jupyterlab/apputils": "^2.0.0",
"@jupyterlab/codemirror": "^2.0.0",
"@jupyterlab/console": "^2.0.0",
"@jupyterlab/coreutils": "^4.0.0",
"@jupyterlab/docregistry": "^2.0.0",
"@jupyterlab/filebrowser": "^2.0.0",
"@jupyterlab/mainmenu": "^2.0.0",
"@jupyterlab/nbformat": "^2.0.0",
"@jupyterlab/services": "^5.0.0",
"@jupyterlab/settingregistry": "^2.0.0",
"@jupyterlab/terminal": "^2.0.0",
"@jupyterlab/ui-components": "^2.0.0",
"@lumino/polling": "^1.0.4",
"@lumino/widgets": "^1.11.1",
"@material-ui/core": "^4.8.2",
"@material-ui/icons": "^4.5.1",
"@phosphor/widgets": "^1.8.0",
"diff-match-patch": "^1.0.4",
"nbdime": "~5.0.1",
"react": "~16.8.4",
"react-dom": "~16.8.4",
"nbdime": "~6.0.0",
"react": "~16.9.0",
"react-dom": "~16.9.0",
"react-textarea-autosize": "^7.1.2",
"typestyle": "^2.0.1"
"typestyle": "^2.0.4"
},
"devDependencies": {
"@babel/core": "^7.5.0",
"@babel/preset-env": "^7.5.0",
"@jupyterlab/testutils": "^1.1.0",
"@jupyterlab/testutils": "^2.0.0",
"@types/codemirror": "^0.0.79",
"@types/diff-match-patch": "^1.0.32",
"@types/enzyme": "3.1.15",
"@types/jest": "^24",
"@types/react": "~16.8.13",
"@types/react-dom": "~16.0.5",
"@types/react": "~16.9.16",
"@types/react-dom": "~16.9.4",
"@types/react-textarea-autosize": "^4.3.5",
"enzyme": "3.7.0",
"enzyme-adapter-react-16": "1.7.0",
Expand All @@ -87,15 +92,15 @@
"jest-fetch-mock": "^1.6.6",
"lint-staged": "8.1.5",
"mkdirp": "^0.5.1",
"prettier": "1.16.4",
"prettier": "^1.19.1",
"puppeteer": "^1.10.0",
"rimraf": "^2.6.1",
"ts-jest": "^24",
"tslint": "^5.11.0",
"tslint-config-prettier": "1.18.0",
"tslint-plugin-prettier": "^2.0.0",
"typescript": "~3.5.1",
"typescript-tslint-plugin": "^0.5.4"
"tslint": "^5.20.1",
"tslint-config-prettier": "^1.18.0",
"tslint-plugin-prettier": "^2.1.0",
"typescript": "~3.7.3",
"yarn-deduplicate": "^1.1.1"
},
"peerDependencies": {
"codemirror": "^5.0.0"
Expand Down Expand Up @@ -124,8 +129,5 @@
"bugs": {
"url": "https://github.com/jupyterlab/jupyterlab-git/issues"
},
"homepage": "https://github.com/jupyterlab/jupyterlab-git",
"resolutions": {
"@types/react": "~16.8.4"
}
"homepage": "https://github.com/jupyterlab/jupyterlab-git.git"
}
34 changes: 31 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
)

import setuptools
from setuptools.command.develop import develop

# The name of the project
name='jupyterlab_git'
Expand All @@ -38,9 +39,36 @@ def runPackLabextension():
pass
pack_labext = command_for_func(runPackLabextension)

class DevelopAndEnable(develop):
def run(self):
develop.run(self)

list_cmd = [
'jupyter',
'serverextension',
'list'
]
enable_cmd = [
'jupyter',
'serverextension',
'enable',
'--py',
'jupyterlab_git'
]

# test if `jupyter` cmd is available
try:
run(list_cmd)
except:
print('`jupyter` cmd not installed, skipping serverextension activation...')
return

print('Enabling serverextension...')
run(enable_cmd)

cmdclass = create_cmdclass('pack_labext', data_files_spec=data_files_spec)
cmdclass['pack_labext'] = pack_labext
cmdclass.pop('develop')
cmdclass['develop'] = DevelopAndEnable

with open("README.md", "r") as fh:
long_description = fh.read()
Expand Down Expand Up @@ -71,14 +99,14 @@ def runPackLabextension():
],
install_requires = [
'notebook',
'nbdime >= 1.1.0',
'nbdime >= 2.0.0',
'pexpect'
],
extras_require = {
'test': [
'pytest',
'pytest-asyncio',
'jupyterlab~=1.1',
'jupyterlab~=2.0',
],
},
)
Expand Down
52 changes: 20 additions & 32 deletions src/components/FileItem.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import { Dialog, showDialog } from '@jupyterlab/apputils';
import { IRenderMimeRegistry } from '@jupyterlab/rendermime';
import { LabIcon } from '@jupyterlab/ui-components';
import * as React from 'react';
import { classes } from 'typestyle';

import { isDiffSupported } from './diff/Diff';
import { openDiffView } from './diff/DiffWidget';
import { ISpecialRef } from './diff/model';
import { diffIcon } from '../icons';
import { GitExtension } from '../model';
import {
disabledFileStyle,
Expand All @@ -12,7 +18,6 @@ import {
fileChangedLabelInfoStyle,
fileChangedLabelStyle,
fileGitButtonStyle,
fileIconStyle,
fileLabelStyle,
fileStyle,
selectedFileChangedLabelStyle,
Expand All @@ -22,19 +27,10 @@ import {
import {
changeStageButtonLeftStyle,
changeStageButtonStyle,
diffFileButtonStyle,
discardFileButtonStyle
} from '../style/GitStageStyle';
import { Git } from '../tokens';
import {
extractFilename,
openListedFile,
parseFileExtension,
parseSelectedFileExtension
} from '../utils';
import { isDiffSupported } from './diff/Diff';
import { openDiffView } from './diff/DiffWidget';
import { ISpecialRef } from './diff/model';
import { extractFilename, openListedFile } from '../utils';

export interface IFileItemProps {
file: Git.IStatusFileResult;
Expand Down Expand Up @@ -123,16 +119,6 @@ export class FileItem extends React.Component<IFileItemProps, {}> {
}
}

getFileLabelIconClass() {
if (this.showDiscardWarning()) {
return classes(fileIconStyle, parseFileExtension(this.props.file.to));
} else {
return this.checkSelected()
? classes(fileIconStyle, parseSelectedFileExtension(this.props.file.to))
: classes(fileIconStyle, parseFileExtension(this.props.file.to));
}
}

getFileClass() {
if (!this.checkSelected() && this.props.disableFile) {
return classes(fileStyle, disabledFileStyle);
Expand Down Expand Up @@ -178,12 +164,7 @@ export class FileItem extends React.Component<IFileItemProps, {}> {
}

getDiffFileIconClass() {
return classes(
fileButtonStyle,
changeStageButtonStyle,
fileGitButtonStyle,
diffFileButtonStyle
);
return classes(fileButtonStyle, changeStageButtonStyle, fileGitButtonStyle);
}

getDiscardFileIconClass() {
Expand Down Expand Up @@ -221,9 +202,7 @@ export class FileItem extends React.Component<IFileItemProps, {}> {
this.props.updateSelectedDiscardFile(this.props.fileIndex);
const result = await showDialog({
title: 'Discard changes',
body: `Are you sure you want to permanently discard changes to ${
this.props.file.from
}? This action cannot be undone.`,
body: `Are you sure you want to permanently discard changes to ${this.props.file.from}? This action cannot be undone.`,
buttons: [Dialog.cancelButton(), Dialog.warnButton({ label: 'Discard' })]
});
if (result.button.accept) {
Expand All @@ -234,6 +213,8 @@ export class FileItem extends React.Component<IFileItemProps, {}> {
}

render() {
const ft = this.props.file.ft;

return (
<li
className={this.getFileClass()}
Expand All @@ -248,7 +229,12 @@ export class FileItem extends React.Component<IFileItemProps, {}> {
this.props.moveFile(this.props.file.to);
}}
/>
<span className={this.getFileLabelIconClass()} />
<LabIcon.resolveReact
icon={ft?.icon}
iconClass={classes(ft?.iconClass, 'jp-Icon')}
stylesheet="listing"
tag="span"
/>
<span
className={this.getFileLabelClass()}
onContextMenu={e => {
Expand Down Expand Up @@ -318,7 +304,9 @@ export class FileItem extends React.Component<IFileItemProps, {}> {
this.props.renderMime
);
}}
/>
>
<diffIcon.react elementPosition="center" paddingLeft="0px" />
</button>
);
}
}
Loading