Skip to content

Commit 3682c76

Browse files
Add icons for more task types (#1030)
## Changes <!-- Summary of your changes that are easy to understand --> ## Tests <!-- How is this tested? -->
1 parent a3c5f14 commit 3682c76

File tree

11 files changed

+92
-16
lines changed

11 files changed

+92
-16
lines changed
Lines changed: 6 additions & 0 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 1 addition & 2 deletions
Loading
Lines changed: 6 additions & 0 deletions
Loading
Lines changed: 6 additions & 0 deletions
Loading
Lines changed: 6 additions & 0 deletions
Loading
Lines changed: 5 additions & 0 deletions
Loading

packages/databricks-vscode/src/ui/bundle-resource-explorer/ResourceTypeHeaderTreeNode.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
} from "./types";
1010
import {ExtensionContext, TreeItemCollapsibleState} from "vscode";
1111
import {PipelineTreeNode} from "./PipelineTreeNode";
12+
import {TreeItemTreeNode} from "./TreeItemTreeNode";
1213

1314
function humaniseResourceType(type: BundleResourceExplorerTreeNode["type"]) {
1415
switch (type) {
@@ -92,6 +93,10 @@ export class ResourceTypeHeaderTreeNode
9293
);
9394
if (pipelines.length > 0) {
9495
roots.push(
96+
new TreeItemTreeNode(
97+
{collapsibleState: TreeItemCollapsibleState.None},
98+
undefined
99+
),
95100
new ResourceTypeHeaderTreeNode(context, "pipelines", pipelines)
96101
);
97102
}

packages/databricks-vscode/src/ui/bundle-resource-explorer/TaskTreeNode.ts

Lines changed: 51 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@ import {
44
BundleResourceExplorerTreeItem,
55
BundleResourceExplorerTreeNode,
66
} from "./types";
7-
import {ExtensionContext, TreeItemCollapsibleState} from "vscode";
7+
import {ExtensionContext, TreeItemCollapsibleState, ThemeIcon} from "vscode";
88
import {JobRunStatus} from "../../bundle/run/JobRunStatus";
99
import {ConnectionManager} from "../../configuration/ConnectionManager";
1010
import {jobs} from "@databricks/databricks-sdk";
1111
import {TaskRunStatusTreeNode} from "./TaskRunStatusTreeNode";
1212
import {ContextUtils} from "./utils";
1313

1414
type Task = Required<BundleResourceExplorerResource<"jobs">>["tasks"][number];
15+
type TaskType = keyof {
16+
[k in keyof Required<Task> as k extends `${string}_task` ? k : never]: k;
17+
};
1518

1619
export class TaskTreeNode implements BundleResourceExplorerTreeNode {
1720
readonly type = "task";
@@ -43,7 +46,7 @@ export class TaskTreeNode implements BundleResourceExplorerTreeNode {
4346
public readonly runMonitor?: JobRunStatus
4447
) {}
4548

46-
private getTaskIconPath(taskType: string) {
49+
private getIconPathForType(taskType: string) {
4750
return {
4851
dark: this.context.asAbsolutePath(
4952
path.join(
@@ -71,21 +74,60 @@ export class TaskTreeNode implements BundleResourceExplorerTreeNode {
7174
);
7275
}
7376

74-
getTreeItem(): BundleResourceExplorerTreeItem {
75-
let iconPath: BundleResourceExplorerTreeItem["iconPath"] = undefined;
77+
get taskType(): TaskType | undefined {
78+
return Object.keys(this.data).find(
79+
(k) =>
80+
k.endsWith("_task") && this.data[k as keyof Task] !== undefined
81+
) as TaskType | undefined;
82+
}
7683

77-
if (this.data.pipeline_task !== undefined) {
78-
iconPath = this.getTaskIconPath("pipelines");
84+
get humanisedTaskType() {
85+
if (this.taskType === undefined) {
86+
return undefined;
7987
}
8088

81-
if (this.data.spark_python_task !== undefined) {
82-
iconPath = this.getTaskIconPath("python");
89+
return this.taskType
90+
.replace("_task", "")
91+
.split("_")
92+
.map((word) => word[0].toUpperCase() + word.slice(1))
93+
.join(" ");
94+
}
95+
96+
getTreeItem(): BundleResourceExplorerTreeItem {
97+
let iconPath: BundleResourceExplorerTreeItem["iconPath"] = undefined;
98+
switch (this.taskType) {
99+
case "pipeline_task":
100+
iconPath = this.getIconPathForType("pipelines");
101+
break;
102+
case "spark_python_task":
103+
iconPath = this.getIconPathForType("python");
104+
break;
105+
case "notebook_task":
106+
iconPath = new ThemeIcon("notebook");
107+
break;
108+
case "condition_task":
109+
iconPath = this.getIconPathForType("fork");
110+
break;
111+
case "run_job_task":
112+
iconPath = this.getIconPathForType("jobs");
113+
break;
114+
case "python_wheel_task":
115+
iconPath = this.getIconPathForType("python");
116+
break;
117+
case "dbt_task":
118+
case "spark_submit_task":
119+
case "sql_task":
120+
case "spark_jar_task":
121+
break;
122+
default:
123+
break;
83124
}
84125

85126
return {
86127
label: this.data.task_key,
87128
id: `${this.data.task_key}-${this.jobId}-${this.jobResourceKey}`,
88-
description: this.data.description,
129+
description: this.humanisedTaskType,
130+
tooltip: this.data.description,
89131
iconPath: iconPath,
90132
contextValue: ContextUtils.getContextString({
91133
nodeType: this.type,

0 commit comments

Comments
 (0)