Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Point users to Python extension in DVC Setup #4124

Merged
merged 7 commits into from
Jun 19, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 44 additions & 9 deletions webview/src/setup/components/dvc/CliUnavailable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,28 @@ import {
updatePythonEnvironment
} from '../../util/messages'
import { Warning } from '../../../shared/components/icons'
import { ExtensionLink } from '../shared/ExtensionLink'
import Tooltip from '../../../shared/components/tooltip/Tooltip'

const PythonExtensionTooltip: React.FC<
PropsWithChildren<{ disabled: boolean }>
> = ({ disabled, children }) => (
<Tooltip
content={
<span>
Install the{' '}
<ExtensionLink extensionId="ms-python.python">
Python extension
</ExtensionLink>
.
</span>
}
interactive={true}
disabled={disabled}
>
<span>{children}</span>
</Tooltip>
)

export const CliUnavailable: React.FC<PropsWithChildren> = ({ children }) => {
const { pythonBinPath, isPythonExtensionUsed, isPythonEnvironmentGlobal } =
Expand All @@ -35,21 +57,17 @@ export const CliUnavailable: React.FC<PropsWithChildren> = ({ children }) => {
)}
.
</p>
<div className={styles.sideBySideButtons}>
<Button onClick={installDvc} text="Install (pip)" />
{isPythonExtensionUsed && (
<Button onClick={updatePythonEnvironment} text="Set Env" />
)}
<Button onClick={setupWorkspace} text="Locate DVC" />
</div>
</>
) : (
<>
<p>
{installationSentence} DVC & DVCLive cannot be auto-installed as Python
was not located.
was not located. Install the{' '}
<ExtensionLink extensionId="ms-python.python">
Python extension
</ExtensionLink>{' '}
to detect or create python environments.
</p>
<Button onClick={setupWorkspace} text="Locate DVC" />
</>
)

Expand All @@ -58,6 +76,23 @@ export const CliUnavailable: React.FC<PropsWithChildren> = ({ children }) => {
<h1>DVC is currently unavailable</h1>
{children}
{conditionalContents}
<div className={styles.sideBySideButtons}>
<PythonExtensionTooltip disabled={canInstall}>
julieg18 marked this conversation as resolved.
Show resolved Hide resolved
<Button
disabled={!canInstall}
onClick={installDvc}
text="Install (pip)"
/>
</PythonExtensionTooltip>
<PythonExtensionTooltip disabled={isPythonExtensionUsed}>
julieg18 marked this conversation as resolved.
Show resolved Hide resolved
<Button
disabled={!isPythonExtensionUsed}
onClick={updatePythonEnvironment}
text="Set Env"
/>
</PythonExtensionTooltip>
<Button onClick={setupWorkspace} text="Locate DVC" />
</div>
</EmptyState>
)
}
14 changes: 3 additions & 11 deletions webview/src/setup/components/remotes/ShowExtension.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ import React from 'react'
import styles from './styles.module.scss'
import { Icon } from '../../../shared/components/Icon'
import { Extensions } from '../../../shared/components/icons'
import { ExtensionLink } from '../shared/ExtensionLink'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Q] Why not move the text out from the original paragraph, put it under the buttons and use this component?

I think that would

  1. draw attention to the text
  2. remove the need to show a tooltip.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea! Here's what that looks like so far:

Screenshot 2023-06-19 at 11 01 48 AM

I adjusted the paragraph styling so that it looks more connected to the disabled buttons vs a separate paragraph entirely.


export const ShowExtension: React.FC<{
capabilities: string
id: string
name: string
}> = ({ capabilities, id, name }) => {
const idQuery = `"@id:${id}"`

return (
<p>
<Icon
Expand All @@ -18,15 +17,8 @@ export const ShowExtension: React.FC<{
height={16}
className={styles.infoIcon}
/>{' '}
The{' '}
<a
href={`command:workbench.extensions.search?${encodeURIComponent(
idQuery
)}`}
>
{name}
</a>{' '}
extension can be used to <span>{capabilities}</span>.
The <ExtensionLink extensionId={id}>{name}</ExtensionLink> extension can
be used to <span>{capabilities}</span>.
</p>
)
}
24 changes: 24 additions & 0 deletions webview/src/setup/components/shared/ExtensionLink.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React, { PropsWithChildren } from 'react'
import type { HTMLAttributes } from 'react'

interface ExtensionLinkProps extends HTMLAttributes<HTMLAnchorElement> {
extensionId: string
}

export const ExtensionLink: React.FC<PropsWithChildren<ExtensionLinkProps>> = ({
extensionId,
children,
...props
}) => {
const idQuery = `"@id:${extensionId}"`
return (
<a
href={`command:workbench.extensions.search?${encodeURIComponent(
idQuery
)}`}
{...props}
>
{children}
</a>
)
}