@@ -63,6 +63,7 @@ import {ParentLinkProps} from '../components/record/relationships/types';
63
63
import { getParentPersistenceData } from '../components/record/relationships/RelatedInformation' ;
64
64
import InheritedDataComponent from '../components/record/inherited_data' ;
65
65
import { NOTEBOOK_NAME_CAPITALIZED } from '../../buildconfig' ;
66
+ import ProgressBar from '../components/progress-bar' ;
66
67
import TransparentButton from '../components/buttons/transparent-button' ;
67
68
import { scrollToDiv } from '../../lib/navigation' ;
68
69
import ArrowDropDown from '@mui/icons-material/ArrowDropDown' ;
@@ -175,6 +176,8 @@ function DraftEdit(props: DraftEditProps) {
175
176
const [ parentLinks , setParentLinks ] = useState ( [ ] as ParentLinkProps [ ] ) ;
176
177
const [ is_link_ready , setIs_link_ready ] = useState ( false ) ;
177
178
179
+ const [ progress , setProgress ] = useState ( 0 ) ;
180
+
178
181
const buttonRef = useRef < HTMLDivElement | null > ( null ) ;
179
182
180
183
useEffect ( ( ) => {
@@ -240,117 +243,113 @@ function DraftEdit(props: DraftEditProps) {
240
243
} ) ;
241
244
navigate ( - 1 ) ;
242
245
return < React . Fragment /> ;
243
- } else if ( uiSpec === null ) {
244
- // Loading
245
- return < CircularProgress size = { 12 } thickness = { 4 } /> ;
246
- } else {
247
- // Loaded, variant picked, show form:
246
+ }
248
247
249
- return (
250
- < React . Fragment >
251
- < Box mb = { 2 } >
252
- < Typography variant = { 'h2' } component = { 'h1' } >
253
- { uiSpec [ 'viewsets' ] [ type_name ] [ 'label' ] ?? type_name } Record
254
- </ Typography >
255
- < Typography variant = { 'subtitle1' } gutterBottom >
256
- Add a record for the{ ' ' }
257
- { project_info !== null ? project_info . name : project_id } project.
258
- </ Typography >
259
- < div
260
- style = { {
261
- display : 'flex' ,
262
- justifyContent : 'flex-end' ,
263
- } }
264
- >
265
- < TransparentButton onClick = { ( ) => scrollToDiv ( buttonRef ) } >
266
- < ArrowDropDown />
267
- Jump to end
268
- </ TransparentButton >
269
- </ div >
270
- </ Box >
271
- < Paper square >
272
- < TabContext value = { value } >
273
- < AppBar position = "static" color = "primary" >
274
- < TabList
275
- onChange = { handleChange }
276
- aria-label = "simple tabs example"
277
- indicatorColor = { 'secondary' }
278
- textColor = "secondary"
279
- >
280
- < Tab label = "Create" value = "1" sx = { { color : '#c2c2c2' } } />
281
- < Tab label = "Meta" value = "2" sx = { { color : '#c2c2c2' } } />
282
- </ TabList >
283
- </ AppBar >
284
- < TabPanel value = "1" sx = { { p : 0 } } >
285
- < Box >
286
- < UnpublishedWarning />
287
- < DraftSyncStatus
288
- last_saved = { draftLastSaved }
289
- is_saving = { isDraftSaving }
290
- error = { draftError }
291
- />
248
+ if ( uiSpec === null ) return < CircularProgress size = { 12 } thickness = { 4 } /> ;
249
+
250
+ return (
251
+ < React . Fragment >
252
+ < Box mb = { 2 } >
253
+ < Typography variant = { 'h2' } component = { 'h1' } >
254
+ { uiSpec [ 'viewsets' ] [ type_name ] [ 'label' ] ?? type_name } Record
255
+ </ Typography >
256
+ < Typography variant = { 'subtitle1' } gutterBottom >
257
+ Add a record for the{ ' ' }
258
+ { project_info !== null ? project_info . name : project_id } project.
259
+ </ Typography >
260
+ < div
261
+ style = { {
262
+ display : 'flex' ,
263
+ justifyContent : 'flex-end' ,
264
+ } }
265
+ >
266
+ < TransparentButton onClick = { ( ) => scrollToDiv ( buttonRef ) } >
267
+ < ArrowDropDown />
268
+ Jump to end
269
+ </ TransparentButton >
270
+ </ div >
271
+ </ Box >
272
+ < div style = { { padding : '10px' } } >
273
+ < ProgressBar percentage = { progress } />
274
+ </ div >
275
+ < div />
276
+ < Paper square >
277
+ < TabContext value = { value } >
278
+ < AppBar position = "static" color = "primary" >
279
+ < TabList
280
+ onChange = { handleChange }
281
+ aria-label = "simple tabs example"
282
+ indicatorColor = { 'secondary' }
283
+ textColor = "secondary"
284
+ >
285
+ < Tab label = "Create" value = "1" sx = { { color : '#c2c2c2' } } />
286
+ < Tab label = "Meta" value = "2" sx = { { color : '#c2c2c2' } } />
287
+ </ TabList >
288
+ </ AppBar >
289
+ < TabPanel value = "1" sx = { { p : 0 } } >
290
+ < Box >
291
+ < UnpublishedWarning />
292
+ < DraftSyncStatus
293
+ last_saved = { draftLastSaved }
294
+ is_saving = { isDraftSaving }
295
+ error = { draftError }
296
+ />
297
+ < Box sx = { { backgroundColor : grey [ 100 ] , p : { xs : 0 , sm : 1 , md : 2 } } } >
292
298
< Box
293
- sx = { { backgroundColor : grey [ 100 ] , p : { xs : 0 , sm : 1 , md : 2 } } }
299
+ component = { Paper }
300
+ elevation = { 0 }
301
+ p = { { xs : 1 , sm : 1 , md : 2 , lg : 2 } }
302
+ variant = { is_mobile ? undefined : 'outlined' }
294
303
>
295
- < Box
296
- component = { Paper }
297
- elevation = { 0 }
298
- p = { { xs : 1 , sm : 1 , md : 2 , lg : 2 } }
299
- variant = { is_mobile ? undefined : 'outlined' }
300
- >
301
- { is_link_ready ? (
302
- < InheritedDataComponent
303
- parentRecords = { parentLinks }
304
- ui_specification = { uiSpec }
305
- />
306
- ) : (
307
- < CircularProgress size = { 24 } />
308
- ) }
309
- < RecordForm
310
- project_id = { project_id }
311
- record_id = { record_id }
312
- type = { type_name }
304
+ { is_link_ready ? (
305
+ < InheritedDataComponent
306
+ parentRecords = { parentLinks }
313
307
ui_specification = { uiSpec }
314
- draft_id = { draft_id }
315
- handleSetIsDraftSaving = { setIsDraftSaving }
316
- handleSetDraftLastSaved = { setDraftLastSaved }
317
- handleSetDraftError = { setDraftError }
318
- draftLastSaved = { draftLastSaved }
319
- mq_above_md = { mq_above_md }
320
- navigate = { navigate }
321
- location = { props . location }
322
- buttonRef = { buttonRef }
323
308
/>
324
- </ Box >
309
+ ) : (
310
+ < CircularProgress size = { 24 } />
311
+ ) }
312
+ < RecordForm
313
+ project_id = { project_id }
314
+ record_id = { record_id }
315
+ type = { type_name }
316
+ ui_specification = { uiSpec }
317
+ draft_id = { draft_id }
318
+ handleSetIsDraftSaving = { setIsDraftSaving }
319
+ handleSetDraftLastSaved = { setDraftLastSaved }
320
+ handleSetDraftError = { setDraftError }
321
+ draftLastSaved = { draftLastSaved }
322
+ mq_above_md = { mq_above_md }
323
+ navigate = { navigate }
324
+ location = { props . location }
325
+ setProgress = { setProgress }
326
+ buttonRef = { buttonRef }
327
+ />
325
328
</ Box >
326
329
</ Box >
327
- </ TabPanel >
328
- < TabPanel value = "2" >
329
- < Box mt = { 2 } >
330
- < Typography variant = { 'h5' } gutterBottom >
331
- Discard Draft
332
- </ Typography >
333
- < RecordDelete
334
- project_id = { project_id }
335
- record_id = { record_id }
336
- revision_id = { null }
337
- draft_id = { draft_id }
338
- show_label = { true }
339
- handleRefresh = { handleRefresh }
340
- />
341
- </ Box >
342
- </ TabPanel >
343
- </ TabContext >
344
- </ Paper >
345
- </ React . Fragment >
346
- ) ;
347
- }
330
+ </ Box >
331
+ </ TabPanel >
332
+ < TabPanel value = "2" >
333
+ < Box mt = { 2 } >
334
+ < Typography variant = { 'h5' } gutterBottom >
335
+ Discard Draft
336
+ </ Typography >
337
+ < RecordDelete
338
+ project_id = { project_id }
339
+ record_id = { record_id }
340
+ revision_id = { null }
341
+ draft_id = { draft_id }
342
+ show_label = { true }
343
+ handleRefresh = { handleRefresh }
344
+ / >
345
+ </ Box >
346
+ </ TabPanel >
347
+ </ TabContext >
348
+ </ Paper >
349
+ </ React . Fragment >
350
+ ) ;
348
351
}
349
352
350
- // type RecordCreateProps = {
351
- // token?: null | undefined | TokenContents;
352
- // };
353
-
354
353
export default function RecordCreate ( ) {
355
354
const { project_id, type_name, draft_id, record_id} = useParams < {
356
355
project_id : ProjectID ;
0 commit comments