mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-31 17:23:31 -05:00
@@ -9,8 +9,8 @@ import { BookTreeItem } from './bookTreeItem';
|
||||
import { getPinnedNotebooks, setPinnedBookPathsInConfig, IBookNotebook } from '../common/utils';
|
||||
|
||||
export interface IBookPinManager {
|
||||
pinNotebook(notebook: BookTreeItem): boolean;
|
||||
unpinNotebook(notebook: BookTreeItem): boolean;
|
||||
pinNotebook(notebook: BookTreeItem): Promise<boolean>;
|
||||
unpinNotebook(notebook: BookTreeItem): Promise<boolean>;
|
||||
}
|
||||
|
||||
enum PinBookOperation {
|
||||
@@ -39,15 +39,15 @@ export class BookPinManager implements IBookPinManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
pinNotebook(notebook: BookTreeItem): boolean {
|
||||
return this.isNotebookPinned(notebook.book.contentPath) ? false : this.updatePinnedBooks(notebook, PinBookOperation.Pin);
|
||||
async pinNotebook(notebook: BookTreeItem): Promise<boolean> {
|
||||
return this.isNotebookPinned(notebook.book.contentPath) ? false : await this.updatePinnedBooks(notebook, PinBookOperation.Pin);
|
||||
}
|
||||
|
||||
unpinNotebook(notebook: BookTreeItem): boolean {
|
||||
return this.updatePinnedBooks(notebook, PinBookOperation.Unpin);
|
||||
async unpinNotebook(notebook: BookTreeItem): Promise<boolean> {
|
||||
return await this.updatePinnedBooks(notebook, PinBookOperation.Unpin);
|
||||
}
|
||||
|
||||
updatePinnedBooks(notebook: BookTreeItem, operation: PinBookOperation) {
|
||||
async updatePinnedBooks(notebook: BookTreeItem, operation: PinBookOperation): Promise<boolean> {
|
||||
let modifiedPinnedBooks = false;
|
||||
let bookPathToChange: string = notebook.book.contentPath;
|
||||
|
||||
@@ -63,9 +63,8 @@ export class BookPinManager implements IBookPinManager {
|
||||
modifiedPinnedBooks = true;
|
||||
}
|
||||
|
||||
setPinnedBookPathsInConfig(pinnedBooks);
|
||||
await setPinnedBookPathsInConfig(pinnedBooks);
|
||||
this.setPinnedSectionContext();
|
||||
|
||||
return modifiedPinnedBooks;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
|
||||
async pinNotebook(bookTreeItem: BookTreeItem): Promise<void> {
|
||||
let bookPathToUpdate = bookTreeItem.book?.contentPath;
|
||||
if (bookPathToUpdate) {
|
||||
let pinStatusChanged = this.bookPinManager.pinNotebook(bookTreeItem);
|
||||
let pinStatusChanged = await this.bookPinManager.pinNotebook(bookTreeItem);
|
||||
if (pinStatusChanged) {
|
||||
bookTreeItem.contextValue = 'pinnedNotebook';
|
||||
}
|
||||
@@ -127,7 +127,7 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
|
||||
async unpinNotebook(bookTreeItem: BookTreeItem): Promise<void> {
|
||||
let bookPathToUpdate = bookTreeItem.book?.contentPath;
|
||||
if (bookPathToUpdate) {
|
||||
let pinStatusChanged = this.bookPinManager.unpinNotebook(bookTreeItem);
|
||||
let pinStatusChanged = await this.bookPinManager.unpinNotebook(bookTreeItem);
|
||||
if (pinStatusChanged) {
|
||||
bookTreeItem.contextValue = 'savedNotebook';
|
||||
}
|
||||
|
||||
@@ -378,13 +378,14 @@ function hasWorkspaceFolders(): boolean {
|
||||
return workspaceFolders && workspaceFolders.length > 0;
|
||||
}
|
||||
|
||||
export function setPinnedBookPathsInConfig(pinnedNotebookPaths: IBookNotebook[]) {
|
||||
export async function setPinnedBookPathsInConfig(pinnedNotebookPaths: IBookNotebook[]): Promise<void> {
|
||||
let config: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration(notebookConfigKey);
|
||||
let storeInWorspace: boolean = hasWorkspaceFolders();
|
||||
|
||||
config.update(pinnedBooksConfigKey, pinnedNotebookPaths, storeInWorspace ? false : vscode.ConfigurationTarget.Global);
|
||||
await config.update(pinnedBooksConfigKey, pinnedNotebookPaths, storeInWorspace ? false : vscode.ConfigurationTarget.Global);
|
||||
}
|
||||
|
||||
|
||||
export interface IBookNotebook {
|
||||
bookPath?: string;
|
||||
notebookPath: string;
|
||||
|
||||
Reference in New Issue
Block a user