Skip to content

Commit ac3941e

Browse files
authored
[DOP-27824] add dataset tags (#71)
* [DOP-27824] add dataset tags * [DOP-27824] add types * [DOP-27824] add sort for stabel order * [DOP-27824] change type annotations * [DOP-27824] change type annotations
1 parent d48ecf9 commit ac3941e

File tree

6 files changed

+46
-2
lines changed

6 files changed

+46
-2
lines changed

src/components/dataset/DatasetRaShow.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ import {
44
SimpleShowLayout,
55
TextField,
66
TabbedShowLayout,
7-
WithRecord,
7+
ArrayField,
88
} from "react-admin";
99
import {
1010
LocationRaNameWithLinkField,
1111
LocationRaTypeWithIconField,
1212
} from "@/components/location";
1313
import DatasetRaLineage from "./DatasetRaLineage";
14+
import DatasetRaTag from "./DatasetRaTag";
1415

1516
const DatasetRaShow = (): ReactElement => {
1617
return (
@@ -33,6 +34,12 @@ const DatasetRaShow = (): ReactElement => {
3334
source="data.name"
3435
label="resources.datasets.fields.name"
3536
/>
37+
<ArrayField
38+
source="data.tags"
39+
label="resources.datasets.fields.tags"
40+
>
41+
<DatasetRaTag />
42+
</ArrayField>
3643

3744
<TabbedShowLayout>
3845
<TabbedShowLayout.Tab label="resources.datasets.tabs.lineage">
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { useRecordContext } from "react-admin";
2+
import { DatasetDetailedResponseV1 } from "@/dataProvider/types";
3+
import { Stack, Chip, Box } from "@mui/material";
4+
5+
const DatasetRaTag = () => {
6+
const record: DatasetDetailedResponseV1 | undefined = useRecordContext();
7+
if (!record) {
8+
return null;
9+
}
10+
return (
11+
<Stack spacing={1}>
12+
{record.data.tags
13+
.sort((a, b) => a.name.localeCompare(b.name))
14+
.map((tag, index) => (
15+
<Box key={index} sx={{ width: "fit-content" }}>
16+
<Chip
17+
label={`${tag.name}: ${tag.value}`}
18+
size="small"
19+
variant="outlined"
20+
sx={{ fontSize: "0.7rem" }}
21+
></Chip>
22+
</Box>
23+
))}
24+
</Stack>
25+
);
26+
};
27+
28+
export default DatasetRaTag;

src/components/dataset/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import DatasetRaShow from "./DatasetRaShow";
22
import DatasetRaList from "./DatasetRaList";
33
import DatasetRaRepr from "./DatasetRaRepr";
4+
import DatasetRaTag from "./DatasetRaTag";
45

5-
export { DatasetRaShow, DatasetRaList, DatasetRaRepr };
6+
export { DatasetRaShow, DatasetRaList, DatasetRaRepr, DatasetRaTag };

src/dataProvider/types.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,16 @@ interface LocationDetailedResponseV1 {
2929
statistics: LocationStatisticsResponseV1;
3030
}
3131

32+
interface TagsResponseV1 {
33+
name: string;
34+
value: string;
35+
}
36+
3237
interface DatasetResponseV1 extends RaRecord {
3338
id: string;
3439
type: string;
3540
name: string;
41+
tags: TagsResponseV1[];
3642
location: LocationResponseV1;
3743
}
3844

src/i18n/en.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ const customEnglishMessages: TranslationMessages = {
6969
fields: {
7070
id: "Internal ID",
7171
name: "Dataset name",
72+
tags: "Tags",
7273
schema: {
7374
exact_match: "Schema projection",
7475
latest_known: "Schema projection (latest)",

src/i18n/ru.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ const customRussianMessages: TranslationMessages = {
6969
fields: {
7070
id: "Внутренний идентификатор",
7171
name: "Имя датасета",
72+
tags: "Теги",
7273
schema: {
7374
exact_match: "Проекция схемы",
7475
latest_known: "Проекция схемы (последняя)",

0 commit comments

Comments
 (0)