mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Remove ApiWrapper from notebook extension (#11224)
* Remove ApiWrapper in notebook extension * delete file * Remove copyrights
This commit is contained in:
@@ -11,7 +11,6 @@ import * as fileServices from 'fs';
|
||||
import * as fs from 'fs-extra';
|
||||
import * as loc from '../common/localizedConstants';
|
||||
import { IJupyterBookToc, IJupyterBookSection } from '../contracts/content';
|
||||
import { ApiWrapper } from '../common/apiWrapper';
|
||||
|
||||
|
||||
const fsPromises = fileServices.promises;
|
||||
@@ -22,7 +21,6 @@ export class BookModel {
|
||||
private _tableOfContentsPath: string;
|
||||
|
||||
private _errorMessage: string;
|
||||
private apiWrapper: ApiWrapper = new ApiWrapper();
|
||||
|
||||
constructor(
|
||||
public readonly bookPath: string,
|
||||
@@ -130,7 +128,7 @@ export class BookModel {
|
||||
this._bookItems.push(book);
|
||||
} catch (e) {
|
||||
this._errorMessage = loc.readBookError(this.bookPath, e instanceof Error ? e.message : e);
|
||||
this.apiWrapper.showErrorMessage(this._errorMessage);
|
||||
vscode.window.showErrorMessage(this._errorMessage);
|
||||
}
|
||||
}
|
||||
return this._bookItems;
|
||||
@@ -216,7 +214,7 @@ export class BookModel {
|
||||
notebooks.push(markdown);
|
||||
} else {
|
||||
this._errorMessage = loc.missingFileError(sections[i].title);
|
||||
this.apiWrapper.showErrorMessage(this._errorMessage);
|
||||
vscode.window.showErrorMessage(this._errorMessage);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -15,7 +15,6 @@ import { BookModel } from './bookModel';
|
||||
import { Deferred } from '../common/promise';
|
||||
import { IBookTrustManager, BookTrustManager } from './bookTrustManager';
|
||||
import * as loc from '../common/localizedConstants';
|
||||
import { ApiWrapper } from '../common/apiWrapper';
|
||||
import * as glob from 'fast-glob';
|
||||
import { isNullOrUndefined } from 'util';
|
||||
import { debounce } from '../common/utils';
|
||||
@@ -43,14 +42,14 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
|
||||
public books: BookModel[];
|
||||
public currentBook: BookModel;
|
||||
|
||||
constructor(private _apiWrapper: ApiWrapper, workspaceFolders: vscode.WorkspaceFolder[], extensionContext: vscode.ExtensionContext, openAsUntitled: boolean, view: string, public providerId: string) {
|
||||
constructor(workspaceFolders: vscode.WorkspaceFolder[], extensionContext: vscode.ExtensionContext, openAsUntitled: boolean, view: string, public providerId: string) {
|
||||
this._openAsUntitled = openAsUntitled;
|
||||
this._extensionContext = extensionContext;
|
||||
this.books = [];
|
||||
this.initialize(workspaceFolders).catch(e => console.error(e));
|
||||
this.viewId = view;
|
||||
this.prompter = new CodeAdapter();
|
||||
this._bookTrustManager = new BookTrustManager(this.books, _apiWrapper);
|
||||
this._bookTrustManager = new BookTrustManager(this.books);
|
||||
|
||||
this._extensionContext.subscriptions.push(azdata.nb.registerNavigationProvider(this));
|
||||
}
|
||||
@@ -83,7 +82,7 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
|
||||
if (bookPathToTrust) {
|
||||
let trustChanged = this._bookTrustManager.setBookAsTrusted(bookPathToTrust);
|
||||
if (trustChanged) {
|
||||
let notebookDocuments = this._apiWrapper.getNotebookDocuments();
|
||||
let notebookDocuments = azdata.nb.notebookDocuments;
|
||||
if (notebookDocuments) {
|
||||
// update trust state of opened items
|
||||
notebookDocuments.forEach(document => {
|
||||
@@ -93,9 +92,9 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
|
||||
}
|
||||
});
|
||||
}
|
||||
this._apiWrapper.showInfoMessage(loc.msgBookTrusted);
|
||||
vscode.window.showInformationMessage(loc.msgBookTrusted);
|
||||
} else {
|
||||
this._apiWrapper.showInfoMessage(loc.msgBookAlreadyTrusted);
|
||||
vscode.window.showInformationMessage(loc.msgBookAlreadyTrusted);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -178,7 +177,7 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
|
||||
if (!this.currentBook) {
|
||||
this.currentBook = book;
|
||||
}
|
||||
this._bookViewer = this._apiWrapper.createTreeView(this.viewId, { showCollapseAll: true, treeDataProvider: this });
|
||||
this._bookViewer = vscode.window.createTreeView(this.viewId, { showCollapseAll: true, treeDataProvider: this });
|
||||
this._bookViewer.onDidChangeVisibility(e => {
|
||||
let openDocument = azdata.nb.activeNotebookEditor;
|
||||
let notebookPath = openDocument?.document.uri;
|
||||
@@ -236,7 +235,7 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
|
||||
let notebookPath: string;
|
||||
// If no uri is passed in, try to use the current active notebook editor
|
||||
if (!uri) {
|
||||
let openDocument = this._apiWrapper.getActiveNotebookEditor();
|
||||
let openDocument = azdata.nb.activeNotebookEditor;
|
||||
if (openDocument) {
|
||||
notebookPath = openDocument.document.uri.fsPath;
|
||||
}
|
||||
@@ -514,7 +513,7 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
|
||||
type: confirm,
|
||||
message: loc.confirmReplace,
|
||||
default: false
|
||||
}, this._apiWrapper);
|
||||
});
|
||||
}
|
||||
|
||||
getNavigation(uri: vscode.Uri): Thenable<azdata.nb.NavigationResult> {
|
||||
|
||||
@@ -7,7 +7,6 @@ import * as vscode from 'vscode';
|
||||
import * as constants from './../common/constants';
|
||||
import { BookTreeItem } from './bookTreeItem';
|
||||
import { BookModel } from './bookModel';
|
||||
import { ApiWrapper } from '../common/apiWrapper';
|
||||
|
||||
export interface IBookTrustManager {
|
||||
isNotebookTrustedByDefault(notebookUri: string): boolean;
|
||||
@@ -20,7 +19,7 @@ enum TrustBookOperation {
|
||||
}
|
||||
|
||||
export class BookTrustManager implements IBookTrustManager {
|
||||
constructor(private books: BookModel[], private apiWrapper: ApiWrapper) { }
|
||||
constructor(private books: BookModel[]) { }
|
||||
|
||||
isNotebookTrustedByDefault(notebookUri: string): boolean {
|
||||
let normalizedNotebookUri: string = path.normalize(notebookUri);
|
||||
@@ -38,7 +37,7 @@ export class BookTrustManager implements IBookTrustManager {
|
||||
let bookPathsInConfig: string[] = this.getTrustedBookPathsInConfig();
|
||||
|
||||
if (this.hasWorkspaceFolders()) {
|
||||
let workspaceFolders = this.apiWrapper.getWorkspaceFolders();
|
||||
let workspaceFolders = vscode.workspace.workspaceFolders;
|
||||
|
||||
trustablePaths = bookPathsInConfig
|
||||
.map(trustableBookPath => workspaceFolders
|
||||
@@ -63,21 +62,21 @@ export class BookTrustManager implements IBookTrustManager {
|
||||
}
|
||||
|
||||
getTrustedBookPathsInConfig(): string[] {
|
||||
let config: vscode.WorkspaceConfiguration = this.apiWrapper.getConfiguration(constants.notebookConfigKey);
|
||||
let config: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration(constants.notebookConfigKey);
|
||||
let trustedBookDirectories: string[] = config.get(constants.trustedBooksConfigKey);
|
||||
|
||||
return trustedBookDirectories;
|
||||
}
|
||||
|
||||
setTrustedBookPathsInConfig(bookPaths: string[]) {
|
||||
let config: vscode.WorkspaceConfiguration = this.apiWrapper.getConfiguration(constants.notebookConfigKey);
|
||||
let config: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration(constants.notebookConfigKey);
|
||||
let storeInWorspace: boolean = this.hasWorkspaceFolders();
|
||||
|
||||
config.update(constants.trustedBooksConfigKey, bookPaths, storeInWorspace ? false : vscode.ConfigurationTarget.Global);
|
||||
}
|
||||
|
||||
hasWorkspaceFolders(): boolean {
|
||||
let workspaceFolders = this.apiWrapper.getWorkspaceFolders();
|
||||
let workspaceFolders = vscode.workspace.workspaceFolders;
|
||||
return workspaceFolders && workspaceFolders.length > 0;
|
||||
}
|
||||
|
||||
@@ -86,7 +85,7 @@ export class BookTrustManager implements IBookTrustManager {
|
||||
let bookPathToChange: string = path.join(bookPath, path.sep);
|
||||
|
||||
if (this.hasWorkspaceFolders()) {
|
||||
let workspaceFolders = this.apiWrapper.getWorkspaceFolders();
|
||||
let workspaceFolders = vscode.workspace.workspaceFolders;
|
||||
let matchingWorkspaceFolder: vscode.WorkspaceFolder = workspaceFolders
|
||||
.find(ws => bookPathToChange.startsWith(path.normalize(ws.uri.fsPath)));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user