diff --git a/src/components/ControlPlanes/ControlPlaneCard/ControlPlaneCard.tsx b/src/components/ControlPlanes/ControlPlaneCard/ControlPlaneCard.tsx index 1b8ed108..9809d8c4 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 { @@ -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 ( <> 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, diff --git a/src/lib/api/types/crate/controlPlanes.ts b/src/lib/api/types/crate/controlPlanes.ts index 2a05b9fb..33ea8498 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 } }]', }; };