1
1
import type { JobSummary } from '@squonk/data-manager-client' ;
2
2
3
- import { Chip , Link , Typography , useTheme } from '@material-ui/core' ;
3
+ import { Chip , CircularProgress , Link , Typography , useTheme } from '@material-ui/core' ;
4
+ import dynamic from 'next/dynamic' ;
4
5
5
- import { BaseCard } from '../../BaseCard' ;
6
+ import type { BaseCardProps } from '../../BaseCard' ;
6
7
import { Chips } from '../../Chips' ;
7
- import { InstancesList } from '../InstancesList' ;
8
+ import type { InstancesListProps } from '../InstancesList' ;
8
9
import type { RunJobButtonProps } from './RunJobButton' ;
9
- import { RunJobButton } from './RunJobButton' ;
10
10
11
- // TODO remove this once the doc_url attribute is in the DM API client
12
- type JobSummaryWithDocUrl = JobSummary & {
13
- doc_url : string ;
14
- } ;
11
+ const RunJobButton = dynamic < RunJobButtonProps > (
12
+ ( ) => import ( './RunJobButton' ) . then ( ( mod ) => mod . RunJobButton ) ,
13
+ { loading : ( ) => < CircularProgress size = "1rem" /> } ,
14
+ ) ;
15
+
16
+ const InstancesList = dynamic < InstancesListProps > (
17
+ ( ) => import ( '../InstancesList' ) . then ( ( mod ) => mod . InstancesList ) ,
18
+ { loading : ( ) => < CircularProgress size = "1rem" /> } ,
19
+ ) ;
20
+
21
+ const BaseCard = dynamic < BaseCardProps > (
22
+ ( ) => import ( '../../BaseCard' ) . then ( ( mod ) => mod . BaseCard ) ,
23
+ { loading : ( ) => < CircularProgress size = "1rem" /> } ,
24
+ ) ;
15
25
16
26
export interface ApplicationCardProps extends Pick < RunJobButtonProps , 'projectId' > {
17
27
/**
@@ -26,45 +36,38 @@ export interface ApplicationCardProps extends Pick<RunJobButtonProps, 'projectId
26
36
*/
27
37
export const JobCard = ( { projectId, job } : ApplicationCardProps ) => {
28
38
// TODO remove this once the doc_url attribute is in the DM API client
29
- const jobSummary = job as JobSummaryWithDocUrl ;
30
39
31
40
const theme = useTheme ( ) ;
32
41
return (
33
42
< BaseCard
34
43
actions = { ( { setExpanded } ) => (
35
- < RunJobButton
36
- jobId = { jobSummary . id }
37
- projectId = { projectId }
38
- onLaunch = { ( ) => setExpanded ( true ) }
39
- />
44
+ < RunJobButton jobId = { job . id } projectId = { projectId } onLaunch = { ( ) => setExpanded ( true ) } />
40
45
) }
41
46
collapsed = {
42
47
< InstancesList
43
- predicate = { ( instance ) =>
44
- instance . job_id === jobSummary . id && instance . job_job === jobSummary . job
45
- }
48
+ predicate = { ( instance ) => instance . job_id === job . id && instance . job_job === job . job }
46
49
/>
47
50
}
48
51
header = { {
49
52
color : theme . palette . primary . main ,
50
- subtitle : jobSummary . name ,
51
- avatar : jobSummary . job [ 0 ] ,
52
- title : jobSummary . job ,
53
+ subtitle : job . name ,
54
+ avatar : job . job [ 0 ] ,
55
+ title : job . job ,
53
56
} }
54
57
key = { projectId } // Reset state when project changes
55
58
>
56
- < Typography gutterBottom > { jobSummary . description } </ Typography >
59
+ < Typography gutterBottom > { job . description } </ Typography >
57
60
< Typography variant = "body2" >
58
- { jobSummary . version } –{ ' ' }
59
- < Link href = { jobSummary . doc_url } rel = "noopener noreferrer" target = "_blank" >
61
+ { job . version } –{ ' ' }
62
+ < Link href = { job . doc_url } rel = "noopener noreferrer" target = "_blank" >
60
63
docs
61
64
</ Link >
62
65
</ Typography >
63
66
< Typography gutterBottom >
64
- < em > { jobSummary . category || '<none>' } </ em > : { jobSummary . collection }
67
+ < em > { job . category || '<none>' } </ em > : { job . collection }
65
68
</ Typography >
66
69
< Chips >
67
- { jobSummary . keywords ?. map ( ( word ) => (
70
+ { job . keywords ?. map ( ( word ) => (
68
71
< Chip color = "primary" key = { word } label = { word } size = "small" variant = "outlined" />
69
72
) ) }
70
73
</ Chips >
0 commit comments