Skip to content

Commit e47593d

Browse files
authored
Add Documentation view (#1579)
## Changes The new view is positioned below the Configuration view. It contains a Quick Start Guide and links to various documentation pages. By default it's visible and expanded, but since it's a separate "view", users can close it, move it to a different place, or hide it completely. <img width="428" alt="Screenshot 2025-02-27 at 10 03 26" src="https://github.com/user-attachments/assets/41a06a91-7867-4529-aae5-9a44bd3d4aa9" /> And that how it looks with experimental views enabled: <img width="428" alt="Screenshot 2025-02-27 at 10 02 40" src="https://github.com/user-attachments/assets/aa5159ab-5bb5-49fc-8dc1-bb1b1858d025" /> ## Tests Manually
1 parent ea91e71 commit e47593d

File tree

6 files changed

+133
-6
lines changed

6 files changed

+133
-6
lines changed

packages/databricks-vscode/package.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,11 @@
419419
"id": "configurationView",
420420
"name": "Configuration"
421421
},
422+
{
423+
"id": "clusterView",
424+
"when": "databricks.feature.views.cluster",
425+
"name": "Clusters"
426+
},
422427
{
423428
"id": "dabsResourceExplorerView",
424429
"name": "Bundle Resource Explorer",
@@ -434,12 +439,11 @@
434439
{
435440
"id": "workspaceFsView",
436441
"name": "Workspace explorer",
437-
"when": "config.databricks.sync.destinationType == workspace && databricks.feature.views.workspace"
442+
"when": "databricks.feature.views.workspace"
438443
},
439444
{
440-
"id": "clusterView",
441-
"when": "databricks.feature.views.cluster",
442-
"name": "Clusters"
445+
"id": "databricksDocsView",
446+
"name": "Documentation"
443447
}
444448
]
445449
},

packages/databricks-vscode/src/configuration/DatabricksWorkspace.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export class DatabricksWorkspace {
2323

2424
get workspaceFsRoot(): RemoteUri {
2525
return new RemoteUri(
26-
Uri.from({scheme: "wsfs", path: `/Users/${this.userName}/.ide`})
26+
Uri.from({scheme: "wsfs", path: `/Users/${this.userName}`})
2727
);
2828
}
2929

packages/databricks-vscode/src/extension.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ import {WorkspaceFolderManager} from "./vscode-objs/WorkspaceFolderManager";
7373
import {SyncCommands} from "./sync/SyncCommands";
7474
import {CodeSynchronizer} from "./sync";
7575
import {BundlePipelinesManager} from "./bundle/BundlePipelinesManager";
76+
import {DocsViewTreeDataProvider} from "./ui/docs-view/DocsViewTreeDataProvider";
7677

7778
// eslint-disable-next-line @typescript-eslint/no-var-requires
7879
const packageJson = require("../package.json");
@@ -834,6 +835,15 @@ export async function activate(
834835
debugWorkflowFactory
835836
);
836837

838+
const docsViewTreeDataProvider = new DocsViewTreeDataProvider();
839+
context.subscriptions.push(
840+
window.registerTreeDataProvider(
841+
"databricksDocsView",
842+
docsViewTreeDataProvider
843+
),
844+
docsViewTreeDataProvider
845+
);
846+
837847
showQuickStartOnFirstUse(context).catch((e) => {
838848
logging.NamedLogger.getOrCreate("Extension").error(
839849
"Quick Start error",

packages/databricks-vscode/src/test/e2e/bundle_variables.e2e.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ describe("Bundle Variables", async function () {
158158
| CustomTreeSection
159159
| undefined;
160160
assert(section);
161+
await (await section.elem).click();
162+
161163
await waitForTreeItems(section, 5_000);
162164

163165
const action = await section.getAction(

packages/databricks-vscode/src/test/e2e/utils/commonUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const ViewSectionTypes = [
1515
"WORKSPACE EXPLORER",
1616
"BUNDLE RESOURCE EXPLORER",
1717
"BUNDLE VARIABLES",
18+
"DOCUMENTATION",
1819
] as const;
1920
export type ViewSectionType = (typeof ViewSectionTypes)[number];
2021

@@ -73,7 +74,6 @@ export async function getViewSection(
7374
}
7475

7576
await section!.expand();
76-
await (await section!.elem).click();
7777
return section;
7878
}
7979

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
import {
2+
Disposable,
3+
ThemeIcon,
4+
TreeDataProvider,
5+
TreeItem,
6+
TreeItemCollapsibleState,
7+
Uri,
8+
} from "vscode";
9+
import {logging} from "@databricks/databricks-sdk";
10+
import {Loggers} from "../../logger";
11+
12+
export interface DocsTreeItem extends TreeItem {
13+
id?: string;
14+
}
15+
16+
export class DocsViewTreeDataProvider
17+
implements TreeDataProvider<DocsTreeItem>, Disposable
18+
{
19+
constructor() {}
20+
21+
dispose() {}
22+
23+
getTreeItem(element: DocsTreeItem): TreeItem | Thenable<TreeItem> {
24+
return element;
25+
}
26+
27+
async getChildren(
28+
parent?: DocsTreeItem | undefined
29+
): Promise<Array<DocsTreeItem>> {
30+
try {
31+
return await this.getDocsChildren(parent);
32+
} catch (e) {
33+
logging.NamedLogger.getOrCreate(Loggers.Extension).error(
34+
`Error getting children for docs view`,
35+
e
36+
);
37+
return [];
38+
}
39+
}
40+
41+
private async getDocsChildren(
42+
parent?: DocsTreeItem | undefined
43+
): Promise<DocsTreeItem[]> {
44+
if (parent !== undefined) {
45+
return [];
46+
}
47+
48+
const quickStartItem = new TreeItem(
49+
"Quick Start Guide",
50+
TreeItemCollapsibleState.None
51+
);
52+
quickStartItem.iconPath = new ThemeIcon("preview");
53+
quickStartItem.command = {
54+
command: "databricks.quickstart.open",
55+
title: "Show Quick Start Guide",
56+
};
57+
58+
const items: DocsTreeItem[] = [quickStartItem];
59+
60+
const baseUrl = "https://docs.databricks.com/";
61+
const docLinks = [
62+
{
63+
label: "Setup authentication",
64+
path: "dev-tools/vscode-ext/authentication",
65+
},
66+
{
67+
label: "Configure your project",
68+
path: "dev-tools/vscode-ext/configure",
69+
},
70+
{
71+
label: "Work with Databricks Asset Bundles",
72+
path: "dev-tools/vscode-ext/bundles",
73+
},
74+
{
75+
label: "Run files on a cluster",
76+
path: "dev-tools/vscode-ext/run",
77+
},
78+
{
79+
label: "Run files with Databricks Connect",
80+
path: "dev-tools/vscode-ext/databricks-connect",
81+
},
82+
{
83+
label: "Run notebooks cell by cell",
84+
path: "dev-tools/vscode-ext/notebooks",
85+
},
86+
{
87+
label: "Run tests on a cluster",
88+
path: "dev-tools/vscode-ext/pytest",
89+
},
90+
{
91+
label: "Explore extension settings",
92+
path: "dev-tools/vscode-ext/settings",
93+
},
94+
{
95+
label: "Troubleshoot problems",
96+
path: "dev-tools/vscode-ext/troubleshooting",
97+
},
98+
];
99+
for (const doc of docLinks) {
100+
const item = new TreeItem(doc.label, TreeItemCollapsibleState.None);
101+
item.iconPath = new ThemeIcon("link");
102+
item.command = {
103+
command: "vscode.open",
104+
title: "Open URL",
105+
arguments: [Uri.parse(`${baseUrl}${doc.path}`)],
106+
};
107+
items.push(item);
108+
}
109+
return items;
110+
}
111+
}

0 commit comments

Comments
 (0)