1- import React , { useEffect , useMemo } from 'react' ;
1+ import React , { useEffect , useMemo , useState } from 'react' ;
22import { useTranslation } from 'react-i18next' ;
33import { useParams } from 'react-router-dom' ;
44
5- import { Box , ColumnLayout , Container , ContentLayout , DetailsHeader , Header , Loader , StatusIndicator } from 'components' ;
5+ import { Box , ColumnLayout , Container , ContentLayout , DetailsHeader , Header , Loader , StatusIndicator , Tabs } from 'components' ;
66
77import { useBreadcrumbs } from 'hooks' ;
88import { riseRouterException } from 'libs' ;
9+ import { getStatusIconType } from 'libs/run' ;
910import { ROUTES } from 'routes' ;
1011import { useGetRunQuery } from 'services/run' ;
1112
12- import { getStatusIconType } from '../../../../../libs/run' ;
1313import { Logs } from '../../Logs' ;
1414import {
1515 getJobListItemBackend ,
@@ -22,9 +22,15 @@ import {
2222 getJobSubmittedAt ,
2323 getJobTerminationReason ,
2424} from '../List/helpers' ;
25+ import { RunMetrics } from '../Metrics' ;
2526
2627import styles from './styles.module.scss' ;
2728
29+ enum CodeTab {
30+ Details = 'details' ,
31+ Metrics = 'metrics' ,
32+ }
33+
2834const getJobSubmissionId = ( job ?: IJob ) : string | undefined => {
2935 if ( ! job ) return ;
3036
@@ -34,6 +40,7 @@ const getJobSubmissionId = (job?: IJob): string | undefined => {
3440export const JobDetails : React . FC = ( ) => {
3541 const { t } = useTranslation ( ) ;
3642 const params = useParams ( ) ;
43+ const [ codeTab , setCodeTab ] = useState < CodeTab > ( CodeTab . Details ) ;
3744 const paramProjectName = params . projectName ?? '' ;
3845 const paramRunId = params . runId ?? '' ;
3946 const paramJobName = params . jobName ?? '' ;
@@ -75,7 +82,7 @@ export const JobDetails: React.FC = () => {
7582 href : ROUTES . RUNS . LIST ,
7683 } ,
7784 {
78- text : paramRunId ,
85+ text : runData ?. run_spec . run_name ?? '' ,
7986 href : ROUTES . PROJECT . DETAILS . RUNS . DETAILS . FORMAT ( paramProjectName , paramRunId ) ,
8087 } ,
8188 {
@@ -99,64 +106,85 @@ export const JobDetails: React.FC = () => {
99106
100107 { jobData && (
101108 < >
102- < Container header = { < Header variant = "h2" > { t ( 'common.general' ) } </ Header > } >
103- < ColumnLayout columns = { 4 } variant = "text-grid" >
104- < div >
105- < Box variant = "awsui-key-label" > { t ( 'projects.run.submitted_at' ) } </ Box >
106- < div > { getJobSubmittedAt ( jobData ) } </ div >
107- </ div >
108-
109- < div >
110- < Box variant = "awsui-key-label" > { t ( 'projects.run.status' ) } </ Box >
111- < div >
112- < StatusIndicator type = { getStatusIconType ( getJobStatus ( jobData ) ) } >
113- { t ( `projects.run.statuses.${ getJobStatus ( jobData ) } ` ) }
114- </ StatusIndicator >
115- </ div >
116- </ div >
117-
118- < div >
119- < Box variant = "awsui-key-label" > { t ( 'projects.run.termination_reason' ) } </ Box >
120- < div > { getJobTerminationReason ( jobData ) } </ div >
121- </ div >
122-
123- < div >
124- < Box variant = "awsui-key-label" > { t ( 'projects.run.backend' ) } </ Box >
125- < div > { getJobListItemBackend ( jobData ) } </ div >
126- </ div >
127-
128- < div >
129- < Box variant = "awsui-key-label" > { t ( 'projects.run.region' ) } </ Box >
130- < div > { getJobListItemRegion ( jobData ) } </ div >
131- </ div >
132-
133- < div >
134- < Box variant = "awsui-key-label" > { t ( 'projects.run.instance' ) } </ Box >
135- < div > { getJobListItemInstance ( jobData ) } </ div >
136- </ div >
137-
138- < div >
139- < Box variant = "awsui-key-label" > { t ( 'projects.run.resources' ) } </ Box >
140- < div > { getJobListItemResources ( jobData ) } </ div >
141- </ div >
142-
143- < div >
144- < Box variant = "awsui-key-label" > { t ( 'projects.run.spot' ) } </ Box >
145- < div > { getJobListItemSpot ( jobData ) } </ div >
146- </ div >
147-
148- < div >
149- < Box variant = "awsui-key-label" > { t ( 'projects.run.price' ) } </ Box >
150- < div > { getJobListItemPrice ( jobData ) } </ div >
151- </ div >
152- </ ColumnLayout >
153- </ Container >
154-
155- < Logs
156- projectName = { paramProjectName }
157- runName = { runData ?. run_spec ?. run_name ?? '' }
158- jobSubmissionId = { getJobSubmissionId ( jobData ) }
159- className = { styles . logs }
109+ < Tabs
110+ onChange = { ( { detail } ) => setCodeTab ( detail . activeTabId as CodeTab ) }
111+ activeTabId = { codeTab }
112+ tabs = { [
113+ {
114+ label : 'Details' ,
115+ id : CodeTab . Details ,
116+ content : (
117+ < div className = { styles . details } >
118+ < Container header = { < Header variant = "h2" > { t ( 'common.general' ) } </ Header > } >
119+ < ColumnLayout columns = { 4 } variant = "text-grid" >
120+ < div >
121+ < Box variant = "awsui-key-label" > { t ( 'projects.run.submitted_at' ) } </ Box >
122+ < div > { getJobSubmittedAt ( jobData ) } </ div >
123+ </ div >
124+
125+ < div >
126+ < Box variant = "awsui-key-label" > { t ( 'projects.run.status' ) } </ Box >
127+ < div >
128+ < StatusIndicator type = { getStatusIconType ( getJobStatus ( jobData ) ) } >
129+ { t ( `projects.run.statuses.${ getJobStatus ( jobData ) } ` ) }
130+ </ StatusIndicator >
131+ </ div >
132+ </ div >
133+
134+ < div >
135+ < Box variant = "awsui-key-label" >
136+ { t ( 'projects.run.termination_reason' ) }
137+ </ Box >
138+ < div > { getJobTerminationReason ( jobData ) } </ div >
139+ </ div >
140+
141+ < div >
142+ < Box variant = "awsui-key-label" > { t ( 'projects.run.backend' ) } </ Box >
143+ < div > { getJobListItemBackend ( jobData ) } </ div >
144+ </ div >
145+
146+ < div >
147+ < Box variant = "awsui-key-label" > { t ( 'projects.run.region' ) } </ Box >
148+ < div > { getJobListItemRegion ( jobData ) } </ div >
149+ </ div >
150+
151+ < div >
152+ < Box variant = "awsui-key-label" > { t ( 'projects.run.instance' ) } </ Box >
153+ < div > { getJobListItemInstance ( jobData ) } </ div >
154+ </ div >
155+
156+ < div >
157+ < Box variant = "awsui-key-label" > { t ( 'projects.run.resources' ) } </ Box >
158+ < div > { getJobListItemResources ( jobData ) } </ div >
159+ </ div >
160+
161+ < div >
162+ < Box variant = "awsui-key-label" > { t ( 'projects.run.spot' ) } </ Box >
163+ < div > { getJobListItemSpot ( jobData ) } </ div >
164+ </ div >
165+
166+ < div >
167+ < Box variant = "awsui-key-label" > { t ( 'projects.run.price' ) } </ Box >
168+ < div > { getJobListItemPrice ( jobData ) } </ div >
169+ </ div >
170+ </ ColumnLayout >
171+ </ Container >
172+
173+ < Logs
174+ projectName = { paramProjectName }
175+ runName = { runData ?. run_spec ?. run_name ?? '' }
176+ jobSubmissionId = { getJobSubmissionId ( jobData ) }
177+ className = { styles . logs }
178+ />
179+ </ div >
180+ ) ,
181+ } ,
182+ {
183+ label : 'Metrics' ,
184+ id : CodeTab . Metrics ,
185+ content : < RunMetrics /> ,
186+ } ,
187+ ] }
160188 />
161189 </ >
162190 ) }
0 commit comments