Remove book notebook from toc (#14704)

* Add remove notebook from book
This commit is contained in:
Barbara Valdez
2021-03-16 15:02:29 -07:00
committed by GitHub
parent ff766a8a14
commit 784d76b886
8 changed files with 94 additions and 29 deletions

View File

@@ -16,7 +16,7 @@ import { Deferred } from '../common/promise';
import { IBookTrustManager, BookTrustManager } from './bookTrustManager';
import * as loc from '../common/localizedConstants';
import * as glob from 'fast-glob';
import { getPinnedNotebooks, confirmReplace } from '../common/utils';
import { getPinnedNotebooks, confirmReplace, getNotebookType } from '../common/utils';
import { IBookPinManager, BookPinManager } from './bookPinManager';
import { BookTocManager, IBookTocManager, quickPickResults } from './bookTocManager';
import { CreateBookDialog } from '../dialog/createBookDialog';
@@ -131,7 +131,7 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
if (bookPathToUpdate) {
let pinStatusChanged = await this.bookPinManager.unpinNotebook(bookTreeItem);
if (pinStatusChanged) {
bookTreeItem.contextValue = 'savedNotebook';
bookTreeItem.contextValue = getNotebookType(bookTreeItem.book);
}
}
}
@@ -198,7 +198,7 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
const updateBook = selectionResults.book;
const targetSection = pickedSection.detail !== undefined ? updateBook.findChildSection(pickedSection.detail) : undefined;
if (movingElement.tableOfContents.sections) {
if (movingElement.contextValue === 'savedNotebook') {
if (movingElement.contextValue === 'savedNotebook' || movingElement.contextValue === 'savedBookNotebook') {
let sourceBook = this.books.find(book => book.getNotebook(path.normalize(movingElement.book.contentPath)));
movingElement.tableOfContents.sections = sourceBook?.bookItems[0].sections;
}
@@ -276,6 +276,10 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
}
}
async removeNotebook(bookItem: BookTreeItem): Promise<void> {
return this.bookTocManager.removeNotebook(bookItem);
}
async closeBook(book: BookTreeItem): Promise<void> {
// remove book from the saved books
let deletedBook: BookModel;