Skip to content
Draft
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
94 changes: 89 additions & 5 deletions packages/databricks-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,44 @@
"command": "databricks.wsfs.refresh",
"title": "Refresh workspace filesystem view",
"icon": "$(refresh)",
"enablement": "databricks.context.activated && databricks.context.loggedIn && config.databricks.sync.destinationType == workspace && databricks.feature.views.workspace && !databricks.context.remoteMode",
"enablement": "databricks.context.activated && databricks.context.loggedIn && config.databricks.sync.destinationType == workspace && !databricks.context.remoteMode",
"category": "Databricks"
},
{
"command": "databricks.wsfs.createFolder",
"title": "Create Folder",
"icon": "$(new-folder)",
"enablement": "databricks.context.activated && databricks.context.loggedIn && databricks.feature.views.workspace && !databricks.context.remoteMode",
"enablement": "databricks.context.activated && databricks.context.loggedIn && !databricks.context.remoteMode",
"category": "Databricks"
},
{
"command": "databricks.wsfs.openInBrowser",
"title": "Open in Browser",
"icon": "$(link-external)",
"category": "Databricks"
},
{
"command": "databricks.wsfs.copyPath",
"title": "Copy Path",
"icon": "$(copy)",
"category": "Databricks"
},
{
"command": "databricks.wsfs.delete",
"title": "Delete",
"icon": "$(trash)",
"category": "Databricks"
},
{
"command": "databricks.wsfs.uploadFile",
"title": "Upload File",
"icon": "$(cloud-upload)",
"category": "Databricks"
},
{
"command": "databricks.wsfs.downloadFile",
"title": "Download",
"icon": "$(cloud-download)",
"category": "Databricks"
},
{
Expand All @@ -210,7 +240,6 @@
"icon": "$(gear)",
"title": "Select a Declarative Automation Bundle target",
"enablement": "databricks.context.activated && !databricks.context.remoteMode",

"category": "Databricks"
},
{
Expand Down Expand Up @@ -450,8 +479,8 @@
},
{
"id": "workspaceFsView",
"name": "Workspace explorer",
"when": "databricks.feature.views.workspace && !databricks.context.remoteMode"
"name": "Workspace file system",
"when": "!databricks.context.remoteMode"
},
{
"id": "databricksDocsView",
Expand Down Expand Up @@ -537,6 +566,11 @@
"when": "view == workspaceFsView",
"group": "navigation@1"
},
{
"command": "databricks.wsfs.uploadFile",
"when": "view == workspaceFsView",
"group": "navigation@1"
},
{
"command": "databricks.bundle.refreshRemoteState",
"when": "view == dabsResourceExplorerView && databricks.context.bundle.deploymentState == idle",
Expand Down Expand Up @@ -583,6 +617,36 @@
}
],
"view/item/context": [
{
"command": "databricks.wsfs.copyPath",
"when": "view == workspaceFsView && viewItem =~ /^wsfs\\./",
"group": "wsfs_nav@0"
},
{
"command": "databricks.wsfs.openInBrowser",
"when": "view == workspaceFsView && viewItem =~ /^wsfs\\./",
"group": "wsfs_nav@1"
},
{
"command": "databricks.wsfs.createFolder",
"when": "view == workspaceFsView && (viewItem == wsfs.directory || viewItem == wsfs.repo)",
"group": "wsfs_mut@0"
},
{
"command": "databricks.wsfs.uploadFile",
"when": "view == workspaceFsView && (viewItem == wsfs.directory || viewItem == wsfs.repo)",
"group": "wsfs_mut@1"
},
{
"command": "databricks.wsfs.downloadFile",
"when": "view == workspaceFsView && (viewItem == wsfs.file || viewItem == wsfs.notebook)",
"group": "wsfs_mut@0"
},
{
"command": "databricks.wsfs.delete",
"when": "view == workspaceFsView && viewItem =~ /^wsfs\\./",
"group": "wsfs_danger@0"
},
{
"command": "databricks.utils.openExternal",
"when": "viewItem =~ /^databricks.*\\.(has-url).*$/ && databricks.context.bundle.deploymentState == idle",
Expand Down Expand Up @@ -841,6 +905,26 @@
"command": "databricks.wsfs.refresh",
"when": "config.databricks.sync.destinationType == workspace"
},
{
"command": "databricks.wsfs.delete",
"when": "false"
},
{
"command": "databricks.wsfs.downloadFile",
"when": "false"
},
{
"command": "databricks.wsfs.copyPath",
"when": "false"
},
{
"command": "databricks.wsfs.openInBrowser",
"when": "false"
},
{
"command": "databricks.wsfs.uploadFile",
"when": "false"
},
{
"command": "databricks.utils.openExternal",
"when": "false"
Expand Down
40 changes: 37 additions & 3 deletions packages/databricks-vscode/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ import {
UtilsCommands,
} from "./utils";
import {ConfigureAutocomplete} from "./language/ConfigureAutocomplete";
import {WorkspaceFsCommands, WorkspaceFsDataProvider} from "./workspace-fs";
import {
WorkspaceFsCommands,
WorkspaceFsDataProvider,
WorkspaceFsFileSystemProvider,
} from "./workspace-fs";
import {CustomWhenContext} from "./vscode-objs/CustomWhenContext";
import {StateStorage} from "./vscode-objs/StateStorage";
import path from "node:path";
Expand Down Expand Up @@ -265,7 +269,6 @@ export async function activate(
// manage contexts for experimental features
function updateFeatureContexts() {
customWhenContext.updateShowClusterView();
customWhenContext.updateShowWorkspaceView();
}

function updateStrictSSLEnv() {
Expand Down Expand Up @@ -382,13 +385,19 @@ export async function activate(
const workspaceFsDataProvider = new WorkspaceFsDataProvider(
connectionManager
);
const workspaceFsFsp = new WorkspaceFsFileSystemProvider(connectionManager);
const workspaceFsCommands = new WorkspaceFsCommands(
workspaceFolderManager,
connectionManager,
workspaceFsDataProvider
workspaceFsDataProvider,
workspaceFsFsp
);

context.subscriptions.push(
workspace.registerFileSystemProvider("wsfs", workspaceFsFsp, {
isCaseSensitive: true,
}),
workspaceFsFsp,
window.registerTreeDataProvider(
"workspaceFsView",
workspaceFsDataProvider
Expand All @@ -402,6 +411,31 @@ export async function activate(
"databricks.wsfs.createFolder",
workspaceFsCommands.createFolder,
workspaceFsCommands
),
telemetry.registerCommand(
"databricks.wsfs.openInBrowser",
workspaceFsCommands.openInBrowser,
workspaceFsCommands
),
telemetry.registerCommand(
"databricks.wsfs.copyPath",
workspaceFsCommands.copyPath,
workspaceFsCommands
),
telemetry.registerCommand(
"databricks.wsfs.delete",
workspaceFsCommands.deleteItem,
workspaceFsCommands
),
telemetry.registerCommand(
"databricks.wsfs.uploadFile",
workspaceFsCommands.uploadFile,
workspaceFsCommands
),
telemetry.registerCommand(
"databricks.wsfs.downloadFile",
workspaceFsCommands.downloadFile,
workspaceFsCommands
)
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {isDirectory, isFile} from "./utils";

export class WorkspaceFsDir extends WorkspaceFsEntity {
override async generateUrl(host: URL): Promise<string> {
return `${host.host}/browse/folders/${this.details.object_id}`;
return `${host.origin}/browse/folders/${this.details.object_id}`;
}

public getAbsoluteChildPath(path: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,14 @@ export abstract class WorkspaceFsEntity {
get basename(): string {
return posix.basename(this.path);
}

@withLogContext(ExposedLoggers.SDK)
async delete(recursive = false, @context ctx?: Context): Promise<void> {
await this._workspaceFsService.delete(
{path: this.path, recursive},
ctx
);
}
}

async function entityFromObjInfo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,15 @@ export class WorkspaceFsFile extends WorkspaceFsEntity {
}

override async generateUrl(host: URL): Promise<string> {
return `${host.host}#folder/${(await this.parent)?.id ?? ""}`;
return `${host.origin}/editor/files/${this.details.object_id}`;
}

async readContent(): Promise<Uint8Array> {
const result = await this._workspaceFsService.export({
path: this.path,
format: "AUTO",
});
return Buffer.from(result.content ?? "", "base64");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
const ViewSectionTypes = [
"CLUSTERS",
"CONFIGURATION",
"WORKSPACE EXPLORER",
"WORKSPACE FILE SYSTEM",
"BUNDLE RESOURCE EXPLORER",
"BUNDLE VARIABLES",
"DOCUMENTATION",
Expand Down
10 changes: 0 additions & 10 deletions packages/databricks-vscode/src/vscode-objs/CustomWhenContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,6 @@ export class CustomWhenContext {
);
}

updateShowWorkspaceView() {
commands.executeCommand(
"setContext",
"databricks.feature.views.workspace",
workspaceConfigs.experimetalFeatureOverides.includes(
"views.workspace"
)
);
}

setIsActiveFileInActiveWorkspace(value: boolean) {
commands.executeCommand(
"setContext",
Expand Down
Loading
Loading