As of JupyterLab v3.6.0, notification is a built-in feature. We highly recommend using it - see documentation. Therefore this project is archived.
Integrate react-toastify
nicely in JupyterLab.
This package is not a JupyterLab extension but a regular npm package. So to add it to your project:
jlpm add jupyterlab_toastify
import { INotification } from 'jupyterlab_toastify';
// Error message notification - do not close automatically
INotification.error('Error');
// Warning message notification - do not close automatically
INotification.warning('Warning');
// Info message notification
INotification.info('Info');
// Success message notification
INotification.success('Success');
// Background task with progression animation
let id = await INotification.inProgress('Task in progress!');
// -> Update text
INotification.update({
toastId: id,
message: 'Updating task...'
});
// -> Update text, status and set closing delay (in ms)
INotification.update({
toastId: id,
message: 'Task succeed',
type: 'success',
autoClose: 3000
});
// Notification with two buttons
INotification.error('Error with button', {
buttons: [
{
label: 'Action1',
callback: () => alert('Action1 was clicked')
},
{
label: 'Action2',
callback: () => alert('Action2 was clicked')
}
]
});
// Close a toast specified by its id
INotification.dismiss(id);
// Close all toasts
INotification.dismiss();
// Default call using `toast` function
// See https://github.com/fkhadra/react-toastify
INotification.notify('Default');
To close a notification, click on the close button.
This is a pure NPM package since v4. You don't need to install a JupyterLab extension.
The toast container will be added to the DOM automatically by react-toastify
.
All functions are asynchronous as
react-toastify
is lazy loaded if required.
react-toastify
v7@jupyterlab/ui-components
react-toastify
v5 introduces the ability to add the toast container automatically.
This extension uses that ability to remove the need of having a dedicated JupyterLab extension
to be installed by users.react-toastify
=> all functions are asynchronousreact-toastify
v6Port to JupyterLab v2
INotification.warning
does not accept options.buttons
optional in update
dismiss
is visible through the INotification
proxyreact-toastify\TypeOptions
update
requires object as input and not a lot of argumentsbuttons
to add buttons with custom callback to the notificationreact-toastify
For a development install (requires npm version 4 or later), do the following in the repository directory:
npm install
npm run build
jupyter labextension install .
To rebuild the package and the JupyterLab app:
npm run build
jupyter lab build