Skip to content

Commit fed3586

Browse files
committed
[DOP-31844] Show last run info on Job list
1 parent 67aca2b commit fed3586

File tree

13 files changed

+119
-32
lines changed

13 files changed

+119
-32
lines changed

src/components/base/DurationRaField.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const DurationRaField = (props: FieldProps): ReactElement => {
77
return (
88
<FunctionField
99
render={(record) => (
10-
<DurationField fieldSet={record.data}></DurationField>
10+
<DurationField fieldSet={record[props.source]} />
1111
)}
1212
{...props}
1313
/>

src/components/base/StatusField.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ const statusToColorMap = {
1313

1414
const StatusField = ({
1515
status,
16+
/* eslint-disable @typescript-eslint/no-unused-vars */
17+
label,
1618
...props
1719
}: { status: keyof typeof statusToColorMap } & ChipProps): ReactNode | null => {
1820
const translate = useTranslate();
Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
import {
2-
OperationDetailedResponseV1,
3-
RunDetailedResponseV1,
4-
} from "@/dataProvider/types";
51
import { ReactElement } from "react";
6-
import { ChipFieldProps, useRecordContext } from "react-admin";
2+
import { ChipFieldProps, useFieldValue } from "react-admin";
73
import StatusField from "./StatusField";
84

95
const StatusRaField = ({
@@ -13,12 +9,10 @@ const StatusRaField = ({
139
children,
1410
...chipProps
1511
}: ChipFieldProps): ReactElement | null => {
16-
const record = useRecordContext<
17-
RunDetailedResponseV1 | OperationDetailedResponseV1
18-
>();
19-
if (!record) return null;
12+
const value = useFieldValue({ source });
13+
if (!value) return null;
2014

21-
return <StatusField status={record.data.status} {...chipProps} />;
15+
return <StatusField status={value} {...chipProps} />;
2216
};
2317

2418
export default StatusRaField;

src/components/job/JobRaList.tsx

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import { ReactElement } from "react";
2-
import { List, TextField, DatagridConfigurable, ArrayField } from "react-admin";
3-
import { ListActions } from "@/components/base";
2+
import {
3+
List,
4+
TextField,
5+
DatagridConfigurable,
6+
ArrayField,
7+
ReferenceField,
8+
} from "react-admin";
9+
import { DurationRaField, ListActions, StatusRaField } from "@/components/base";
410
import {
511
LocationRaNameWithLinkField,
612
LocationRaTypeWithIconField,
@@ -34,14 +40,33 @@ const JobRaList = (): ReactElement => {
3440
<LocationRaTypeWithIconField
3541
source="data.location.type"
3642
label="resources.locations.fields.type"
43+
sortable={false}
3744
/>
3845
<LocationRaNameWithLinkField
3946
source="data.location.name"
4047
label="resources.locations.fields.name"
48+
sortable={false}
49+
/>
50+
<ReferenceField
51+
reference="runs"
52+
source="last_run.id"
53+
label="resources.jobs.fields.last_run"
54+
sortable={false}
55+
/>
56+
<DurationRaField
57+
source="last_run"
58+
label="resources.jobs.fields.last_duration"
59+
sortable={false}
60+
/>
61+
<StatusRaField
62+
source="last_run.status"
63+
label="resources.jobs.fields.last_status"
64+
sortable={false}
4165
/>
4266
<ArrayField
4367
source="data.tags"
4468
label="resources.jobs.fields.tags"
69+
sortable={false}
4570
>
4671
<JobRaTag />
4772
</ArrayField>

src/components/job/JobRaListForLocation.tsx

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
import { ReactElement } from "react";
22

3-
import { ListActions } from "@/components/base";
4-
import { List, TextField, DatagridConfigurable, ArrayField } from "react-admin";
3+
import { DurationRaField, ListActions, StatusRaField } from "@/components/base";
4+
import {
5+
List,
6+
TextField,
7+
DatagridConfigurable,
8+
ArrayField,
9+
ReferenceField,
10+
} from "react-admin";
511
import JobRaTypeField from "./JobRaTypeField";
612
import JobRaListFilters from "./JobRaListFilters";
713
import JobRaTag from "./JobRaTag";
@@ -33,6 +39,22 @@ const JobRaListForLocation = ({
3339
label="resources.jobs.fields.name"
3440
sortable={false}
3541
/>
42+
<ReferenceField
43+
reference="runs"
44+
source="last_run.id"
45+
label="resources.jobs.fields.last_run"
46+
sortable={false}
47+
/>
48+
<DurationRaField
49+
source="last_run"
50+
label="resources.jobs.fields.last_duration"
51+
sortable={false}
52+
/>
53+
<StatusRaField
54+
source="last_run.status"
55+
label="resources.jobs.fields.last_status"
56+
sortable={false}
57+
/>
3658
<ArrayField
3759
source="data.tags"
3860
label="resources.jobs.fields.tags"

src/components/operation/OperationRaListForRun.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,16 @@ const OperationRaListForRun = ({
5959
}
6060
sortable={false}
6161
/>
62-
<StatusRaField source="status" sortable={false} />
63-
<DurationRaField source="duration" sortable={false} />
62+
<StatusRaField
63+
source="data.status"
64+
label="resources.operations.fields.status"
65+
sortable={false}
66+
/>
67+
<DurationRaField
68+
source="data"
69+
label="resources.operations.fields.duration"
70+
sortable={false}
71+
/>
6472
<IOStatisticsField source="statistics.inputs" />
6573
<IOStatisticsField source="statistics.outputs" />
6674
</DatagridConfigurable>

src/components/operation/OperationRaShow.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ const OperationRaShow = (): ReactElement => {
7171
showTime={true}
7272
/>
7373

74-
<StatusRaField source="status" />
74+
<StatusRaField
75+
source="data.status"
76+
label="resources.operations.fields.status"
77+
/>
7578
<Labeled label="resources.operations.sections.ended">
7679
<Stack direction="row" spacing={3}>
7780
<Labeled label="resources.operations.sections.when">
@@ -81,7 +84,7 @@ const OperationRaShow = (): ReactElement => {
8184
/>
8285
</Labeled>
8386
<Labeled label="resources.operations.sections.duration">
84-
<DurationRaField source="duration" />
87+
<DurationRaField source="data" />
8588
</Labeled>
8689
</Stack>
8790
</Labeled>

src/components/run/RunRaList.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,27 @@ const RunRaList = (): ReactElement => {
3030
>
3131
<DatagridConfigurable bulkActionButtons={false}>
3232
<ReferenceField
33+
reference="runs"
3334
source="data.id"
3435
label="resources.runs.fields.created_at"
35-
reference="runs"
3636
sortable={false}
3737
/>
3838
<ReferenceField
39+
reference="jobs"
3940
source="data.job_id"
4041
label="resources.runs.fields.job"
41-
reference="jobs"
4242
sortable={false}
4343
/>
44-
<StatusRaField source="status" sortable={false} />
45-
<DurationRaField source="duration" sortable={false} />
44+
<StatusRaField
45+
source="data.status"
46+
label="resources.runs.fields.status"
47+
sortable={false}
48+
/>
49+
<DurationRaField
50+
source="data"
51+
label="resources.runs.fields.duration"
52+
sortable={false}
53+
/>
4654
<WrapperField source="started_by_user" sortable={false}>
4755
<TextField source="data.started_by_user.name" />
4856
</WrapperField>

src/components/run/RunRaListForJob.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,22 @@ const RunRaListForJob = ({ jobId }: { jobId: number }): ReactElement => {
3232
>
3333
<DatagridConfigurable bulkActionButtons={false}>
3434
<ReferenceField
35+
reference="runs"
3536
source="data.id"
3637
label="resources.runs.fields.created_at"
37-
reference="runs"
3838
sortable={false}
3939
/>
4040
{/* Do not show job, as we already in JobShow page*/}
41-
<StatusRaField source="status" sortable={false} />
42-
<DurationRaField source="duration" sortable={false} />
41+
<StatusRaField
42+
source="data.status"
43+
label="resources.runs.fields.status"
44+
sortable={false}
45+
/>
46+
<DurationRaField
47+
source="data"
48+
label="resources.runs.fields.duration"
49+
sortable={false}
50+
/>
4351
<WrapperField source="started_by_user" sortable={false}>
4452
<TextField source="data.started_by_user.name" />
4553
</WrapperField>

src/components/run/RunRaListForParentRun.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,27 @@ const RunRaListForParentRun = ({
3737
>
3838
<DatagridConfigurable bulkActionButtons={false}>
3939
<ReferenceField
40+
reference="runs"
4041
source="data.id"
4142
label="resources.runs.fields.created_at"
42-
reference="runs"
4343
sortable={false}
4444
/>
4545
<ReferenceField
46+
reference="jobs"
4647
source="data.job_id"
4748
label="resources.runs.fields.job"
48-
reference="jobs"
4949
sortable={false}
5050
/>
51-
<StatusRaField source="status" sortable={false} />
52-
<DurationRaField source="duration" sortable={false} />
51+
<StatusRaField
52+
source="data.status"
53+
label="resources.runs.fields.status"
54+
sortable={false}
55+
/>
56+
<DurationRaField
57+
source="data"
58+
label="resources.runs.fields.duration"
59+
sortable={false}
60+
/>
5361
<WrapperField source="started_by_user" sortable={false}>
5462
<TextField source="data.started_by_user.name" />
5563
</WrapperField>

0 commit comments

Comments
 (0)