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
212 changes: 212 additions & 0 deletions packages/databricks-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,58 @@
"enablement": "databricks.context.activated && databricks.context.loggedIn && databricks.feature.views.workspace",
"category": "Databricks"
},
{
"command": "databricks.unityCatalog.filter",
"title": "Filter",
"icon": "$(search)",
"category": "Databricks"
},
{
"command": "databricks.unityCatalog.refresh",
"title": "Refresh Unity Catalog view",
"icon": "$(refresh)",
"enablement": "databricks.context.activated && databricks.context.loggedIn",
"category": "Databricks"
},
{
"command": "databricks.unityCatalog.copyStorageLocation",
"title": "Copy storage location",
"category": "Databricks"
},
{
"command": "databricks.unityCatalog.copyViewSql",
"title": "Copy view SQL",
"category": "Databricks"
},
{
"command": "databricks.unityCatalog.copyName",
"title": "Copy",
"category": "Databricks"
},
{
"command": "databricks.unityCatalog.refreshNode",
"title": "Refresh",
"icon": "$(refresh)",
"category": "Databricks"
},
{
"command": "databricks.unityCatalog.pinSchema",
"title": "Pin Schema",
"icon": "$(star-empty)",
"category": "Databricks"
},
{
"command": "databricks.unityCatalog.unpinSchema",
"title": "Unpin Schema",
"icon": "$(star-full)",
"category": "Databricks"
},
{
"command": "databricks.unityCatalog.openExternal",
"title": "Open in Databricks",
"icon": "$(link-external)",
"category": "Databricks"
},
{
"command": "databricks.call",
"title": "Call",
Expand Down Expand Up @@ -448,12 +500,107 @@
"name": "Workspace explorer",
"when": "databricks.feature.views.workspace"
},
{
"id": "unityCatalogView",
"name": "Unity Catalog",
"when": "databricks.context.activated && databricks.context.loggedIn"
},
{
"id": "databricksDocsView",
"name": "Documentation"
}
]
},
"colors": [
{
"id": "databricks.unityCatalog.catalog",
"description": "Icon color for Unity Catalog catalog nodes",
"defaults": {
"dark": "#9B6CF7",
"light": "#6B2FD4",
"highContrast": "#C586C0",
"highContrastLight": "#6B2FD4"
}
},
{
"id": "databricks.unityCatalog.schema",
"description": "Icon color for Unity Catalog schema nodes",
"defaults": {
"dark": "#0DB7C4",
"light": "#007A85",
"highContrast": "#4EC9B0",
"highContrastLight": "#007A85"
}
},
{
"id": "databricks.unityCatalog.table",
"description": "Icon color for Unity Catalog table nodes",
"defaults": {
"dark": "#FF6B2C",
"light": "#C84B0A",
"highContrast": "#FF6B2C",
"highContrastLight": "#C84B0A"
}
},
{
"id": "databricks.unityCatalog.volume",
"description": "Icon color for Unity Catalog volume nodes",
"defaults": {
"dark": "#4FC1E9",
"light": "#0E6FA0",
"highContrast": "#4FC1E9",
"highContrastLight": "#0E6FA0"
}
},
{
"id": "databricks.unityCatalog.function",
"description": "Icon color for Unity Catalog function nodes",
"defaults": {
"dark": "#FFB347",
"light": "#A06000",
"highContrast": "#FFCA28",
"highContrastLight": "#A06000"
}
},
{
"id": "databricks.unityCatalog.columnKey",
"description": "Icon color for Unity Catalog non-nullable (key) column nodes",
"defaults": {
"dark": "#F47C7C",
"light": "#C0392B",
"highContrast": "#F47C7C",
"highContrastLight": "#C0392B"
}
},
{
"id": "databricks.unityCatalog.column",
"description": "Icon color for Unity Catalog nullable column nodes",
"defaults": {
"dark": "#8EAFC2",
"light": "#4A6B82",
"highContrast": "#8EAFC2",
"highContrastLight": "#4A6B82"
}
},
{
"id": "databricks.unityCatalog.registeredModel",
"description": "Color for registered model nodes in the Unity Catalog view",
"defaults": {
"dark": "#C586C0",
"light": "#AF00DB",
"highContrast": "#C586C0"
}
},
{
"id": "databricks.unityCatalog.modelVersion",
"description": "Color for model version nodes in the Unity Catalog view",
"defaults": {
"dark": "#B5CEA8",
"light": "#008000",
"highContrast": "#B5CEA8"
}
}
],
"viewsWelcome": [
{
"view": "configurationView",
Expand Down Expand Up @@ -531,6 +678,16 @@
"when": "view == workspaceFsView",
"group": "navigation@1"
},
{
"command": "databricks.unityCatalog.filter",
"when": "view == unityCatalogView",
"group": "navigation@2"
},
{
"command": "databricks.unityCatalog.refresh",
"when": "view == unityCatalogView",
"group": "navigation@1"
},
{
"command": "databricks.bundle.refreshRemoteState",
"when": "view == dabsResourceExplorerView && databricks.context.bundle.deploymentState == idle",
Expand Down Expand Up @@ -587,6 +744,61 @@
"when": "viewItem =~ /^databricks.*\\.(has-url).*$/ && databricks.context.bundle.deploymentState == idle",
"group": "navigation_2@0"
},
{
"command": "databricks.unityCatalog.openExternal",
"when": "view == unityCatalogView && viewItem =~ /\\.has-url/",
"group": "inline@1"
},
{
"command": "databricks.unityCatalog.openExternal",
"when": "view == unityCatalogView && viewItem =~ /\\.has-url/",
"group": "navigation_2@0"
},
{
"command": "databricks.unityCatalog.copyName",
"when": "view == unityCatalogView && viewItem =~ /unityCatalog/",
"group": "navigation_2@0"
},
{
"command": "databricks.unityCatalog.copyStorageLocation",
"when": "view == unityCatalogView && viewItem =~ /\\.has-storage/",
"group": "navigation_2@1"
},
{
"command": "databricks.unityCatalog.copyViewSql",
"when": "view == unityCatalogView && viewItem =~ /\\.is-view/",
"group": "navigation_2@2"
},
{
"command": "databricks.unityCatalog.refreshNode",
"when": "view == unityCatalogView && viewItem =~ /^unityCatalog\\.(?!column)/",
"group": "navigation_2@3"
},
{
"command": "databricks.unityCatalog.refreshNode",
"when": "view == unityCatalogView && viewItem =~ /^unityCatalog\\.(?!column)/",
"group": "inline@2"
},
{
"command": "databricks.unityCatalog.pinSchema",
"when": "view == unityCatalogView && viewItem =~ /^unityCatalog\\.schema/ && !(viewItem =~ /\\.is-pinned/)",
"group": "inline@3"
},
{
"command": "databricks.unityCatalog.unpinSchema",
"when": "view == unityCatalogView && viewItem =~ /^unityCatalog\\.schema.*\\.is-pinned/",
"group": "inline@3"
},
{
"command": "databricks.unityCatalog.pinSchema",
"when": "view == unityCatalogView && viewItem =~ /^unityCatalog\\.schema/ && !(viewItem =~ /\\.is-pinned/)",
"group": "navigation_2@4"
},
{
"command": "databricks.unityCatalog.unpinSchema",
"when": "view == unityCatalogView && viewItem =~ /^unityCatalog\\.schema.*\\.is-pinned/",
"group": "navigation_2@4"
},
{
"command": "databricks.utils.goToDefinition",
"when": "viewItem =~ /^databricks.*\\.(has-source-location).*$/",
Expand Down
100 changes: 100 additions & 0 deletions packages/databricks-vscode/src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
commands,
debug,
env,
ExtensionContext,
extensions,
window,
Expand All @@ -26,6 +27,7 @@ import {
FileUtils,
PackageJsonUtils,
TerraformUtils,
UrlUtils,
UtilsCommands,
} from "./utils";
import {ConfigureAutocomplete} from "./language/ConfigureAutocomplete";
Expand Down Expand Up @@ -74,6 +76,10 @@ import {SyncCommands} from "./sync/SyncCommands";
import {CodeSynchronizer} from "./sync";
import {BundlePipelinesManager} from "./bundle/BundlePipelinesManager";
import {DocsViewTreeDataProvider} from "./ui/docs-view/DocsViewTreeDataProvider";
import {
UnityCatalogTreeDataProvider,
UnityCatalogTreeNode,
} from "./ui/unity-catalog/UnityCatalogTreeDataProvider";

// eslint-disable-next-line @typescript-eslint/no-var-requires
const packageJson = require("../package.json");
Expand Down Expand Up @@ -370,6 +376,100 @@ export async function activate(
)
);

const unityCatalogTreeDataProvider = new UnityCatalogTreeDataProvider(
connectionManager,
stateStorage
);
const unityCatalogTreeView = window.createTreeView("unityCatalogView", {
treeDataProvider: unityCatalogTreeDataProvider,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
filterOnType: true,
} as any);
context.subscriptions.push(
unityCatalogTreeDataProvider,
unityCatalogTreeView,
telemetry.registerCommand(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is already too big, let's consider moving the commands logic out of it.

"databricks.unityCatalog.refresh",
unityCatalogTreeDataProvider.refresh,
unityCatalogTreeDataProvider
),
telemetry.registerCommand(
"databricks.unityCatalog.refreshNode",
(node: UnityCatalogTreeNode) =>
unityCatalogTreeDataProvider.refreshNode(node)
),
telemetry.registerCommand(
"databricks.unityCatalog.copyStorageLocation",
async (node: UnityCatalogTreeNode) => {
if (
(node.kind === "table" || node.kind === "volume") &&
node.storageLocation
) {
await env.clipboard.writeText(node.storageLocation);
}
}
),
telemetry.registerCommand(
"databricks.unityCatalog.copyViewSql",
async (node: UnityCatalogTreeNode) => {
if (node.kind === "table" && node.viewDefinition) {
await env.clipboard.writeText(node.viewDefinition);
}
}
),
telemetry.registerCommand(
"databricks.unityCatalog.copyName",
async (node: UnityCatalogTreeNode) => {
if (node.kind === "error" || node.kind === "empty") {
return;
}
const text = node.kind === "column" ? node.name : node.fullName;
await env.clipboard.writeText(text);
window.showInformationMessage("Copied to clipboard");
}
),
telemetry.registerCommand(
"databricks.unityCatalog.openExternal",
async (node: UnityCatalogTreeNode) => {
if (node.kind === "error" || node.kind === "column") {
return;
}
const url =
unityCatalogTreeDataProvider.getNodeExploreUrl(node);
if (!url) {
window.showErrorMessage(
"Databricks: Can't open external link. No URL found."
);
return;
}
await UrlUtils.openExternal(url);
}
),
commands.registerCommand(
"databricks.unityCatalog.filter",
async () => {
await commands.executeCommand("unityCatalogView.focus");
await commands.executeCommand("list.find");
}
),
telemetry.registerCommand(
"databricks.unityCatalog.pinSchema",
(node: UnityCatalogTreeNode) => {
if (node.kind === "schema") {
return unityCatalogTreeDataProvider.pinSchema(node);
}
}
),
telemetry.registerCommand(
"databricks.unityCatalog.unpinSchema",
(node: UnityCatalogTreeNode) => {
if (node.kind === "schema") {
return unityCatalogTreeDataProvider.unpinSchema(node);
}
}
)
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another command idea: would it be useful to have "pin"/"star" action on schema level, with pinned items being at the top (in the sort order, or in a separate "pinned" node)?


const configureAutocomplete = new ConfigureAutocomplete(
context,
stateStorage,
Expand Down
Loading
Loading