mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
Search sections in Jupyter Viewlet (#9346)
This commit is contained in:
@@ -293,11 +293,6 @@
|
|||||||
"when": "nodeType=~/^mssqlCluster/ && nodeLabel=~/[^\\s]+(\\.(csv|tsv|txt))$/ && nodeType == mssqlCluster:file",
|
"when": "nodeType=~/^mssqlCluster/ && nodeLabel=~/[^\\s]+(\\.(csv|tsv|txt))$/ && nodeType == mssqlCluster:file",
|
||||||
"group": "1notebook@1"
|
"group": "1notebook@1"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"command": "jupyter.cmd.newNotebook",
|
|
||||||
"when": "connectionProvider == HADOOP_KNOX && nodeType && nodeType == Server",
|
|
||||||
"group": "1root@1"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"command": "jupyter.cmd.analyzeNotebook",
|
"command": "jupyter.cmd.analyzeNotebook",
|
||||||
"when": "nodeType=~/^hdfs/ && nodeLabel=~/[^\\s]+(\\.(csv|tsv|txt))$/ && nodeType == hdfs:file",
|
"when": "nodeType=~/^hdfs/ && nodeLabel=~/[^\\s]+(\\.(csv|tsv|txt))$/ && nodeType == hdfs:file",
|
||||||
@@ -307,7 +302,7 @@
|
|||||||
"view/item/context": [
|
"view/item/context": [
|
||||||
{
|
{
|
||||||
"command": "notebook.command.searchBook",
|
"command": "notebook.command.searchBook",
|
||||||
"when": "view == bookTreeView && viewItem == savedBook",
|
"when": "view == bookTreeView && viewItem == savedBook || viewItem == section",
|
||||||
"group": "inline"
|
"group": "inline"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -398,7 +393,6 @@
|
|||||||
"name": "pysparkkernel",
|
"name": "pysparkkernel",
|
||||||
"displayName": "PySpark",
|
"displayName": "PySpark",
|
||||||
"connectionProviderIds": [
|
"connectionProviderIds": [
|
||||||
"HADOOP_KNOX",
|
|
||||||
"MSSQL"
|
"MSSQL"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -406,7 +400,6 @@
|
|||||||
"name": "sparkkernel",
|
"name": "sparkkernel",
|
||||||
"displayName": "Spark | Scala",
|
"displayName": "Spark | Scala",
|
||||||
"connectionProviderIds": [
|
"connectionProviderIds": [
|
||||||
"HADOOP_KNOX",
|
|
||||||
"MSSQL"
|
"MSSQL"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -414,7 +407,6 @@
|
|||||||
"name": "sparkrkernel",
|
"name": "sparkrkernel",
|
||||||
"displayName": "Spark | R",
|
"displayName": "Spark | R",
|
||||||
"connectionProviderIds": [
|
"connectionProviderIds": [
|
||||||
"HADOOP_KNOX",
|
|
||||||
"MSSQL"
|
"MSSQL"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -45,6 +45,9 @@ export class BookTreeItem extends vscode.TreeItem {
|
|||||||
this.contextValue = 'savedBook';
|
this.contextValue = 'savedBook';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (book.type === BookTreeItemType.Markdown && book.page.expand_sections) {
|
||||||
|
this.contextValue = 'section';
|
||||||
|
}
|
||||||
this.setPageVariables();
|
this.setPageVariables();
|
||||||
this.setCommand();
|
this.setCommand();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ import { BookModel } from './bookModel';
|
|||||||
import { Deferred } from '../common/promise';
|
import { Deferred } from '../common/promise';
|
||||||
import * as loc from '../common/localizedConstants';
|
import * as loc from '../common/localizedConstants';
|
||||||
|
|
||||||
|
const Content = 'content';
|
||||||
|
|
||||||
export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeItem> {
|
export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeItem> {
|
||||||
|
|
||||||
private _onDidChangeTreeData: vscode.EventEmitter<BookTreeItem | undefined> = new vscode.EventEmitter<BookTreeItem | undefined>();
|
private _onDidChangeTreeData: vscode.EventEmitter<BookTreeItem | undefined> = new vscode.EventEmitter<BookTreeItem | undefined>();
|
||||||
@@ -94,9 +96,9 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
|
|||||||
const bookRoot = this.currentBook.bookItems[0];
|
const bookRoot = this.currentBook.bookItems[0];
|
||||||
const sectionToOpen = bookRoot.findChildSection(urlToOpen);
|
const sectionToOpen = bookRoot.findChildSection(urlToOpen);
|
||||||
const urlPath = sectionToOpen ? sectionToOpen.url : bookRoot.tableOfContents.sections[0].url;
|
const urlPath = sectionToOpen ? sectionToOpen.url : bookRoot.tableOfContents.sections[0].url;
|
||||||
const sectionToOpenMarkdown: string = path.join(this.currentBook.bookPath, 'content', urlPath.concat('.md'));
|
const sectionToOpenMarkdown: string = path.join(this.currentBook.bookPath, Content, urlPath.concat('.md'));
|
||||||
// The Notebook editor expects a posix path for the resource (it will still resolve to the correct fsPath based on OS)
|
// The Notebook editor expects a posix path for the resource (it will still resolve to the correct fsPath based on OS)
|
||||||
const sectionToOpenNotebook: string = path.posix.join(this.currentBook.bookPath, 'content', urlPath.concat('.ipynb'));
|
const sectionToOpenNotebook: string = path.posix.join(this.currentBook.bookPath, Content, urlPath.concat('.ipynb'));
|
||||||
if (await fs.pathExists(sectionToOpenMarkdown)) {
|
if (await fs.pathExists(sectionToOpenMarkdown)) {
|
||||||
this.openMarkdown(sectionToOpenMarkdown);
|
this.openMarkdown(sectionToOpenMarkdown);
|
||||||
}
|
}
|
||||||
@@ -189,9 +191,13 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async searchJupyterBooks(): Promise<void> {
|
public async searchJupyterBooks(treeItem?: BookTreeItem): Promise<void> {
|
||||||
if (this.currentBook && this.currentBook.bookPath) {
|
if (this.currentBook && this.currentBook.bookPath) {
|
||||||
let filesToIncludeFiltered = path.join(this.currentBook.bookPath, '**', '*.md') + ',' + path.join(this.currentBook.bookPath, '**', '*.ipynb');
|
let folderToSearch = this.currentBook.bookPath;
|
||||||
|
if (treeItem && treeItem.uri) {
|
||||||
|
folderToSearch = path.join(folderToSearch, Content, path.dirname(treeItem.uri));
|
||||||
|
}
|
||||||
|
let filesToIncludeFiltered = path.join(folderToSearch, '**', '*.md') + ',' + path.join(folderToSearch, '**', '*.ipynb');
|
||||||
vscode.commands.executeCommand('workbench.action.findInFiles', { filesToInclude: filesToIncludeFiltered, query: '' });
|
vscode.commands.executeCommand('workbench.action.findInFiles', { filesToInclude: filesToIncludeFiltered, query: '' });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -272,7 +278,7 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
|
|||||||
if (element) {
|
if (element) {
|
||||||
let parentPath;
|
let parentPath;
|
||||||
if (element.root.endsWith('.md')) {
|
if (element.root.endsWith('.md')) {
|
||||||
parentPath = path.join(this.currentBook.bookPath, 'content', 'readme.md');
|
parentPath = path.join(this.currentBook.bookPath, Content, 'readme.md');
|
||||||
if (parentPath === element.root) {
|
if (parentPath === element.root) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ export async function activate(extensionContext: vscode.ExtensionContext): Promi
|
|||||||
extensionContext.subscriptions.push(vscode.commands.registerCommand('bookTreeView.openMarkdown', (resource) => bookTreeViewProvider.openMarkdown(resource)));
|
extensionContext.subscriptions.push(vscode.commands.registerCommand('bookTreeView.openMarkdown', (resource) => bookTreeViewProvider.openMarkdown(resource)));
|
||||||
extensionContext.subscriptions.push(vscode.commands.registerCommand('bookTreeView.openExternalLink', (resource) => bookTreeViewProvider.openExternalLink(resource)));
|
extensionContext.subscriptions.push(vscode.commands.registerCommand('bookTreeView.openExternalLink', (resource) => bookTreeViewProvider.openExternalLink(resource)));
|
||||||
extensionContext.subscriptions.push(vscode.commands.registerCommand('notebook.command.saveBook', () => untitledBookTreeViewProvider.saveJupyterBooks()));
|
extensionContext.subscriptions.push(vscode.commands.registerCommand('notebook.command.saveBook', () => untitledBookTreeViewProvider.saveJupyterBooks()));
|
||||||
extensionContext.subscriptions.push(vscode.commands.registerCommand('notebook.command.searchBook', () => bookTreeViewProvider.searchJupyterBooks()));
|
extensionContext.subscriptions.push(vscode.commands.registerCommand('notebook.command.searchBook', (item) => bookTreeViewProvider.searchJupyterBooks(item)));
|
||||||
extensionContext.subscriptions.push(vscode.commands.registerCommand('notebook.command.searchUntitledBook', () => untitledBookTreeViewProvider.searchJupyterBooks()));
|
extensionContext.subscriptions.push(vscode.commands.registerCommand('notebook.command.searchUntitledBook', () => untitledBookTreeViewProvider.searchJupyterBooks()));
|
||||||
extensionContext.subscriptions.push(vscode.commands.registerCommand('notebook.command.openBook', () => bookTreeViewProvider.openNewBook()));
|
extensionContext.subscriptions.push(vscode.commands.registerCommand('notebook.command.openBook', () => bookTreeViewProvider.openNewBook()));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user