Skip to content

Commit ec20c7d

Browse files
committed
[DOP-31841] Show job tags
1 parent 2adf20f commit ec20c7d

File tree

8 files changed

+61
-13
lines changed

8 files changed

+61
-13
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "data-rentgen",
3-
"version": "0.4.8",
3+
"version": "0.5.0",
44
"private": true,
55
"description": "Frontend for Data.Rentgen",
66
"license": "Apache-2.0",
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { TagResponseV1 } from "@/dataProvider/types";
2+
import { Chip, Box } from "@mui/material";
3+
4+
const TagValuesField = ({ tag }: { tag: TagResponseV1 }) => {
5+
return (
6+
<Box sx={{ width: "fit-content" }}>
7+
{tag.values.map((tag_value, tag_value_index) => (
8+
<Chip
9+
key={tag_value_index}
10+
label={`${tag.name}: ${tag_value.value}`}
11+
size="small"
12+
variant="outlined"
13+
sx={{ fontSize: "0.7rem" }}
14+
/>
15+
))}
16+
</Box>
17+
);
18+
};
19+
20+
export default TagValuesField;

src/components/base/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import ListActions from "./ListActions";
88
import RowCountField from "./RowCountField";
99
import StatusField from "./StatusField";
1010
import StatusRaField from "./StatusRaField";
11+
import TagValuesField from "./TagValuesField";
1112

1213
export {
1314
ByteCountField,
@@ -20,4 +21,5 @@ export {
2021
StatusField,
2122
StatusRaField,
2223
IOStatisticsField,
24+
TagValuesField,
2325
};

src/components/dataset/DatasetRaTag.tsx

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { useRecordContext } from "react-admin";
22
import { DatasetDetailedResponseV1 } from "@/dataProvider/types";
3-
import { Stack, Chip, Box } from "@mui/material";
3+
import { Stack, Box } from "@mui/material";
4+
import { TagValuesField } from "@/components/base";
45

56
const DatasetRaTag = () => {
67
const record: DatasetDetailedResponseV1 | undefined = useRecordContext();
@@ -11,15 +12,7 @@ const DatasetRaTag = () => {
1112
<Stack spacing={1}>
1213
{record.tags?.map((tag, tag_index) => (
1314
<Box key={tag_index} sx={{ width: "fit-content" }}>
14-
{tag.values.map((tag_value, tag_value_index) => (
15-
<Chip
16-
key={tag_value_index}
17-
label={`${tag.name}: ${tag_value.value}`}
18-
size="small"
19-
variant="outlined"
20-
sx={{ fontSize: "0.7rem" }}
21-
/>
22-
))}
15+
<TagValuesField tag={tag} />
2316
</Box>
2417
))}
2518
</Stack>

src/components/job/JobRaShow.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { ReactElement } from "react";
22
import {
3+
ArrayField,
34
Show,
45
SimpleShowLayout,
56
TabbedShowLayout,
@@ -14,6 +15,7 @@ import {
1415
LocationRaTypeWithIconField,
1516
} from "@/components/location";
1617
import JobRaTypeField from "./JobRaTypeField";
18+
import JobRaTag from "./JobRaTag";
1719

1820
const JobRaShow = (): ReactElement => {
1921
return (
@@ -37,6 +39,12 @@ const JobRaShow = (): ReactElement => {
3739
source="data.location.name"
3840
label="resources.locations.fields.name"
3941
/>
42+
<ArrayField
43+
source="data.tags"
44+
label="resources.datasets.fields.tags"
45+
>
46+
<JobRaTag />
47+
</ArrayField>
4048

4149
<TabbedShowLayout>
4250
<TabbedShowLayout.Tab label="resources.jobs.tabs.runs">

src/components/job/JobRaTag.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { useRecordContext } from "react-admin";
2+
import { JobDetailedResponseV1 } from "@/dataProvider/types";
3+
import { Stack, Box } from "@mui/material";
4+
import { TagValuesField } from "@/components/base";
5+
6+
const JobRaTag = () => {
7+
const record: JobDetailedResponseV1 | undefined = useRecordContext();
8+
if (!record) {
9+
return null;
10+
}
11+
return (
12+
<Stack spacing={1}>
13+
{record.tags?.map((tag, tag_index) => (
14+
<Box key={tag_index} sx={{ width: "fit-content" }}>
15+
<TagValuesField tag={tag} />
16+
</Box>
17+
))}
18+
</Stack>
19+
);
20+
};
21+
22+
export default JobRaTag;

src/dataProvider/types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ interface JobResponseV1 extends RaRecord {
6767
interface JobDetailedResponseV1 {
6868
id: string;
6969
data: JobResponseV1;
70+
tags: TagResponseV1[];
7071
}
7172

7273
interface JobTypesResponseV1 {
@@ -336,4 +337,6 @@ export type {
336337
PersonalTokenScopeV1,
337338
PersonalTokenDetailedResponseV1,
338339
PersonalTokenCreateDetailedResponseV1,
340+
TagResponseV1,
341+
TagValueResponseV1,
339342
};

0 commit comments

Comments
 (0)