Skip to content

Commit 68ef132

Browse files
committed
adjust connect button enablement
1 parent 7d95fba commit 68ef132

File tree

2 files changed

+35
-4
lines changed

2 files changed

+35
-4
lines changed

src/components/ControlPlanes/ConnectButton.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,11 @@ export default function ConnectButton(props: Props) {
103103
props.workspaceName,
104104
)}/mcps/${props.controlPlaneName}/context/${context.name}`}
105105
additionalText={`(${
106-
currentContext === context.name
106+
context.context.user === 'openmcp'
107107
? t('ConnectButton.defaultIdP')
108108
: t('ConnectButton.unsupportedIdP')
109109
})`}
110-
disabled={currentContext !== context.name}
110+
disabled={context.context.user !== 'openmcp'}
111111
/>
112112
))}
113113
<MenuItem

src/components/ControlPlanes/ControlPlaneCard/ControlPlaneCard.tsx

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ import {
1717
ReadyStatus,
1818
} from '../../../lib/api/types/crate/controlPlanes.ts';
1919
import { ListWorkspacesType } from '../../../lib/api/types/crate/listWorkspaces.ts';
20-
import { useApiResourceMutation } from '../../../lib/api/useApiResource.ts';
20+
import useResource, {
21+
useApiResourceMutation,
22+
} from '../../../lib/api/useApiResource.ts';
2123
import {
2224
DeleteMCPResource,
2325
DeleteMCPType,
@@ -28,6 +30,8 @@ import {
2830
import { YamlViewButtonWithLoader } from '../../Yaml/YamlViewButtonWithLoader.tsx';
2931
import { useToast } from '../../../context/ToastContext.tsx';
3032
import { canConnectToMCP } from '../controlPlanes.ts';
33+
import { ResourceObject } from '../../../lib/api/types/crate/resourceObject.ts';
34+
import { Infobox } from '../../Ui/Infobox/Infobox.tsx';
3135

3236
interface Props {
3337
controlPlane: ListControlPlanesType;
@@ -60,7 +64,29 @@ export function ControlPlaneCard({
6064
const name = controlPlane.metadata.name;
6165
const namespace = controlPlane.metadata.namespace;
6266

63-
const isConnectButtonEnabled = canConnectToMCP(controlPlane);
67+
// Disable the Connect button if the system IdP is disabled
68+
const controlPlaneConfig = useResource(
69+
ResourceObject(
70+
controlPlane.metadata.namespace,
71+
'managedcontrolplanes',
72+
controlPlane.metadata.name,
73+
),
74+
undefined,
75+
true,
76+
);
77+
78+
const isSystemIdentityProviderEnabled =
79+
// @ts-ignore
80+
!!controlPlaneConfig.data?.spec?.authentication
81+
?.enableSystemIdentityProvider;
82+
83+
const isConnectButtonEnabled =
84+
canConnectToMCP(controlPlane) &&
85+
isSystemIdentityProviderEnabled &&
86+
!controlPlaneConfig.isLoading;
87+
88+
const showWarningBecauseOfDisabledSystemIdentityProvider =
89+
!controlPlaneConfig.isLoading && !isSystemIdentityProviderEnabled;
6490

6591
return (
6692
<>
@@ -108,6 +134,11 @@ export function ControlPlaneCard({
108134
resourceName={controlPlane.metadata.name}
109135
resourceType={'managedcontrolplanes'}
110136
/>
137+
{showWarningBecauseOfDisabledSystemIdentityProvider && (
138+
<Infobox size="sm" variant="warning">
139+
{t('ConnectButton.unsupportedIdP')}
140+
</Infobox>
141+
)}
111142
<ConnectButton
112143
disabled={!isConnectButtonEnabled}
113144
controlPlaneName={name}

0 commit comments

Comments
 (0)