Create book dialog improvements (#14429)

* add improvements TODO on creating book experience

* fix create book to support a more complex folder structure

* replace \\ to a forward slash on windows

* address pr comments

* fix tests

* use the posix version of path.sep
This commit is contained in:
Barbara Valdez
2021-03-02 21:23:28 -08:00
committed by GitHub
parent 36e228ebf7
commit 3f0ca8b714
6 changed files with 89 additions and 73 deletions

View File

@@ -159,15 +159,15 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
const updateBook = this.books.find(book => book.bookPath === pickedBook.detail).bookItems[0];
if (updateBook) {
let bookSections = updateBook.sections;
while (bookSections?.length > 0) {
while (bookSections) {
bookOptions = [{ label: loc.labelAddToLevel, detail: pickedSection ? pickedSection.detail : '' }];
bookSections.forEach(section => {
if (section.sections) {
bookOptions.push({ label: section.title ? section.title : section.file, detail: section.file });
}
});
bookSections = [];
if (bookOptions.length > 1) {
bookSections = undefined;
if (bookOptions.length >= 1) {
pickedSection = await vscode.window.showQuickPick(bookOptions, {
canPickMany: false,
placeHolder: loc.labelBookSection
@@ -186,16 +186,16 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
}
}
}
return { quickPickSection: pickedSection, book: updateBook };
return pickedSection ? { quickPickSection: pickedSection, book: updateBook } : undefined;
}
return undefined;
}
async editBook(movingElement: BookTreeItem): Promise<void> {
const selectionResults = await this.getSelectionQuickPick(movingElement);
const pickedSection = selectionResults.quickPickSection;
const updateBook = selectionResults.book;
if (pickedSection && updateBook) {
if (selectionResults) {
const pickedSection = selectionResults.quickPickSection;
const updateBook = selectionResults.book;
const targetSection = pickedSection.detail !== undefined ? updateBook.findChildSection(pickedSection.detail) : undefined;
if (movingElement.tableOfContents.sections) {
if (movingElement.contextValue === 'savedNotebook') {