-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expand file tree
/
Copy pathFeatureViewEdgesList.tsx
More file actions
91 lines (79 loc) · 2.22 KB
/
Copy pathFeatureViewEdgesList.tsx
File metadata and controls
91 lines (79 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import React from "react";
import { EuiBasicTable, EuiLoadingSpinner } from "@elastic/eui";
import EuiCustomLink from "../../components/EuiCustomLink";
import { useParams } from "react-router-dom";
import useLoadRelationshipData from "../../queries/useLoadRelationshipsData";
import { EntityRelation } from "../../parsers/parseEntityRelationships";
import { FEAST_FCO_TYPES } from "../../parsers/types";
interface FeatureViewEdgesListInterace {
fvNames: string[];
}
const whereFSconsumesThisFv = (fvName: string) => {
return (r: EntityRelation) => {
return (
r.source.name === fvName &&
r.target.type === FEAST_FCO_TYPES.featureService
);
};
};
const useGetFSConsumersOfFV = (fvList: string[]) => {
const relationshipQuery = useLoadRelationshipData();
const data = relationshipQuery.data
? fvList.reduce((memo: Record<string, string[]>, fvName) => {
if (relationshipQuery.data) {
memo[fvName] = relationshipQuery.data
.filter(whereFSconsumesThisFv(fvName))
.map((fs) => {
return fs.target.name;
});
}
return memo;
}, {})
: undefined;
return {
...relationshipQuery,
data,
};
};
const FeatureViewEdgesList = ({ fvNames }: FeatureViewEdgesListInterace) => {
const { projectName } = useParams();
const { isLoading, data } = useGetFSConsumersOfFV(fvNames);
const columns = [
{
name: "Name",
field: "",
render: ({ name }: { name: string }) => {
return (
<EuiCustomLink to={`/p/${projectName}/feature-view/${name}`}>
{name}
</EuiCustomLink>
);
},
},
{
name: "FS Consumers",
field: "",
render: ({ name }: { name: string }) => {
return (
<React.Fragment>
{isLoading && <EuiLoadingSpinner size="s" />}
{data && data[name].length}
</React.Fragment>
);
},
},
];
const getRowProps = (item: string) => {
return {
"data-test-subj": `row-${item}`,
};
};
return (
<EuiBasicTable
columns={columns}
items={fvNames.map((name) => ({ name }))}
rowProps={getRowProps}
/>
);
};
export default FeatureViewEdgesList;