@@ -19,6 +19,7 @@ import {
1919import { GlobalEventBus , GlobalEvents } from "../GlobalEventBus" ;
2020
2121import { debounce } from "../utils/debounce" ;
22+ import { ExtensionConfigurations } from "../constants/PowerQuerySdkConfiguration" ;
2223import { extensionI18n } from "../i18n/extension" ;
2324import { getAnyPqFileBeneathTheFirstWorkspace } from "../utils/vscodes" ;
2425import { LifecycleCommands } from "../commands/LifecycleCommands" ;
@@ -41,15 +42,6 @@ export class LifecycleTreeViewItem extends TreeItem {
4142}
4243
4344const staticLifecycleTreeViewItem : LifecycleTreeViewItem [ ] = [
44- new LifecycleTreeViewItem (
45- extensionI18n [ "PQSdk.lifecycleTreeView.item.setupWorkspace.title" ] ,
46- {
47- title : extensionI18n [ "PQSdk.lifecycleTreeView.item.setupWorkspace.title" ] ,
48- command : `${ LifecycleCommands . SetupCurrentWorkspaceCommand } ` ,
49- arguments : [ ] ,
50- } ,
51- new ThemeIcon ( "pencil" ) ,
52- ) ,
5345 new LifecycleTreeViewItem (
5446 extensionI18n [ "PQSdk.lifecycleTreeView.item.createOneCredential.title" ] ,
5547 {
@@ -107,6 +99,16 @@ const staticLifecycleTreeViewItem: LifecycleTreeViewItem[] = [
10799 ) ,
108100] ;
109101
102+ const staticSetupWorkspaceTreeViewItem : LifecycleTreeViewItem = new LifecycleTreeViewItem (
103+ extensionI18n [ "PQSdk.lifecycleTreeView.item.setupWorkspace.title" ] ,
104+ {
105+ title : extensionI18n [ "PQSdk.lifecycleTreeView.item.setupWorkspace.title" ] ,
106+ command : `${ LifecycleCommands . SetupCurrentWorkspaceCommand } ` ,
107+ arguments : [ ] ,
108+ } ,
109+ new ThemeIcon ( "pencil" ) ,
110+ ) ;
111+
110112export class LifeCycleTaskTreeView implements TreeDataProvider < LifecycleTreeViewItem > {
111113 public static TreeViewName : string = `${ TreeViewPrefix } .LifeCycleTaskTreeView` ;
112114
@@ -121,8 +123,15 @@ export class LifeCycleTaskTreeView implements TreeDataProvider<LifecycleTreeView
121123 this . debouncedRefresh ( ) ;
122124 } ) ;
123125
126+ // subscribe to DefaultExtensionLocation changed
124127 // eslint-disable-next-line @typescript-eslint/no-explicit-any
125- globalEventBus . on ( GlobalEvents . VSCodeEvents . ConfigDidChangePowerQueryTestLocation , ( _args : any [ ] ) => {
128+ globalEventBus . on ( GlobalEvents . VSCodeEvents . ConfigDidChangePQTestExtension , ( _args : any [ ] ) => {
129+ this . debouncedRefresh ( ) ;
130+ } ) ;
131+
132+ // subscribe to DefaultQueryFileLocation changed
133+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
134+ globalEventBus . on ( GlobalEvents . VSCodeEvents . ConfigDidChangePQTestQuery , ( _args : any [ ] ) => {
126135 this . debouncedRefresh ( ) ;
127136 } ) ;
128137 }
@@ -146,6 +155,19 @@ export class LifeCycleTaskTreeView implements TreeDataProvider<LifecycleTreeView
146155 if ( element ) return undefined ;
147156
148157 if ( await this . isValidWorkspace ( ) ) {
158+ // if we missed DefaultQueryFileLocation or DefaultExtensionLocation
159+ if (
160+ ! ExtensionConfigurations . DefaultQueryFileLocation ||
161+ ! ExtensionConfigurations . DefaultExtensionLocation
162+ ) {
163+ // do a shallow copy of the static item list
164+ const result : LifecycleTreeViewItem [ ] = staticLifecycleTreeViewItem . slice ( ) ;
165+ // unshift staticSetupWorkspaceTreeViewItem to the items head
166+ result . unshift ( staticSetupWorkspaceTreeViewItem ) ;
167+
168+ return result ;
169+ }
170+
149171 return staticLifecycleTreeViewItem ;
150172 }
151173
0 commit comments