Skip to content

Commit f5cee53

Browse files
committed
feat: show flux graph
1 parent 67a781c commit f5cee53

File tree

3 files changed

+21
-34
lines changed

3 files changed

+21
-34
lines changed

src/components/BentoGrid/GraphCard/GraphCard.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
import React from 'react';
22
import Graph from '../../Graphs/Graph';
33
import styles from './GraphCard.module.css';
4+
import { ColorBy } from '../../Graphs/types';
45

56
export interface GraphCardProps {
67
title?: string;
78
className?: string;
9+
colorBy?: ColorBy;
810
}
911

1012
export const GraphCard: React.FC<GraphCardProps> = ({
11-
className = ''
13+
className = '',
14+
colorBy = 'source'
1215
}) => {
1316
return (
1417
<div className={`${styles.container} ${className}`}>
1518
<div className={styles.simpleWrapper}>
16-
<Graph />
19+
<Graph colorBy={colorBy} />
1720
</div>
1821
</div>
1922
);

src/components/Graphs/Graph.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState, useCallback, useMemo } from 'react';
1+
import React, { useState, useCallback, useMemo, useEffect } from 'react';
22
import { ReactFlow, Background, Controls, Node, BackgroundVariant } from '@xyflow/react';
33
import type { NodeProps } from '@xyflow/react';
44
import { Button, Popover } from '@ui5/webcomponents-react';
@@ -28,14 +28,23 @@ const nodeTypes = {
2828
),
2929
};
3030

31-
const Graph: React.FC = () => {
31+
interface GraphProps {
32+
colorBy?: ColorBy;
33+
}
34+
35+
const Graph: React.FC<GraphProps> = ({ colorBy: initialColorBy = 'source' }) => {
3236
const { t } = useTranslation();
3337
const { isDarkTheme } = useTheme();
34-
const [colorBy, setColorBy] = useState<ColorBy>('source');
38+
const [colorBy, setColorBy] = useState<ColorBy>(initialColorBy);
3539
const [yamlDialogOpen, setYamlDialogOpen] = useState(false);
3640
const [yamlResource, setYamlResource] = useState<ManagedResourceItem | null>(null);
3741
const [filterPopoverOpen, setFilterPopoverOpen] = useState(false);
3842

43+
// Update colorBy when prop changes
44+
useEffect(() => {
45+
setColorBy(initialColorBy);
46+
}, [initialColorBy]);
47+
3948
const handleYamlClick = useCallback((item: ManagedResourceItem) => {
4049
setYamlResource(item);
4150
setYamlDialogOpen(true);

src/spaces/mcp/pages/McpPage.tsx

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -130,32 +130,6 @@ function McpPageContent({ mcp, controlPlaneName }: { mcp: any; controlPlaneName:
130130
}, 300);
131131
};
132132

133-
// Remove separate page logic - we'll do dynamic expansion within the grid
134-
// if (expandedCard) {
135-
// return (
136-
// <McpPageExpanded
137-
// mcp={mcp}
138-
// controlPlaneName={controlPlaneName}
139-
// onCollapse={handleCollapseExpanded}
140-
// />
141-
// );
142-
// }
143-
144-
// For now, small cards will also scroll to their respective sections
145-
const handleKyvernoClick = () => {
146-
const el = document.querySelector('#crossplane');
147-
if (el) {
148-
el.scrollIntoView({ behavior: 'smooth', block: 'start' });
149-
}
150-
};
151-
152-
const handleVaultClick = () => {
153-
const el = document.querySelector('#crossplane');
154-
if (el) {
155-
el.scrollIntoView({ behavior: 'smooth', block: 'start' });
156-
}
157-
};
158-
159133
return (
160134
<ObjectPage
161135
preserveHeaderStateOnClick={true}
@@ -205,7 +179,10 @@ function McpPageContent({ mcp, controlPlaneName }: { mcp: any; controlPlaneName:
205179
gridRow="1 / 5"
206180
className={expandedCard ? styles.expandedCard : ''}
207181
>
208-
<GraphCard title="Resource Dependencies" />
182+
<GraphCard
183+
title="Resource Dependencies"
184+
colorBy={expandedCard === 'gitops' ? 'flux' : 'source'}
185+
/>
209186
</BentoCard>
210187

211188
{/* Crossplane component - shows in default view or when expanded */}
@@ -335,7 +312,6 @@ function McpPageContent({ mcp, controlPlaneName }: { mcp: any; controlPlaneName:
335312
isLoading={managedResourcesLoading}
336313
error={managedResourcesError}
337314
config={veleroConfig}
338-
onClick={handleKyvernoClick}
339315
size="small"
340316
/>
341317
</BentoCard>
@@ -354,7 +330,6 @@ function McpPageContent({ mcp, controlPlaneName }: { mcp: any; controlPlaneName:
354330
isLoading={managedResourcesLoading}
355331
error={managedResourcesError}
356332
config={vaultConfig}
357-
onClick={handleVaultClick}
358333
size="small"
359334
/>
360335
</BentoCard>

0 commit comments

Comments
 (0)