Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for details in the Commands #14102

Merged
merged 1 commit into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 33 additions & 3 deletions src/api.proposed.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Or please wait for these to be finalized and released.

import { CancellationToken } from 'vscode';
import { Command, Event, Uri } from 'vscode';

Check warning on line 9 in src/api.proposed.d.ts

View workflow job for this annotation

GitHub Actions / Lint

'Command' is defined but never used

declare module './api' {
/**
Expand All @@ -21,7 +21,7 @@
/**
* 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 @@
*/
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 @@
* 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
Loading