@@ -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" ;
88import { JobRunStatus } from "../../bundle/run/JobRunStatus" ;
99import { ConnectionManager } from "../../configuration/ConnectionManager" ;
1010import { jobs } from "@databricks/databricks-sdk" ;
1111import { TaskRunStatusTreeNode } from "./TaskRunStatusTreeNode" ;
1212import { ContextUtils } from "./utils" ;
1313
1414type 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
1619export 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