Skip to content

Commit 794967d

Browse files
committed
refactor
1 parent 49c9ce1 commit 794967d

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
lines changed

src/components/Yaml/YamlLoader.tsx

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,27 @@
1-
import YamlViewer from './YamlViewer.tsx';
21
import { ResourceProps } from './YamlViewButton.tsx';
32
import { FC } from 'react';
4-
import { useManagedControlPlaneYamlQuery } from '@/spaces/onboarding/services/YamlServices/YamlService.ts';
53
import Loading from '@components/Shared/Loading.tsx';
4+
import useResource from '@lib/api/useApiResource.ts';
5+
import { ResourceObject } from '@lib/api/types/crate/resourceObject.ts';
6+
import { stringify } from 'yaml';
7+
import YamlViewer from '@components/Yaml/YamlViewer.tsx';
68

79
export const YamlLoader: FC<ResourceProps> = ({
810
workspaceName,
911
projectName,
1012
resourceType,
1113
resourceName,
1214
}) => {
13-
const { data, loading } = useManagedControlPlaneYamlQuery(
14-
workspaceName,
15-
projectName,
15+
// const { data, loading } = useManagedControlPlaneYamlQuery(
16+
// workspaceName,
17+
// projectName,
18+
// );
19+
20+
const { isLoading, data } = useResource(
21+
ResourceObject(projectName, workspaceName, resourceType, resourceName),
1622
);
17-
if (loading) return <Loading />;
23+
if (isLoading) return <Loading />;
1824
// if (!workspaceName || !projectName || !resourceName || resourceType)
1925
// return <div />;
20-
return <YamlViewer yamlString={data} />;
26+
return <YamlViewer yamlString={stringify(data)} />;
2127
};

src/components/Yaml/YamlViewer.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ const YamlViewer: FC<YamlViewerProps> = ({ yamlString }) => {
3232
} catch (error) {
3333
console.error('Invalid YAML:', error);
3434
}
35-
3635
return (
3736
<div className={styles.container}>
3837
<FlexBox

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ export const ListControlPlanes = (
6060
projectName: string | null,
6161
workspaceName: string,
6262
): Resource<ListControlPlanesType[]> => {
63-
console.log('CP2');
6463
return {
6564
path:
6665
projectName === null
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Resource } from '../resource.ts';
22
import { ControlPlaneType } from './controlPlanes.ts';
33

4-
export const ControlPlane = (
4+
export const ResourceObject = (
55
projectName: string,
66
workspaceName: string,
77
resourceType: string = 'mcp',

0 commit comments

Comments
 (0)