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
23 changes: 4 additions & 19 deletions src/components/ControlPlanes/ControlPlaneCard/ControlPlaneCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
ReadyStatus,
} from '../../../lib/api/types/crate/controlPlanes.ts';
import { ListWorkspacesType } from '../../../lib/api/types/crate/listWorkspaces.ts';
import useResource, {
import {
useApiResourceMutation,
} from '../../../lib/api/useApiResource.ts';
Copy link
Preview

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 useApiResourceMutation import is not used in this component and can be removed to clean up unused code.

Copilot uses AI. Check for mistakes.

import {
Expand All @@ -30,7 +30,6 @@ 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 {
Expand Down Expand Up @@ -64,29 +63,15 @@ export function ControlPlaneCard({
const name = controlPlane.metadata.name;
const namespace = controlPlane.metadata.namespace;

// 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
?.enableSystemIdentityProvider;
Boolean(controlPlane.spec?.authentication?.enableSystemIdentityProvider);

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

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

return (
<>
Expand Down
17 changes: 6 additions & 11 deletions src/components/ControlPlanes/controlPlanes.spec.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
import { describe, it, expect } from 'vitest';

import {
ControlPlaneType,
ControlPlaneStatusCondition,
ReadyStatus,
} from '../../lib/api/types/crate/controlPlanes';
import { ControlPlaneType, ControlPlaneStatusCondition, ReadyStatus } from '../../lib/api/types/crate/controlPlanes';
import { canConnectToMCP } from './controlPlanes';

const createCondition = (
overrides: Partial<ControlPlaneStatusCondition>,
): ControlPlaneStatusCondition => ({
const createCondition = (overrides: Partial<ControlPlaneStatusCondition>): ControlPlaneStatusCondition => ({
type: 'Unknown',
status: false,
reason: 'DefaultReason',
Expand All @@ -18,14 +12,15 @@ const createCondition = (
...overrides,
});

const createControlPlane = (
conditions: ControlPlaneStatusCondition[],
): ControlPlaneType => ({
const createControlPlane = (conditions: ControlPlaneStatusCondition[]): ControlPlaneType => ({
metadata: {
name: '',
namespace: '',
},
spec: {
authentication: {
enableSystemIdentityProvider: true,
},
components: {
crossplane: undefined,
btpServiceOperator: undefined,
Expand Down
27 changes: 15 additions & 12 deletions src/lib/api/types/crate/controlPlanes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ export interface Metadata {
export interface ControlPlaneType {
metadata: Metadata;
spec:
| {
components: ControlPlaneComponentsType;
}
| undefined;
| {
authentication: {
enableSystemIdentityProvider?: boolean;
};
components: ControlPlaneComponentsType;
}
| undefined;
status: ControlPlaneStatusType | undefined;
}

Expand All @@ -33,13 +36,13 @@ export interface ControlPlaneStatusType {
status: ReadyStatus;
conditions: ControlPlaneStatusCondition[];
access:
| {
key: string | undefined;
name: string | undefined;
namespace: string | undefined;
kubeconfig: string | undefined;
}
| undefined;
| {
key: string | undefined;
name: string | undefined;
namespace: string | undefined;
kubeconfig: string | undefined;
}
| undefined;
}

export interface ControlPlaneStatusCondition {
Expand All @@ -65,7 +68,7 @@ export const ListControlPlanes = (
projectName === null
? null
: `/apis/core.openmcp.cloud/v1alpha1/namespaces/project-${projectName}--ws-${workspaceName}/managedcontrolplanes`,
jq: '[.items[] | {metadata: .metadata | {name, namespace}, status: { conditions: [.status.conditions[] | {type: .type, status: .status, message: .message, reason: .reason, lastTransitionTime: .lastTransitionTime}], access: .status.components.authentication.access, status: .status.status } }]',
jq: '[.items[] |{spec: .spec | {authentication}, metadata: .metadata | {name, namespace}, status: { conditions: [.status.conditions[] | {type: .type, status: .status, message: .message, reason: .reason, lastTransitionTime: .lastTransitionTime}], access: .status.components.authentication.access, status: .status.status } }]',
Copy link
Preview

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 jq projection only selects spec.authentication but omits spec.components, which conflicts with the ControlPlaneType interface that expects both fields. Consider including components in the projection or updating the type to match the returned shape.

Suggested change
jq: '[.items[] |{spec: .spec | {authentication}, metadata: .metadata | {name, namespace}, status: { conditions: [.status.conditions[] | {type: .type, status: .status, message: .message, reason: .reason, lastTransitionTime: .lastTransitionTime}], access: .status.components.authentication.access, status: .status.status } }]',
jq: '[.items[] |{spec: .spec | {authentication, components}, metadata: .metadata | {name, namespace}, status: { conditions: [.status.conditions[] | {type: .type, status: .status, message: .message, reason: .reason, lastTransitionTime: .lastTransitionTime}], access: .status.components.authentication.access, status: .status.status } }]',

Copilot uses AI. Check for mistakes.

};
};

Expand Down
Loading