import { Widget } from "@lumino/widgets"; import { IStatusBar } from "@jupyterlab/statusbar"; import getLatestVersion from "./getLatestVersion"; import { showDialog } from "@jupyterlab/apputils"; import { parse as parseSemver } from "semver"; import { version } from "../../package.json"; const updateWidget = new Widget(); updateWidget.node.style.cursor = "pointer"; updateWidget.node.onclick = showUpdateDialog; const updateDialog = new Widget(); updateDialog.node.innerHTML = `
To update to the latest Tabnine version, run:
pip install --upgrade jupyterlab_tabnine
in your terminal, and restart JupyterLab
`; function showUpdateDialog() { showDialog({ title: "Tabnine Update", body: updateDialog, }); } export default function registerUpdateWidget(statusBar: IStatusBar) { getLatestVersion().then((latestVersion) => { const currentVersion = parseSemver(version); if (latestVersion.compare(currentVersion) > 0) { updateWidget.node.innerHTML = `
Tabnine v${latestVersion} is available!
`; statusBar.registerStatusItem("tabnine-update", { align: "left", item: updateWidget, }); } }); }