Skip to content

Commit

Permalink
Add support for details in the Commands (#14102)
Browse files Browse the repository at this point in the history
  • Loading branch information
DonJayamanne authored Aug 11, 2023
1 parent e2c071e commit 6c07072
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 8 deletions.
36 changes: 33 additions & 3 deletions src/api.proposed.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ declare module './api' {
/**
* Jupyter auth Token.
*/
readonly token: string;
readonly token?: string;
/**
* Authorization header to be used when connecting to the server.
*/
Expand Down Expand Up @@ -82,6 +82,36 @@ declare module './api' {
*/
getJupyterServers(token: CancellationToken): Promise<JupyterServer[]>;
}
/**
* Represents a reference to a Jupyter Server command. Provides a title which
* will be used to represent a command in the UI and, optionally,
* an array of arguments which will be passed to the command handler
* function when invoked.
*/
export interface JupyterServerCommand {
/**
* Title of the command, like `save`.
*/
title: string;
/**
* A human-readable string which is rendered less prominent in a separate line.
*/
detail?: string;
/**
* The identifier of the actual command handler.
* @see {@link commands.registerCommand}
*/
command: string;
/**
* A tooltip for the command, when represented in the UI.
*/
tooltip?: string;
/**
* Arguments that the command handler should be
* invoked with.
*/
arguments?: unknown[];
}
/**
* Provider of Jupyter Server Commands.
* Each command allows the user to perform an action.
Expand All @@ -96,11 +126,11 @@ declare module './api' {
* Default command to be used when there are no servers. This can be read and updated by the extension.
* If not set, and there are not servers, then the user will be prompted to select a command from a list of commands returned by `getCommands`.
*/
selected?: Command;
selected?: JupyterServerCommand;
/**
* Returns a list of commands to be displayed to the user.
*/
getCommands(token: CancellationToken): Promise<Command[]>;
getCommands(token: CancellationToken): Promise<JupyterServerCommand[]>;
}
export interface JupyterServerCollection {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class JupyterUriProviderAdaptor extends Disposables implements IJupyterUriProvid
return {
baseUrl: info.baseUrl.toString(),
displayName: server.label,
token: info.token,
token: info.token || '',
authorizationHeader: info.authorizationHeader,
mappedRemoteNotebookDir: info.mappedRemoteNotebookDir?.toString(),
webSocketProtocols: info.webSocketProtocols
Expand Down
13 changes: 9 additions & 4 deletions src/standalone/userJupyterServer/userServerUrlProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
CancellationError,
CancellationToken,
CancellationTokenSource,
Command,
Disposable,
Event,
EventEmitter,
Expand Down Expand Up @@ -55,7 +54,13 @@ import { Common, DataScience } from '../../platform/common/utils/localize';
import { noop } from '../../platform/common/utils/misc';
import { traceError, traceWarning } from '../../platform/logging';
import { IJupyterPasswordConnectInfo, JupyterPasswordConnect } from './jupyterPasswordConnect';
import { IJupyterServerUri, JupyterServer, JupyterServerCommandProvider, JupyterServerProvider } from '../../api';
import {
IJupyterServerUri,
JupyterServer,
JupyterServerCommand,
JupyterServerCommandProvider,
JupyterServerProvider
} from '../../api';
import { IMultiStepInputFactory } from '../../platform/common/utils/multiStepInput';
import { JupyterSelfCertsError } from '../../platform/errors/jupyterSelfCertsError';
import { JupyterSelfCertsExpiredError } from '../../platform/errors/jupyterSelfCertsExpiredError';
Expand Down Expand Up @@ -134,12 +139,12 @@ export class UserJupyterServerUrlProvider
disposables
);
}
selected: Command = {
selected: JupyterServerCommand = {
title: DataScience.jupyterSelectURIPrompt,
tooltip: DataScience.jupyterSelectURINewDetail,
command: 'jupyter.selectLocalJupyterServer'
};
async getCommands(_token: CancellationToken): Promise<Command[]> {
async getCommands(_token: CancellationToken): Promise<JupyterServerCommand[]> {
return [
{
title: DataScience.jupyterSelectURIPrompt,
Expand Down

0 comments on commit 6c07072

Please sign in to comment.