diff --git a/news/2 Fixes/8021.md b/news/2 Fixes/8021.md new file mode 100644 index 000000000000..479b3442d628 --- /dev/null +++ b/news/2 Fixes/8021.md @@ -0,0 +1 @@ +Clear up wording around jupyterServerURI and remove the quick pick from the flow of setting that. \ No newline at end of file diff --git a/package.json b/package.json index 6803d0f35d7d..4e2a6d6ff99b 100644 --- a/package.json +++ b/package.json @@ -1526,7 +1526,7 @@ "python.dataScience.jupyterServerURI": { "type": "string", "default": "local", - "description": "Select the Jupyter server URI to connect to. Select 'local' to launch a new Jupyter server on the local machine.", + "description": "When a Notebook Editor or Interactive Window session is started, create the kernel on the specified Jupyter server. Select 'local' to create a new Jupyter server on this local machine.", "scope": "resource" }, "python.dataScience.notebookFileRoot": { diff --git a/package.nls.json b/package.nls.json index d30f4e203bc7..628f0d09e94b 100644 --- a/package.nls.json +++ b/package.nls.json @@ -50,7 +50,7 @@ "python.command.python.datascience.execSelectionInteractive.title": "Run Selection/Line in Python Interactive Window", "python.command.python.datascience.runcell.title": "Run Cell", "python.command.python.datascience.showhistorypane.title": "Show Python Interactive Window", - "python.command.python.datascience.selectjupyteruri.title": "Specify Jupyter Server URI", + "python.command.python.datascience.selectjupyteruri.title": "Specify local or remote Jupyter server for connections", "python.command.python.datascience.importnotebook.title": "Import Jupyter Notebook", "python.command.python.datascience.opennotebook.title": "Open in Notebook Editor", "python.command.python.datascience.importnotebookfile.title": "Convert to Python Script", @@ -184,10 +184,9 @@ "Linter.replaceWithSelectedLinter": "Multiple linters are enabled in settings. Replace with '{0}'?", "DataScience.libraryNotInstalled": "Data Science library {0} is not installed. Install?", "DataScience.jupyterInstall": "Install", - "DataScience.jupyterSelectURILaunchLocal": "Launch a local Jupyter server when needed", - "DataScience.jupyterSelectURISpecifyURI": "Type in the URI to connect to a running Jupyter server", - "DataScience.jupyterSelectURIPrompt": "Enter the URI of a Jupyter server", + "DataScience.jupyterSelectURIPrompt": "Enter the URI of the running Jupyter server or specify 'local' to create one locally when needed", "DataScience.jupyterSelectURIInvalidURI": "Invalid URI specified", + "DataScience.jupyterSelectWatermarkFormat": "{0} OR {1}", "DataScience.jupyterSelectPasswordPrompt": "Enter your notebook password", "DataScience.jupyterNotebookFailure": "Jupyter notebook failed to launch. \r\n{0}", "DataScience.jupyterNotebookConnectFailed": "Failed to connect to Jupyter notebook. \r\n{0}\r\n{1}", diff --git a/package.nls.nl.json b/package.nls.nl.json index 4197ddaa9e75..fbd609feb622 100644 --- a/package.nls.nl.json +++ b/package.nls.nl.json @@ -98,10 +98,6 @@ "DataScience.pythonRestartHeader": "Kernel herstart:", "Linter.InstalledButNotEnabled": "Linter {0} is geinstalleerd maar niet ingeschakeld.", "Linter.replaceWithSelectedLinter": "Meerdere linters zijn ingeschakeld in de instellingen. Vervangen met '{0}'?", - "DataScience.jupyterSelectURILaunchLocal": "Een lokale Jupyter-server starten wanneer nodig", - "DataScience.jupyterSelectURISpecifyURI": "Voer de URI in om te verbinden met een draaiende Jupiter-server", - "DataScience.jupyterSelectURIPrompt": "Voer de URI in van een Jupiter-server", - "DataScience.jupyterSelectURIInvalidURI": "Ongeldige URI gespecificeerd", "DataScience.jupyterNotebookFailure": "Jupyter-notebook kon niet starten. \r\n{0}", "DataScience.jupyterNotebookConnectFailed": "Verbinden met Jupiter-notebook is niet gelukt. \r\n{0}\r\n{1}", "DataScience.notebookVersionFormat": "Jupyter-notebook versie: {0}", diff --git a/src/client/common/utils/localize.ts b/src/client/common/utils/localize.ts index e57898002f11..e904ead6130b 100644 --- a/src/client/common/utils/localize.ts +++ b/src/client/common/utils/localize.ts @@ -177,10 +177,9 @@ export namespace DataScience { export const pythonNewHeader = localize('DataScience.pythonNewHeader', 'Started new kernel:'); export const pythonVersionHeaderNoPyKernel = localize('DataScience.pythonVersionHeaderNoPyKernel', 'Python Version may not match, no ipykernel found:'); - export const jupyterSelectURILaunchLocal = localize('DataScience.jupyterSelectURILaunchLocal', 'Launch local Jupyter server'); - export const jupyterSelectURISpecifyURI = localize('DataScience.jupyterSelectURISpecifyURI', 'Type in the URI for the Jupyter server'); - export const jupyterSelectURIPrompt = localize('DataScience.jupyterSelectURIPrompt', 'Enter the URI of a Jupyter server'); + export const jupyterSelectURIPrompt = localize('DataScience.jupyterSelectURIPrompt', 'Enter the URI of the running Jupyter server or specify "local" to create one locally when needed'); export const jupyterSelectURIInvalidURI = localize('DataScience.jupyterSelectURIInvalidURI', 'Invalid URI specified'); + export const jupyterSelectWatermarkFormat = localize('DataScience.jupyterSelectWatermarkFormat', '{0} OR {1}'); export const jupyterSelectPasswordPrompt = localize('DataScience.jupyterSelectPasswordPrompt', 'Enter your notebook password'); export const jupyterNotebookFailure = localize('DataScience.jupyterNotebookFailure', 'Jupyter notebook failed to launch. \r\n{0}'); export const jupyterNotebookConnectFailed = localize('DataScience.jupyterNotebookConnectFailed', 'Failed to connect to Jupyter notebook. \r\n{0}\r\n{1}'); diff --git a/src/client/datascience/datascience.ts b/src/client/datascience/datascience.ts index dc32a43b9b76..efdaaacce034 100644 --- a/src/client/datascience/datascience.ts +++ b/src/client/datascience/datascience.ts @@ -218,18 +218,15 @@ export class DataScience implements IDataScience { @captureTelemetry(Telemetry.SelectJupyterURI) public async selectJupyterURI(): Promise { - const quickPickOptions = [localize.DataScience.jupyterSelectURILaunchLocal(), localize.DataScience.jupyterSelectURISpecifyURI()]; - const selection = await this.appShell.showQuickPick(quickPickOptions, { ignoreFocusOut: true }); - switch (selection) { - case localize.DataScience.jupyterSelectURILaunchLocal(): - return this.setJupyterURIToLocal(); - break; - case localize.DataScience.jupyterSelectURISpecifyURI(): - return this.selectJupyterLaunchURI(); - break; - default: - // If user cancels quick pick we will get undefined as the selection and fall through here - break; + const userURI = await this.appShell.showInputBox({ + prompt: localize.DataScience.jupyterSelectURIPrompt(), + placeHolder: localize.DataScience.jupyterSelectWatermarkFormat().format('local', 'https://hostname:8080/?token=849d61a414abafab97bc4aab1f3547755ddc232c2b8cb7fe'), validateInput: this.validateSelectJupyterURI, ignoreFocusOut: true + }); + + if (userURI && userURI.toUpperCase() === 'LOCAL') { + await this.setJupyterURIToLocal(); + } else if (userURI) { + await this.setJupyterURIToRemote(userURI); } } @@ -274,6 +271,22 @@ export class DataScience implements IDataScience { this.commandManager.executeCommand('workbench.action.debug.continue'); } } + private validateSelectJupyterURI = (inputText: string): string | undefined | null => { + // First check if the input is 'local' specifically checking against local so culture less comparison is fine + if (inputText.toUpperCase() === 'LOCAL') { + return null; + } + + try { + // tslint:disable-next-line:no-unused-expression + new URL(inputText); + } catch { + return localize.DataScience.jupyterSelectURIInvalidURI(); + } + + // Return null tells the dialog that our string is valid + return null; + } @captureTelemetry(Telemetry.SetJupyterURIToLocal) private async setJupyterURIToLocal(): Promise { @@ -281,16 +294,8 @@ export class DataScience implements IDataScience { } @captureTelemetry(Telemetry.SetJupyterURIToUserSpecified) - private async selectJupyterLaunchURI(): Promise { - // First get the proposed URI from the user - const userURI = await this.appShell.showInputBox({ - prompt: localize.DataScience.jupyterSelectURIPrompt(), - placeHolder: 'https://hostname:8080/?token=849d61a414abafab97bc4aab1f3547755ddc232c2b8cb7fe', validateInput: this.validateURI, ignoreFocusOut: true - }); - - if (userURI) { - await this.configuration.updateSetting('dataScience.jupyterServerURI', userURI, undefined, vscode.ConfigurationTarget.Workspace); - } + private async setJupyterURIToRemote(userURI: string): Promise { + await this.configuration.updateSetting('dataScience.jupyterServerURI', userURI, undefined, vscode.ConfigurationTarget.Workspace); } @captureTelemetry(Telemetry.AddCellBelow) @@ -370,18 +375,6 @@ export class DataScience implements IDataScience { } } - private validateURI = (testURI: string): string | undefined | null => { - try { - // tslint:disable-next-line:no-unused-expression - new URL(testURI); - } catch { - return localize.DataScience.jupyterSelectURIInvalidURI(); - } - - // Return null tells the dialog that our string is valid - return null; - } - private onSettingsChanged = () => { const settings = this.configuration.getSettings(); const enabled = settings.datascience.enabled; @@ -512,9 +505,9 @@ export class DataScience implements IDataScience { } } @swallowExceptions('Error in sending DS Startup telemetry') - private sendStartupTelemetry(){ + private sendStartupTelemetry() { const filesConfig = this.workspace.getConfiguration('files'); - sendTelemetryEvent(Telemetry.AutoSaveEnabled, undefined, {enabled: filesConfig.get('autoSave', 'off') !== 'off'}); + sendTelemetryEvent(Telemetry.AutoSaveEnabled, undefined, { enabled: filesConfig.get('autoSave', 'off') !== 'off' }); } private async createNewNotebook(): Promise { diff --git a/src/test/datascience/execution.unit.test.ts b/src/test/datascience/execution.unit.test.ts index 65e7fe4497c7..c8b063f3a690 100644 --- a/src/test/datascience/execution.unit.test.ts +++ b/src/test/datascience/execution.unit.test.ts @@ -573,7 +573,7 @@ suite('Jupyter Execution', async () => { when(workspaceService.onDidChangeConfiguration).thenReturn(configChangeEvent.event); when(application.withProgress(anything(), anything())).thenCall((_, cb: (_: any, token: any) => Promise) => { return new Promise((resolve, reject) => { - cb({report: noop}, new CancellationTokenSource().token).then(resolve).catch(reject); + cb({ report: noop }, new CancellationTokenSource().token).then(resolve).catch(reject); }); }); @@ -751,7 +751,7 @@ suite('Jupyter Execution', async () => { reset(application); when(application.withProgress(anything(), anything())).thenCall((_, cb: (_: any, token: any) => Promise) => { return new Promise((resolve, reject) => { - cb({report: noop}, progressCancellation.token).then(resolve).catch(reject); + cb({ report: noop }, progressCancellation.token).then(resolve).catch(reject); }); }); @@ -770,7 +770,7 @@ suite('Jupyter Execution', async () => { reset(application); when(application.withProgress(anything(), anything())).thenCall((_, cb: (_: any, token: any) => Promise) => { return new Promise((resolve, reject) => { - cb({report: noop}, progressCancellation.token).then(resolve).catch(reject); + cb({ report: noop }, progressCancellation.token).then(resolve).catch(reject); }); });