Skip to content

Commit 3196daf

Browse files
authored
Always give status bar item a command and update tooltip (#3001)
1 parent 1d3da67 commit 3196daf

File tree

2 files changed

+35
-16
lines changed

2 files changed

+35
-16
lines changed

extension/src/status.ts

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,17 @@ export class Status extends Disposable {
8787
}
8888

8989
private getCommand() {
90-
if (this.available) {
90+
if (this.workers) {
9191
return
9292
}
93+
94+
if (this.available) {
95+
return {
96+
command: RegisteredCommands.EXTENSION_SETUP_WORKSPACE,
97+
title: Title.SETUP_WORKSPACE
98+
}
99+
}
100+
93101
return {
94102
command: RegisteredCommands.SETUP_SHOW,
95103
title: Title.SHOW_SETUP
@@ -98,22 +106,24 @@ export class Status extends Disposable {
98106

99107
private getEnvDetails() {
100108
const dvcPath = this.config.getCliPath()
101-
if (dvcPath) {
102-
return { indicator: '(Global)', tooltip: dvcPath }
109+
const pythonBinPath = this.config.getPythonBinPath()
110+
if (dvcPath || !pythonBinPath) {
111+
return {
112+
indicator: '(Global)',
113+
tooltip: `Locate DVC at: ${dvcPath || 'dvc'}`
114+
}
103115
}
104116

105117
if (this.config.isPythonExtensionUsed()) {
106118
return {
107119
indicator: '(Auto)',
108-
tooltip: 'Interpreter set by Python extension'
120+
tooltip: `Locate DVC in the Python environment selected by the Python extension: ${pythonBinPath}`
109121
}
110122
}
111123

112-
const pythonBinPath = this.config.getPythonBinPath()
113-
if (pythonBinPath) {
114-
return { indicator: '(Manual)', tooltip: pythonBinPath }
124+
return {
125+
indicator: '(Manual)',
126+
tooltip: `Locate DVC in this Python environment: ${pythonBinPath}`
115127
}
116-
117-
return { indicator: '(Global)', tooltip: 'dvc' }
118128
}
119129
}

extension/src/test/suite/status.test.ts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ suite('Status Test Suite', () => {
3434
const loadingText = '$(loading~spin) DVC (Global)'
3535
const waitingText = '$(circle-large-outline) DVC (Global)'
3636

37+
const setupWorkspaceCommand = {
38+
command: RegisteredCommands.EXTENSION_SETUP_WORKSPACE,
39+
title: Title.SETUP_WORKSPACE
40+
}
41+
3742
it('should show the correct status of the cli', async () => {
3843
const cwd = __dirname
3944
const processCompleted = disposable.track(new EventEmitter<CliResult>())
@@ -83,7 +88,7 @@ suite('Status Test Suite', () => {
8388
await status.setAvailability(true)
8489

8590
expect(mockStatusBarItem.text).to.equal(waitingText)
86-
expect(mockStatusBarItem.command).to.equal(undefined)
91+
expect(mockStatusBarItem.command).to.deep.equal(setupWorkspaceCommand)
8792

8893
processStarted.fire(firstFinishedCommand)
8994

@@ -113,7 +118,7 @@ suite('Status Test Suite', () => {
113118
})
114119

115120
expect(mockStatusBarItem.text).to.equal(waitingText)
116-
expect(mockStatusBarItem.command).to.equal(undefined)
121+
expect(mockStatusBarItem.command).to.deep.equal(setupWorkspaceCommand)
117122

118123
await status.setAvailability(false)
119124

@@ -219,7 +224,7 @@ suite('Status Test Suite', () => {
219224
await status.setAvailability(true)
220225

221226
expect(mockStatusBarItem.text).to.equal(waitingText)
222-
expect(mockStatusBarItem.tooltip).to.equal('dvc')
227+
expect(mockStatusBarItem.tooltip).to.equal('Locate DVC at: dvc')
223228

224229
const mockPythonPath = resolve('a', 'virtual', 'environment')
225230

@@ -231,7 +236,7 @@ suite('Status Test Suite', () => {
231236
'$(circle-large-outline) DVC (Auto)'
232237
)
233238
expect(mockStatusBarItem.tooltip).to.equal(
234-
'Interpreter set by Python extension'
239+
`Locate DVC in the Python environment selected by the Python extension: ${mockPythonPath}`
235240
)
236241

237242
setupMocks(false, undefined, mockPythonPath)
@@ -241,7 +246,9 @@ suite('Status Test Suite', () => {
241246
expect(mockStatusBarItem.text).to.equal(
242247
'$(circle-large-outline) DVC (Manual)'
243248
)
244-
expect(mockStatusBarItem.tooltip).to.equal(mockPythonPath)
249+
expect(mockStatusBarItem.tooltip).to.equal(
250+
`Locate DVC in this Python environment: ${mockPythonPath}`
251+
)
245252

246253
const mockDvcPath = resolve('path', 'to', 'dvc')
247254

@@ -252,7 +259,9 @@ suite('Status Test Suite', () => {
252259
expect(mockStatusBarItem.text).to.equal(
253260
'$(circle-large-outline) DVC (Global)'
254261
)
255-
expect(mockStatusBarItem.tooltip).to.equal(mockDvcPath)
262+
expect(mockStatusBarItem.tooltip).to.equal(
263+
`Locate DVC at: ${mockDvcPath}`
264+
)
256265

257266
setupMocks(false, 'dvc', mockPythonPath)
258267

@@ -261,7 +270,7 @@ suite('Status Test Suite', () => {
261270
expect(mockStatusBarItem.text).to.equal(
262271
'$(circle-large-outline) DVC (Global)'
263272
)
264-
expect(mockStatusBarItem.tooltip).to.equal('dvc')
273+
expect(mockStatusBarItem.tooltip).to.equal('Locate DVC at: dvc')
265274
})
266275
})
267276
})

0 commit comments

Comments
 (0)