mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-08 09:38:26 -05:00
Pinning Notebooks on Notebooks view (#11963)
* initial commit * added tests * code cleanup and more tests * add missed util test * changes to address comments * remove pin from resources
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
import * as vscode from 'vscode';
|
||||
import { NotebookUtils } from './notebookUtils';
|
||||
import { BookTreeViewProvider } from '../book/bookTreeView';
|
||||
import { NavigationProviders, BOOKS_VIEWID, PROVIDED_BOOKS_VIEWID, extensionOutputChannelName } from './constants';
|
||||
import { NavigationProviders, BOOKS_VIEWID, PROVIDED_BOOKS_VIEWID, PINNED_BOOKS_VIEWID, extensionOutputChannelName } from './constants';
|
||||
|
||||
/**
|
||||
* Global context for the application
|
||||
@@ -16,6 +16,7 @@ export class AppContext {
|
||||
public readonly notebookUtils: NotebookUtils;
|
||||
public readonly bookTreeViewProvider: BookTreeViewProvider;
|
||||
public readonly providedBookTreeViewProvider: BookTreeViewProvider;
|
||||
public readonly pinnedBookTreeViewProvider: BookTreeViewProvider;
|
||||
public readonly outputChannel: vscode.OutputChannel;
|
||||
|
||||
constructor(public readonly extensionContext: vscode.ExtensionContext) {
|
||||
@@ -24,6 +25,7 @@ export class AppContext {
|
||||
let workspaceFolders = vscode.workspace.workspaceFolders?.slice() ?? [];
|
||||
this.bookTreeViewProvider = new BookTreeViewProvider(workspaceFolders, extensionContext, false, BOOKS_VIEWID, NavigationProviders.NotebooksNavigator);
|
||||
this.providedBookTreeViewProvider = new BookTreeViewProvider([], extensionContext, true, PROVIDED_BOOKS_VIEWID, NavigationProviders.ProvidedBooksNavigator);
|
||||
this.pinnedBookTreeViewProvider = new BookTreeViewProvider([], extensionContext, false, PINNED_BOOKS_VIEWID, NavigationProviders.NotebooksNavigator);
|
||||
this.outputChannel = vscode.window.createOutputChannel(extensionOutputChannelName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ export const pythonPathConfigKey = 'pythonPath';
|
||||
export const existingPythonConfigKey = 'useExistingPython';
|
||||
export const notebookConfigKey = 'notebook';
|
||||
export const trustedBooksConfigKey = 'trustedBooks';
|
||||
export const pinnedBooksConfigKey = 'pinnedNotebooks';
|
||||
export const maxBookSearchDepth = 'maxBookSearchDepth';
|
||||
export const remoteBookDownloadTimeout = 'remoteBookDownloadTimeout';
|
||||
export const collapseBookItems = 'collapseBookItems';
|
||||
@@ -45,10 +46,13 @@ export const sparkScalaDisplayName = 'Spark | Scala';
|
||||
export const sparkRDisplayName = 'Spark | R';
|
||||
export const powershellDisplayName = 'PowerShell';
|
||||
export const allKernelsName = 'All Kernels';
|
||||
|
||||
export const BOOKS_VIEWID = 'bookTreeView';
|
||||
export const PROVIDED_BOOKS_VIEWID = 'providedBooksView';
|
||||
export const PINNED_BOOKS_VIEWID = 'pinnedBooksView';
|
||||
|
||||
export const visitedNotebooksMementoKey = 'notebooks.visited';
|
||||
export const pinnedNotebooksMementoKey = 'notebooks.pinned';
|
||||
|
||||
export enum BuiltInCommands {
|
||||
SetContext = 'setContext'
|
||||
@@ -69,6 +73,7 @@ export enum NavigationProviders {
|
||||
}
|
||||
|
||||
export const unsavedBooksContextKey = 'unsavedBooks';
|
||||
export const showPinnedBooksContextKey = 'showPinnedbooks';
|
||||
|
||||
export const pythonWindowsInstallUrl = 'https://go.microsoft.com/fwlink/?linkid=2110625';
|
||||
export const pythonMacInstallUrl = 'https://go.microsoft.com/fwlink/?linkid=2128152';
|
||||
|
||||
@@ -25,6 +25,8 @@ export const msgBookTrusted = localize('msgBookTrusted', "Book is now trusted in
|
||||
export const msgBookAlreadyTrusted = localize('msgBookAlreadyTrusted', "Book is already trusted in this workspace.");
|
||||
export const msgBookUntrusted = localize('msgBookUntrusted', "Book is no longer trusted in this workspace");
|
||||
export const msgBookAlreadyUntrusted = localize('msgBookAlreadyUntrusted', "Book is already untrusted in this workspace.");
|
||||
export function msgBookPinned(book: string): string { return localize('msgBookPinned', "Book {0} is now pinned in the workspace.", book); }
|
||||
export function msgBookUnpinned(book: string): string { return localize('msgBookUnpinned', "Book {0} is no longer pinned in this workspace", book); }
|
||||
export const missingTocError = localize('bookInitializeFailed', "Failed to find a Table of Contents file in the specified book.");
|
||||
export const noBooksSelectedError = localize('noBooksSelected', "No books are currently selected in the viewlet.");
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import * as nls from 'vscode-nls';
|
||||
import * as vscode from 'vscode';
|
||||
import * as azdata from 'azdata';
|
||||
import * as crypto from 'crypto';
|
||||
import { notebookLanguages } from './constants';
|
||||
import { notebookLanguages, notebookConfigKey, pinnedBooksConfigKey } from './constants';
|
||||
|
||||
const localize = nls.loadMessageBundle();
|
||||
|
||||
@@ -323,3 +323,18 @@ export async function getRandomToken(size: number = 24): Promise<string> {
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function isBookItemPinned(notebookPath: string): boolean {
|
||||
let pinnedNotebooks: string[] = getPinnedNotebooks();
|
||||
if (pinnedNotebooks?.indexOf(notebookPath) > -1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function getPinnedNotebooks(): string[] {
|
||||
let config: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration(notebookConfigKey);
|
||||
let pinnedNotebooks: string[] = config.get(pinnedBooksConfigKey) ?? [];
|
||||
|
||||
return pinnedNotebooks;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user