Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rendering New Notebooks Panel using VS Code Task Provider #1784

Merged
merged 7 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,21 @@
"title": "Open Cloud Panel",
"category": "Runme",
"description": "Open Cloud Panel"
},
{
"command": "runme.openNotebook",
"title": "Open",
"icon": "$(preferences-open-settings)"
},
{
"command": "runme.runSelectedCell",
"title": "Run",
"icon": "$(play)"
},
{
"command": "runme.openSelectedCell",
"title": "Open",
"icon": "$(preferences-open-settings)"
}
],
"menus": {
Expand Down Expand Up @@ -617,6 +632,23 @@
"group": "navigation",
"when": "notebookType == runme && notebookMode != sessionOutputs && notebookCellType == 'code'"
}
],
"view/item/context": [
{
"command": "runme.openNotebook",
"when": "view == runme.launcher && viewItem == markdownNotebook",
"group": "inline"
},
{
"command": "runme.runSelectedCell",
"when": "view == runme.launcher && viewItem == markdownCell",
"group": "inline"
},
{
"command": "runme.openSelectedCell",
"when": "view == runme.launcher && viewItem == markdownCell",
"group": "inline"
}
]
},
"languages": [
Expand Down
36 changes: 27 additions & 9 deletions src/extension/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,33 @@ export class RunmeExtension {
let treeViewer: RunmeTreeProvider

if (kernel.isFeatureOn(FeatureName.NewTreeProvider)) {
await commands.executeCommand('setContext', 'runme.launcher.isExpanded', true)
await commands.executeCommand('setContext', 'runme.launcher.includeUnnamed', true)
treeViewer = new RunmeLauncherProviderBeta(
kernel,
server,
serializer,
getDefaultWorkspace(),
runner,
)
await commands.executeCommand('setContext', 'runme.launcher.isExpanded', false)
await commands.executeCommand('setContext', 'runme.launcher.includeUnnamed', false)
treeViewer = new RunmeLauncherProviderBeta(kernel, serializer)

if (treeViewer.openNotebook) {
context.subscriptions.push(
RunmeExtension.registerCommand(
'runme.openNotebook',
treeViewer.openNotebook.bind(treeViewer),
),
)
}

if (treeViewer.runCell) {
context.subscriptions.push(
RunmeExtension.registerCommand(
'runme.runSelectedCell',
treeViewer.runCell.bind(treeViewer),
),
)
}
if (treeViewer.openCell) {
RunmeExtension.registerCommand(
'runme.openSelectedCell',
treeViewer.openCell.bind(treeViewer),
)
}
} else {
treeViewer = new RunmeLauncherProvider(getDefaultWorkspace())
}
Expand Down
14 changes: 7 additions & 7 deletions src/extension/provider/codelens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,15 +214,15 @@ export class RunmeCodeLensProvider implements CodeLensProvider, Disposable {
break
}

const task = await RunmeTaskProvider.newRunmeTask(
document.uri.fsPath,
getAnnotations(cell.metadata).name,
const task = await RunmeTaskProvider.newRunmeTask({
filePath: document.uri.fsPath,
command: getAnnotations(cell.metadata).name,
notebook,
cell,
{},
this.runner!,
this.kernel?.getRunnerEnvironment(),
)
options: {},
runner: this.runner!,
runnerEnv: this.kernel?.getRunnerEnvironment(),
})

await tasks.executeTask(task)
}
Expand Down
13 changes: 13 additions & 0 deletions src/extension/provider/launcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ interface IRunmeFileProps {
description?: string
iconPath?: string | Uri | { light: string | Uri; dark: string | Uri } | ThemeIcon
resourceUri?: Uri
cellIndex?: number
parent?: string
documentPath?: string
}

interface TreeFile {
Expand All @@ -43,6 +46,10 @@ let i = 0
export const GLOB_PATTERN = '**/*.{md,mdr,mdx}'

export class RunmeFile extends TreeItem {
public readonly cellIndex: number | undefined
public readonly parent?: string
public readonly documentPath?: string

constructor(
public label: string,
options: IRunmeFileProps,
Expand All @@ -54,6 +61,9 @@ export class RunmeFile extends TreeItem {
this.contextValue = options.contextValue
this.description = options.description
this.resourceUri = options.resourceUri
this.cellIndex = options.cellIndex
this.parent = options.parent
this.documentPath = options.documentPath

if (options.iconPath) {
this.iconPath = options.iconPath
Expand All @@ -75,6 +85,9 @@ export interface RunmeTreeProvider extends TreeDataProvider<RunmeFile>, Disposab
collapseAll(): Promise<void>
expandAll(): Promise<void>
openFile(options: OpenFileOptions): Promise<void>
openNotebook?(runmeFile: RunmeFile): Promise<void>
openCell?(runmeFile: RunmeFile): Promise<void>
runCell?(runmeFile: RunmeFile): Promise<void>
}

export class RunmeLauncherProvider implements RunmeTreeProvider {
Expand Down
Loading