Skip to content

Commit

Permalink
Add tooltip for now
Browse files Browse the repository at this point in the history
  • Loading branch information
julieg18 committed May 2, 2023
1 parent 7b177c4 commit e05c8f4
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 10 deletions.
27 changes: 22 additions & 5 deletions extension/src/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ export class Status extends Disposable {
}

private setState(isWorking: boolean) {
const indicator = this.getEnvIndicator()
const { indicator, tooltip } = this.getEnvDetails()
this.statusBarItem.text = this.getText(isWorking, indicator)
this.statusBarItem.tooltip = tooltip

this.statusBarItem.color = this.getColor()

Expand Down Expand Up @@ -90,23 +91,39 @@ export class Status extends Disposable {
return
}

if (this.available) {
return {
command: RegisteredCommands.EXTENSION_SETUP_WORKSPACE,
title: Title.SETUP_WORKSPACE
}
}

return {
command: RegisteredCommands.SETUP_SHOW,
title: Title.SHOW_SETUP
}
}

private getEnvIndicator() {
private getEnvDetails() {
const dvcPath = this.config.getCliPath()
const pythonBinPath = this.config.getPythonBinPath()
if (dvcPath || !pythonBinPath) {
return '(Global)'
return {
indicator: '(Global)',
tooltip: `Locate DVC at: ${dvcPath || 'dvc'}`
}
}

if (this.config.isPythonExtensionUsed()) {
return '(Auto)'
return {
indicator: '(Auto)',
tooltip: `Locate DVC in the Python environment selected by the Python extension: ${pythonBinPath}`
}
}

return '(Manual)'
return {
indicator: '(Manual)',
tooltip: `Locate DVC in this Python environment: ${pythonBinPath}`
}
}
}
21 changes: 16 additions & 5 deletions extension/src/test/suite/status.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ suite('Status Test Suite', () => {
const loadingText = '$(loading~spin) DVC (Global)'
const waitingText = '$(circle-large-outline) DVC (Global)'

const setupShowCommand = {
command: RegisteredCommands.SETUP_SHOW,
title: Title.SHOW_SETUP
const setupWorkspaceCommand = {
command: RegisteredCommands.EXTENSION_SETUP_WORKSPACE,
title: Title.SETUP_WORKSPACE
}

it('should show the correct status of the cli', async () => {
Expand Down Expand Up @@ -88,7 +88,7 @@ suite('Status Test Suite', () => {
await status.setAvailability(true)

expect(mockStatusBarItem.text).to.equal(waitingText)
expect(mockStatusBarItem.command).to.deep.equal(setupShowCommand)
expect(mockStatusBarItem.command).to.deep.equal(setupWorkspaceCommand)

processStarted.fire(firstFinishedCommand)

Expand Down Expand Up @@ -118,7 +118,7 @@ suite('Status Test Suite', () => {
})

expect(mockStatusBarItem.text).to.equal(waitingText)
expect(mockStatusBarItem.command).to.deep.equal(setupShowCommand)
expect(mockStatusBarItem.command).to.deep.equal(setupWorkspaceCommand)

await status.setAvailability(false)

Expand Down Expand Up @@ -224,6 +224,7 @@ suite('Status Test Suite', () => {
await status.setAvailability(true)

expect(mockStatusBarItem.text).to.equal(waitingText)
expect(mockStatusBarItem.tooltip).to.equal('Locate DVC at: dvc')

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

Expand All @@ -234,6 +235,9 @@ suite('Status Test Suite', () => {
expect(mockStatusBarItem.text).to.equal(
'$(circle-large-outline) DVC (Auto)'
)
expect(mockStatusBarItem.tooltip).to.equal(
`Locate DVC in the Python environment selected by the Python extension: ${mockPythonPath}`
)

setupMocks(false, undefined, mockPythonPath)

Expand All @@ -242,6 +246,9 @@ suite('Status Test Suite', () => {
expect(mockStatusBarItem.text).to.equal(
'$(circle-large-outline) DVC (Manual)'
)
expect(mockStatusBarItem.tooltip).to.equal(
`Locate DVC in this Python environment: ${mockPythonPath}`
)

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

Expand All @@ -252,6 +259,9 @@ suite('Status Test Suite', () => {
expect(mockStatusBarItem.text).to.equal(
'$(circle-large-outline) DVC (Global)'
)
expect(mockStatusBarItem.tooltip).to.equal(
`Locate DVC at: ${mockDvcPath}`
)

setupMocks(false, 'dvc', mockPythonPath)

Expand All @@ -260,6 +270,7 @@ suite('Status Test Suite', () => {
expect(mockStatusBarItem.text).to.equal(
'$(circle-large-outline) DVC (Global)'
)
expect(mockStatusBarItem.tooltip).to.equal('Locate DVC at: dvc')
})
})
})

0 comments on commit e05c8f4

Please sign in to comment.