Skip to content

Commit a7f87ec

Browse files
changing logic for connect to mcp
1 parent 70b7d34 commit a7f87ec

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/components/ControlPlanes/ControlPlaneCard/ControlPlaneCard.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import MCPHealthPopoverButton from '../../ControlPlane/MCPHealthPopoverButton.ts
1313
import styles from './ControlPlaneCard.module.css';
1414
import { KubectlDeleteMcp } from '../../Dialogs/KubectlCommandInfo/Controllers/KubectlDeleteMcp.tsx';
1515
import {
16+
ControlPlaneType,
1617
ListControlPlanesType,
1718
ReadyStatus,
1819
} from '../../../lib/api/types/crate/controlPlanes.ts';
@@ -59,6 +60,22 @@ export function ControlPlaneCard({
5960
const name = controlPlane.metadata.name;
6061
const namespace = controlPlane.metadata.namespace;
6162

63+
const canConnectToMCP = (controlPlane: ControlPlaneType): boolean => {
64+
const conditions = controlPlane.status?.conditions ?? [];
65+
66+
return [
67+
'APIServerHealthy',
68+
'AuthenticationHealthy',
69+
'AuthorizationHealthy',
70+
].every((type) =>
71+
conditions.some(
72+
(condition) => condition.type === type && condition.status === true,
73+
),
74+
);
75+
};
76+
77+
const isConnectButtonEnabled = canConnectToMCP(controlPlane);
78+
6279
return (
6380
<>
6481
<Card key={`${name}--${namespace}`} className={styles.card}>
@@ -106,7 +123,7 @@ export function ControlPlaneCard({
106123
resourceType={'managedcontrolplanes'}
107124
/>
108125
<ConnectButton
109-
disabled={controlPlane.status?.status !== ReadyStatus.Ready}
126+
disabled={isConnectButtonEnabled}
110127
controlPlaneName={name}
111128
projectName={projectName}
112129
workspaceName={workspace.metadata.name ?? ''}

0 commit comments

Comments
 (0)