mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-04 17:23:45 -05:00
* fix search for pinned notebooks * fix filtering when verifying that a search folder is not a subdirectory from the current folder queries path * Show book node on pinned notebooks search results * fix parent node on pinned notebooks search results * fix search for pinned notebook and modify how pinned notebooks are stored in workspace * update format of pinned notebooks for users that used the september release version * removed unused functions * Address PR comments * fix parent node for legacy version of jupyter books * remove cast from book path
This commit is contained in:
@@ -325,16 +325,45 @@ export async function getRandomToken(size: number = 24): Promise<string> {
|
||||
}
|
||||
|
||||
export function isBookItemPinned(notebookPath: string): boolean {
|
||||
let pinnedNotebooks: string[] = getPinnedNotebooks();
|
||||
if (pinnedNotebooks?.indexOf(notebookPath) > -1) {
|
||||
let pinnedNotebooks: IBookNotebook[] = getPinnedNotebooks();
|
||||
if (pinnedNotebooks?.find(x => x.notebookPath === notebookPath)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function getPinnedNotebooks(): string[] {
|
||||
export function getPinnedNotebooks(): IBookNotebook[] {
|
||||
let config: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration(notebookConfigKey);
|
||||
let pinnedNotebooks: string[] = config.get(pinnedBooksConfigKey) ?? [];
|
||||
|
||||
return pinnedNotebooks;
|
||||
let pinnedNotebooks: [] = config.get(pinnedBooksConfigKey);
|
||||
let updateFormat: boolean = false;
|
||||
const pinnedBookDirectories = pinnedNotebooks.map(elem => {
|
||||
if (typeof (elem) === 'string') {
|
||||
updateFormat = true;
|
||||
return { notebookPath: elem, bookPath: '' };
|
||||
} else {
|
||||
return elem as IBookNotebook;
|
||||
}
|
||||
});
|
||||
if (updateFormat) {
|
||||
//Need to modify the format of how pinnedNotebooks are stored for users that used the September release version.
|
||||
setPinnedBookPathsInConfig(pinnedBookDirectories);
|
||||
}
|
||||
return pinnedBookDirectories;
|
||||
}
|
||||
|
||||
function hasWorkspaceFolders(): boolean {
|
||||
let workspaceFolders = vscode.workspace.workspaceFolders;
|
||||
return workspaceFolders && workspaceFolders.length > 0;
|
||||
}
|
||||
|
||||
export function setPinnedBookPathsInConfig(pinnedNotebookPaths: IBookNotebook[]) {
|
||||
let config: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration(notebookConfigKey);
|
||||
let storeInWorspace: boolean = hasWorkspaceFolders();
|
||||
|
||||
config.update(pinnedBooksConfigKey, pinnedNotebookPaths, storeInWorspace ? false : vscode.ConfigurationTarget.Global);
|
||||
}
|
||||
|
||||
export interface IBookNotebook {
|
||||
bookPath?: string;
|
||||
notebookPath: string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user