Skip to content

Commit

Permalink
Show setup on new install (#3994)
Browse files Browse the repository at this point in the history
  • Loading branch information
julieg18 authored May 31, 2023
1 parent 27be3fd commit a863a41
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 67 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,16 +146,16 @@ These are the VS Code [settings] available for the Extension:

[settings]: https://code.visualstudio.com/docs/getstarted/settings

| **Option** | **Description** |
| -------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `dvc.dvcPath` | Path or shell command to the DVC binary. Required unless Microsoft's [Python extension] is installed and the `dvc` package found in its environment. |
| `dvc.pythonPath` | Path to the desired Python interpreter to use with DVC. Should only be utilized when using a virtual environment without Microsoft's [Python extension]. |
| `dvc.experimentsTableHeadMaxHeight` | Maximum height of experiment table head rows. |
| `dvc.focusedProjects` | A subset of paths to the workspace's available DVC projects. Using this option will override project auto-discovery. |
| `dvc.doNotShowWalkthroughAfterInstall` | Do not prompt to show the Get Started page after installing. Useful for pre-configured development environments |
| `dvc.doNotRecommendAddStudioToken` | Do not prompt to add a [studio.token] to the global DVC config, which enables automatic sharing of experiments to [Studio]. |
| `dvc.doNotRecommendRedHatExtension` | Do not prompt to install the Red Hat YAML extension, which helps with DVC YAML schema validation (`dvc.yaml` and `.dvc` files). |
| `dvc.doNotShowCliUnavailable` | Do not warn when the workspace contains a DVC project but the DVC binary is unavailable. |
| **Option** | **Description** |
| ----------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `dvc.dvcPath` | Path or shell command to the DVC binary. Required unless Microsoft's [Python extension] is installed and the `dvc` package found in its environment. |
| `dvc.pythonPath` | Path to the desired Python interpreter to use with DVC. Should only be utilized when using a virtual environment without Microsoft's [Python extension]. |
| `dvc.experimentsTableHeadMaxHeight` | Maximum height of experiment table head rows. |
| `dvc.focusedProjects` | A subset of paths to the workspace's available DVC projects. Using this option will override project auto-discovery. |
| `dvc.doNotShowSetupAfterInstall` | Do not prompt to show the setup page after installing. Useful for pre-configured development environments |
| `dvc.doNotRecommendAddStudioToken` | Do not prompt to add a [studio.token] to the global DVC config, which enables automatic sharing of experiments to [Studio]. |
| `dvc.doNotRecommendRedHatExtension` | Do not prompt to install the Red Hat YAML extension, which helps with DVC YAML schema validation (`dvc.yaml` and `.dvc` files). |
| `dvc.doNotShowCliUnavailable` | Do not warn when the workspace contains a DVC project but the DVC binary is unavailable. |

> **Note** that the `Setup The Workspace` command helps you set up the basic
> ones at the [Workspace level] (saved to `.vscode/setting.json`).
Expand Down
4 changes: 2 additions & 2 deletions extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -615,8 +615,8 @@
"type": "boolean",
"default": null
},
"dvc.doNotShowWalkthroughAfterInstall": {
"description": "Do not prompt to show the Get Started page after installing. Useful for pre-configured development environments.",
"dvc.doNotShowSetupAfterInstall": {
"description": "Do not prompt to show the setup page after installing. Useful for pre-configured development environments.",
"type": "boolean",
"default": null
},
Expand Down
8 changes: 3 additions & 5 deletions extension/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,8 @@ import {
} from './telemetry'
import { RegisteredCommands } from './commands/external'
import { StopWatch } from './util/time'
import {
registerWalkthroughCommands,
showWalkthroughOnFirstUse
} from './vscode/walkthrough'
import { registerWalkthroughCommands } from './vscode/walkthrough'
import { showSetupOnFirstUse } from './setup/util'
import { WorkspaceRepositories } from './repository/workspace'
import { recommendRedHatExtensionOnce } from './vscode/recommend'
import { WorkspacePlots } from './plots/workspace'
Expand Down Expand Up @@ -258,7 +256,7 @@ class Extension extends Disposable {

registerPersistenceCommands(context.workspaceState, this.internalCommands)

void showWalkthroughOnFirstUse(env.isNewAppInstall)
void showSetupOnFirstUse(env.isNewAppInstall)
this.dispose.track(recommendRedHatExtensionOnce())

this.dispose.track(new LanguageClient())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { commands } from 'vscode'
import { showWalkthroughOnFirstUse } from './walkthrough'
import { ConfigKey, getConfigValue, setUserConfigValue } from './config'
import { Toast } from './toast'
import { Response } from './response'
import { showSetupOnFirstUse } from './util'
import { ConfigKey, getConfigValue, setUserConfigValue } from '../vscode/config'
import { Toast } from '../vscode/toast'
import { Response } from '../vscode/response'
import { RegisteredCommands } from '../commands/external'

jest.mock('vscode')
jest.mock('./toast')
jest.mock('./config')
jest.mock('../vscode/toast')
jest.mock('../vscode/config')

const mockedCommands = jest.mocked(commands)
const mockedExecuteCommand = jest.fn()
Expand All @@ -24,59 +24,59 @@ beforeEach(() => {
jest.resetAllMocks()
})

describe('showWalkthroughOnFirstUse', () => {
it('should ask to show the walkthrough after a new install', async () => {
await showWalkthroughOnFirstUse(true)
describe('showSetupOnFirstUse', () => {
it('should ask to show the setup page after a new install', async () => {
await showSetupOnFirstUse(true)
expect(mockedAskShowOrCloseOrNever).toHaveBeenCalledTimes(1)
})

it('should not ask to show the walkthrough when the install is not new', async () => {
await showWalkthroughOnFirstUse(false)
it('should not ask to show the setup page when the install is not new', async () => {
await showSetupOnFirstUse(false)
expect(mockedAskShowOrCloseOrNever).not.toHaveBeenCalled()
})

it('should not ask to show the walkthrough when the user has set a config option', async () => {
it('should not ask to show the setup page when the user has set a config option', async () => {
mockedGetConfigValue.mockReturnValueOnce(true)
await showWalkthroughOnFirstUse(true)
await showSetupOnFirstUse(true)
expect(mockedAskShowOrCloseOrNever).not.toHaveBeenCalled()
expect(mockedGetConfigValue).toHaveBeenCalledTimes(1)
expect(mockedGetConfigValue).toHaveBeenCalledWith(
ConfigKey.DO_NOT_SHOW_WALKTHROUGH_AFTER_INSTALL
ConfigKey.DO_NOT_SHOW_SETUP_AFTER_INSTALL
)
})

it('should set the config option if the user responds with never', async () => {
mockedAskShowOrCloseOrNever.mockResolvedValueOnce(Response.NEVER)
await showWalkthroughOnFirstUse(true)
await showSetupOnFirstUse(true)

expect(mockedSetConfigValue).toHaveBeenCalledTimes(1)
expect(mockedSetConfigValue).toHaveBeenCalledWith(
ConfigKey.DO_NOT_SHOW_WALKTHROUGH_AFTER_INSTALL,
ConfigKey.DO_NOT_SHOW_SETUP_AFTER_INSTALL,
true
)
})

it('should show the walkthrough if the user responds with show', async () => {
it('should show the setup page if the user responds with show', async () => {
mockedAskShowOrCloseOrNever.mockResolvedValueOnce(Response.SHOW)
await showWalkthroughOnFirstUse(true)
await showSetupOnFirstUse(true)

expect(mockedSetConfigValue).not.toHaveBeenCalled()
expect(mockedExecuteCommand).toHaveBeenCalledWith(
RegisteredCommands.EXTENSION_GET_STARTED
RegisteredCommands.SETUP_SHOW
)
})

it('should take no action if the user closes the dialog', async () => {
mockedAskShowOrCloseOrNever.mockResolvedValueOnce(undefined)
await showWalkthroughOnFirstUse(true)
await showSetupOnFirstUse(true)

expect(mockedSetConfigValue).not.toHaveBeenCalled()
expect(mockedExecuteCommand).not.toHaveBeenCalled()
})

it('should take no action if the user respond with close', async () => {
mockedAskShowOrCloseOrNever.mockResolvedValueOnce(Response.CLOSE)
await showWalkthroughOnFirstUse(true)
await showSetupOnFirstUse(true)

expect(mockedSetConfigValue).not.toHaveBeenCalled()
expect(mockedExecuteCommand).not.toHaveBeenCalled()
Expand Down
27 changes: 27 additions & 0 deletions extension/src/setup/util.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { commands } from 'vscode'
import { RegisteredCommands } from '../commands/external'
import { ConfigKey, getConfigValue, setUserConfigValue } from '../vscode/config'
import { Response } from '../vscode/response'
import { Toast } from '../vscode/toast'

export const showSetupOnFirstUse = async (
isNewAppInstall: boolean
): Promise<void> => {
if (
!isNewAppInstall ||
getConfigValue<boolean>(ConfigKey.DO_NOT_SHOW_SETUP_AFTER_INSTALL)
) {
return
}

const response = await Toast.askShowOrCloseOrNever(
'Need help? Go to our setup view.'
)

if (response === Response.SHOW) {
void commands.executeCommand(RegisteredCommands.SETUP_SHOW)
}
if (response === Response.NEVER) {
void setUserConfigValue(ConfigKey.DO_NOT_SHOW_SETUP_AFTER_INSTALL, true)
}
}
2 changes: 1 addition & 1 deletion extension/src/vscode/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export enum ConfigKey {
DO_NOT_RECOMMEND_ADD_STUDIO_TOKEN = 'dvc.doNotRecommendAddStudioToken',
DO_NOT_RECOMMEND_RED_HAT = 'dvc.doNotRecommendRedHatExtension',
DO_NOT_SHOW_CLI_UNAVAILABLE = 'dvc.doNotShowCliUnavailable',
DO_NOT_SHOW_WALKTHROUGH_AFTER_INSTALL = 'dvc.doNotShowWalkthroughAfterInstall',
DO_NOT_SHOW_SETUP_AFTER_INSTALL = 'dvc.doNotShowSetupAfterInstall',
DVC_PATH = 'dvc.dvcPath',
EXP_TABLE_HEAD_MAX_HEIGHT = 'dvc.experimentsTableHeadMaxHeight',
FOCUSED_PROJECTS = 'dvc.focusedProjects',
Expand Down
28 changes: 0 additions & 28 deletions extension/src/vscode/walkthrough.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import { commands } from 'vscode'
import { ConfigKey, getConfigValue, setUserConfigValue } from './config'
import { Response } from './response'
import { Toast } from './toast'
import { RegisteredCommands } from '../commands/external'
import { InternalCommands } from '../commands/internal'
import { joinTruthyItems } from '../util/array'
Expand All @@ -25,28 +22,3 @@ export const registerWalkthroughCommands = (
() => commands.executeCommand('workbench.action.quickOpen', '> DVC')
)
}

export const showWalkthroughOnFirstUse = async (
isNewAppInstall: boolean
): Promise<void> => {
if (
!isNewAppInstall ||
getConfigValue<boolean>(ConfigKey.DO_NOT_SHOW_WALKTHROUGH_AFTER_INSTALL)
) {
return
}

const response = await Toast.askShowOrCloseOrNever(
'Need help? There is a walkthrough.'
)

if (response === Response.SHOW) {
void commands.executeCommand(RegisteredCommands.EXTENSION_GET_STARTED)
}
if (response === Response.NEVER) {
void setUserConfigValue(
ConfigKey.DO_NOT_SHOW_WALKTHROUGH_AFTER_INSTALL,
true
)
}
}

0 comments on commit a863a41

Please sign in to comment.