From 7744000e9e99aa2933d9025e442c291abf5d8615 Mon Sep 17 00:00:00 2001 From: enrico-kaack-comp Date: Thu, 10 Jul 2025 15:43:28 +0200 Subject: [PATCH 1/4] use spec.authentication to determine system IDP --- .../ControlPlaneCard/ControlPlaneCard.tsx | 19 +++---------- src/lib/api/types/crate/controlPlanes.ts | 27 ++++++++++--------- 2 files changed, 18 insertions(+), 28 deletions(-) diff --git a/src/components/ControlPlanes/ControlPlaneCard/ControlPlaneCard.tsx b/src/components/ControlPlanes/ControlPlaneCard/ControlPlaneCard.tsx index 1b8ed108..4819739f 100644 --- a/src/components/ControlPlanes/ControlPlaneCard/ControlPlaneCard.tsx +++ b/src/components/ControlPlanes/ControlPlaneCard/ControlPlaneCard.tsx @@ -64,29 +64,16 @@ 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 + !!controlPlane.spec?.authentication ?.enableSystemIdentityProvider; const isConnectButtonEnabled = canConnectToMCP(controlPlane) && - isSystemIdentityProviderEnabled && - !controlPlaneConfig.isLoading; + isSystemIdentityProviderEnabled const showWarningBecauseOfDisabledSystemIdentityProvider = - !controlPlaneConfig.isLoading && !isSystemIdentityProviderEnabled; + !isSystemIdentityProviderEnabled; return ( <> diff --git a/src/lib/api/types/crate/controlPlanes.ts b/src/lib/api/types/crate/controlPlanes.ts index 2a05b9fb..5f369f29 100644 --- a/src/lib/api/types/crate/controlPlanes.ts +++ b/src/lib/api/types/crate/controlPlanes.ts @@ -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; } @@ -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 { @@ -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 } }]', }; }; From 2bd1c7afca8c4916f1c46fa6600df6e3c231b71c Mon Sep 17 00:00:00 2001 From: enrico-kaack-comp Date: Thu, 10 Jul 2025 15:54:48 +0200 Subject: [PATCH 2/4] fix jq --- .../ControlPlanes/ControlPlaneCard/ControlPlaneCard.tsx | 3 +-- src/lib/api/types/crate/controlPlanes.ts | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/components/ControlPlanes/ControlPlaneCard/ControlPlaneCard.tsx b/src/components/ControlPlanes/ControlPlaneCard/ControlPlaneCard.tsx index 4819739f..93fa808e 100644 --- a/src/components/ControlPlanes/ControlPlaneCard/ControlPlaneCard.tsx +++ b/src/components/ControlPlanes/ControlPlaneCard/ControlPlaneCard.tsx @@ -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'; import { @@ -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 { diff --git a/src/lib/api/types/crate/controlPlanes.ts b/src/lib/api/types/crate/controlPlanes.ts index 5f369f29..33ea8498 100644 --- a/src/lib/api/types/crate/controlPlanes.ts +++ b/src/lib/api/types/crate/controlPlanes.ts @@ -68,7 +68,7 @@ export const ListControlPlanes = ( projectName === null ? null : `/apis/core.openmcp.cloud/v1alpha1/namespaces/project-${projectName}--ws-${workspaceName}/managedcontrolplanes`, - 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}, 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 } }]', }; }; From f85c96fbc9aa8381bddae3a470d8bf1a1a868624 Mon Sep 17 00:00:00 2001 From: Andreas Kienle Date: Thu, 10 Jul 2025 15:59:44 +0200 Subject: [PATCH 3/4] Fix unit test --- .../ControlPlanes/controlPlanes.spec.ts | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/components/ControlPlanes/controlPlanes.spec.ts b/src/components/ControlPlanes/controlPlanes.spec.ts index 33841846..698bd1a8 100644 --- a/src/components/ControlPlanes/controlPlanes.spec.ts +++ b/src/components/ControlPlanes/controlPlanes.spec.ts @@ -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 => ({ +const createCondition = (overrides: Partial): ControlPlaneStatusCondition => ({ type: 'Unknown', status: false, reason: 'DefaultReason', @@ -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, From ebf0168caf87745455ab6fce2e3f123acb78faac Mon Sep 17 00:00:00 2001 From: Andreas Kienle Date: Thu, 10 Jul 2025 16:04:05 +0200 Subject: [PATCH 4/4] Update src/components/ControlPlanes/ControlPlaneCard/ControlPlaneCard.tsx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../ControlPlanes/ControlPlaneCard/ControlPlaneCard.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/ControlPlanes/ControlPlaneCard/ControlPlaneCard.tsx b/src/components/ControlPlanes/ControlPlaneCard/ControlPlaneCard.tsx index 93fa808e..9809d8c4 100644 --- a/src/components/ControlPlanes/ControlPlaneCard/ControlPlaneCard.tsx +++ b/src/components/ControlPlanes/ControlPlaneCard/ControlPlaneCard.tsx @@ -64,8 +64,7 @@ export function ControlPlaneCard({ const namespace = controlPlane.metadata.namespace; const isSystemIdentityProviderEnabled = - !!controlPlane.spec?.authentication - ?.enableSystemIdentityProvider; + Boolean(controlPlane.spec?.authentication?.enableSystemIdentityProvider); const isConnectButtonEnabled = canConnectToMCP(controlPlane) &&