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