-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Give Setup webview a single section (#3448)
- Loading branch information
1 parent
38dc789
commit 40e7d96
Showing
5 changed files
with
170 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import React from 'react' | ||
import { CliIncompatible } from './CliIncompatible' | ||
import { CliUnavailable } from './CliUnavailable' | ||
import { ProjectUninitialized } from './ProjectUninitialized' | ||
import { | ||
checkCompatibility, | ||
initializeDvc, | ||
initializeGit, | ||
installDvc, | ||
selectPythonInterpreter, | ||
setupWorkspace, | ||
showScmPanel | ||
} from './messages' | ||
import { NeedsGitCommit } from './NeedsGitCommit' | ||
import { NoData } from './NoData' | ||
import { EmptyState } from '../../shared/components/emptyState/EmptyState' | ||
|
||
export type SetupExperimentsProps = { | ||
canGitInitialize: boolean | undefined | ||
cliCompatible: boolean | undefined | ||
hasData: boolean | undefined | ||
isPythonExtensionInstalled: boolean | ||
needsGitInitialized: boolean | undefined | ||
needsGitCommit: boolean | ||
projectInitialized: boolean | ||
pythonBinPath: string | undefined | ||
} | ||
|
||
export const SetupExperiments: React.FC<SetupExperimentsProps> = ({ | ||
canGitInitialize, | ||
cliCompatible, | ||
hasData, | ||
isPythonExtensionInstalled, | ||
needsGitInitialized, | ||
needsGitCommit, | ||
projectInitialized, | ||
pythonBinPath | ||
// eslint-disable-next-line sonarjs/cognitive-complexity | ||
}) => { | ||
if (cliCompatible === false) { | ||
return <CliIncompatible checkCompatibility={checkCompatibility} /> | ||
} | ||
|
||
if (cliCompatible === undefined) { | ||
return ( | ||
<CliUnavailable | ||
installDvc={installDvc} | ||
isPythonExtensionInstalled={isPythonExtensionInstalled} | ||
pythonBinPath={pythonBinPath} | ||
selectPythonInterpreter={selectPythonInterpreter} | ||
setupWorkspace={setupWorkspace} | ||
/> | ||
) | ||
} | ||
|
||
if (!projectInitialized) { | ||
return ( | ||
<ProjectUninitialized | ||
canGitInitialize={canGitInitialize} | ||
initializeDvc={initializeDvc} | ||
initializeGit={initializeGit} | ||
needsGitInitialized={needsGitInitialized} | ||
/> | ||
) | ||
} | ||
|
||
if (needsGitCommit) { | ||
return <NeedsGitCommit showScmPanel={showScmPanel} /> | ||
} | ||
|
||
if (hasData === undefined) { | ||
return <EmptyState>Loading Project...</EmptyState> | ||
} | ||
|
||
if (!hasData) { | ||
return <NoData /> | ||
} | ||
|
||
return <EmptyState>{"You're all setup"}</EmptyState> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { MessageFromWebviewType } from 'dvc/src/webview/contract' | ||
import { sendMessage } from '../../shared/vscode' | ||
|
||
export const checkCompatibility = () => { | ||
sendMessage({ type: MessageFromWebviewType.CHECK_CLI_COMPATIBLE }) | ||
} | ||
|
||
export const initializeGit = () => { | ||
sendMessage({ | ||
type: MessageFromWebviewType.INITIALIZE_GIT | ||
}) | ||
} | ||
|
||
export const initializeDvc = () => { | ||
sendMessage({ | ||
type: MessageFromWebviewType.INITIALIZE_DVC | ||
}) | ||
} | ||
|
||
export const showScmPanel = () => { | ||
sendMessage({ type: MessageFromWebviewType.SHOW_SCM_PANEL }) | ||
} | ||
|
||
export const installDvc = () => { | ||
sendMessage({ type: MessageFromWebviewType.INSTALL_DVC }) | ||
} | ||
|
||
export const selectPythonInterpreter = () => { | ||
sendMessage({ type: MessageFromWebviewType.SELECT_PYTHON_INTERPRETER }) | ||
} | ||
|
||
export const setupWorkspace = () => { | ||
sendMessage({ type: MessageFromWebviewType.SETUP_WORKSPACE }) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters