/** * @packageDocumentation * @module running */ import type { IMovableSectionSource, ISectionEntry } from '@jupyterlab/apputils'; import type { IStateDB } from '@jupyterlab/statedb'; import type { ITranslator } from '@jupyterlab/translation'; import type { IScore, LabIcon, Toolbar } from '@jupyterlab/ui-components'; import { CommandToolbarButton, PanelWithToolbar, ReactWidget, SidePanel, ToolbarButton } from '@jupyterlab/ui-components'; import { Token } from '@lumino/coreutils'; import type { IDisposable } from '@lumino/disposable'; import type { Message } from '@lumino/messaging'; import type { ISignal } from '@lumino/signaling'; import type { AccordionPanel } from '@lumino/widgets'; import { Panel, Widget } from '@lumino/widgets'; import type { ReactNode } from 'react'; /** * The running sessions managers token. */ export declare const IRunningSessionManagers: Token; /** * The running sessions token. */ export declare const IRunningSessionSidebar: Token; /** * The running interface. */ export interface IRunningSessionManagers { /** * Add a running item manager. * * @param manager - The running item manager. * */ add(manager: IRunningSessions.IManager): IDisposable; /** * Signal emitted when a new manager is added. */ added: ISignal; /** * Return an array of managers. */ items(): ReadonlyArray; } export declare class RunningSessionManagers implements IRunningSessionManagers { /** * Signal emitted when a new manager is added. */ get added(): ISignal; /** * Add a running item manager. * * @param manager - The running item manager. * */ add(manager: IRunningSessions.IManager): IDisposable; /** * Return an iterator of launcher items. */ items(): ReadonlyArray; private _added; private _managers; } interface IFilterProvider { filter(item: IRunningSessions.IRunningItem): Partial | null; filterChanged: ISignal; } declare class FilterWidget extends ReactWidget implements IFilterProvider { constructor(translator: ITranslator); get filterChanged(): ISignal; render(): JSX.Element; filter(item: IRunningSessions.IRunningItem): Partial | null; private _getTextContent; private _updateFilter; private _filterFn; private _filterChanged; private _trans; } /** * The Section component contains the shared look and feel for an interactive * list of kernels and sessions. * * It is specialized for each based on its props. */ export declare class Section extends PanelWithToolbar { constructor(options: Section.IOptions); /** * Toggle between list and tree view. */ toggleListView(forceOn?: boolean): void; /** * Dispose the resources held by the widget */ dispose(): void; private get _shutdownAllLabel(); private _initializeToolbar; private _onListChanged; private _updateEmptyClass; get viewChanged(): ISignal; private _updateButtons; private _buttons; private _manager; private _listView; private _listWidget; private _filterProvider?; private _collapseToggled; private _viewChanged; private _trans; } /** * Statics for Section. */ declare namespace Section { /** * Initialisation options for section. */ interface IOptions { manager: IRunningSessions.IManager; showToolbar?: boolean; filterProvider?: IFilterProvider; translator?: ITranslator; viewMode?: 'tree' | 'list'; } /** * Information about section view state. */ interface IViewState { /** * View mode */ mode: 'tree' | 'list'; } } /** * The interface exposing the running sessions sidebar widget properties. */ export interface IRunningSessionSidebar extends IMovableSectionSource { /** * The toolbar of the running sidebar. */ readonly toolbar: Toolbar; } /** * A class that exposes the running terminal and kernel sessions. */ export declare class RunningSessions extends SidePanel implements IRunningSessionSidebar { /** * Construct a new running widget. */ constructor(managers: IRunningSessionManagers, translator?: ITranslator, stateDB?: IStateDB | null); get accordionPanel(): AccordionPanel; /** * Dispose the resources held by the widget */ dispose(): void; /** * Remove a section by manager name and return the widget. * * @param managerName - The name of the manager whose section to remove. * @returns The removed section widget, or null if not found. */ removeSectionById(managerName: string): Widget | null; /** * Re-insert a previously removed section back into the sidebar. * * @param widget - The section widget to re-insert. */ reinsertSection(widget: Widget): void; /** * Add a section for a new manager. * * @param managers Managers * @param manager New manager */ protected addSection(managers: unknown, manager: IRunningSessions.IManager): Promise; /** * Update state database with the new state of a given section. */ private _updateState; /** * Get current state from the state database. */ private _getState; /** * Signal emitted when a section is added to this sidebar. */ get sectionAdded(): ISignal; /** * Return the currently-available sections with their accordion title nodes. */ getSections(): ReadonlyArray; protected managers: IRunningSessionManagers; protected translator: ITranslator; private _stateDB; private _sectionMap; private readonly _sectionAdded; } /** * A panel intended for use within `Dialog` to allow searching tabs and running sessions. */ export declare class SearchableSessions extends Panel { constructor(managers: IRunningSessionManagers, translator?: ITranslator); /** * Dispose the resources held by the widget */ dispose(): void; /** * Click active element when the user confirmed the choice in the dialog. */ getValue(): void; /** * Handle incoming events. */ handleEvent(event: Event): void; /** * A message handler invoked on an `'after-attach'` message. */ protected onAfterAttach(_: Message): void; /** * A message handler invoked on an `'after-detach'` message. */ protected onAfterDetach(_: Message): void; /** * Force focus on the filter input. * * Note: forces focus because this widget is intended to be used in `Dialog`, * which does not support focusing React widget nested within a non-React * widget (a limitation of `focusNodeSelector` option implementation). */ private _forceFocusInput; /** * Navigate between items using up/down keys by shifting focus. */ private _evtKeydown; /** * Set and mark active item relative to the current. * * Returns whether an active item was set. */ private _updateActive; private _translator; private _filterWidget; private _activeIndex; private _list; } /** * A panel list of searchable sessions. */ export declare class SearchableSessionsList extends Panel { constructor(managers: IRunningSessionManagers, filterWidget: FilterWidget, translator?: ITranslator); /** * Dispose the resources held by the widget */ dispose(): void; /** * Add a section for a new manager. * * @param managers Managers * @param manager New manager */ protected addSection(managers: unknown, manager: IRunningSessions.IManager): void; private _managers; private _translator; private _emptyIndicator; private _filterWidget; } /** * The namespace for the `IRunningSessions` class statics. */ export declare namespace IRunningSessions { /** * A manager of running items grouped under a single section. */ 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. * * If the manager supports tree view, it should set the flag * {@link supportsMultipleViews}. * It must return nested item if mode is `tree`. * Otherwise it must return a flat list. */ running(options: { mode: 'tree' | 'list'; }): IRunningItem[]; /** * Force a refresh of the running models. */ refreshRunning(): void; /** * A signal that should be emitted when the item list has changed. */ runningChanged: ISignal; /** * A string used to describe the shutdown action. */ shutdownLabel?: string | ((item: IRunningSessions.IRunningItem) => 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 | (() => string); /** * The icon to show for shutting down an individual item in this section. */ shutdownItemIcon?: LabIcon; /** * Used to add arbitrary buttons to this section */ toolbarButtons?: (ToolbarButton | CommandToolbarButton)[]; /** * Whether the manager supports tree view for its items * or only a flat list. */ supportsMultipleViews?: boolean; } /** * A running item. */ interface IRunningItem { /** * 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: () => ReactNode; /** * 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; } } export {};