Skip to content

Commit a1c0308

Browse files
authored
feat(import): import wizard error UI (#6677)
This PR changes the UI of the import wizard to better reflect errors in the header. Note: this is a part of a larger change in the import flow (using the loading screen - PR #6630), but was extracted to minimize PR size since it can be reviewed independently. Please review only the wizard appearance, the flow itself will be changed. <video src="https://github.com/user-attachments/assets/cee5fa7d-c161-47bb-a182-369f063fdf4a"></video> **Manual Tests:** I hereby swear that: - [X] I opened a hydrogen project and it loaded - [X] I could navigate to various routes in Play mode
1 parent 303377c commit a1c0308

File tree

1 file changed

+71
-35
lines changed

1 file changed

+71
-35
lines changed

editor/src/components/editor/import-wizard/import-wizard.tsx

+71-35
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export const ImportWizard = React.memo(() => {
9696
flex: 'none',
9797
}}
9898
>
99-
<div css={{ fontSize: 16, fontWeight: 400 }}>Cloning Project</div>
99+
<Header />
100100
</FlexRow>
101101
<div
102102
className='import-wizard-body'
@@ -119,7 +119,7 @@ export const ImportWizard = React.memo(() => {
119119
className='import-wizard-footer'
120120
css={{
121121
display: 'flex',
122-
justifyContent: 'space-between',
122+
justifyContent: 'flex-end',
123123
alignItems: 'center',
124124
width: '100%',
125125
marginTop: 20,
@@ -154,23 +154,6 @@ function ActionButtons() {
154154
)
155155
const colorTheme = useColorTheme()
156156
const dispatch = useDispatch()
157-
const result = importResult.result
158-
const textColor = React.useMemo(() => {
159-
switch (result) {
160-
case ImportOperationResult.Success:
161-
return colorTheme.green.value
162-
case ImportOperationResult.Warn:
163-
return colorTheme.warningOrange.value
164-
case ImportOperationResult.Error:
165-
return colorTheme.error.value
166-
case ImportOperationResult.CriticalError:
167-
return colorTheme.error.value
168-
case null:
169-
return colorTheme.fg0.value
170-
default:
171-
assertNever(result)
172-
}
173-
}, [colorTheme, result])
174157
const hideWizard = React.useCallback(() => {
175158
hideImportWizard(dispatch)
176159
}, [dispatch])
@@ -199,10 +182,6 @@ function ActionButtons() {
199182
'everyone',
200183
)
201184
}, [dispatch, importResult.importStatus.status, importState, projectName])
202-
const textStyle = {
203-
color: textColor,
204-
fontSize: 14,
205-
}
206185
const buttonStyle = {
207186
backgroundColor: colorTheme.buttonBackground.value,
208187
padding: 20,
@@ -219,7 +198,6 @@ function ActionButtons() {
219198
case ImportOperationResult.Success:
220199
return (
221200
<React.Fragment>
222-
<div style={textStyle}>Project Imported Successfully</div>
223201
<Button onClick={hideWizard} style={buttonStyle}>
224202
Continue To Editor
225203
</Button>
@@ -228,7 +206,6 @@ function ActionButtons() {
228206
case ImportOperationResult.Warn:
229207
return (
230208
<React.Fragment>
231-
<div style={textStyle}>Project Imported With Warnings</div>
232209
<Button onClick={hideWizard} style={buttonStyle}>
233210
Continue To Editor
234211
</Button>
@@ -237,38 +214,31 @@ function ActionButtons() {
237214
case ImportOperationResult.CriticalError:
238215
return (
239216
<React.Fragment>
240-
<div style={textStyle}>Error Importing Project</div>
241-
<Button style={{ ...buttonStyle, marginLeft: 'auto' }} onClick={importADifferentProject}>
217+
<Button style={buttonStyle} onClick={importADifferentProject}>
242218
Cancel
243219
</Button>
244220
</React.Fragment>
245221
)
246222
case ImportOperationResult.Error:
247223
return (
248224
<React.Fragment>
249-
<div style={textStyle}>
250-
{importResult.importStatus.status !== 'done'
251-
? 'Error While Importing Project'
252-
: 'Project Imported With Errors'}
253-
</div>
254225
{when(
255226
importResult.importStatus.status !== 'done',
256227
<Button
257228
style={{
258229
cursor: 'pointer',
259-
marginLeft: 'auto',
260230
}}
261231
onClick={continueAnyway}
262232
>
263233
Continue Anyway
264234
</Button>,
265235
)}
266236
{importResult.importStatus.status === 'done' ? (
267-
<Button style={{ ...buttonStyle }} onClick={hideWizard}>
237+
<Button style={buttonStyle} onClick={hideWizard}>
268238
Continue To Editor
269239
</Button>
270240
) : (
271-
<Button style={{ ...buttonStyle }} onClick={importADifferentProject}>
241+
<Button style={buttonStyle} onClick={importADifferentProject}>
272242
Cancel
273243
</Button>
274244
)}
@@ -278,3 +248,69 @@ function ActionButtons() {
278248
assertNever(importResult.result)
279249
}
280250
}
251+
252+
function Header() {
253+
const importState = useEditorState(
254+
Substores.github,
255+
(store) => store.editor.importState,
256+
'ImportWizard importState',
257+
)
258+
const totalImportResult: TotalImportResult = React.useMemo(
259+
() => getTotalImportStatusAndResult(importState),
260+
[importState],
261+
)
262+
const colorTheme = useColorTheme()
263+
const importResult = totalImportResult.result
264+
const importStatus = totalImportResult.importStatus.status
265+
const textColor = React.useMemo(() => {
266+
if (importStatus !== 'done' && importStatus !== 'paused') {
267+
return colorTheme.fg0.value
268+
}
269+
switch (importResult) {
270+
case ImportOperationResult.Success:
271+
return colorTheme.green.value
272+
case ImportOperationResult.Warn:
273+
return colorTheme.warningOrange.value
274+
case ImportOperationResult.Error:
275+
return colorTheme.error.value
276+
case ImportOperationResult.CriticalError:
277+
return colorTheme.error.value
278+
case null:
279+
return colorTheme.fg0.value
280+
default:
281+
assertNever(importResult)
282+
}
283+
}, [
284+
colorTheme.error.value,
285+
colorTheme.fg0.value,
286+
colorTheme.green.value,
287+
colorTheme.warningOrange.value,
288+
importStatus,
289+
importResult,
290+
])
291+
292+
const getStatusText = () => {
293+
if (importStatus !== 'done' && importStatus !== 'paused') {
294+
return 'Cloning Project'
295+
}
296+
297+
switch (importResult) {
298+
case ImportOperationResult.Success:
299+
return 'Project Imported Successfully'
300+
case ImportOperationResult.Warn:
301+
return 'Project Imported With Warnings'
302+
case ImportOperationResult.CriticalError:
303+
return 'Error Importing Project'
304+
case ImportOperationResult.Error:
305+
return importStatus !== 'done'
306+
? 'Error While Importing Project'
307+
: 'Project Imported With Errors'
308+
case null:
309+
return 'Cloning Project'
310+
default:
311+
assertNever(importResult)
312+
}
313+
}
314+
315+
return <div style={{ color: textColor, fontSize: 16, fontWeight: 400 }}>{getStatusText()}</div>
316+
}

0 commit comments

Comments
 (0)