@jupyterlab/running
Advanced tools
Comparing version 4.0.0-alpha.18 to 4.0.0-alpha.19
@@ -71,3 +71,3 @@ /** | ||
*/ | ||
protected addSection(managers: IRunningSessionManagers, manager: IRunningSessions.IManager): void; | ||
protected addSection(_: unknown, manager: IRunningSessions.IManager): void; | ||
protected managers: IRunningSessionManagers; | ||
@@ -84,10 +84,37 @@ protected translator: ITranslator; | ||
interface IManager { | ||
/** | ||
* Name that is shown to the user in plural. | ||
*/ | ||
name: string; | ||
/** | ||
* Called when the shutdown all button is pressed. | ||
*/ | ||
shutdownAll(): void; | ||
/** | ||
* List the running models. | ||
*/ | ||
running(): IRunningItem[]; | ||
/** | ||
* Force a refresh of the running models. | ||
*/ | ||
refreshRunning(): void; | ||
/** | ||
* A signal that should be emitted when the item list has changed. | ||
*/ | ||
runningChanged: ISignal<any, any>; | ||
/** | ||
* A string used to describe the shutdown action. | ||
*/ | ||
shutdownLabel?: string; | ||
/** | ||
* A string used to describe the shutdown all action. | ||
*/ | ||
shutdownAllLabel?: string; | ||
/** | ||
* A string used as the body text in the shutdown all confirmation dialog. | ||
*/ | ||
shutdownAllConfirmationText?: string; | ||
/** | ||
* The icon to show for shutting down an individual item in this section. | ||
*/ | ||
shutdownItemIcon?: LabIcon; | ||
@@ -99,9 +126,42 @@ } | ||
interface IRunningItem { | ||
open: () => void; | ||
shutdown: () => void; | ||
icon: () => LabIcon; | ||
/** | ||
* Optional child nodes that belong to a top-level running item. | ||
*/ | ||
children?: IRunningItem[]; | ||
/** | ||
* Optional CSS class name to add to the running item. | ||
*/ | ||
className?: string; | ||
/** | ||
* Optional context hint to add to the `data-context` attribute of an item. | ||
*/ | ||
context?: string; | ||
/** | ||
* Called when the running item is clicked. | ||
*/ | ||
open?: () => void; | ||
/** | ||
* Called when the shutdown button is pressed on a particular item. | ||
*/ | ||
shutdown?: () => void; | ||
/** | ||
* The `LabIcon` to use as the icon for the running item or the string | ||
* `src` URL. | ||
*/ | ||
icon: () => LabIcon | string; | ||
/** | ||
* Called to determine the label for each item. | ||
*/ | ||
label: () => string; | ||
/** | ||
* Called to determine the `title` attribute for each item, which is | ||
* revealed on hover. | ||
*/ | ||
labelTitle?: () => string; | ||
/** | ||
* Called to determine the `detail` attribute, which is shown optionally in | ||
* a column after the label. | ||
*/ | ||
detail?: () => string; | ||
} | ||
} |
@@ -9,3 +9,3 @@ // Copyright (c) Jupyter Development Team. | ||
import { nullTranslator } from '@jupyterlab/translation'; | ||
import { closeIcon, PanelWithToolbar, ReactWidget, refreshIcon, SidePanel, ToolbarButton, ToolbarButtonComponent, UseSignal } from '@jupyterlab/ui-components'; | ||
import { caretDownIcon, caretRightIcon, closeIcon, PanelWithToolbar, ReactWidget, refreshIcon, SidePanel, ToolbarButton, ToolbarButtonComponent, UseSignal } from '@jupyterlab/ui-components'; | ||
import { Token } from '@lumino/coreutils'; | ||
@@ -90,18 +90,44 @@ import { DisposableDelegate } from '@lumino/disposable'; | ||
function Item(props) { | ||
var _a; | ||
var _a, _b; | ||
const { runningItem } = props; | ||
const classList = [ITEM_CLASS]; | ||
const detail = (_a = runningItem.detail) === null || _a === void 0 ? void 0 : _a.call(runningItem); | ||
const icon = runningItem.icon(); | ||
const detail = (_a = runningItem.detail) === null || _a === void 0 ? void 0 : _a.call(runningItem); | ||
const title = runningItem.labelTitle ? runningItem.labelTitle() : ''; | ||
const translator = props.translator || nullTranslator; | ||
const trans = translator.load('jupyterlab'); | ||
// Handle shutdown requests. | ||
let stopPropagation = false; | ||
const shutdownItemIcon = props.shutdownItemIcon || closeIcon; | ||
const shutdownLabel = props.shutdownLabel || trans.__('Shut Down'); | ||
const shutdownItemIcon = props.shutdownItemIcon || closeIcon; | ||
return (React.createElement("li", { className: ITEM_CLASS }, | ||
React.createElement(icon.react, { tag: "span", stylesheet: "runningItem" }), | ||
React.createElement("span", { className: ITEM_LABEL_CLASS, title: runningItem.labelTitle ? runningItem.labelTitle() : '', onClick: () => runningItem.open() }, runningItem.label()), | ||
detail && React.createElement("span", { className: ITEM_DETAIL_CLASS }, detail), | ||
React.createElement(ToolbarButtonComponent, { className: SHUTDOWN_BUTTON_CLASS, icon: shutdownItemIcon, onClick: () => runningItem.shutdown(), tooltip: shutdownLabel }))); | ||
const shutdown = () => { | ||
var _a; | ||
stopPropagation = true; | ||
(_a = runningItem.shutdown) === null || _a === void 0 ? void 0 : _a.call(runningItem); | ||
}; | ||
// Manage collapsed state. Use the shutdown flag in lieu of `stopPropagation`. | ||
const [collapsed, collapse] = React.useState(false); | ||
const collapsible = !!((_b = runningItem.children) === null || _b === void 0 ? void 0 : _b.length); | ||
const onClick = collapsible | ||
? () => !stopPropagation && collapse(!collapsed) | ||
: undefined; | ||
if (runningItem.className) { | ||
classList.push(runningItem.className); | ||
} | ||
if (props.child) { | ||
classList.push('jp-mod-running-child'); | ||
} | ||
return (React.createElement(React.Fragment, null, | ||
React.createElement("li", null, | ||
React.createElement("div", { className: classList.join(' '), onClick: onClick, "data-context": runningItem.context || '' }, | ||
collapsible && | ||
(collapsed ? (React.createElement(caretRightIcon.react, { tag: "span", stylesheet: "runningItem" })) : (React.createElement(caretDownIcon.react, { tag: "span", stylesheet: "runningItem" }))), | ||
typeof icon === 'string' ? (icon ? (React.createElement("img", { src: icon })) : undefined) : (React.createElement(icon.react, { tag: "span", stylesheet: "runningItem" })), | ||
React.createElement("span", { className: ITEM_LABEL_CLASS, title: title, onClick: runningItem.open && (() => runningItem.open()) }, runningItem.label()), | ||
detail && React.createElement("span", { className: ITEM_DETAIL_CLASS }, detail), | ||
runningItem.shutdown && (React.createElement(ToolbarButtonComponent, { className: SHUTDOWN_BUTTON_CLASS, icon: shutdownItemIcon, onClick: shutdown, tooltip: shutdownLabel }))), | ||
collapsible && !collapsed && (React.createElement(List, { child: true, runningItems: runningItem.children, shutdownItemIcon: shutdownItemIcon, translator: translator }))))); | ||
} | ||
function List(props) { | ||
return (React.createElement("ul", { className: LIST_CLASS }, props.runningItems.map((item, i) => (React.createElement(Item, { key: i, runningItem: item, shutdownLabel: props.shutdownLabel, shutdownItemIcon: props.shutdownItemIcon, translator: props.translator }))))); | ||
return (React.createElement("ul", { className: LIST_CLASS }, props.runningItems.map((item, i) => (React.createElement(Item, { child: props.child, key: i, runningItem: item, shutdownLabel: props.shutdownLabel, shutdownItemIcon: props.shutdownItemIcon, translator: props.translator }))))); | ||
} | ||
@@ -223,3 +249,3 @@ /** | ||
*/ | ||
addSection(managers, manager) { | ||
addSection(_, manager) { | ||
this.addWidget(new Section({ manager, translator: this.translator })); | ||
@@ -226,0 +252,0 @@ } |
{ | ||
"name": "@jupyterlab/running", | ||
"version": "4.0.0-alpha.18", | ||
"version": "4.0.0-alpha.19", | ||
"description": "JupyterLab - Running Sessions Panel", | ||
@@ -39,8 +39,8 @@ "homepage": "https://github.com/jupyterlab/jupyterlab", | ||
"dependencies": { | ||
"@jupyterlab/apputils": "^4.0.0-alpha.18", | ||
"@jupyterlab/translation": "^4.0.0-alpha.18", | ||
"@jupyterlab/ui-components": "^4.0.0-alpha.33", | ||
"@lumino/coreutils": "^2.0.0-alpha.6", | ||
"@lumino/disposable": "^2.0.0-alpha.6", | ||
"@lumino/signaling": "^2.0.0-alpha.6", | ||
"@jupyterlab/apputils": "^4.0.0-alpha.19", | ||
"@jupyterlab/translation": "^4.0.0-alpha.19", | ||
"@jupyterlab/ui-components": "^4.0.0-alpha.34", | ||
"@lumino/coreutils": "^2.0.0-beta.0", | ||
"@lumino/disposable": "^2.0.0-beta.1", | ||
"@lumino/signaling": "^2.0.0-beta.1", | ||
"react": "^18.2.0" | ||
@@ -47,0 +47,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28641
548