UNPKG

2.77 kBTypeScriptView Raw
1import { ITranslator } from '@jupyterlab/translation';
2import { VDomModel, VDomRenderer } from '@jupyterlab/ui-components';
3import { KeyboardEvent } from 'react';
4import { ISessionContext } from './sessioncontext';
5/**
6 * Helper function to translate kernel statuses mapping by using
7 * input translator.
8 *
9 * @param translator - Language translator.
10 * @return The translated kernel status mapping.
11 */
12export declare function translateKernelStatuses(translator?: ITranslator): Record<ISessionContext.KernelDisplayStatus, string>;
13/**
14 * A VDomRenderer widget for displaying the status of a kernel.
15 */
16export declare class KernelStatus extends VDomRenderer<KernelStatus.Model> {
17 /**
18 * Construct the kernel status widget.
19 */
20 constructor(opts: KernelStatus.IOptions, translator?: ITranslator);
21 /**
22 * Render the kernel status item.
23 */
24 render(): JSX.Element | null;
25 translator: ITranslator;
26 private _handleClick;
27 private _handleKeyDown;
28}
29/**
30 * A namespace for KernelStatus statics.
31 */
32export declare namespace KernelStatus {
33 /**
34 * A VDomModel for the kernel status indicator.
35 */
36 class Model extends VDomModel {
37 constructor(translator?: ITranslator);
38 /**
39 * The name of the kernel.
40 */
41 get kernelName(): string;
42 /**
43 * The current status of the kernel.
44 */
45 get status(): string | undefined;
46 /**
47 * A display name for the activity.
48 */
49 get activityName(): string;
50 set activityName(val: string);
51 /**
52 * The current client session associated with the kernel status indicator.
53 */
54 get sessionContext(): ISessionContext | null;
55 set sessionContext(sessionContext: ISessionContext | null);
56 /**
57 * React to changes to the kernel status.
58 */
59 private _onKernelStatusChanged;
60 /**
61 * React to changes in the kernel.
62 */
63 private _onKernelChanged;
64 private _getAllState;
65 private _triggerChange;
66 protected translation: ITranslator;
67 private _trans;
68 private _activityName;
69 private _kernelName;
70 private _kernelStatus;
71 private _sessionContext;
72 private readonly _statusNames;
73 }
74 /**
75 * Options for creating a KernelStatus object.
76 */
77 interface IOptions {
78 /**
79 * A click handler for the item. By default
80 * we launch a kernel selection dialog.
81 */
82 onClick: () => void;
83 /**
84 * A key press handler for the item. By default
85 * we launch a kernel selection dialog.
86 */
87 onKeyDown: (event: KeyboardEvent<HTMLImageElement>) => void;
88 }
89}