Skip to content

Commit a84b9ff

Browse files
fix: disable connection to unsupported IdP (#172)
1 parent 5f6787b commit a84b9ff

File tree

3 files changed

+42
-6
lines changed

3 files changed

+42
-6
lines changed

public/locales/en.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@
5858
"emptyListSubtitleMessage": "Create a workspace to get started"
5959
},
6060
"ConnectButton": {
61-
"buttonText": "Connect"
61+
"buttonText": "Connect",
62+
"defaultIdP": "default IdP",
63+
"unsupportedIdP": "non-default IdP not supported"
6264
},
6365
"MCPHealthPopoverButton": {
6466
"statusHeader": "Status",

src/components/ControlPlanes/ConnectButton.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,12 @@ export default function ConnectButton(props: Props) {
102102
data-target={`/mcp/projects/${props.projectName}/workspaces/${extractWorkspaceNameFromNamespace(
103103
props.workspaceName,
104104
)}/mcps/${props.controlPlaneName}/context/${context.name}`}
105-
additionalText={
106-
currentContext === context.name ? '(default IdP)' : undefined
107-
}
105+
additionalText={`(${
106+
context.context.user === 'openmcp'
107+
? t('ConnectButton.defaultIdP')
108+
: t('ConnectButton.unsupportedIdP')
109+
})`}
110+
disabled={context.context.user !== 'openmcp'}
108111
/>
109112
))}
110113
<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)