mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
Fix/prev next links issue (#10523)
* intital test code * added tests * remove commented code * fix for failing tests * reuse exported enum * changes to address comments * add back onVisibility highlight * port highlight fix from Chris * fix tests
This commit is contained in:
@@ -186,7 +186,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"command": "notebook.command.searchUntitledBook",
|
"command": "notebook.command.searchProvidedBook",
|
||||||
"title": "%title.searchJupyterBook%",
|
"title": "%title.searchJupyterBook%",
|
||||||
"category": "%books-preview-category%",
|
"category": "%books-preview-category%",
|
||||||
"icon": {
|
"icon": {
|
||||||
@@ -319,7 +319,7 @@
|
|||||||
"when": "false"
|
"when": "false"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"command": "notebook.command.searchUntitledBook",
|
"command": "notebook.command.searchProvidedBook",
|
||||||
"when": "false"
|
"when": "false"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -381,7 +381,7 @@
|
|||||||
"group": "inline"
|
"group": "inline"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"command": "notebook.command.searchUntitledBook",
|
"command": "notebook.command.searchProvidedBook",
|
||||||
"when": "view == providedBooksView && viewItem == providedBook && providedBooks",
|
"when": "view == providedBooksView && viewItem == providedBook && providedBooks",
|
||||||
"group": "inline"
|
"group": "inline"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
import * as azdata from 'azdata';
|
|
||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
import * as yaml from 'js-yaml';
|
import * as yaml from 'js-yaml';
|
||||||
import { BookTreeItem, BookTreeItemType } from './bookTreeItem';
|
import { BookTreeItem, BookTreeItemType } from './bookTreeItem';
|
||||||
@@ -17,11 +16,10 @@ import { ApiWrapper } from '../common/apiWrapper';
|
|||||||
|
|
||||||
const fsPromises = fileServices.promises;
|
const fsPromises = fileServices.promises;
|
||||||
|
|
||||||
export class BookModel implements azdata.nb.NavigationProvider {
|
export class BookModel {
|
||||||
private _bookItems: BookTreeItem[];
|
private _bookItems: BookTreeItem[];
|
||||||
private _allNotebooks = new Map<string, BookTreeItem>();
|
private _allNotebooks = new Map<string, BookTreeItem>();
|
||||||
private _tableOfContentsPath: string;
|
private _tableOfContentsPath: string;
|
||||||
readonly providerId: string = 'BookNavigator';
|
|
||||||
|
|
||||||
private _errorMessage: string;
|
private _errorMessage: string;
|
||||||
private apiWrapper: ApiWrapper = new ApiWrapper();
|
private apiWrapper: ApiWrapper = new ApiWrapper();
|
||||||
@@ -32,7 +30,6 @@ export class BookModel implements azdata.nb.NavigationProvider {
|
|||||||
public readonly isNotebook: boolean,
|
public readonly isNotebook: boolean,
|
||||||
private _extensionContext: vscode.ExtensionContext) {
|
private _extensionContext: vscode.ExtensionContext) {
|
||||||
this._bookItems = [];
|
this._bookItems = [];
|
||||||
this._extensionContext.subscriptions.push(azdata.nb.registerNavigationProvider(this));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async initializeContents(): Promise<void> {
|
public async initializeContents(): Promise<void> {
|
||||||
@@ -251,30 +248,6 @@ export class BookModel implements azdata.nb.NavigationProvider {
|
|||||||
return this._tableOfContentsPath;
|
return this._tableOfContentsPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
getNavigation(uri: vscode.Uri): Thenable<azdata.nb.NavigationResult> {
|
|
||||||
let notebook = !this.openAsUntitled ? this._allNotebooks.get(uri.fsPath) : this._allNotebooks.get(path.basename(uri.fsPath));
|
|
||||||
let result: azdata.nb.NavigationResult;
|
|
||||||
if (notebook) {
|
|
||||||
result = {
|
|
||||||
hasNavigation: true,
|
|
||||||
previous: notebook.previousUri ?
|
|
||||||
this.openAsUntitled ? this.getUntitledUri(notebook.previousUri) : vscode.Uri.file(notebook.previousUri) : undefined,
|
|
||||||
next: notebook.nextUri ? this.openAsUntitled ? this.getUntitledUri(notebook.nextUri) : vscode.Uri.file(notebook.nextUri) : undefined
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
result = {
|
|
||||||
hasNavigation: false,
|
|
||||||
previous: undefined,
|
|
||||||
next: undefined
|
|
||||||
};
|
|
||||||
}
|
|
||||||
return Promise.resolve(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
getUntitledUri(resource: string): vscode.Uri {
|
|
||||||
return vscode.Uri.parse(`untitled:${resource}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
public get errorMessage(): string {
|
public get errorMessage(): string {
|
||||||
return this._errorMessage;
|
return this._errorMessage;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ interface BookSearchResults {
|
|||||||
bookPaths: string[];
|
bookPaths: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeItem> {
|
export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeItem>, azdata.nb.NavigationProvider {
|
||||||
private _onDidChangeTreeData: vscode.EventEmitter<BookTreeItem | undefined> = new vscode.EventEmitter<BookTreeItem | undefined>();
|
private _onDidChangeTreeData: vscode.EventEmitter<BookTreeItem | undefined> = new vscode.EventEmitter<BookTreeItem | undefined>();
|
||||||
readonly onDidChangeTreeData: vscode.Event<BookTreeItem | undefined> = this._onDidChangeTreeData.event;
|
readonly onDidChangeTreeData: vscode.Event<BookTreeItem | undefined> = this._onDidChangeTreeData.event;
|
||||||
private _throttleTimer: any;
|
private _throttleTimer: any;
|
||||||
@@ -43,7 +43,7 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
|
|||||||
public books: BookModel[];
|
public books: BookModel[];
|
||||||
public currentBook: BookModel;
|
public currentBook: BookModel;
|
||||||
|
|
||||||
constructor(private _apiWrapper: ApiWrapper, workspaceFolders: vscode.WorkspaceFolder[], extensionContext: vscode.ExtensionContext, openAsUntitled: boolean, view: string) {
|
constructor(private _apiWrapper: ApiWrapper, workspaceFolders: vscode.WorkspaceFolder[], extensionContext: vscode.ExtensionContext, openAsUntitled: boolean, view: string, public providerId: string) {
|
||||||
this._openAsUntitled = openAsUntitled;
|
this._openAsUntitled = openAsUntitled;
|
||||||
this._extensionContext = extensionContext;
|
this._extensionContext = extensionContext;
|
||||||
this.books = [];
|
this.books = [];
|
||||||
@@ -51,10 +51,11 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
|
|||||||
this.viewId = view;
|
this.viewId = view;
|
||||||
this.prompter = new CodeAdapter();
|
this.prompter = new CodeAdapter();
|
||||||
this._bookTrustManager = new BookTrustManager(this.books, _apiWrapper);
|
this._bookTrustManager = new BookTrustManager(this.books, _apiWrapper);
|
||||||
|
|
||||||
|
this._extensionContext.subscriptions.push(azdata.nb.registerNavigationProvider(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
private async initialize(workspaceFolders: vscode.WorkspaceFolder[]): Promise<void> {
|
private async initialize(workspaceFolders: vscode.WorkspaceFolder[]): Promise<void> {
|
||||||
await vscode.commands.executeCommand('setContext', 'providedBooks', this._openAsUntitled);
|
|
||||||
await Promise.all(workspaceFolders.map(async (workspaceFolder) => {
|
await Promise.all(workspaceFolders.map(async (workspaceFolder) => {
|
||||||
try {
|
try {
|
||||||
await this.loadNotebooksInFolder(workspaceFolder.uri.fsPath);
|
await this.loadNotebooksInFolder(workspaceFolder.uri.fsPath);
|
||||||
@@ -204,8 +205,9 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
|
|||||||
|
|
||||||
async openNotebook(resource: string): Promise<void> {
|
async openNotebook(resource: string): Promise<void> {
|
||||||
try {
|
try {
|
||||||
|
await vscode.commands.executeCommand(constants.BuiltInCommands.SetContext, constants.unsavedBooksContextKey, false);
|
||||||
if (this._openAsUntitled) {
|
if (this._openAsUntitled) {
|
||||||
this.openNotebookAsUntitled(resource);
|
await this.openNotebookAsUntitled(resource);
|
||||||
} else {
|
} else {
|
||||||
// let us keep a list of already visited notebooks so that we do not trust them again, potentially
|
// let us keep a list of already visited notebooks so that we do not trust them again, potentially
|
||||||
// overriding user changes
|
// overriding user changes
|
||||||
@@ -256,8 +258,9 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
openNotebookAsUntitled(resource: string): void {
|
async openNotebookAsUntitled(resource: string): Promise<void> {
|
||||||
try {
|
try {
|
||||||
|
await vscode.commands.executeCommand(constants.BuiltInCommands.SetContext, constants.unsavedBooksContextKey, true);
|
||||||
let untitledFileName: vscode.Uri = this.getUntitledNotebookUri(resource);
|
let untitledFileName: vscode.Uri = this.getUntitledNotebookUri(resource);
|
||||||
vscode.workspace.openTextDocument(resource).then((document) => {
|
vscode.workspace.openTextDocument(resource).then((document) => {
|
||||||
let initialContent = document.getText();
|
let initialContent = document.getText();
|
||||||
@@ -493,4 +496,29 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
|
|||||||
default: false
|
default: false
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getNavigation(uri: vscode.Uri): Thenable<azdata.nb.NavigationResult> {
|
||||||
|
let result: azdata.nb.NavigationResult;
|
||||||
|
let notebook = this.currentBook?.getNotebook(uri.fsPath);
|
||||||
|
if (notebook) {
|
||||||
|
result = {
|
||||||
|
hasNavigation: true,
|
||||||
|
previous: notebook.previousUri ?
|
||||||
|
this.currentBook?.openAsUntitled ? this.getUntitledNotebookUri(notebook.previousUri) : vscode.Uri.file(notebook.previousUri) : undefined,
|
||||||
|
next: notebook.nextUri ? this.currentBook?.openAsUntitled ? this.getUntitledNotebookUri(notebook.nextUri) : vscode.Uri.file(notebook.nextUri) : undefined
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
result = {
|
||||||
|
hasNavigation: false,
|
||||||
|
previous: undefined,
|
||||||
|
next: undefined
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return Promise.resolve(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public getBookFromItemPath(itemPath: string): BookModel | undefined {
|
||||||
|
let selectedBook = this.books.find(b => itemPath.toLowerCase().indexOf(b.bookPath.toLowerCase()) > -1);
|
||||||
|
return selectedBook;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,6 +56,13 @@ export enum PythonPkgType {
|
|||||||
Anaconda = 'Anaconda'
|
Anaconda = 'Anaconda'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export enum NavigationProviders {
|
||||||
|
NotebooksNavigator = 'BookNavigator.Notebooks',
|
||||||
|
ProvidedBooksNavigator = 'BookNavigator.ProvidedBooks'
|
||||||
|
}
|
||||||
|
|
||||||
|
export const unsavedBooksContextKey = 'unsavedBooks';
|
||||||
|
|
||||||
export const pythonWindowsInstallUrl = 'https://go.microsoft.com/fwlink/?linkid=2110625';
|
export const pythonWindowsInstallUrl = 'https://go.microsoft.com/fwlink/?linkid=2110625';
|
||||||
export const pythonMacInstallUrl = 'https://go.microsoft.com/fwlink/?linkid=2128152';
|
export const pythonMacInstallUrl = 'https://go.microsoft.com/fwlink/?linkid=2128152';
|
||||||
export const pythonLinuxInstallUrl = 'https://go.microsoft.com/fwlink/?linkid=2110524';
|
export const pythonLinuxInstallUrl = 'https://go.microsoft.com/fwlink/?linkid=2110524';
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import { IExtensionApi, IPackageManageProvider } from './types';
|
|||||||
import { CellType } from './contracts/content';
|
import { CellType } from './contracts/content';
|
||||||
import { NotebookUriHandler } from './protocol/notebookUriHandler';
|
import { NotebookUriHandler } from './protocol/notebookUriHandler';
|
||||||
import { BookTreeViewProvider } from './book/bookTreeView';
|
import { BookTreeViewProvider } from './book/bookTreeView';
|
||||||
|
import { NavigationProviders } from './common/constants';
|
||||||
import { newNotebook, openNotebook, runActiveCell, runAllCells, clearActiveCellOutput, addCell, analyzeNotebook } from './common/notebookUtils';
|
import { newNotebook, openNotebook, runActiveCell, runAllCells, clearActiveCellOutput, addCell, analyzeNotebook } from './common/notebookUtils';
|
||||||
|
|
||||||
const localize = nls.loadMessageBundle();
|
const localize = nls.loadMessageBundle();
|
||||||
@@ -34,7 +35,7 @@ export async function activate(extensionContext: vscode.ExtensionContext): Promi
|
|||||||
extensionContext.subscriptions.push(vscode.commands.registerCommand('notebook.command.saveBook', () => providedBookTreeViewProvider.saveJupyterBooks()));
|
extensionContext.subscriptions.push(vscode.commands.registerCommand('notebook.command.saveBook', () => providedBookTreeViewProvider.saveJupyterBooks()));
|
||||||
extensionContext.subscriptions.push(vscode.commands.registerCommand('notebook.command.trustBook', (resource) => bookTreeViewProvider.trustBook(resource)));
|
extensionContext.subscriptions.push(vscode.commands.registerCommand('notebook.command.trustBook', (resource) => bookTreeViewProvider.trustBook(resource)));
|
||||||
extensionContext.subscriptions.push(vscode.commands.registerCommand('notebook.command.searchBook', (item) => bookTreeViewProvider.searchJupyterBooks(item)));
|
extensionContext.subscriptions.push(vscode.commands.registerCommand('notebook.command.searchBook', (item) => bookTreeViewProvider.searchJupyterBooks(item)));
|
||||||
extensionContext.subscriptions.push(vscode.commands.registerCommand('notebook.command.searchUntitledBook', () => providedBookTreeViewProvider.searchJupyterBooks()));
|
extensionContext.subscriptions.push(vscode.commands.registerCommand('notebook.command.searchProvidedBook', () => providedBookTreeViewProvider.searchJupyterBooks()));
|
||||||
extensionContext.subscriptions.push(vscode.commands.registerCommand('notebook.command.openBook', () => bookTreeViewProvider.openNewBook()));
|
extensionContext.subscriptions.push(vscode.commands.registerCommand('notebook.command.openBook', () => bookTreeViewProvider.openNewBook()));
|
||||||
extensionContext.subscriptions.push(vscode.commands.registerCommand('notebook.command.closeBook', (book: any) => bookTreeViewProvider.closeBook(book)));
|
extensionContext.subscriptions.push(vscode.commands.registerCommand('notebook.command.closeBook', (book: any) => bookTreeViewProvider.closeBook(book)));
|
||||||
extensionContext.subscriptions.push(vscode.commands.registerCommand('notebook.command.closeNotebook', (book: any) => bookTreeViewProvider.closeBook(book)));
|
extensionContext.subscriptions.push(vscode.commands.registerCommand('notebook.command.closeNotebook', (book: any) => bookTreeViewProvider.closeBook(book)));
|
||||||
@@ -109,9 +110,6 @@ export async function activate(extensionContext: vscode.ExtensionContext): Promi
|
|||||||
await vscode.commands.executeCommand('vscode.open', vscode.Uri.parse(urlToOpen));
|
await vscode.commands.executeCommand('vscode.open', vscode.Uri.parse(urlToOpen));
|
||||||
}));
|
}));
|
||||||
|
|
||||||
extensionContext.subscriptions.push(vscode.commands.registerCommand('notebook.command.revealInBooksViewlet', (uri: vscode.Uri, shouldReveal: boolean) => bookTreeViewProvider.revealActiveDocumentInViewlet(uri, shouldReveal)));
|
|
||||||
extensionContext.subscriptions.push(vscode.commands.registerCommand('notebook.command.revealInUntitledBooksViewlet', (uri: vscode.Uri, shouldReveal: boolean) => providedBookTreeViewProvider.revealActiveDocumentInViewlet(uri, shouldReveal)));
|
|
||||||
|
|
||||||
let appContext = new AppContext(extensionContext, new ApiWrapper());
|
let appContext = new AppContext(extensionContext, new ApiWrapper());
|
||||||
controller = new JupyterController(appContext);
|
controller = new JupyterController(appContext);
|
||||||
let result = await controller.activate();
|
let result = await controller.activate();
|
||||||
@@ -120,9 +118,9 @@ export async function activate(extensionContext: vscode.ExtensionContext): Promi
|
|||||||
}
|
}
|
||||||
|
|
||||||
let workspaceFolders = vscode.workspace.workspaceFolders?.slice() ?? [];
|
let workspaceFolders = vscode.workspace.workspaceFolders?.slice() ?? [];
|
||||||
const bookTreeViewProvider = new BookTreeViewProvider(appContext.apiWrapper, workspaceFolders, extensionContext, false, BOOKS_VIEWID);
|
const bookTreeViewProvider = new BookTreeViewProvider(appContext.apiWrapper, workspaceFolders, extensionContext, false, BOOKS_VIEWID, NavigationProviders.NotebooksNavigator);
|
||||||
await bookTreeViewProvider.initialized;
|
await bookTreeViewProvider.initialized;
|
||||||
const providedBookTreeViewProvider = new BookTreeViewProvider(appContext.apiWrapper, [], extensionContext, true, PROVIDED_BOOKS_VIEWID);
|
const providedBookTreeViewProvider = new BookTreeViewProvider(appContext.apiWrapper, [], extensionContext, true, PROVIDED_BOOKS_VIEWID, NavigationProviders.ProvidedBooksNavigator);
|
||||||
await providedBookTreeViewProvider.initialized;
|
await providedBookTreeViewProvider.initialized;
|
||||||
|
|
||||||
azdata.nb.onDidChangeActiveNotebookEditor(e => {
|
azdata.nb.onDidChangeActiveNotebookEditor(e => {
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import { AppContext } from '../../common/appContext';
|
|||||||
import { ApiWrapper } from '../../common/apiWrapper';
|
import { ApiWrapper } from '../../common/apiWrapper';
|
||||||
import { BookModel } from '../../book/bookModel';
|
import { BookModel } from '../../book/bookModel';
|
||||||
import { BookTrustManager } from '../../book/bookTrustManager';
|
import { BookTrustManager } from '../../book/bookTrustManager';
|
||||||
|
import { NavigationProviders } from '../../common/constants';
|
||||||
|
|
||||||
export interface IExpectedBookItem {
|
export interface IExpectedBookItem {
|
||||||
title: string;
|
title: string;
|
||||||
@@ -119,7 +120,7 @@ describe('BookTreeViewProviderTests', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should initialize correctly with empty workspace array', async () => {
|
it('should initialize correctly with empty workspace array', async () => {
|
||||||
const bookTreeViewProvider = new BookTreeViewProvider(appContext.apiWrapper, [], mockExtensionContext, false, 'bookTreeView');
|
const bookTreeViewProvider = new BookTreeViewProvider(appContext.apiWrapper, [], mockExtensionContext, false, 'bookTreeView', NavigationProviders.NotebooksNavigator);
|
||||||
await bookTreeViewProvider.initialized;
|
await bookTreeViewProvider.initialized;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -129,7 +130,7 @@ describe('BookTreeViewProviderTests', function () {
|
|||||||
name: '',
|
name: '',
|
||||||
index: 0
|
index: 0
|
||||||
};
|
};
|
||||||
const bookTreeViewProvider = new BookTreeViewProvider(appContext.apiWrapper, [folder], mockExtensionContext, false, 'bookTreeView');
|
const bookTreeViewProvider = new BookTreeViewProvider(appContext.apiWrapper, [folder], mockExtensionContext, false, 'bookTreeView', NavigationProviders.NotebooksNavigator);
|
||||||
await bookTreeViewProvider.initialized;
|
await bookTreeViewProvider.initialized;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -144,13 +145,14 @@ describe('BookTreeViewProviderTests', function () {
|
|||||||
name: '',
|
name: '',
|
||||||
index: 0
|
index: 0
|
||||||
};
|
};
|
||||||
const bookTreeViewProvider = new BookTreeViewProvider(appContext.apiWrapper, [book, nonBook], mockExtensionContext, false, 'bookTreeView');
|
const bookTreeViewProvider = new BookTreeViewProvider(appContext.apiWrapper, [book, nonBook], mockExtensionContext, false, 'bookTreeView', NavigationProviders.NotebooksNavigator);
|
||||||
await bookTreeViewProvider.initialized;
|
await bookTreeViewProvider.initialized;
|
||||||
should(bookTreeViewProvider.books.length).equal(1, 'Expected book was not initialized');
|
should(bookTreeViewProvider.books.length).equal(1, 'Expected book was not initialized');
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('BookTreeViewProvider.getChildren', function (): void {
|
describe('getChildren', function (): void {
|
||||||
let bookTreeViewProvider: BookTreeViewProvider;
|
let bookTreeViewProvider: BookTreeViewProvider;
|
||||||
|
let providedbookTreeViewProvider: BookTreeViewProvider;
|
||||||
let book: BookTreeItem;
|
let book: BookTreeItem;
|
||||||
let notebook1: BookTreeItem;
|
let notebook1: BookTreeItem;
|
||||||
|
|
||||||
@@ -160,12 +162,15 @@ describe('BookTreeViewProviderTests', function () {
|
|||||||
name: '',
|
name: '',
|
||||||
index: 0
|
index: 0
|
||||||
};
|
};
|
||||||
bookTreeViewProvider = new BookTreeViewProvider(appContext.apiWrapper, [folder], mockExtensionContext, false, 'bookTreeView');
|
bookTreeViewProvider = new BookTreeViewProvider(appContext.apiWrapper, [folder], mockExtensionContext, false, 'bookTreeView', NavigationProviders.NotebooksNavigator);
|
||||||
|
providedbookTreeViewProvider = new BookTreeViewProvider(appContext.apiWrapper, [], mockExtensionContext, true, 'providedBooksView', NavigationProviders.ProvidedBooksNavigator);
|
||||||
let errorCase = new Promise((resolve, reject) => setTimeout(() => resolve(), 5000));
|
let errorCase = new Promise((resolve, reject) => setTimeout(() => resolve(), 5000));
|
||||||
await Promise.race([bookTreeViewProvider.initialized, errorCase.then(() => { throw new Error('BookTreeViewProvider did not initialize in time'); })]);
|
await Promise.race([bookTreeViewProvider.initialized, errorCase.then(() => { throw new Error('BookTreeViewProvider did not initialize in time'); })]);
|
||||||
|
await Promise.race([providedbookTreeViewProvider.initialized, errorCase.then(() => { throw new Error('ProvidedBooksTreeViewProvider did not initialize in time'); })]);
|
||||||
|
await providedbookTreeViewProvider.openBook(bookFolderPath, undefined, false, false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return all book nodes when element is undefined', async function (): Promise<void> {
|
it('bookTreeViewProvider should return all book nodes when element is undefined', async function (): Promise<void> {
|
||||||
const children = await bookTreeViewProvider.getChildren();
|
const children = await bookTreeViewProvider.getChildren();
|
||||||
should(children).be.Array();
|
should(children).be.Array();
|
||||||
should(children.length).equal(1);
|
should(children.length).equal(1);
|
||||||
@@ -173,7 +178,7 @@ describe('BookTreeViewProviderTests', function () {
|
|||||||
should(book.title).equal(expectedBook.title);
|
should(book.title).equal(expectedBook.title);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return all page nodes when element is a book', async function (): Promise<void> {
|
it('bookTreeViewProvider should return all page nodes when element is a book', async function (): Promise<void> {
|
||||||
const children = await bookTreeViewProvider.getChildren(book);
|
const children = await bookTreeViewProvider.getChildren(book);
|
||||||
should(children).be.Array();
|
should(children).be.Array();
|
||||||
should(children.length).equal(3);
|
should(children.length).equal(3);
|
||||||
@@ -185,7 +190,7 @@ describe('BookTreeViewProviderTests', function () {
|
|||||||
equalBookItems(externalLink, expectedExternalLink);
|
equalBookItems(externalLink, expectedExternalLink);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return all sections when element is a notebook', async function (): Promise<void> {
|
it('bookTreeViewProvider should return all sections when element is a notebook', async function (): Promise<void> {
|
||||||
const children = await bookTreeViewProvider.getChildren(notebook1);
|
const children = await bookTreeViewProvider.getChildren(notebook1);
|
||||||
should(children).be.Array();
|
should(children).be.Array();
|
||||||
should(children.length).equal(2);
|
should(children.length).equal(2);
|
||||||
@@ -195,7 +200,7 @@ describe('BookTreeViewProviderTests', function () {
|
|||||||
equalBookItems(notebook3, expectedNotebook3);
|
equalBookItems(notebook3, expectedNotebook3);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should set notebooks trusted to true on trustBook', async () => {
|
it('bookTreeViewProvider should set notebooks trusted to true on trustBook', async () => {
|
||||||
let notebook1Path = path.join(rootFolderPath, 'Book', 'content', 'notebook1.ipynb');
|
let notebook1Path = path.join(rootFolderPath, 'Book', 'content', 'notebook1.ipynb');
|
||||||
let bookTrustManager: BookTrustManager = new BookTrustManager(bookTreeViewProvider.books, appContext.apiWrapper);
|
let bookTrustManager: BookTrustManager = new BookTrustManager(bookTreeViewProvider.books, appContext.apiWrapper);
|
||||||
let isTrusted = bookTrustManager.isNotebookTrustedByDefault(vscode.Uri.file(notebook1Path).fsPath);
|
let isTrusted = bookTrustManager.isNotebookTrustedByDefault(vscode.Uri.file(notebook1Path).fsPath);
|
||||||
@@ -207,17 +212,58 @@ describe('BookTreeViewProviderTests', function () {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('getNavigation should get previous and next urls correctly from the bookModel', async () => {
|
it('bookTreeViewProvider getNavigation should get previous and next urls correctly from the bookModel', async () => {
|
||||||
let notebook1Path = path.join(rootFolderPath, 'Book', 'content', 'notebook1.ipynb');
|
let notebook1Path = path.join(rootFolderPath, 'Book', 'content', 'notebook1.ipynb');
|
||||||
let notebook2Path = path.join(rootFolderPath, 'Book', 'content', 'notebook2.ipynb');
|
let notebook2Path = path.join(rootFolderPath, 'Book', 'content', 'notebook2.ipynb');
|
||||||
let notebook3Path = path.join(rootFolderPath, 'Book', 'content', 'notebook3.ipynb');
|
let notebook3Path = path.join(rootFolderPath, 'Book', 'content', 'notebook3.ipynb');
|
||||||
const result = await bookTreeViewProvider.currentBook.getNavigation(vscode.Uri.file(notebook2Path));
|
const result = await bookTreeViewProvider.getNavigation(vscode.Uri.file(notebook2Path));
|
||||||
should(result.hasNavigation).be.true('getNavigation failed to get previous and next urls');
|
should(result.hasNavigation).be.true('getNavigation failed to get previous and next urls');
|
||||||
should(result.next.fsPath).equal(vscode.Uri.file(notebook3Path).fsPath, 'getNavigation failed to get the next url');
|
should(result.next.fsPath).equal(vscode.Uri.file(notebook3Path).fsPath, 'getNavigation failed to get the next url');
|
||||||
should(result.previous.fsPath).equal(vscode.Uri.file(notebook1Path).fsPath, 'getNavigation failed to get the previous url');
|
should(result.previous.fsPath).equal(vscode.Uri.file(notebook1Path).fsPath, 'getNavigation failed to get the previous url');
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('providedBookTreeViewProvider should return all book nodes when element is undefined', async function (): Promise<void> {
|
||||||
|
const children = await providedbookTreeViewProvider.getChildren();
|
||||||
|
should(children).be.Array();
|
||||||
|
should(children.length).equal(1);
|
||||||
|
book = children[0];
|
||||||
|
should(book.title).equal(expectedBook.title);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('providedBookTreeViewProvider should return all page nodes when element is a book', async function (): Promise<void> {
|
||||||
|
const children = await providedbookTreeViewProvider.getChildren(book);
|
||||||
|
should(children).be.Array();
|
||||||
|
should(children.length).equal(3);
|
||||||
|
notebook1 = children[0];
|
||||||
|
const markdown = children[1];
|
||||||
|
const externalLink = children[2];
|
||||||
|
equalBookItems(notebook1, expectedNotebook1);
|
||||||
|
equalBookItems(markdown, expectedMarkdown);
|
||||||
|
equalBookItems(externalLink, expectedExternalLink);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('providedBookTreeViewProvider should return all sections when element is a notebook', async function (): Promise<void> {
|
||||||
|
const children = await providedbookTreeViewProvider.getChildren(notebook1);
|
||||||
|
should(children).be.Array();
|
||||||
|
should(children.length).equal(2);
|
||||||
|
const notebook2 = children[0];
|
||||||
|
const notebook3 = children[1];
|
||||||
|
equalBookItems(notebook2, expectedNotebook2);
|
||||||
|
equalBookItems(notebook3, expectedNotebook3);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('providedBookTreeViewProvider getNavigation should get previous and next urls correctly from the bookModel', async () => {
|
||||||
|
let notebook1Path = path.join(rootFolderPath, 'Book', 'content', 'notebook1.ipynb');
|
||||||
|
let notebook2Path = path.join(rootFolderPath, 'Book', 'content', 'notebook2.ipynb');
|
||||||
|
let notebook3Path = path.join(rootFolderPath, 'Book', 'content', 'notebook3.ipynb');
|
||||||
|
const result = await providedbookTreeViewProvider.getNavigation(vscode.Uri.file(notebook2Path));
|
||||||
|
should(result.hasNavigation).be.true('getNavigation failed to get previous and next urls');
|
||||||
|
should(result.next.fsPath).equal(notebook3Path, 'getNavigation failed to get the next url');
|
||||||
|
should(result.previous.fsPath).equal(notebook1Path, 'getNavigation failed to get the previous url');
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
this.afterAll(async function (): Promise<void> {
|
this.afterAll(async function (): Promise<void> {
|
||||||
console.log('Removing temporary files...');
|
console.log('Removing temporary files...');
|
||||||
@@ -226,7 +272,6 @@ describe('BookTreeViewProviderTests', function () {
|
|||||||
}
|
}
|
||||||
console.log('Successfully removed temporary files.');
|
console.log('Successfully removed temporary files.');
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -253,7 +298,7 @@ describe('BookTreeViewProviderTests', function () {
|
|||||||
index: 0
|
index: 0
|
||||||
};
|
};
|
||||||
appContext = new AppContext(mockExtensionContext, new ApiWrapper());
|
appContext = new AppContext(mockExtensionContext, new ApiWrapper());
|
||||||
bookTreeViewProvider = new BookTreeViewProvider(appContext.apiWrapper, [folder], mockExtensionContext, false, 'bookTreeView');
|
bookTreeViewProvider = new BookTreeViewProvider(appContext.apiWrapper, [folder], mockExtensionContext, false, 'bookTreeView', NavigationProviders.NotebooksNavigator);
|
||||||
let errorCase = new Promise((resolve, reject) => setTimeout(() => resolve(), 5000));
|
let errorCase = new Promise((resolve, reject) => setTimeout(() => resolve(), 5000));
|
||||||
await Promise.race([bookTreeViewProvider.initialized, errorCase.then(() => { throw new Error('BookTreeViewProvider did not initialize in time'); })]);
|
await Promise.race([bookTreeViewProvider.initialized, errorCase.then(() => { throw new Error('BookTreeViewProvider did not initialize in time'); })]);
|
||||||
appContext = new AppContext(undefined, new ApiWrapper());
|
appContext = new AppContext(undefined, new ApiWrapper());
|
||||||
@@ -296,7 +341,7 @@ describe('BookTreeViewProviderTests', function () {
|
|||||||
index: 0
|
index: 0
|
||||||
};
|
};
|
||||||
appContext = new AppContext(mockExtensionContext, new ApiWrapper());
|
appContext = new AppContext(mockExtensionContext, new ApiWrapper());
|
||||||
bookTreeViewProvider = new BookTreeViewProvider(appContext.apiWrapper, [folder], mockExtensionContext, false, 'bookTreeView');
|
bookTreeViewProvider = new BookTreeViewProvider(appContext.apiWrapper, [folder], mockExtensionContext, false, 'bookTreeView', NavigationProviders.NotebooksNavigator);
|
||||||
let errorCase = new Promise((resolve, reject) => setTimeout(() => resolve(), 5000));
|
let errorCase = new Promise((resolve, reject) => setTimeout(() => resolve(), 5000));
|
||||||
await Promise.race([bookTreeViewProvider.initialized, errorCase.then(() => { throw new Error('BookTreeViewProvider did not initialize in time'); })]);
|
await Promise.race([bookTreeViewProvider.initialized, errorCase.then(() => { throw new Error('BookTreeViewProvider did not initialize in time'); })]);
|
||||||
appContext = new AppContext(undefined, new ApiWrapper());
|
appContext = new AppContext(undefined, new ApiWrapper());
|
||||||
@@ -356,7 +401,7 @@ describe('BookTreeViewProviderTests', function () {
|
|||||||
index: 0
|
index: 0
|
||||||
};
|
};
|
||||||
appContext = new AppContext(mockExtensionContext, new ApiWrapper());
|
appContext = new AppContext(mockExtensionContext, new ApiWrapper());
|
||||||
bookTreeViewProvider = new BookTreeViewProvider(appContext.apiWrapper, [folder], mockExtensionContext, false, 'bookTreeView');
|
bookTreeViewProvider = new BookTreeViewProvider(appContext.apiWrapper, [folder], mockExtensionContext, false, 'bookTreeView', NavigationProviders.NotebooksNavigator);
|
||||||
let errorCase = new Promise((resolve, reject) => setTimeout(() => resolve(), 5000));
|
let errorCase = new Promise((resolve, reject) => setTimeout(() => resolve(), 5000));
|
||||||
await Promise.race([bookTreeViewProvider.initialized, errorCase.then(() => { throw new Error('BookTreeViewProvider did not initialize in time'); })]);
|
await Promise.race([bookTreeViewProvider.initialized, errorCase.then(() => { throw new Error('BookTreeViewProvider did not initialize in time'); })]);
|
||||||
appContext = new AppContext(undefined, new ApiWrapper());
|
appContext = new AppContext(undefined, new ApiWrapper());
|
||||||
@@ -399,7 +444,7 @@ describe('BookTreeViewProviderTests', function () {
|
|||||||
|
|
||||||
const mockExtensionContext = new MockExtensionContext();
|
const mockExtensionContext = new MockExtensionContext();
|
||||||
appContext = new AppContext(mockExtensionContext, new ApiWrapper());
|
appContext = new AppContext(mockExtensionContext, new ApiWrapper());
|
||||||
bookTreeViewProvider = new BookTreeViewProvider(appContext.apiWrapper, [], mockExtensionContext, false, 'bookTreeView');
|
bookTreeViewProvider = new BookTreeViewProvider(appContext.apiWrapper, [], mockExtensionContext, false, 'bookTreeView', NavigationProviders.NotebooksNavigator);
|
||||||
let errorCase = new Promise((resolve, reject) => setTimeout(() => resolve(), 5000));
|
let errorCase = new Promise((resolve, reject) => setTimeout(() => resolve(), 5000));
|
||||||
await Promise.race([bookTreeViewProvider.initialized, errorCase.then(() => { throw new Error('BookTreeViewProvider did not initialize in time'); })]);
|
await Promise.race([bookTreeViewProvider.initialized, errorCase.then(() => { throw new Error('BookTreeViewProvider did not initialize in time'); })]);
|
||||||
appContext = new AppContext(undefined, new ApiWrapper());
|
appContext = new AppContext(undefined, new ApiWrapper());
|
||||||
@@ -483,7 +528,7 @@ describe('BookTreeViewProviderTests', function () {
|
|||||||
|
|
||||||
const mockExtensionContext = new MockExtensionContext();
|
const mockExtensionContext = new MockExtensionContext();
|
||||||
appContext = new AppContext(mockExtensionContext, new ApiWrapper());
|
appContext = new AppContext(mockExtensionContext, new ApiWrapper());
|
||||||
bookTreeViewProvider = new BookTreeViewProvider(appContext.apiWrapper, [], mockExtensionContext, false, 'bookTreeView');
|
bookTreeViewProvider = new BookTreeViewProvider(appContext.apiWrapper, [], mockExtensionContext, false, 'bookTreeView', NavigationProviders.NotebooksNavigator);
|
||||||
let errorCase = new Promise((resolve, reject) => setTimeout(() => resolve(), 5000));
|
let errorCase = new Promise((resolve, reject) => setTimeout(() => resolve(), 5000));
|
||||||
await Promise.race([bookTreeViewProvider.initialized, errorCase.then(() => { throw new Error('BookTreeViewProvider did not initialize in time'); })]);
|
await Promise.race([bookTreeViewProvider.initialized, errorCase.then(() => { throw new Error('BookTreeViewProvider did not initialize in time'); })]);
|
||||||
appContext = new AppContext(undefined, new ApiWrapper());
|
appContext = new AppContext(undefined, new ApiWrapper());
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
import { Directive, Inject, HostListener, Input } from '@angular/core';
|
import { Directive, Inject, HostListener, Input } from '@angular/core';
|
||||||
|
|
||||||
import { URI } from 'vs/base/common/uri';
|
import { URI } from 'vs/base/common/uri';
|
||||||
import { IOpenerService } from 'vs/platform/opener/common/opener';
|
import { IOpenerService } from 'vs/platform/opener/common/opener';
|
||||||
import { onUnexpectedError } from 'vs/base/common/errors';
|
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||||
|
|||||||
@@ -55,7 +55,6 @@ import { CodeCellComponent } from 'sql/workbench/contrib/notebook/browser/cellVi
|
|||||||
import { TextCellComponent } from 'sql/workbench/contrib/notebook/browser/cellViews/textCell.component';
|
import { TextCellComponent } from 'sql/workbench/contrib/notebook/browser/cellViews/textCell.component';
|
||||||
import { NotebookInput } from 'sql/workbench/contrib/notebook/browser/models/notebookInput';
|
import { NotebookInput } from 'sql/workbench/contrib/notebook/browser/models/notebookInput';
|
||||||
import { IColorTheme } from 'vs/platform/theme/common/themeService';
|
import { IColorTheme } from 'vs/platform/theme/common/themeService';
|
||||||
import { ICommandService } from 'vs/platform/commands/common/commands';
|
|
||||||
import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry';
|
import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry';
|
||||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||||
|
|
||||||
@@ -105,7 +104,6 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
|
|||||||
@Inject(ICapabilitiesService) private capabilitiesService: ICapabilitiesService,
|
@Inject(ICapabilitiesService) private capabilitiesService: ICapabilitiesService,
|
||||||
@Inject(ITextFileService) private textFileService: ITextFileService,
|
@Inject(ITextFileService) private textFileService: ITextFileService,
|
||||||
@Inject(ILogService) private readonly logService: ILogService,
|
@Inject(ILogService) private readonly logService: ILogService,
|
||||||
@Inject(ICommandService) private commandService: ICommandService,
|
|
||||||
@Inject(IAdsTelemetryService) private adstelemetryService: IAdsTelemetryService,
|
@Inject(IAdsTelemetryService) private adstelemetryService: IAdsTelemetryService,
|
||||||
@Inject(IConfigurationService) private _configurationService: IConfigurationService
|
@Inject(IConfigurationService) private _configurationService: IConfigurationService
|
||||||
) {
|
) {
|
||||||
@@ -516,8 +514,6 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
|
|||||||
this._navProvider = this.notebookService.getNavigationProvider(this._notebookParams.notebookUri);
|
this._navProvider = this.notebookService.getNavigationProvider(this._notebookParams.notebookUri);
|
||||||
|
|
||||||
if (this.contextKeyService.getContextKeyValue('bookOpened') && this._navProvider) {
|
if (this.contextKeyService.getContextKeyValue('bookOpened') && this._navProvider) {
|
||||||
// If there's a book opened but the current notebook isn't part of the book, this is a no-op
|
|
||||||
this.commandService.executeCommand('notebook.command.revealInBooksViewlet', this._notebookParams.notebookUri, false);
|
|
||||||
this._navProvider.getNavigation(this._notebookParams.notebookUri).then(result => {
|
this._navProvider.getNavigation(this._notebookParams.notebookUri).then(result => {
|
||||||
this.navigationResult = result;
|
this.navigationResult = result;
|
||||||
this.addButton(localize('previousButtonLabel', "< Previous"),
|
this.addButton(localize('previousButtonLabel', "< Previous"),
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import { INotebookService } from 'sql/workbench/services/notebook/browser/notebo
|
|||||||
import { Emitter } from 'vs/base/common/event';
|
import { Emitter } from 'vs/base/common/event';
|
||||||
import { Registry } from 'vs/platform/registry/common/platform';
|
import { Registry } from 'vs/platform/registry/common/platform';
|
||||||
import { NotebookProviderRegistration, INotebookProviderRegistry, Extensions } from 'sql/workbench/services/notebook/common/notebookRegistry';
|
import { NotebookProviderRegistration, INotebookProviderRegistry, Extensions } from 'sql/workbench/services/notebook/common/notebookRegistry';
|
||||||
|
import { MockContextKeyService } from 'vs/platform/keybinding/test/common/mockKeybindingService';
|
||||||
|
|
||||||
suite('Notebook Service Tests', function (): void {
|
suite('Notebook Service Tests', function (): void {
|
||||||
let notebookService: INotebookService;
|
let notebookService: INotebookService;
|
||||||
@@ -31,6 +32,7 @@ suite('Notebook Service Tests', function (): void {
|
|||||||
const extensionService = new TestExtensionService();
|
const extensionService = new TestExtensionService();
|
||||||
const fileService = new TestFileService();
|
const fileService = new TestFileService();
|
||||||
const logService = new NullLogService();
|
const logService = new NullLogService();
|
||||||
|
const contextService = new MockContextKeyService();
|
||||||
const queryManagementService = new NBTestQueryManagementService();
|
const queryManagementService = new NBTestQueryManagementService();
|
||||||
|
|
||||||
const instantiationService = new TestInstantiationService();
|
const instantiationService = new TestInstantiationService();
|
||||||
@@ -47,7 +49,7 @@ suite('Notebook Service Tests', function (): void {
|
|||||||
instantiationService.stub(IExtensionManagementService, 'onDidUninstallExtension', didUninstallEvent.event);
|
instantiationService.stub(IExtensionManagementService, 'onDidUninstallExtension', didUninstallEvent.event);
|
||||||
const extensionManagementService = instantiationService.get(IExtensionManagementService);
|
const extensionManagementService = instantiationService.get(IExtensionManagementService);
|
||||||
|
|
||||||
notebookService = new NotebookService(lifecycleService, storageService, extensionService, extensionManagementService, instantiationService, fileService, logService, queryManagementService);
|
notebookService = new NotebookService(lifecycleService, storageService, extensionService, extensionManagementService, instantiationService, fileService, logService, queryManagementService, contextService);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Validate default properties on create', async function (): Promise<void> {
|
test('Validate default properties on create', async function (): Promise<void> {
|
||||||
|
|||||||
@@ -34,6 +34,16 @@ export interface ILanguageMagic {
|
|||||||
executionTarget?: string;
|
executionTarget?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Valid navigation providers.
|
||||||
|
*/
|
||||||
|
export enum NavigationProviders {
|
||||||
|
NotebooksNavigator = 'BookNavigator.Notebooks',
|
||||||
|
ProvidedBooksNavigator = 'BookNavigator.ProvidedBooks'
|
||||||
|
}
|
||||||
|
|
||||||
|
export const unsavedBooksContextKey = 'unsavedBooks';
|
||||||
|
|
||||||
export interface INotebookService {
|
export interface INotebookService {
|
||||||
_serviceBrand: undefined;
|
_serviceBrand: undefined;
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import { Registry } from 'vs/platform/registry/common/platform';
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
INotebookService, INotebookManager, INotebookProvider,
|
INotebookService, INotebookManager, INotebookProvider,
|
||||||
DEFAULT_NOTEBOOK_FILETYPE, INotebookEditor, SQL_NOTEBOOK_PROVIDER, INavigationProvider, ILanguageMagic
|
DEFAULT_NOTEBOOK_FILETYPE, INotebookEditor, SQL_NOTEBOOK_PROVIDER, INavigationProvider, ILanguageMagic, NavigationProviders, unsavedBooksContextKey
|
||||||
} from 'sql/workbench/services/notebook/browser/notebookService';
|
} from 'sql/workbench/services/notebook/browser/notebookService';
|
||||||
import { RenderMimeRegistry } from 'sql/workbench/services/notebook/browser/outputs/registry';
|
import { RenderMimeRegistry } from 'sql/workbench/services/notebook/browser/outputs/registry';
|
||||||
import { standardRendererFactories } from 'sql/workbench/services/notebook/browser/outputs/factories';
|
import { standardRendererFactories } from 'sql/workbench/services/notebook/browser/outputs/factories';
|
||||||
@@ -36,6 +36,7 @@ import { NotebookChangeType } from 'sql/workbench/services/notebook/common/contr
|
|||||||
import { find, firstIndex } from 'vs/base/common/arrays';
|
import { find, firstIndex } from 'vs/base/common/arrays';
|
||||||
import { onUnexpectedError } from 'vs/base/common/errors';
|
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||||
import { notebookConstants } from 'sql/workbench/services/notebook/browser/interfaces';
|
import { notebookConstants } from 'sql/workbench/services/notebook/browser/interfaces';
|
||||||
|
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||||
|
|
||||||
export interface NotebookProviderProperties {
|
export interface NotebookProviderProperties {
|
||||||
provider: string;
|
provider: string;
|
||||||
@@ -115,7 +116,8 @@ export class NotebookService extends Disposable implements INotebookService {
|
|||||||
@IInstantiationService private _instantiationService: IInstantiationService,
|
@IInstantiationService private _instantiationService: IInstantiationService,
|
||||||
@IFileService private readonly _fileService: IFileService,
|
@IFileService private readonly _fileService: IFileService,
|
||||||
@ILogService private readonly _logService: ILogService,
|
@ILogService private readonly _logService: ILogService,
|
||||||
@IQueryManagementService private readonly _queryManagementService: IQueryManagementService
|
@IQueryManagementService private readonly _queryManagementService: IQueryManagementService,
|
||||||
|
@IContextKeyService private contextKeyService: IContextKeyService,
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
this._providersMemento = new Memento('notebookProviders', this._storageService);
|
this._providersMemento = new Memento('notebookProviders', this._storageService);
|
||||||
@@ -220,7 +222,11 @@ export class NotebookService extends Disposable implements INotebookService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getNavigationProvider(): INavigationProvider {
|
getNavigationProvider(): INavigationProvider {
|
||||||
let provider = this._navigationProviders.size > 0 ? this._navigationProviders.values().next().value : undefined;
|
let provider;
|
||||||
|
if (this._navigationProviders.size > 0) {
|
||||||
|
const providerName = this.contextKeyService.getContextKeyValue(unsavedBooksContextKey) ? NavigationProviders.ProvidedBooksNavigator : NavigationProviders.NotebooksNavigator;
|
||||||
|
provider = this._navigationProviders.get(providerName);
|
||||||
|
}
|
||||||
return provider;
|
return provider;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user