1 | /**
|
2 | * @packageDocumentation
|
3 | * @module launcher
|
4 | */
|
5 | import { VDomModel, VDomRenderer } from '@jupyterlab/apputils';
|
6 | import { ITranslator } from '@jupyterlab/translation';
|
7 | import { IIterator } from '@lumino/algorithm';
|
8 | import { CommandRegistry } from '@lumino/commands';
|
9 | import { ReadonlyJSONObject, Token } from '@lumino/coreutils';
|
10 | import { IDisposable } from '@lumino/disposable';
|
11 | import { Widget } from '@lumino/widgets';
|
12 | import * as React from 'react';
|
13 | /**
|
14 | * The launcher token.
|
15 | */
|
16 | export declare const ILauncher: Token<ILauncher>;
|
17 | /**
|
18 | * The launcher interface.
|
19 | */
|
20 | export interface ILauncher {
|
21 | /**
|
22 | * Add a command item to the launcher, and trigger re-render event for parent
|
23 | * widget.
|
24 | *
|
25 | * @param options - The specification options for a launcher item.
|
26 | *
|
27 | * @returns A disposable that will remove the item from Launcher, and trigger
|
28 | * re-render event for parent widget.
|
29 | *
|
30 | */
|
31 | add(options: ILauncher.IItemOptions): IDisposable;
|
32 | }
|
33 | /**
|
34 | * LauncherModel keeps track of the path to working directory and has a list of
|
35 | * LauncherItems, which the Launcher will render.
|
36 | */
|
37 | export declare class LauncherModel extends VDomModel implements ILauncher {
|
38 | /**
|
39 | * Add a command item to the launcher, and trigger re-render event for parent
|
40 | * widget.
|
41 | *
|
42 | * @param options - The specification options for a launcher item.
|
43 | *
|
44 | * @returns A disposable that will remove the item from Launcher, and trigger
|
45 | * re-render event for parent widget.
|
46 | *
|
47 | */
|
48 | add(options: ILauncher.IItemOptions): IDisposable;
|
49 | /**
|
50 | * Return an iterator of launcher items.
|
51 | */
|
52 | items(): IIterator<ILauncher.IItemOptions>;
|
53 | protected itemsList: ILauncher.IItemOptions[];
|
54 | }
|
55 | /**
|
56 | * A virtual-DOM-based widget for the Launcher.
|
57 | */
|
58 | export declare class Launcher extends VDomRenderer<LauncherModel> {
|
59 | /**
|
60 | * Construct a new launcher widget.
|
61 | */
|
62 | constructor(options: ILauncher.IOptions);
|
63 | /**
|
64 | * The cwd of the launcher.
|
65 | */
|
66 | get cwd(): string;
|
67 | set cwd(value: string);
|
68 | /**
|
69 | * Whether there is a pending item being launched.
|
70 | */
|
71 | get pending(): boolean;
|
72 | set pending(value: boolean);
|
73 | /**
|
74 | * Render the launcher to virtual DOM nodes.
|
75 | */
|
76 | protected render(): React.ReactElement<any> | null;
|
77 | protected translator: ITranslator;
|
78 | private _trans;
|
79 | private _commands;
|
80 | private _callback;
|
81 | private _pending;
|
82 | private _cwd;
|
83 | }
|
84 | /**
|
85 | * The namespace for `ILauncher` class statics.
|
86 | */
|
87 | export declare namespace ILauncher {
|
88 | /**
|
89 | * The options used to create a Launcher.
|
90 | */
|
91 | interface IOptions {
|
92 | /**
|
93 | * The model of the launcher.
|
94 | */
|
95 | model: LauncherModel;
|
96 | /**
|
97 | * The cwd of the launcher.
|
98 | */
|
99 | cwd: string;
|
100 | /**
|
101 | * The command registry used by the launcher.
|
102 | */
|
103 | commands: CommandRegistry;
|
104 | /**
|
105 | * The application language translation.
|
106 | */
|
107 | translator?: ITranslator;
|
108 | /**
|
109 | * The callback used when an item is launched.
|
110 | */
|
111 | callback: (widget: Widget) => void;
|
112 | }
|
113 | /**
|
114 | * The options used to create a launcher item.
|
115 | */
|
116 | interface IItemOptions {
|
117 | /**
|
118 | * The command ID for the launcher item.
|
119 | *
|
120 | * #### Notes
|
121 | * If the command's `execute` method returns a `Widget` or
|
122 | * a promise that resolves with a `Widget`, then that widget will
|
123 | * replace the launcher in the same location of the application
|
124 | * shell. If the `execute` method does something else
|
125 | * (i.e., create a modal dialog), then the launcher will not be
|
126 | * disposed.
|
127 | */
|
128 | command: string;
|
129 | /**
|
130 | * The arguments given to the command for
|
131 | * creating the launcher item.
|
132 | *
|
133 | * ### Notes
|
134 | * The launcher will also add the current working
|
135 | * directory of the filebrowser in the `cwd` field
|
136 | * of the args, which a command may use to create
|
137 | * the activity with respect to the right directory.
|
138 | */
|
139 | args?: ReadonlyJSONObject;
|
140 | /**
|
141 | * The category for the launcher item.
|
142 | *
|
143 | * The default value is an empty string.
|
144 | */
|
145 | category?: string;
|
146 | /**
|
147 | * The rank for the launcher item.
|
148 | *
|
149 | * The rank is used when ordering launcher items for display. After grouping
|
150 | * into categories, items are sorted in the following order:
|
151 | * 1. Rank (lower is better)
|
152 | * 3. Display Name (locale order)
|
153 | *
|
154 | * The default rank is `Infinity`.
|
155 | */
|
156 | rank?: number;
|
157 | /**
|
158 | * For items that have a kernel associated with them, the URL of the kernel
|
159 | * icon.
|
160 | *
|
161 | * This is not a CSS class, but the URL that points to the icon in the kernel
|
162 | * spec.
|
163 | */
|
164 | kernelIconUrl?: string;
|
165 | /**
|
166 | * Metadata about the item. This can be used by the launcher to
|
167 | * affect how the item is displayed.
|
168 | */
|
169 | metadata?: ReadonlyJSONObject;
|
170 | }
|
171 | }
|