Skip to content

Commit 59ae23d

Browse files
authored
Add completion status to setup sections (#3823)
1 parent 97bf8fa commit 59ae23d

File tree

11 files changed

+337
-34
lines changed

11 files changed

+337
-34
lines changed

webview/src/setup/components/App.test.tsx

Lines changed: 209 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import React from 'react'
99
import { SetupSection, SetupData } from 'dvc/src/setup/webview/contract'
1010
import { App } from './App'
1111
import { vsCodeApi } from '../../shared/api'
12+
import { TooltipIconType } from '../../shared/components/sectionContainer/InfoTooltip'
1213

1314
jest.mock('../../shared/api')
1415
jest.mock('../../shared/components/codeSlider/CodeSlider')
@@ -629,6 +630,58 @@ describe('App', () => {
629630
type: MessageFromWebviewType.SELECT_PYTHON_INTERPRETER
630631
})
631632
})
633+
634+
it('should show an error icon if DVC is not setup', () => {
635+
renderApp({
636+
canGitInitialize: false,
637+
cliCompatible: true,
638+
dvcCliDetails: {
639+
command: 'python -m dvc',
640+
version: '1.0.0'
641+
},
642+
hasData: false,
643+
isPythonExtensionUsed: false,
644+
isStudioConnected: false,
645+
needsGitCommit: false,
646+
needsGitInitialized: undefined,
647+
projectInitialized: false,
648+
pythonBinPath: undefined,
649+
sectionCollapsed: undefined,
650+
shareLiveToStudio: false
651+
})
652+
653+
const iconWrapper = screen.getAllByTestId('info-tooltip-toggle')[0]
654+
655+
expect(
656+
within(iconWrapper).getByTestId(TooltipIconType.ERROR)
657+
).toBeInTheDocument()
658+
})
659+
660+
it('should show a passed icon if DVC CLI is compatible and project is initialized', () => {
661+
renderApp({
662+
canGitInitialize: false,
663+
cliCompatible: true,
664+
dvcCliDetails: {
665+
command: 'python -m dvc',
666+
version: '1.0.0'
667+
},
668+
hasData: true,
669+
isPythonExtensionUsed: true,
670+
isStudioConnected: true,
671+
needsGitCommit: false,
672+
needsGitInitialized: false,
673+
projectInitialized: true,
674+
pythonBinPath: 'python',
675+
sectionCollapsed: undefined,
676+
shareLiveToStudio: false
677+
})
678+
679+
const iconWrapper = screen.getAllByTestId('info-tooltip-toggle')[0]
680+
681+
expect(
682+
within(iconWrapper).getByTestId(TooltipIconType.PASSED)
683+
).toBeInTheDocument()
684+
})
632685
})
633686

634687
describe('Experiments', () => {
@@ -823,6 +876,84 @@ describe('App', () => {
823876
type: MessageFromWebviewType.OPEN_EXPERIMENTS_WEBVIEW
824877
})
825878
})
879+
880+
it('should show an error icon if experiments are not setup', () => {
881+
renderApp({
882+
canGitInitialize: false,
883+
cliCompatible: true,
884+
dvcCliDetails: {
885+
command: 'python -m dvc',
886+
version: '1.0.0'
887+
},
888+
hasData: false,
889+
isPythonExtensionUsed: false,
890+
isStudioConnected: false,
891+
needsGitCommit: false,
892+
needsGitInitialized: undefined,
893+
projectInitialized: true,
894+
pythonBinPath: undefined,
895+
sectionCollapsed: undefined,
896+
shareLiveToStudio: false
897+
})
898+
899+
const iconWrapper = screen.getAllByTestId('info-tooltip-toggle')[1]
900+
901+
expect(
902+
within(iconWrapper).getByTestId(TooltipIconType.ERROR)
903+
).toBeInTheDocument()
904+
})
905+
906+
it('should show an error icon if dvc is not setup', () => {
907+
renderApp({
908+
canGitInitialize: false,
909+
cliCompatible: false,
910+
dvcCliDetails: {
911+
command: 'dvc',
912+
version: '1.0.0'
913+
},
914+
hasData: false,
915+
isPythonExtensionUsed: false,
916+
isStudioConnected: false,
917+
needsGitCommit: false,
918+
needsGitInitialized: undefined,
919+
projectInitialized: false,
920+
pythonBinPath: undefined,
921+
sectionCollapsed: undefined,
922+
shareLiveToStudio: false
923+
})
924+
925+
const iconWrapper = screen.getAllByTestId('info-tooltip-toggle')[1]
926+
927+
expect(
928+
within(iconWrapper).getByTestId(TooltipIconType.ERROR)
929+
).toBeInTheDocument()
930+
})
931+
932+
it('should show a passed icon if experiments are setup', () => {
933+
renderApp({
934+
canGitInitialize: false,
935+
cliCompatible: true,
936+
dvcCliDetails: {
937+
command: 'python -m dvc',
938+
version: '1.0.0'
939+
},
940+
hasData: true,
941+
isPythonExtensionUsed: true,
942+
isStudioConnected: true,
943+
needsGitCommit: false,
944+
needsGitInitialized: false,
945+
projectInitialized: true,
946+
pythonBinPath: 'python',
947+
sectionCollapsed: undefined,
948+
shareLiveToStudio: false
949+
})
950+
951+
const iconWrapper = screen.getAllByTestId('info-tooltip-toggle')[1]
952+
953+
expect(
954+
within(iconWrapper).getByTestId(TooltipIconType.PASSED)
955+
).toBeInTheDocument()
956+
})
826957
})
827958

828959
describe('Studio not connected', () => {
@@ -933,6 +1064,58 @@ describe('App', () => {
9331064
type: MessageFromWebviewType.SAVE_STUDIO_TOKEN
9341065
})
9351066
})
1067+
1068+
it('should show an error icon if dvc is not compatible', () => {
1069+
renderApp({
1070+
canGitInitialize: false,
1071+
cliCompatible: false,
1072+
dvcCliDetails: {
1073+
command: 'python -m dvc',
1074+
version: '1.0.0'
1075+
},
1076+
hasData: false,
1077+
isPythonExtensionUsed: false,
1078+
isStudioConnected: false,
1079+
needsGitCommit: false,
1080+
needsGitInitialized: undefined,
1081+
projectInitialized: true,
1082+
pythonBinPath: undefined,
1083+
sectionCollapsed: undefined,
1084+
shareLiveToStudio: false
1085+
})
1086+
1087+
const iconWrapper = screen.getAllByTestId('info-tooltip-toggle')[2]
1088+
1089+
expect(
1090+
within(iconWrapper).getByTestId(TooltipIconType.ERROR)
1091+
).toBeInTheDocument()
1092+
})
1093+
1094+
it('should show an info icon if dvc is compatible but studio is not connected', () => {
1095+
renderApp({
1096+
canGitInitialize: false,
1097+
cliCompatible: true,
1098+
dvcCliDetails: {
1099+
command: 'python -m dvc',
1100+
version: '1.0.0'
1101+
},
1102+
hasData: true,
1103+
isPythonExtensionUsed: true,
1104+
isStudioConnected: false,
1105+
needsGitCommit: false,
1106+
needsGitInitialized: false,
1107+
projectInitialized: true,
1108+
pythonBinPath: 'python',
1109+
sectionCollapsed: undefined,
1110+
shareLiveToStudio: false
1111+
})
1112+
1113+
const iconWrapper = screen.getAllByTestId('info-tooltip-toggle')[2]
1114+
1115+
expect(
1116+
within(iconWrapper).getByTestId(TooltipIconType.INFO)
1117+
).toBeInTheDocument()
1118+
})
9361119
})
9371120

9381121
describe('Studio connected', () => {
@@ -990,6 +1173,32 @@ describe('App', () => {
9901173
type: MessageFromWebviewType.SAVE_STUDIO_TOKEN
9911174
})
9921175
})
1176+
1177+
it('should show a passed icon if connected', () => {
1178+
renderApp({
1179+
canGitInitialize: false,
1180+
cliCompatible: true,
1181+
dvcCliDetails: {
1182+
command: 'python -m dvc',
1183+
version: '1.0.0'
1184+
},
1185+
hasData: false,
1186+
isPythonExtensionUsed: false,
1187+
isStudioConnected: true,
1188+
needsGitCommit: true,
1189+
needsGitInitialized: false,
1190+
projectInitialized: true,
1191+
pythonBinPath: undefined,
1192+
sectionCollapsed: undefined,
1193+
shareLiveToStudio: false
1194+
})
1195+
1196+
const iconWrapper = screen.getAllByTestId('info-tooltip-toggle')[2]
1197+
1198+
expect(
1199+
within(iconWrapper).getByTestId(TooltipIconType.PASSED)
1200+
).toBeInTheDocument()
1201+
})
9931202
})
9941203

9951204
describe('focused section', () => {

webview/src/setup/components/App.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,16 @@ export const App: React.FC = () => {
9090
})
9191
}
9292

93+
const isDvcSetup = !!cliCompatible && projectInitialized
94+
9395
return (
9496
<>
9597
<SetupContainer
9698
sectionKey={SetupSection.DVC}
9799
title="DVC"
98100
sectionCollapsed={sectionCollapsed}
99101
setSectionCollapsed={setSectionCollapsed}
102+
isSetup={isDvcSetup}
100103
>
101104
<Dvc
102105
canGitInitialize={canGitInitialize}
@@ -115,6 +118,7 @@ export const App: React.FC = () => {
115118
title="Experiments"
116119
sectionCollapsed={sectionCollapsed}
117120
setSectionCollapsed={setSectionCollapsed}
121+
isSetup={isDvcSetup && !!hasData}
118122
>
119123
<Experiments
120124
needsGitCommit={needsGitCommit}
@@ -128,6 +132,8 @@ export const App: React.FC = () => {
128132
title="Studio"
129133
sectionCollapsed={sectionCollapsed}
130134
setSectionCollapsed={setSectionCollapsed}
135+
isSetup={!!cliCompatible}
136+
isConnected={isStudioConnected}
131137
>
132138
<Studio
133139
isStudioConnected={isStudioConnected}

webview/src/setup/components/SetupContainer.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,38 @@ import {
44
} from 'dvc/src/setup/webview/contract'
55
import React from 'react'
66
import { SectionContainer } from '../../shared/components/sectionContainer/SectionContainer'
7+
import { TooltipIconType } from '../../shared/components/sectionContainer/InfoTooltip'
8+
9+
const getTooltipIconType = (isSetup: boolean, isConnected = true) => {
10+
if (!isSetup) {
11+
return TooltipIconType.ERROR
12+
}
13+
14+
return isConnected ? TooltipIconType.PASSED : TooltipIconType.INFO
15+
}
716

817
export const SetupContainer: React.FC<{
918
children: React.ReactNode
1019
sectionCollapsed: typeof DEFAULT_SECTION_COLLAPSED
1120
sectionKey: SetupSection
1221
setSectionCollapsed: (value: typeof DEFAULT_SECTION_COLLAPSED) => void
1322
title: string
23+
isSetup: boolean
24+
isConnected?: boolean
1425
}> = ({
1526
children,
1627
sectionCollapsed,
1728
sectionKey,
1829
setSectionCollapsed,
19-
title
30+
title,
31+
isSetup,
32+
isConnected
2033
}) => (
2134
<SectionContainer
2235
sectionCollapsed={sectionCollapsed[sectionKey]}
2336
sectionKey={sectionKey}
2437
title={title}
38+
icon={getTooltipIconType(isSetup, isConnected)}
2539
onToggleSection={() =>
2640
setSectionCollapsed({
2741
...sectionCollapsed,
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import React from 'react'
2+
3+
function PassFilled(props: React.SVGProps<SVGSVGElement>) {
4+
return (
5+
<svg
6+
width="16"
7+
height="16"
8+
viewBox="0 0 16 16"
9+
xmlns="http://www.w3.org/2000/svg"
10+
fill="currentColor"
11+
{...props}
12+
>
13+
<path
14+
fillRule="evenodd"
15+
clipRule="evenodd"
16+
d="M8 15A7 7 0 1 0 8 1a7 7 0 0 0 0 14zm-1.02-4.13h-.71L4 8.6l.71-.71 1.92 1.92 4.2-4.21.71.71-4.56 4.56z"
17+
/>
18+
</svg>
19+
)
20+
}
21+
22+
export default PassFilled

webview/src/shared/components/icons/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export { default as GraphLine } from './GraphLine'
1818
export { default as Gripper } from './Gripper'
1919
export { default as Info } from './Info'
2020
export { default as Lines } from './Lines'
21+
export { default as PassFilled } from './PassFilled'
2122
export { default as Pin } from './Pin'
2223
export { default as Refresh } from './Refresh'
2324
export { default as UpArrow } from './UpArrow'

0 commit comments

Comments
 (0)