Skip to content

Commit 428e14f

Browse files
committed
refactor
1 parent 046afb0 commit 428e14f

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

src/components/Yaml/YamlLoader.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ResourceProps } from './YamlViewButton.tsx';
1+
import { YamlViewButtonProps } from './YamlViewButton.tsx';
22
import { FC } from 'react';
33

44
import { stringify } from 'yaml';
@@ -10,7 +10,7 @@ import IllustratedError from '../Shared/IllustratedError.tsx';
1010
import YamlViewer from './YamlViewer.tsx';
1111
import useResource from '../../lib/api/useApiResource';
1212

13-
export const YamlLoader: FC<ResourceProps> = ({
13+
export const YamlLoader: FC<YamlViewButtonProps> = ({
1414
workspaceName,
1515
resourceType,
1616
resourceName,

src/components/Yaml/YamlViewButton.tsx

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ import { FC, useState } from 'react';
33
import { YamlLoader } from './YamlLoader.tsx';
44
import { useTranslation } from 'react-i18next';
55

6-
export type ResourceProps = {
6+
export type YamlViewButtonProps = {
77
workspaceName?: string;
88
resourceType: 'projects' | 'workspaces' | 'managedcontrolplanes';
99
resourceName: string;
1010
};
1111

12-
export const YamlViewButton: FC<ResourceProps> = ({
12+
export const YamlViewButton: FC<YamlViewButtonProps> = ({
1313
workspaceName,
1414
resourceType,
1515
resourceName,
@@ -31,12 +31,17 @@ export const YamlViewButton: FC<ResourceProps> = ({
3131
}
3232
/>
3333
}
34+
onClose={() => {
35+
setIsOpen(false);
36+
}}
3437
>
35-
<YamlLoader
36-
workspaceName={workspaceName}
37-
resourceName={resourceName}
38-
resourceType={resourceType}
39-
/>
38+
{isOpen && (
39+
<YamlLoader
40+
workspaceName={workspaceName}
41+
resourceName={resourceName}
42+
resourceType={resourceType}
43+
/>
44+
)}
4045
</Dialog>
4146
<Button
4247
icon="document"

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import { Resource } from '../resource.ts';
2-
import { ControlPlaneType } from './controlPlanes.ts';
32

43
export const ResourceObject = (
54
workspaceName: string,
65
resourceType: string,
76
resourceName: string,
8-
): Resource<ControlPlaneType> => {
7+
): Resource<unknown> => {
98
return {
109
path: `/apis/core.openmcp.cloud/v1alpha1/${workspaceName ? `namespaces/${workspaceName}/` : ''}${resourceType}/${resourceName}`,
1110
};

0 commit comments

Comments
 (0)