Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 3 additions & 1 deletion public/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@
"emptyListSubtitleMessage": "Create a workspace to get started"
},
"ConnectButton": {
"buttonText": "Connect"
"buttonText": "Connect",
"defaultIdP": "default IdP",
"unsupportedIdP": "non-default IdP not supported"
},
"MCPHealthPopoverButton": {
"statusHeader": "Status",
Expand Down
9 changes: 6 additions & 3 deletions src/components/ControlPlanes/ConnectButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,12 @@ export default function ConnectButton(props: Props) {
data-target={`/mcp/projects/${props.projectName}/workspaces/${extractWorkspaceNameFromNamespace(
props.workspaceName,
)}/mcps/${props.controlPlaneName}/context/${context.name}`}
additionalText={
currentContext === context.name ? '(default IdP)' : undefined
}
additionalText={`(${
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use the mcp resource and check the spec.authentication.enableSystemIdentityProvider === true

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed as discussed

context.context.user === 'openmcp'
? t('ConnectButton.defaultIdP')
: t('ConnectButton.unsupportedIdP')
})`}
disabled={context.context.user !== 'openmcp'}
Comment on lines +106 to +110
Copy link

Copilot AI Jul 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The string 'openmcp' is used directly to detect the system IdP. Consider extracting this into a named constant to avoid magic strings and improve readability.

Suggested change
context.context.user === 'openmcp'
? t('ConnectButton.defaultIdP')
: t('ConnectButton.unsupportedIdP')
})`}
disabled={context.context.user !== 'openmcp'}
context.context.user === SYSTEM_IDP
? t('ConnectButton.defaultIdP')
: t('ConnectButton.unsupportedIdP')
})`}
disabled={context.context.user !== SYSTEM_IDP}

Copilot uses AI. Check for mistakes.
/>
))}
<MenuItem
Expand Down
35 changes: 33 additions & 2 deletions src/components/ControlPlanes/ControlPlaneCard/ControlPlaneCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ import {
ReadyStatus,
} from '../../../lib/api/types/crate/controlPlanes.ts';
import { ListWorkspacesType } from '../../../lib/api/types/crate/listWorkspaces.ts';
import { useApiResourceMutation } from '../../../lib/api/useApiResource.ts';
import useResource, {
useApiResourceMutation,
} from '../../../lib/api/useApiResource.ts';
Comment on lines +20 to +22
Copy link

Copilot AI Jul 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The imported useApiResourceMutation is not used in this file. Remove it to clean up unused imports.

Suggested change
import useResource, {
useApiResourceMutation,
} from '../../../lib/api/useApiResource.ts';
import useResource from '../../../lib/api/useApiResource.ts';

Copilot uses AI. Check for mistakes.
import {
DeleteMCPResource,
DeleteMCPType,
Expand All @@ -28,6 +30,8 @@ import {
import { YamlViewButtonWithLoader } from '../../Yaml/YamlViewButtonWithLoader.tsx';
import { useToast } from '../../../context/ToastContext.tsx';
import { canConnectToMCP } from '../controlPlanes.ts';
import { ResourceObject } from '../../../lib/api/types/crate/resourceObject.ts';
import { Infobox } from '../../Ui/Infobox/Infobox.tsx';

interface Props {
controlPlane: ListControlPlanesType;
Expand Down Expand Up @@ -60,7 +64,29 @@ export function ControlPlaneCard({
const name = controlPlane.metadata.name;
const namespace = controlPlane.metadata.namespace;

const isConnectButtonEnabled = canConnectToMCP(controlPlane);
// Disable the Connect button if the system IdP is disabled
const controlPlaneConfig = useResource(
ResourceObject(
controlPlane.metadata.namespace,
'managedcontrolplanes',
controlPlane.metadata.name,
),
undefined,
true,
);

const isSystemIdentityProviderEnabled =
// @ts-ignore
!!controlPlaneConfig.data?.spec?.authentication
Comment on lines +79 to +80
Copy link

Copilot AI Jul 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid using // @ts-ignore to suppress type errors. Consider updating the type definitions for controlPlaneConfig.data.spec.authentication so you can safely access enableSystemIdentityProvider without ignoring TypeScript.

Suggested change
// @ts-ignore
!!controlPlaneConfig.data?.spec?.authentication
!!(controlPlaneConfig.data as ControlPlaneConfigData)?.spec?.authentication

Copilot uses AI. Check for mistakes.
?.enableSystemIdentityProvider;

const isConnectButtonEnabled =
canConnectToMCP(controlPlane) &&
isSystemIdentityProviderEnabled &&
!controlPlaneConfig.isLoading;

const showWarningBecauseOfDisabledSystemIdentityProvider =
!controlPlaneConfig.isLoading && !isSystemIdentityProviderEnabled;

return (
<>
Expand Down Expand Up @@ -108,6 +134,11 @@ export function ControlPlaneCard({
resourceName={controlPlane.metadata.name}
resourceType={'managedcontrolplanes'}
/>
{showWarningBecauseOfDisabledSystemIdentityProvider && (
<Infobox size="sm" variant="warning">
{t('ConnectButton.unsupportedIdP')}
</Infobox>
)}
<ConnectButton
disabled={!isConnectButtonEnabled}
controlPlaneName={name}
Expand Down
Loading