Skip to content
This repository was archived by the owner on Feb 3, 2023. It is now read-only.

Commit 2bc1f25

Browse files
authored
Update for JupyterLab 3 (#13)
* Update for JupyterLab 3 * Install jupyterlab preversion * Try fixing extension path * Refactor as yarn workspaces * Correct CI script
1 parent 3937310 commit 2bc1f25

File tree

30 files changed

+4340
-187
lines changed

30 files changed

+4340
-187
lines changed

.github/workflows/main.yml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,25 @@ jobs:
1010

1111
steps:
1212
- name: Checkout
13-
uses: actions/checkout@v1
13+
uses: actions/checkout@v2
1414
- name: Install node
1515
uses: actions/setup-node@v1
1616
with:
17-
node-version: "12.x"
17+
node-version: "14.x"
1818
- name: Install Python
19-
uses: actions/setup-python@v1
19+
uses: actions/setup-python@v2
2020
with:
21-
python-version: "3.7"
21+
python-version: "3.x"
2222
architecture: "x64"
2323
- name: Install dependencies
24-
run: python -m pip install jupyterlab
24+
run: python -m pip install --pre jupyterlab
2525
- name: Build the extension
2626
run: |
27-
jlpm
28-
cd test-jlab-toastify
2927
jlpm install
30-
jlpm remove jupyterlab_toastify
31-
jlpm add file:${PWD}/..
32-
jupyter labextension install .
28+
cd packages/jupyterlab_toastify
29+
jlpm run build
30+
cd ..
31+
jupyter labextension link jupyterlab_toastify test-jlab-toastify
32+
33+
jupyter labextension list 2>&1 | grep -ie "test-jlab-toastify.*OK"
3334
python -m jupyterlab.browser_check

.github/workflows/publish.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@ jobs:
2121
- name: Install dependencies
2222
run: |
2323
python -m pip install --upgrade pip
24-
pip install jupyterlab~=2.0
24+
pip install jupyterlab
2525
- name: Build and publish NPM package
2626
run: |
27-
npm install
27+
yarn install
28+
cd packages/jupyterlab_toastify
2829
npm publish
2930
env:
3031
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ node_modules/
66
*.log
77
tsconfig.tsbuildinfo
88
test-jlab-toastify/yarn.lock
9+
test-jlab-toastify/jupyterlab_toastify-dev.tgz

LICENSE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
packages/jupyterlab_toastify/LICENSE.txt

binder/environment.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
channels:
2+
- conda-forge
3+
- conda-forge/label/jupyterlab_rc
4+
- conda-forge/label/jupyterlab_server_rc
5+
dependencies:
6+
- python >=3.6,<3.9
7+
- jupyterlab =3
8+
- nodejs >=11

binder/postBuild

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Binder postBuild instructions
4+
set -eux
5+
jlpm install
6+
cd packages/jupyterlab_toastify
7+
yarn run build
8+
cd ../..
9+
10+
jupyter labextension link packages/jupyterlab_toastify packages/test-jlab-toastify --no-build
11+
jupyter lab build --minimize=False

package.json

Lines changed: 6 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,7 @@
11
{
2-
"name": "jupyterlab_toastify",
3-
"version": "4.1.2",
4-
"description": "Integrate 'react-toastify' nicely in JupyterLab.",
5-
"keywords": [
6-
"jupyter",
7-
"jupyterlab",
8-
"jupyterlab-extension"
9-
],
10-
"homepage": "https://github.com/fcollonval/jupyterlab_toastify",
11-
"bugs": {
12-
"url": "https://github.com/fcollonval/jupyterlab_toastify/issues"
13-
},
14-
"license": "BSD-3-Clause",
15-
"author": "Frederic Collonval",
16-
"files": [
17-
"lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}",
18-
"style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}"
19-
],
20-
"main": "lib/index.js",
21-
"types": "lib/index.d.ts",
22-
"style": "style/index.css",
23-
"repository": {
24-
"type": "git",
25-
"url": "https://github.com/fcollonval/jupyterlab_toastify.git"
26-
},
27-
"scripts": {
28-
"build": "tsc",
29-
"clean": "rimraf lib tsconfig.tsbuildinfo",
30-
"watch": "tsc -w",
31-
"precommit": "pretty-quick --staged",
32-
"prepare": "jlpm run clean && jlpm run build"
33-
},
34-
"dependencies": {
35-
"@fortawesome/fontawesome-svg-core": "^1.2.30",
36-
"@fortawesome/free-solid-svg-icons": "^5.14.0",
37-
"@fortawesome/react-fontawesome": "^0.1.11",
38-
"react-toastify": "^6.0.5"
39-
},
40-
"peerDependencies": {
41-
"react": "^16.0.0",
42-
"react-dom": "^16.6.0"
43-
},
44-
"devDependencies": {
45-
"@types/react": "^16.9.0",
46-
"husky": "^0.14.3",
47-
"prettier": "1.14.2",
48-
"pretty-quick": "^1.6.0",
49-
"react": "~16.9.0",
50-
"react-dom": "~16.9.0",
51-
"rimraf": "~2.6.1",
52-
"typescript": "~3.7.0"
53-
},
54-
"publishConfig": {
55-
"access": "public"
56-
}
57-
}
2+
"private": true,
3+
"workspaces": [
4+
"packages/jupyterlab_toastify",
5+
"packages/test-jlab-toastify"
6+
]
7+
}
File renamed without changes.
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
# jupyterlab_toastify
2+
3+
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/fcollonval/jupyterlab_toastify/master?urlpath=lab)
4+
[![GitHub CI](https://github.com/fcollonval/jupyterlab_toastify/workflows/CI/badge.svg)](https://github.com/fcollonval/jupyterlab_toastify/actions?query=workflow%3ACI)
5+
[![npm](https://img.shields.io/npm/v/jupyterlab_toastify.svg?style=flat-square)](https://www.npmjs.com/package/jupyterlab_toastify)
6+
7+
Integrate [`react-toastify`](https://github.com/fkhadra/react-toastify) nicely in JupyterLab.
8+
9+
![example](jupyterlab_notifications.gif)
10+
11+
## Usage
12+
13+
```javascript
14+
import { INotification } from "jupyterlab_toastify";
15+
16+
// Error message notification - do not close automatically
17+
INotification.error("Error");
18+
// Warning message notification - do not close automatically
19+
INotification.warning("Warning");
20+
// Info message notification
21+
INotification.info("Info");
22+
// Success message notification
23+
INotification.success("Success");
24+
25+
// Background task with progression animation
26+
let id = await INotification.inProgress("Task in progress!");
27+
// -> Update text
28+
INotification.update({
29+
toastId: id,
30+
message: "Updating task..."
31+
});
32+
// -> Update text, status and set closing delay (in ms)
33+
INotification.update({
34+
toastId: id,
35+
message: "Task succeed",
36+
type: "success",
37+
autoClose: 3000
38+
});
39+
40+
// Notification with two buttons
41+
INotification.error("Error with button", {
42+
buttons: [
43+
{
44+
label: "Action1",
45+
callback: () => alert("Action1 was clicked")
46+
},
47+
{
48+
label: "Action2",
49+
callback: () => alert("Action2 was clicked")
50+
}
51+
]
52+
});
53+
54+
// Close a toast specified by its id
55+
INotification.dismiss(id);
56+
57+
// Close all toasts
58+
INotification.dismiss();
59+
60+
// Default call using `toast` function
61+
// See https://github.com/fkhadra/react-toastify
62+
INotification.notify("Default");
63+
```
64+
65+
To close a notification, click on the close button.
66+
67+
## Prerequisites
68+
69+
- [react](https://reactjs.org/) ^16.0 || ^17.0
70+
- [react-toastify](https://github.com/fkhadra/react-toastify) ^6.0
71+
72+
## Installation
73+
74+
This is a pure NPM package since v4. You don't need to install a JupyterLab extension.
75+
76+
The toast container will be added to the DOM automatically by `react-toastify`.
77+
78+
> All functions are asynchronous as `react-toastify` is lazy loaded if required.
79+
80+
## Changelog
81+
82+
### v4.1.1
83+
84+
- Bug fixes:
85+
- Remove dependency on `@jupyterlab/ui-components`
86+
87+
### v4.1.0
88+
89+
- Features
90+
- Use SVG icons
91+
92+
### v4.0.0
93+
94+
- Features
95+
- `react-toastify` v5 introduces the ability to add the toast container automatically.
96+
This extension uses that ability to remove the need of having a dedicated JupyterLab extension
97+
to be installed by users.
98+
- Lazy load `react-toastify` => all functions are asynchronous
99+
- Bump to `react-toastify` v6
100+
101+
### v3.0.0
102+
103+
Port to JupyterLab v2
104+
105+
### v2.3.1
106+
107+
- BUG `INotification.warning` does not accept options.
108+
- Respect latest extension cookiecutter parameters
109+
110+
### v2.3.0
111+
112+
- Port to JupyterLab v1
113+
114+
### v2.2.0
115+
116+
- Different corrections
117+
- `buttons` optional in `update`
118+
- `dismiss` is visible through the `INotification` proxy
119+
120+
### v2.1.0
121+
122+
- Update to JupyterLab 0.35
123+
- Update to react-toastify 4.4 => change enum for notifications type to `react-toastify\TypeOptions`
124+
125+
### v2.0.0
126+
127+
- API change: helper functions accept options in addition to the message
128+
- API change: `update` requires object as input and not a lot of arguments
129+
- New option `buttons` to add buttons with custom callback to the notification
130+
131+
### v1.x
132+
133+
- First version using `react-toastify`
134+
- Five scenarii:
135+
- Error
136+
- Warning
137+
- Info
138+
- Success
139+
- InProgress
140+
141+
## Development
142+
143+
For a development install (requires npm version 4 or later), do the following in the repository directory:
144+
145+
```bash
146+
npm install
147+
npm run build
148+
jupyter labextension install .
149+
```
150+
151+
To rebuild the package and the JupyterLab app:
152+
153+
```bash
154+
npm run build
155+
jupyter lab build
156+
```
Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"name": "test-jlab-toastify",
3-
"version": "0.1.0",
4-
"description": "A dummy JupyterLab extension to test `jupyterlab-toastify`.",
2+
"name": "jupyterlab_toastify",
3+
"version": "4.1.3",
4+
"description": "Integrate 'react-toastify' nicely in JupyterLab.",
55
"keywords": [
66
"jupyter",
77
"jupyterlab",
@@ -27,31 +27,31 @@
2727
"scripts": {
2828
"build": "tsc",
2929
"clean": "rimraf lib tsconfig.tsbuildinfo",
30-
"prepare": "jlpm run clean && jlpm run build",
31-
"watch": "tsc -w"
30+
"watch": "tsc -w",
31+
"precommit": "pretty-quick --staged",
32+
"prepare": "jlpm run clean && jlpm run build"
3233
},
3334
"dependencies": {
34-
"@jupyterlab/application": "^2.0.0",
35-
"jupyterlab_toastify": "file:./.."
36-
},
37-
"devDependencies": {
38-
"@types/react": "~16.9.0",
39-
"react": "~16.9.0",
40-
"rimraf": "^2.6.1",
41-
"typescript": "~3.7.0"
35+
"@fortawesome/fontawesome-svg-core": "^1.2.30",
36+
"@fortawesome/free-solid-svg-icons": "^5.14.0",
37+
"@fortawesome/react-fontawesome": "^0.1.11",
38+
"react-toastify": "^6.0.5"
4239
},
4340
"peerDependencies": {
44-
"react": "^16.0.0",
45-
"react-dom": "^16.6.0"
41+
"react": "^16.0.0 || ^17.0.0",
42+
"react-dom": "^16.6.0 || ^17.0.0"
4643
},
47-
"sideEffects": [
48-
"style/*.css"
49-
],
50-
"jupyterlab": {
51-
"extension": true
44+
"devDependencies": {
45+
"@types/react": "^16.9.0",
46+
"husky": "^0.14.3",
47+
"prettier": "^1.19.0",
48+
"pretty-quick": "^1.6.0",
49+
"react": "^16.13.1 || ^17.0.0",
50+
"react-dom": "^16.13.0 || ^17.0.0",
51+
"rimraf": "^3.0.2",
52+
"typescript": "~4.0.3"
5253
},
53-
"private": true,
54-
"resolutions": {
55-
"@types/react": "~16.9.0"
54+
"publishConfig": {
55+
"access": "public"
5656
}
5757
}

0 commit comments

Comments
 (0)