-
Notifications
You must be signed in to change notification settings - Fork 29
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
Changes from 4 commits
65bef89
6b1656b
e8f6cec
6f047a5
4eea17c
3119616
b92216c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import React, { PropsWithChildren } from 'react' | ||
import React, { PropsWithChildren, ReactElement } from 'react' | ||
import { useSelector } from 'react-redux' | ||
import styles from './styles.module.scss' | ||
import { Button } from '../../../shared/components/button/Button' | ||
|
@@ -10,6 +10,30 @@ 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<{ | ||
dataTestId: string | ||
disabled: boolean | ||
children: ReactElement | ||
}> = ({ dataTestId, disabled, children }) => ( | ||
<Tooltip | ||
content={ | ||
<span data-testid={dataTestId}> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if we need the extra tooltips since it does tell you to install the python extension in the text 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we need the tooltip either. It looks very strange with almost the same text popping up next to the original. |
||
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 } = | ||
|
@@ -35,21 +59,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" /> | ||
</> | ||
) | ||
|
||
|
@@ -58,6 +78,35 @@ export const CliUnavailable: React.FC<PropsWithChildren> = ({ children }) => { | |
<h1>DVC is currently unavailable</h1> | ||
{children} | ||
{conditionalContents} | ||
<div className={styles.sideBySideButtons}> | ||
<span className={styles.buttonWrapper}> | ||
julieg18 marked this conversation as resolved.
Show resolved
Hide resolved
julieg18 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<PythonExtensionTooltip | ||
dataTestId="install-tooltip" | ||
disabled={canInstall} | ||
> | ||
<Button | ||
disabled={!canInstall} | ||
onClick={installDvc} | ||
text="Install (pip)" | ||
/> | ||
</PythonExtensionTooltip> | ||
</span> | ||
julieg18 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<span className={styles.buttonWrapper}> | ||
<PythonExtensionTooltip | ||
dataTestId="set-env-tooltip" | ||
disabled={isPythonExtensionUsed} | ||
> | ||
<Button | ||
disabled={!isPythonExtensionUsed} | ||
onClick={updatePythonEnvironment} | ||
text="Set Env" | ||
/> | ||
</PythonExtensionTooltip> | ||
</span> | ||
<span className={styles.buttonWrapper}> | ||
<Button onClick={setupWorkspace} text="Locate DVC" /> | ||
</span> | ||
</div> | ||
</EmptyState> | ||
) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
export const ShowExtension: React.FC<{ | ||
capabilities: string | ||
id: string | ||
name: string | ||
}> = ({ capabilities, id, name }) => { | ||
const idQuery = `"@id:${id}"` | ||
|
||
return ( | ||
<p> | ||
<Icon | ||
|
@@ -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> | ||
) | ||
} |
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> | ||
) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My original plan was to add tests for checking if buttons and tooltips were disabled depending on circumstances but for some reason, tooltips and buttons weren't disabling in the tests. They are working in Storybook and in development but not in testing. Any ideas what's going on?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the magic virtual dom probably doesn't set the properly correctly