mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
do not prompt for notebook uri file (#15809)
This commit is contained in:
@@ -87,19 +87,18 @@ export class NotebookUriHandler implements vscode.UriHandler {
|
|||||||
vscode.window.showErrorMessage(localize('unsupportedScheme', "Cannot open link {0} as only HTTP, HTTPS, and File links are supported", url));
|
vscode.window.showErrorMessage(localize('unsupportedScheme', "Cannot open link {0} as only HTTP, HTTPS, and File links are supported", url));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let doOpen = await this.prompter.promptSingle<boolean>(<IQuestion>{
|
|
||||||
type: QuestionTypes.confirm,
|
|
||||||
message: localize('notebook.confirmOpen', "Download and open '{0}'?", url),
|
|
||||||
default: true
|
|
||||||
});
|
|
||||||
if (!doOpen) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let contents: string;
|
let contents: string;
|
||||||
if (uri.scheme === 'file') {
|
if (uri.scheme === 'file') {
|
||||||
contents = await readJson(uri.fsPath);
|
contents = await readJson(uri.fsPath);
|
||||||
} else {
|
} else {
|
||||||
|
let doOpen = await this.prompter.promptSingle<boolean>(<IQuestion>{
|
||||||
|
type: QuestionTypes.confirm,
|
||||||
|
message: localize('notebook.confirmOpen', "Download and open '{0}'?", url),
|
||||||
|
default: true
|
||||||
|
});
|
||||||
|
if (!doOpen) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
contents = await this.download(url);
|
contents = await this.download(url);
|
||||||
}
|
}
|
||||||
let untitledUriPath = this.getUntitledUriPath(path.basename(uri.fsPath));
|
let untitledUriPath = this.getUntitledUriPath(path.basename(uri.fsPath));
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ import * as constants from '../../common/constants';
|
|||||||
|
|
||||||
import { NotebookUriHandler } from '../../protocol/notebookUriHandler';
|
import { NotebookUriHandler } from '../../protocol/notebookUriHandler';
|
||||||
import { CellTypes } from '../../contracts/content';
|
import { CellTypes } from '../../contracts/content';
|
||||||
import { winPlatform } from '../../common/constants';
|
|
||||||
|
|
||||||
describe('Notebook URI Handler', function (): void {
|
describe('Notebook URI Handler', function (): void {
|
||||||
let notebookUriHandler: NotebookUriHandler;
|
let notebookUriHandler: NotebookUriHandler;
|
||||||
@@ -55,10 +54,8 @@ describe('Notebook URI Handler', function (): void {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should show error message when no query passed into open', async function (): Promise<void> {
|
it('should show error message when no query passed into open', async function (): Promise<void> {
|
||||||
let showQuickPickStub = sinon.stub(vscode.window, 'showQuickPick').resolves(Promise.resolve(loc.msgYes) as any);
|
|
||||||
await notebookUriHandler.handleUri(vscode.Uri.parse('azuredatastudio://microsoft.notebook/open'));
|
await notebookUriHandler.handleUri(vscode.Uri.parse('azuredatastudio://microsoft.notebook/open'));
|
||||||
|
|
||||||
sinon.assert.calledOnce(showQuickPickStub);
|
|
||||||
sinon.assert.calledOnce(showErrorMessageSpy);
|
sinon.assert.calledOnce(showErrorMessageSpy);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -123,13 +120,12 @@ describe('Notebook URI Handler', function (): void {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should open notebook when file uri is valid', async function (): Promise<void> {
|
it('should open notebook when file uri is valid', async function (): Promise<void> {
|
||||||
let showQuickPickStub = sinon.stub(vscode.window, 'showQuickPick').resolves(Promise.resolve(loc.msgYes) as any);
|
|
||||||
let notebookDir: string = path.join(os.tmpdir(), `notebook_${uuid.v4()}`);
|
let notebookDir: string = path.join(os.tmpdir(), `notebook_${uuid.v4()}`);
|
||||||
let notebookPath: string = path.join(notebookDir, 'hello.ipynb');
|
let notebookPath: string = path.join(notebookDir, 'hello.ipynb');
|
||||||
|
|
||||||
await fs.mkdir(notebookDir);
|
await fs.mkdir(notebookDir);
|
||||||
let baseUrl = 'azuredatastudio://microsoft.notebook/open?url=file://';
|
let baseUrl = 'azuredatastudio://microsoft.notebook/open?url=file://';
|
||||||
if (process.platform === winPlatform) {
|
if (process.platform === constants.winPlatform) {
|
||||||
// URI paths are formatted as "hostname/path", but since we're using a local path
|
// URI paths are formatted as "hostname/path", but since we're using a local path
|
||||||
// we omit the host part and just add the slash. Unix paths already start with a
|
// we omit the host part and just add the slash. Unix paths already start with a
|
||||||
// forward slash, but we have to prepend it manually when using Windows paths.
|
// forward slash, but we have to prepend it manually when using Windows paths.
|
||||||
@@ -159,7 +155,6 @@ describe('Notebook URI Handler', function (): void {
|
|||||||
|
|
||||||
await notebookUriHandler.handleUri(fileNotebookUri);
|
await notebookUriHandler.handleUri(fileNotebookUri);
|
||||||
|
|
||||||
sinon.assert.calledOnce(showQuickPickStub);
|
|
||||||
sinon.assert.calledWith(showNotebookDocumentStub, sinon.match.any, sinon.match({ initialContent: notebookContent }));
|
sinon.assert.calledWith(showNotebookDocumentStub, sinon.match.any, sinon.match({ initialContent: notebookContent }));
|
||||||
sinon.assert.callCount(showErrorMessageSpy, 0);
|
sinon.assert.callCount(showErrorMessageSpy, 0);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user