mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-09 17:52:34 -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));
|
||||
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;
|
||||
if (uri.scheme === 'file') {
|
||||
contents = await readJson(uri.fsPath);
|
||||
} 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);
|
||||
}
|
||||
let untitledUriPath = this.getUntitledUriPath(path.basename(uri.fsPath));
|
||||
|
||||
@@ -19,7 +19,6 @@ import * as constants from '../../common/constants';
|
||||
|
||||
import { NotebookUriHandler } from '../../protocol/notebookUriHandler';
|
||||
import { CellTypes } from '../../contracts/content';
|
||||
import { winPlatform } from '../../common/constants';
|
||||
|
||||
describe('Notebook URI Handler', function (): void {
|
||||
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> {
|
||||
let showQuickPickStub = sinon.stub(vscode.window, 'showQuickPick').resolves(Promise.resolve(loc.msgYes) as any);
|
||||
await notebookUriHandler.handleUri(vscode.Uri.parse('azuredatastudio://microsoft.notebook/open'));
|
||||
|
||||
sinon.assert.calledOnce(showQuickPickStub);
|
||||
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> {
|
||||
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 notebookPath: string = path.join(notebookDir, 'hello.ipynb');
|
||||
|
||||
await fs.mkdir(notebookDir);
|
||||
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
|
||||
// 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.
|
||||
@@ -159,7 +155,6 @@ describe('Notebook URI Handler', function (): void {
|
||||
|
||||
await notebookUriHandler.handleUri(fileNotebookUri);
|
||||
|
||||
sinon.assert.calledOnce(showQuickPickStub);
|
||||
sinon.assert.calledWith(showNotebookDocumentStub, sinon.match.any, sinon.match({ initialContent: notebookContent }));
|
||||
sinon.assert.callCount(showErrorMessageSpy, 0);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user