Skip to content

Commit

Permalink
Update required text and remove "Select Python..."
Browse files Browse the repository at this point in the history
  • Loading branch information
julieg18 committed Apr 27, 2023
1 parent a05091b commit 11b8ea0
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 97 deletions.
50 changes: 3 additions & 47 deletions webview/src/setup/components/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ describe('App', () => {
})

const envDetails = screen.getByTestId('dvc-env-details')
const command = `1.0.0 (required >= ${MIN_CLI_VERSION} and < ${MAX_CLI_VERSION}.0.0)`
const command = `1.0.0 (${MIN_CLI_VERSION} <= required < ${MAX_CLI_VERSION}.0.0)`

expect(within(envDetails).getByText('Version')).toBeInTheDocument()
expect(within(envDetails).getByText(command)).toBeInTheDocument()
Expand All @@ -520,7 +520,7 @@ describe('App', () => {
shareLiveToStudio: false
})
const envDetails = screen.getByTestId('dvc-env-details')
const command = `Not found (required >= ${MIN_CLI_VERSION} and < ${MAX_CLI_VERSION}.0.0)`
const command = `Not found (${MIN_CLI_VERSION} <= required < ${MAX_CLI_VERSION}.0.0)`

expect(within(envDetails).getByText('Version')).toBeInTheDocument()
expect(within(envDetails).getByText(command)).toBeInTheDocument()
Expand Down Expand Up @@ -552,7 +552,7 @@ describe('App', () => {
expect(within(envDetails).getByText(command)).toBeInTheDocument()
})

it('should show user an example command with a "Configure" button if dvc is installed without the python extension', () => {
it('should show user an example command with a "Configure" button if dvc is installed', () => {
renderApp({
canGitInitialize: false,
cliCompatible: true,
Expand All @@ -576,59 +576,15 @@ describe('App', () => {
expect(within(envDetails).getByText('Command')).toBeInTheDocument()

const configureButton = within(envDetails).getByText('Configure')
const selectButton = within(envDetails).queryByText(
'Select Python Interpreter'
)

expect(configureButton).toBeInTheDocument()
expect(selectButton).not.toBeInTheDocument()

fireEvent.click(configureButton)

expect(mockPostMessage).toHaveBeenCalledWith({
type: MessageFromWebviewType.SETUP_WORKSPACE
})
})

it('should show user an example command with "Configure" and "Select Python Interpreter" buttons if dvc is installed with the python extension', () => {
renderApp({
canGitInitialize: false,
cliCompatible: true,
dvcCliDetails: {
command: 'python -m dvc',
version: '1.0.0'
},
hasData: true,
isPythonExtensionInstalled: true,
isStudioConnected: true,
needsGitCommit: false,
needsGitInitialized: false,
projectInitialized: true,
pythonBinPath: 'python',
sectionCollapsed: undefined,
shareLiveToStudio: false
})

const envDetails = screen.getByTestId('dvc-env-details')

expect(within(envDetails).getByText('Command')).toBeInTheDocument()

const configureButton = within(envDetails).getByText('Configure')
const selectButton = within(envDetails).getByText(
'Select Python Interpreter'
)

expect(configureButton).toBeInTheDocument()
expect(selectButton).toBeInTheDocument()

mockPostMessage.mockClear()

fireEvent.click(selectButton)

expect(mockPostMessage).toHaveBeenCalledWith({
type: MessageFromWebviewType.SELECT_PYTHON_INTERPRETER
})
})
})

describe('Experiments', () => {
Expand Down
5 changes: 0 additions & 5 deletions webview/src/setup/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ export const App: React.FC = () => {
const [pythonBinPath, setPythonBinPath] = useState<string | undefined>(
undefined
)
const [isPythonExtensionInstalled, setIsPythonExtensionInstalled] =
useState<boolean>(false)
const [hasData, setHasData] = useState<boolean | undefined>(false)
const [sectionCollapsed, setSectionCollapsed] = useState(
DEFAULT_SECTION_COLLAPSED
Expand All @@ -51,7 +49,6 @@ export const App: React.FC = () => {
setCliCompatible(data.data.cliCompatible)
setHasData(data.data.hasData)
setDvcCliDetails(data.data.dvcCliDetails)
setIsPythonExtensionInstalled(data.data.isPythonExtensionInstalled)
setNeedsGitInitialized(data.data.needsGitInitialized)
setNeedsGitCommit(data.data.needsGitCommit)
setProjectInitialized(data.data.projectInitialized)
Expand All @@ -67,7 +64,6 @@ export const App: React.FC = () => {
setCliCompatible,
setHasData,
setDvcCliDetails,
setIsPythonExtensionInstalled,
setNeedsGitInitialized,
setNeedsGitCommit,
setProjectInitialized,
Expand Down Expand Up @@ -99,7 +95,6 @@ export const App: React.FC = () => {
canGitInitialize={canGitInitialize}
cliCompatible={cliCompatible}
dvcCliDetails={dvcCliDetails}
isPythonExtensionInstalled={isPythonExtensionInstalled}
needsGitInitialized={needsGitInitialized}
projectInitialized={projectInitialized}
pythonBinPath={pythonBinPath}
Expand Down
9 changes: 1 addition & 8 deletions webview/src/setup/components/dvc/Dvc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export type DvcProps = {
canGitInitialize: boolean | undefined
cliCompatible: boolean | undefined
dvcCliDetails: DvcCliDetails | undefined
isPythonExtensionInstalled: boolean
needsGitInitialized: boolean | undefined
projectInitialized: boolean
pythonBinPath: string | undefined
Expand All @@ -32,19 +31,13 @@ export const Dvc: React.FC<DvcProps> = ({
canGitInitialize,
cliCompatible,
dvcCliDetails,
isPythonExtensionInstalled,
needsGitInitialized,
projectInitialized,
pythonBinPath,
setSectionCollapsed,
isExperimentsAvailable
}) => {
const children = dvcCliDetails && (
<DvcEnvDetails
{...dvcCliDetails}
isPythonExtensionInstalled={isPythonExtensionInstalled}
/>
)
const children = dvcCliDetails && <DvcEnvDetails {...dvcCliDetails} />

if (cliCompatible === false) {
return (
Expand Down
17 changes: 2 additions & 15 deletions webview/src/setup/components/dvc/DvcEnvCommandRow.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import React from 'react'
import { DvcEnvInfoRow } from './DvcEnvInfoRow'
import styles from './styles.module.scss'
import { selectPythonInterpreter, setupWorkspace } from '../messages'
import { setupWorkspace } from '../messages'

interface DvcEnvCommandRowProps {
command: string
isPythonExtensionInstalled: boolean
}

export const DvcEnvCommandRow: React.FC<DvcEnvCommandRowProps> = ({
command,
isPythonExtensionInstalled
command
}) => {
const commandText = command || 'Not found'
const commandValue = (
Expand All @@ -20,17 +18,6 @@ export const DvcEnvCommandRow: React.FC<DvcEnvCommandRowProps> = ({
<button className={styles.buttonAsLink} onClick={setupWorkspace}>
Configure
</button>
{isPythonExtensionInstalled && (
<>
<span className={styles.separator} />
<button
className={styles.buttonAsLink}
onClick={selectPythonInterpreter}
>
Select Python Interpreter
</button>
</>
)}
</span>
</>
)
Expand Down
18 changes: 4 additions & 14 deletions webview/src/setup/components/dvc/DvcEnvDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,18 @@ import { DvcEnvInfoRow } from './DvcEnvInfoRow'
import styles from './styles.module.scss'
import { DvcEnvCommandRow } from './DvcEnvCommandRow'

interface DvcEnvDetailsProps extends DvcCliDetails {
isPythonExtensionInstalled: boolean
}

export const DvcEnvDetails: React.FC<DvcEnvDetailsProps> = ({
export const DvcEnvDetails: React.FC<DvcCliDetails> = ({
command,
version,
isPythonExtensionInstalled
version
}) => {
const versionText = `${
version || 'Not found'
} (required >= ${MIN_CLI_VERSION} and < ${MAX_CLI_VERSION}.0.0)`
} (${MIN_CLI_VERSION} <= required < ${MAX_CLI_VERSION}.0.0)`

return (
<table data-testid="dvc-env-details" className={styles.envDetails}>
<tbody>
{version && (
<DvcEnvCommandRow
command={command}
isPythonExtensionInstalled={isPythonExtensionInstalled}
/>
)}
{version && <DvcEnvCommandRow command={command} />}
<DvcEnvInfoRow title="Version" text={versionText} />
</tbody>
</table>
Expand Down
8 changes: 0 additions & 8 deletions webview/src/setup/components/dvc/styles.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,6 @@
flex-direction: column;
}

.separator {
margin: 0 5px;

&::before {
content: '|';
}
}

.buttonAsLink {
@extend %buttonAsLink;

Expand Down

0 comments on commit 11b8ea0

Please sign in to comment.