Skip to content

Commit

Permalink
Minor fixes for configurationView (#1031)
Browse files Browse the repository at this point in the history
## Changes
* Fix deeplinks for all configuration view entities. 
* For cluster and sync destination created after deploy, show "Created"
tag and tooltip "created after deploy".
* Show a notification saying "Loading databricks profiles", when calling
list profiles because it is slow and makes UI seem unresponsive.
* Don't show empty auth type in the profiles quickpick.

## Tests
<!-- How is this tested? -->
  • Loading branch information
kartikgupta-db authored Feb 5, 2024
1 parent 3682c76 commit 9f16b58
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 29 deletions.
2 changes: 1 addition & 1 deletion packages/databricks-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@
"view/item/context": [
{
"command": "databricks.utils.openExternal",
"when": "view == configurationView && viewItem =~ /^databricks.configuration.(cluster|sync).*$/",
"when": "viewItem =~ /^databricks.*\\.(has-url).*$/",
"group": "inline@1"
},
{
Expand Down
22 changes: 21 additions & 1 deletion packages/databricks-vscode/resources/light/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,15 @@ export class ConnectionCommands implements Disposable {
}

async configureLoginCommand() {
await this.connectionManager.configureLogin();
await window.withProgress(
{
location: {viewId: "configurationView"},
title: "Configuring Databricks login",
},
async () => {
await this.connectionManager.configureLogin();
}
);
}

openDatabricksConfigFileCommand() {
Expand Down
53 changes: 38 additions & 15 deletions packages/databricks-vscode/src/configuration/LoginWizard.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import {commands, QuickPickItem, QuickPickItemKind, window} from "vscode";
import {
commands,
QuickPickItem,
QuickPickItemKind,
window,
ProgressLocation,
} from "vscode";
import {
InputFlowAction,
InputStep,
Expand Down Expand Up @@ -136,11 +142,18 @@ export class LoginWizard {
);
})
.map((profile) => {
const humanisedAuthType = humaniseSdkAuthType(
profile.authType
);
const detail = humanisedAuthType
? `Authenticate using ${humaniseSdkAuthType(
profile.authType
)}`
: `Authenticate using profile ${profile.name}`;

return {
label: profile.name,
detail: `Authenticate using ${humaniseSdkAuthType(
profile.authType
)} from ${profile.name} profile`,
detail,
authType: profile.authType as SdkAuthType,
profile: profile.name,
};
Expand Down Expand Up @@ -357,18 +370,28 @@ function humaniseSdkAuthType(sdkAuthType: string) {
}

export async function listProfiles(cliWrapper: CliWrapper) {
const profiles = (
await cliWrapper.listProfiles(workspaceConfigs.databrickscfgLocation)
).filter((profile) => {
try {
UrlUtils.normalizeHost(profile.host!.toString());
return true;
} catch (e) {
return false;
}
});
return await window.withProgress(
{
location: ProgressLocation.Notification,
title: "Loading Databricks profiles",
},
async () => {
const profiles = (
await cliWrapper.listProfiles(
workspaceConfigs.databrickscfgLocation
)
).filter((profile) => {
try {
UrlUtils.normalizeHost(profile.host!.toString());
return true;
} catch (e) {
return false;
}
});

return profiles;
return profiles;
}
);
}

async function validateDatabricksHost(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
import {ConfigurationTreeItem} from "./types";
import {Cluster} from "../../sdk-extensions";
import {onError} from "../../utils/onErrorDecorator";
import {LabelUtils} from "../../ui/bundle-resource-explorer/utils";

const TREE_ICON_ID = "CLUSTER";
function getContextValue(key: string) {
Expand Down Expand Up @@ -116,15 +117,19 @@ export class ClusterComponent extends BaseComponent {
return [];
}
const {icon, contextValue} = getTreeItemsForClusterState(cluster);

const url = await cluster.url;
return [
{
label: "Cluster",
label: url
? "Cluster"
: LabelUtils.addModifiedTag("Cluster", "created"),
tooltip: url ? undefined : "Created after deploy",
description: cluster.name,
collapsibleState: TreeItemCollapsibleState.Expanded,
contextValue: contextValue,
contextValue: url ? `${contextValue}.has-url` : contextValue,
iconPath: icon,
id: TREE_ICON_ID,
url,
},
];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {ConnectionManager} from "../ConnectionManager";
import {BaseComponent} from "./BaseComponent";
import {ConfigurationTreeItem} from "./types";
import {TreeItemCollapsibleState, ThemeIcon, ThemeColor} from "vscode";
import {LabelUtils} from "../../ui/bundle-resource-explorer/utils";

const TREE_ICON_ID = "WORKSPACE";
function getContextValue(key: string) {
Expand Down Expand Up @@ -70,10 +71,20 @@ export class SyncDestinationComponent extends BaseComponent {
}),
this.configModel.onDidChangeKey("remoteRootPath")(() => {
this.onDidChangeEmitter.fire();
}),
this.configModel.onDidChangeKey("remoteStateConfig")(() => {
this.onDidChangeEmitter.fire();
})
);
}

async getUrl() {
return this.connectionManager.workspaceClient
? await this.connectionManager.syncDestinationMapper?.remoteUri.getUrl(
this.connectionManager.workspaceClient
)
: undefined;
}
private async getRoot(): Promise<ConfigurationTreeItem[]> {
const config = await this.configModel.get("remoteRootPath");
if (config === undefined) {
Expand All @@ -86,19 +97,20 @@ export class SyncDestinationComponent extends BaseComponent {
this.codeSynchronizer
);

const url = await this.getUrl();

return [
{
label: "Sync",
label: url
? "Sync"
: LabelUtils.addModifiedTag("Sync", "created"),
tooltip: url ? undefined : "Created after deploy",
description: posix.basename(posix.dirname(config)),
collapsibleState: TreeItemCollapsibleState.Expanded,
contextValue: contextValue,
contextValue: url ? `${contextValue}.has-url` : contextValue,
iconPath: icon,
id: TREE_ICON_ID,
url: this.connectionManager.workspaceClient
? await this.connectionManager.syncDestinationMapper?.remoteUri.getUrl(
this.connectionManager.workspaceClient
)
: undefined,
url: url,
},
];
}
Expand All @@ -121,7 +133,6 @@ export class SyncDestinationComponent extends BaseComponent {
if (workspaceFsPath === undefined) {
return [];
}
//TODO: Disable syncing for all targets (dev/staging/prod)

const children: ConfigurationTreeItem[] = [
{
Expand Down

0 comments on commit 9f16b58

Please sign in to comment.