Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix TypeScript errors in lineage visualization components
Co-Authored-By: Francisco Javier Arceo <arceofrancisco@gmail.com>
  • Loading branch information
commit 3a53836367622ad6a00dd127f3b6b0231211f8d6
10 changes: 7 additions & 3 deletions ui/src/components/RegistryVisualization.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,7 @@ const RegistryVisualization: React.FC<RegistryVisualizationProps> = ({
registryData,
relationships,
indirectRelationships,
filterNode,
}) => {
const [nodes, setNodes, onNodesChange] = useNodesState([]);
const [edges, setEdges, onEdgesChange] = useEdgesState([]);
Expand All @@ -596,13 +597,15 @@ const RegistryVisualization: React.FC<RegistryVisualizationProps> = ({
let relationshipsToShow = showIndirectRelationships
? [...relationships, ...indirectRelationships]
: relationships;

// Filter relationships based on filterNode if provided
if (filterNode) {
relationshipsToShow = relationshipsToShow.filter((rel) => {
return (
(rel.source.type === filterNode.type && rel.source.name === filterNode.name) ||
(rel.target.type === filterNode.type && rel.target.name === filterNode.name)
(rel.source.type === filterNode.type &&
rel.source.name === filterNode.name) ||
(rel.target.type === filterNode.type &&
rel.target.name === filterNode.name)
);
});
}
Expand Down Expand Up @@ -636,6 +639,7 @@ const RegistryVisualization: React.FC<RegistryVisualizationProps> = ({
indirectRelationships,
showIndirectRelationships,
showIsolatedNodes,
filterNode,
setNodes,
setEdges,
]);
Expand Down
42 changes: 30 additions & 12 deletions ui/src/components/RegistryVisualizationTab.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import React, { useContext, useState } from "react";
import { EuiEmptyPrompt, EuiLoadingSpinner, EuiSpacer, EuiSelect, EuiFormRow, EuiFlexGroup, EuiFlexItem } from "@elastic/eui";
import {
EuiEmptyPrompt,
EuiLoadingSpinner,
EuiSpacer,
EuiSelect,
EuiFormRow,
EuiFlexGroup,
EuiFlexItem,
} from "@elastic/eui";
import useLoadRegistry from "../queries/useLoadRegistry";
import RegistryPathContext from "../contexts/RegistryPathContext";
import RegistryVisualization from "./RegistryVisualization";
Expand All @@ -10,25 +18,33 @@ const RegistryVisualizationTab = () => {
const { isLoading, isSuccess, isError, data } = useLoadRegistry(registryUrl);
const [selectedObjectType, setSelectedObjectType] = useState("");
const [selectedObjectName, setSelectedObjectName] = useState("");

const getObjectOptions = (objects: any, type: string) => {
switch (type) {
case "dataSource":
const dataSources = new Set<string>();
objects.featureViews?.forEach((fv: any) => {
if (fv.spec?.batchSource?.name) dataSources.add(fv.spec.batchSource.name);
if (fv.spec?.batchSource?.name)
dataSources.add(fv.spec.batchSource.name);
});
objects.streamFeatureViews?.forEach((sfv: any) => {
if (sfv.spec?.batchSource?.name) dataSources.add(sfv.spec.batchSource.name);
if (sfv.spec?.streamSource?.name) dataSources.add(sfv.spec.streamSource.name);
if (sfv.spec?.batchSource?.name)
dataSources.add(sfv.spec.batchSource.name);
if (sfv.spec?.streamSource?.name)
dataSources.add(sfv.spec.streamSource.name);
});
return Array.from(dataSources);
case "entity":
return objects.entities?.map((entity: any) => entity.spec?.name) || [];
case "featureView":
return [...(objects.featureViews?.map((fv: any) => fv.spec?.name) || []),
...(objects.onDemandFeatureViews?.map((odfv: any) => odfv.spec?.name) || []),
...(objects.streamFeatureViews?.map((sfv: any) => sfv.spec?.name) || [])];
return [
...(objects.featureViews?.map((fv: any) => fv.spec?.name) || []),
...(objects.onDemandFeatureViews?.map(
(odfv: any) => odfv.spec?.name,
) || []),
...(objects.streamFeatureViews?.map((sfv: any) => sfv.spec?.name) ||
[]),
];
case "featureService":
return objects.featureServices?.map((fs: any) => fs.spec?.name) || [];
default:
Expand Down Expand Up @@ -84,10 +100,12 @@ const RegistryVisualizationTab = () => {
<EuiSelect
options={[
{ value: "", text: "All" },
...getObjectOptions(data.objects, selectedObjectType).map((name) => ({
value: name,
text: name,
})),
...getObjectOptions(data.objects, selectedObjectType).map(
(name: string) => ({
value: name,
text: name,
}),
),
]}
value={selectedObjectName}
onChange={(e) => setSelectedObjectName(e.target.value)}
Expand Down
Loading