@@ -96,7 +96,7 @@ export const ImportWizard = React.memo(() => {
96
96
flex : 'none' ,
97
97
} }
98
98
>
99
- < div css = { { fontSize : 16 , fontWeight : 400 } } > Cloning Project </ div >
99
+ < Header / >
100
100
</ FlexRow >
101
101
< div
102
102
className = 'import-wizard-body'
@@ -119,7 +119,7 @@ export const ImportWizard = React.memo(() => {
119
119
className = 'import-wizard-footer'
120
120
css = { {
121
121
display : 'flex' ,
122
- justifyContent : 'space-between ' ,
122
+ justifyContent : 'flex-end ' ,
123
123
alignItems : 'center' ,
124
124
width : '100%' ,
125
125
marginTop : 20 ,
@@ -154,23 +154,6 @@ function ActionButtons() {
154
154
)
155
155
const colorTheme = useColorTheme ( )
156
156
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 ] )
174
157
const hideWizard = React . useCallback ( ( ) => {
175
158
hideImportWizard ( dispatch )
176
159
} , [ dispatch ] )
@@ -199,10 +182,6 @@ function ActionButtons() {
199
182
'everyone' ,
200
183
)
201
184
} , [ dispatch , importResult . importStatus . status , importState , projectName ] )
202
- const textStyle = {
203
- color : textColor ,
204
- fontSize : 14 ,
205
- }
206
185
const buttonStyle = {
207
186
backgroundColor : colorTheme . buttonBackground . value ,
208
187
padding : 20 ,
@@ -219,7 +198,6 @@ function ActionButtons() {
219
198
case ImportOperationResult . Success :
220
199
return (
221
200
< React . Fragment >
222
- < div style = { textStyle } > Project Imported Successfully</ div >
223
201
< Button onClick = { hideWizard } style = { buttonStyle } >
224
202
Continue To Editor
225
203
</ Button >
@@ -228,7 +206,6 @@ function ActionButtons() {
228
206
case ImportOperationResult . Warn :
229
207
return (
230
208
< React . Fragment >
231
- < div style = { textStyle } > Project Imported With Warnings</ div >
232
209
< Button onClick = { hideWizard } style = { buttonStyle } >
233
210
Continue To Editor
234
211
</ Button >
@@ -237,38 +214,31 @@ function ActionButtons() {
237
214
case ImportOperationResult . CriticalError :
238
215
return (
239
216
< React . Fragment >
240
- < div style = { textStyle } > Error Importing Project</ div >
241
- < Button style = { { ...buttonStyle , marginLeft : 'auto' } } onClick = { importADifferentProject } >
217
+ < Button style = { buttonStyle } onClick = { importADifferentProject } >
242
218
Cancel
243
219
</ Button >
244
220
</ React . Fragment >
245
221
)
246
222
case ImportOperationResult . Error :
247
223
return (
248
224
< React . Fragment >
249
- < div style = { textStyle } >
250
- { importResult . importStatus . status !== 'done'
251
- ? 'Error While Importing Project'
252
- : 'Project Imported With Errors' }
253
- </ div >
254
225
{ when (
255
226
importResult . importStatus . status !== 'done' ,
256
227
< Button
257
228
style = { {
258
229
cursor : 'pointer' ,
259
- marginLeft : 'auto' ,
260
230
} }
261
231
onClick = { continueAnyway }
262
232
>
263
233
Continue Anyway
264
234
</ Button > ,
265
235
) }
266
236
{ importResult . importStatus . status === 'done' ? (
267
- < Button style = { { ... buttonStyle } } onClick = { hideWizard } >
237
+ < Button style = { buttonStyle } onClick = { hideWizard } >
268
238
Continue To Editor
269
239
</ Button >
270
240
) : (
271
- < Button style = { { ... buttonStyle } } onClick = { importADifferentProject } >
241
+ < Button style = { buttonStyle } onClick = { importADifferentProject } >
272
242
Cancel
273
243
</ Button >
274
244
) }
@@ -278,3 +248,69 @@ function ActionButtons() {
278
248
assertNever ( importResult . result )
279
249
}
280
250
}
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