Books/viewlet refactor (#7208)

* add saved/untitled views to the books viewlet and provide save option to untitled

* addressed comments

* fixes after merge

* await on async methods

* reverted back

* await on promise

* added localize for books view names

* initial commit

* missed a file change

* changes to make the merges work part1

* fixes after merges 2

* getChildren to get all books

* chnages to address comments

* fsPromises instead of fs.readSync

* merged master

* replaced deprecated fs.exists async call with pathExists

* renamed method
This commit is contained in:
Maddy
2019-09-20 10:47:33 -07:00
committed by GitHub
parent 1f61a2581c
commit ac6a4e590d
12 changed files with 439 additions and 242 deletions

View File

@@ -24,6 +24,7 @@ export interface BookTreeItemFormat {
page: any;
type: BookTreeItemType;
treeItemCollapsibleState: number;
isUntitled: boolean;
}
export class BookTreeItem extends vscode.TreeItem {
@@ -39,6 +40,9 @@ export class BookTreeItem extends vscode.TreeItem {
if (book.type === BookTreeItemType.Book) {
this.collapsibleState = book.treeItemCollapsibleState;
this._sections = book.page;
if (book.isUntitled) {
this.contextValue = 'untitledBook';
}
} else {
this.setPageVariables();
this.setCommand();
@@ -63,12 +67,12 @@ export class BookTreeItem extends vscode.TreeItem {
private setCommand() {
if (this.book.type === BookTreeItemType.Notebook) {
let pathToNotebook = path.join(this.book.root, 'content', this._uri.concat('.ipynb'));
this.command = { command: 'bookTreeView.openNotebook', title: localize('openNotebookCommand', 'Open Notebook'), arguments: [pathToNotebook], };
this.command = { command: this.book.isUntitled ? 'bookTreeView.openUntitledNotebook' : 'bookTreeView.openNotebook', title: localize('openNotebookCommand', "Open Notebook"), arguments: [pathToNotebook], };
} else if (this.book.type === BookTreeItemType.Markdown) {
let pathToMarkdown = path.join(this.book.root, 'content', this._uri.concat('.md'));
this.command = { command: 'bookTreeView.openMarkdown', title: localize('openMarkdownCommand', 'Open Markdown'), arguments: [pathToMarkdown], };
this.command = { command: 'bookTreeView.openMarkdown', title: localize('openMarkdownCommand', "Open Markdown"), arguments: [pathToMarkdown], };
} else if (this.book.type === BookTreeItemType.ExternalLink) {
this.command = { command: 'bookTreeView.openExternalLink', title: localize('openExternalLinkCommand', 'Open External Link'), arguments: [this._uri], };
this.command = { command: 'bookTreeView.openExternalLink', title: localize('openExternalLinkCommand', "Open External Link"), arguments: [this._uri], };
}
}