Skip to content

Commit b0d3186

Browse files
enrico-kaack-compandreaskienleCopilot
authored
fix: fix connect button system IDP (#178)
Co-authored-by: Andreas Kienle <andreas.kienle@sap.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 4f775ba commit b0d3186

File tree

3 files changed

+25
-42
lines changed

3 files changed

+25
-42
lines changed

src/components/ControlPlanes/ControlPlaneCard/ControlPlaneCard.tsx

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
ReadyStatus,
1818
} from '../../../lib/api/types/crate/controlPlanes.ts';
1919
import { ListWorkspacesType } from '../../../lib/api/types/crate/listWorkspaces.ts';
20-
import useResource, {
20+
import {
2121
useApiResourceMutation,
2222
} from '../../../lib/api/useApiResource.ts';
2323
import {
@@ -30,7 +30,6 @@ import {
3030
import { YamlViewButtonWithLoader } from '../../Yaml/YamlViewButtonWithLoader.tsx';
3131
import { useToast } from '../../../context/ToastContext.tsx';
3232
import { canConnectToMCP } from '../controlPlanes.ts';
33-
import { ResourceObject } from '../../../lib/api/types/crate/resourceObject.ts';
3433
import { Infobox } from '../../Ui/Infobox/Infobox.tsx';
3534

3635
interface Props {
@@ -64,29 +63,15 @@ export function ControlPlaneCard({
6463
const name = controlPlane.metadata.name;
6564
const namespace = controlPlane.metadata.namespace;
6665

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-
7866
const isSystemIdentityProviderEnabled =
79-
// @ts-ignore
80-
!!controlPlaneConfig.data?.spec?.authentication
81-
?.enableSystemIdentityProvider;
67+
Boolean(controlPlane.spec?.authentication?.enableSystemIdentityProvider);
8268

8369
const isConnectButtonEnabled =
8470
canConnectToMCP(controlPlane) &&
85-
isSystemIdentityProviderEnabled &&
86-
!controlPlaneConfig.isLoading;
71+
isSystemIdentityProviderEnabled
8772

8873
const showWarningBecauseOfDisabledSystemIdentityProvider =
89-
!controlPlaneConfig.isLoading && !isSystemIdentityProviderEnabled;
74+
!isSystemIdentityProviderEnabled;
9075

9176
return (
9277
<>

src/components/ControlPlanes/controlPlanes.spec.ts

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
import { describe, it, expect } from 'vitest';
22

3-
import {
4-
ControlPlaneType,
5-
ControlPlaneStatusCondition,
6-
ReadyStatus,
7-
} from '../../lib/api/types/crate/controlPlanes';
3+
import { ControlPlaneType, ControlPlaneStatusCondition, ReadyStatus } from '../../lib/api/types/crate/controlPlanes';
84
import { canConnectToMCP } from './controlPlanes';
95

10-
const createCondition = (
11-
overrides: Partial<ControlPlaneStatusCondition>,
12-
): ControlPlaneStatusCondition => ({
6+
const createCondition = (overrides: Partial<ControlPlaneStatusCondition>): ControlPlaneStatusCondition => ({
137
type: 'Unknown',
148
status: false,
159
reason: 'DefaultReason',
@@ -18,14 +12,15 @@ const createCondition = (
1812
...overrides,
1913
});
2014

21-
const createControlPlane = (
22-
conditions: ControlPlaneStatusCondition[],
23-
): ControlPlaneType => ({
15+
const createControlPlane = (conditions: ControlPlaneStatusCondition[]): ControlPlaneType => ({
2416
metadata: {
2517
name: '',
2618
namespace: '',
2719
},
2820
spec: {
21+
authentication: {
22+
enableSystemIdentityProvider: true,
23+
},
2924
components: {
3025
crossplane: undefined,
3126
btpServiceOperator: undefined,

src/lib/api/types/crate/controlPlanes.ts

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@ export interface Metadata {
1010
export interface ControlPlaneType {
1111
metadata: Metadata;
1212
spec:
13-
| {
14-
components: ControlPlaneComponentsType;
15-
}
16-
| undefined;
13+
| {
14+
authentication: {
15+
enableSystemIdentityProvider?: boolean;
16+
};
17+
components: ControlPlaneComponentsType;
18+
}
19+
| undefined;
1720
status: ControlPlaneStatusType | undefined;
1821
}
1922

@@ -33,13 +36,13 @@ export interface ControlPlaneStatusType {
3336
status: ReadyStatus;
3437
conditions: ControlPlaneStatusCondition[];
3538
access:
36-
| {
37-
key: string | undefined;
38-
name: string | undefined;
39-
namespace: string | undefined;
40-
kubeconfig: string | undefined;
41-
}
42-
| undefined;
39+
| {
40+
key: string | undefined;
41+
name: string | undefined;
42+
namespace: string | undefined;
43+
kubeconfig: string | undefined;
44+
}
45+
| undefined;
4346
}
4447

4548
export interface ControlPlaneStatusCondition {
@@ -65,7 +68,7 @@ export const ListControlPlanes = (
6568
projectName === null
6669
? null
6770
: `/apis/core.openmcp.cloud/v1alpha1/namespaces/project-${projectName}--ws-${workspaceName}/managedcontrolplanes`,
68-
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 } }]',
71+
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 } }]',
6972
};
7073
};
7174

0 commit comments

Comments
 (0)