Skip to content

Commit

Permalink
Move git commit logic to experiments
Browse files Browse the repository at this point in the history
  • Loading branch information
julieg18 committed Apr 11, 2023
1 parent 2960a29 commit 395f31f
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 13 deletions.
20 changes: 20 additions & 0 deletions webview/src/setup/components/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const renderApp = ({
isPythonExtensionInstalled,
isStudioConnected,
needsGitInitialized,
needsGitCommit,
projectInitialized,
pythonBinPath,
sectionCollapsed,
Expand All @@ -38,6 +39,7 @@ const renderApp = ({
hasData,
isPythonExtensionInstalled,
isStudioConnected,
needsGitCommit,
needsGitInitialized,
projectInitialized,
pythonBinPath,
Expand Down Expand Up @@ -489,6 +491,24 @@ describe('App', () => {
).not.toBeInTheDocument()
})

it('should show a screen saying there needs to be a git commit if the project is initialized, dvc is installed, but has not git commit', () => {
renderApp({
canGitInitialize: false,
cliCompatible: true,
hasData: false,
isPythonExtensionInstalled: false,
isStudioConnected: false,
needsGitCommit: true,
needsGitInitialized: false,
projectInitialized: true,
pythonBinPath: undefined,
sectionCollapsed: undefined,
shareLiveToStudio: false
})

expect(screen.getByText('No Git commits detected')).toBeInTheDocument()
})

it('should show a loading screen if the project is loading in data', () => {
renderApp({
canGitInitialize: false,
Expand Down
4 changes: 2 additions & 2 deletions webview/src/setup/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ export const App: React.FC = () => {
cliCompatible={cliCompatible}
isPythonExtensionInstalled={isPythonExtensionInstalled}
needsGitInitialized={needsGitInitialized}
needsGitCommit={needsGitCommit}
projectInitialized={projectInitialized}
pythonBinPath={pythonBinPath}
isExperimentsAvailable={hasData}
Expand All @@ -109,7 +108,8 @@ export const App: React.FC = () => {
setSectionCollapsed={setSectionCollapsed}
>
<Experiments
isDvcSetup={projectInitialized && !!cliCompatible && !needsGitCommit}
needsGitCommit={needsGitCommit}
isDvcSetup={projectInitialized && !!cliCompatible}
hasData={hasData}
setSectionCollapsed={setSectionCollapsed}
/>
Expand Down
11 changes: 2 additions & 9 deletions webview/src/setup/components/Dvc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ import {
installDvc,
selectPythonInterpreter,
setupWorkspace,
showExperiments,
showScmPanel
showExperiments
} from './messages'
import { NeedsGitCommit } from './NeedsGitCommit'

import { EmptyState } from '../../shared/components/emptyState/EmptyState'
import { Beaker } from '../../shared/components/icons'
import { IconButton } from '../../shared/components/button/IconButton'
Expand All @@ -23,7 +22,6 @@ export type DvcProps = {
cliCompatible: boolean | undefined
isPythonExtensionInstalled: boolean
needsGitInitialized: boolean | undefined
needsGitCommit: boolean
projectInitialized: boolean
pythonBinPath: string | undefined
isExperimentsAvailable: boolean | undefined
Expand All @@ -35,7 +33,6 @@ export const Dvc: React.FC<DvcProps> = ({
cliCompatible,
isPythonExtensionInstalled,
needsGitInitialized,
needsGitCommit,
projectInitialized,
pythonBinPath,
setSectionCollapsed,
Expand Down Expand Up @@ -68,10 +65,6 @@ export const Dvc: React.FC<DvcProps> = ({
)
}

if (needsGitCommit) {
return <NeedsGitCommit showScmPanel={showScmPanel} />
}

return (
<EmptyState isFullScreen={false}>
<h1>Setup Complete</h1>
Expand Down
11 changes: 9 additions & 2 deletions webview/src/setup/components/Experiments.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React from 'react'
import { SectionCollapsed } from 'dvc/src/setup/webview/contract'
import { showExperiments } from './messages'
import { showExperiments, showScmPanel } from './messages'
import { NoData } from './NoData'
import { NeedsGitCommit } from './NeedsGitCommit'
import { EmptyState } from '../../shared/components/emptyState/EmptyState'
import { IconButton } from '../../shared/components/button/IconButton'
import { Beaker } from '../../shared/components/icons'
Expand All @@ -11,12 +12,14 @@ export type ExperimentsProps = {
isDvcSetup: boolean
hasData: boolean | undefined
setSectionCollapsed: (sectionCollapsed: SectionCollapsed) => void
needsGitCommit: boolean
}

export const Experiments: React.FC<ExperimentsProps> = ({
isDvcSetup,
hasData,
setSectionCollapsed
setSectionCollapsed,
needsGitCommit
}) => {
if (!isDvcSetup) {
return (
Expand All @@ -37,6 +40,10 @@ export const Experiments: React.FC<ExperimentsProps> = ({
)
}

if (needsGitCommit) {
return <NeedsGitCommit showScmPanel={showScmPanel} />
}

if (hasData === undefined) {
return <EmptyState isFullScreen={false}>Loading Project...</EmptyState>
}
Expand Down

0 comments on commit 395f31f

Please sign in to comment.