Skip to content

Commit 9e58f60

Browse files
committed
refactor
1 parent 794967d commit 9e58f60

File tree

6 files changed

+19
-23
lines changed

6 files changed

+19
-23
lines changed

public/locales/en.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,5 +235,9 @@
235235
"max25chars": "Max length is 25 characters.",
236236
"userExists": "User with this email already exists!",
237237
"atLeastOneUser": "You need to have at least one member assigned."
238+
},
239+
"common": {
240+
"close": "Close",
241+
"cannotLoadData": "Cannot load data"
238242
}
239243
}

src/components/ControlPlanes/ControlPlaneCard/ControlPlaneCard.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,8 @@ export function ControlPlaneCard({
9393
>
9494
<YamlViewButton
9595
workspaceName={controlPlane.metadata.namespace}
96-
projectName={controlPlane.metadata.name}
9796
resourceName={controlPlane.metadata.name}
98-
resourceType={'managedcontrolplane'}
97+
resourceType={'managedcontrolplanes'}
9998
/>
10099
<ConnectButton
101100
disabled={controlPlane.status?.status !== ReadyStatus.Ready}

src/components/Yaml/YamlLoader.tsx

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,22 @@ import useResource from '@lib/api/useApiResource.ts';
55
import { ResourceObject } from '@lib/api/types/crate/resourceObject.ts';
66
import { stringify } from 'yaml';
77
import YamlViewer from '@components/Yaml/YamlViewer.tsx';
8+
import IllustratedError from '@components/Shared/IllustratedError.tsx';
9+
import { useTranslation } from 'react-i18next';
810

911
export const YamlLoader: FC<ResourceProps> = ({
1012
workspaceName,
11-
projectName,
1213
resourceType,
1314
resourceName,
1415
}) => {
15-
// const { data, loading } = useManagedControlPlaneYamlQuery(
16-
// workspaceName,
17-
// projectName,
18-
// );
19-
20-
const { isLoading, data } = useResource(
21-
ResourceObject(projectName, workspaceName, resourceType, resourceName),
16+
const { isLoading, data, error } = useResource(
17+
ResourceObject(workspaceName, resourceType, resourceName),
2218
);
19+
const { t } = useTranslation();
2320
if (isLoading) return <Loading />;
24-
// if (!workspaceName || !projectName || !resourceName || resourceType)
25-
// return <div />;
21+
if (!workspaceName || !resourceName || !resourceType || error) {
22+
return <IllustratedError error={t('common.cannotLoadData')} />;
23+
}
24+
2625
return <YamlViewer yamlString={stringify(data)} />;
2726
};

src/components/Yaml/YamlViewButton.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
import { Bar, Button, Dialog } from '@ui5/webcomponents-react';
22
import { FC, useState } from 'react';
33
import { YamlLoader } from './YamlLoader.tsx';
4+
import { useTranslation } from 'react-i18next';
45

56
export type ResourceProps = {
6-
projectName: string;
77
workspaceName: string;
88
resourceType: string;
99
resourceName: string;
1010
};
1111

1212
export const YamlViewButton: FC<ResourceProps> = ({
13-
projectName,
1413
workspaceName,
1514
resourceType,
1615
resourceName,
1716
}) => {
1817
const [isOpen, setIsOpen] = useState(false);
19-
18+
const { t } = useTranslation();
2019
return (
2120
<>
2221
<Dialog
@@ -27,15 +26,14 @@ export const YamlViewButton: FC<ResourceProps> = ({
2726
design="Footer"
2827
endContent={
2928
<Button design="Emphasized" onClick={() => setIsOpen(false)}>
30-
Close
29+
{t('common.close')}
3130
</Button>
3231
}
3332
/>
3433
}
3534
>
3635
<YamlLoader
3736
workspaceName={workspaceName}
38-
projectName={projectName}
3937
resourceName={resourceName}
4038
resourceType={resourceType}
4139
/>

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@ import { Resource } from '../resource.ts';
22
import { ControlPlaneType } from './controlPlanes.ts';
33

44
export const ResourceObject = (
5-
projectName: string,
65
workspaceName: string,
7-
resourceType: string = 'mcp',
6+
resourceType: string,
87
resourceName: string,
98
): Resource<ControlPlaneType> => {
10-
console.log('CP1');
119
return {
12-
path: `/apis/core.openmcp.cloud/v1alpha1/namespaces/project-${projectName}--ws-${workspaceName}/${resourceType}/${resourceName}`,
10+
path: `/apis/core.openmcp.cloud/v1alpha1/namespaces/${workspaceName}/${resourceType}/${resourceName}`,
1311
};
1412
};

src/views/ControlPlanes/ControlPlaneView.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ export default function ControlPlaneView() {
5757
return <IllustratedError error={t('ControlPlaneView.accessError')} />;
5858
}
5959

60-
console.log(mcp);
6160
return (
6261
<McpContextProvider
6362
context={{
@@ -86,7 +85,6 @@ export default function ControlPlaneView() {
8685
<MCPHealthPopoverButton mcpStatus={mcp?.status} />
8786
<YamlViewButton
8887
workspaceName={''}
89-
projectName={''}
9088
resourceType={''}
9189
resourceName={''}
9290
/>

0 commit comments

Comments
 (0)