Skip to content

Commit 3dc9a0b

Browse files
committed
fixes
1 parent 7dfa905 commit 3dc9a0b

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

src/components/Yaml/YamlLoader.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ import Loading from '../Shared/Loading.tsx';
99
import IllustratedError from '../Shared/IllustratedError.tsx';
1010
import YamlViewer from './YamlViewer.tsx';
1111
import useResource from '../../lib/api/useApiResource';
12+
import {
13+
removeManagedFieldsProperty,
14+
Resource,
15+
} from '../../utils/removeManagedFieldsProperty.ts';
1216

1317
export const YamlLoader: FC<YamlViewButtonProps> = ({
1418
workspaceName,
@@ -17,6 +21,8 @@ export const YamlLoader: FC<YamlViewButtonProps> = ({
1721
}) => {
1822
const { isLoading, data, error } = useResource(
1923
ResourceObject(workspaceName ?? '', resourceType, resourceName),
24+
undefined,
25+
true,
2026
);
2127
const { t } = useTranslation();
2228
if (isLoading) return <Loading />;
@@ -26,7 +32,7 @@ export const YamlLoader: FC<YamlViewButtonProps> = ({
2632

2733
return (
2834
<YamlViewer
29-
yamlString={stringify(data)}
35+
yamlString={stringify(removeManagedFieldsProperty(data as Resource))}
3036
filename={`${workspaceName ? `${workspaceName}_` : ''}${resourceType}_${resourceName}`}
3137
/>
3238
);

src/lib/api/useApiResource.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export { useApiResource as default };
1919
export const useApiResource = <T>(
2020
resource: Resource<T>,
2121
config?: SWRConfiguration,
22+
excludeMcpConfig?: boolean,
2223
) => {
2324
const apiConfig = useContext(ApiConfigContext);
2425

@@ -29,7 +30,7 @@ export const useApiResource = <T>(
2930
([path, apiConfig]) =>
3031
fetchApiServerJson<T>(
3132
path,
32-
apiConfig,
33+
excludeMcpConfig ? { ...apiConfig, mcpConfig: undefined } : apiConfig,
3334
resource.jq,
3435
resource.method,
3536
resource.body,

src/views/ControlPlanes/ControlPlaneView.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,28 @@ import MCPHealthPopoverButton from '../../components/ControlPlane/MCPHealthPopov
2929
import useResource from '../../lib/api/useApiResource';
3030

3131
import { YamlViewButton } from '../../components/Yaml/YamlViewButton.tsx';
32+
import { YamlViewButtonWithLoader } from '../../components/Yaml/YamlViewButtonWithLoader.tsx';
3233

3334
export default function ControlPlaneView() {
3435
const { projectName, workspaceName, controlPlaneName, contextName } =
3536
useParams();
3637
const { t } = useTranslation();
3738

39+
console.log('contextName');
40+
console.log(contextName);
41+
console.log('controlPlaneName');
42+
console.log(controlPlaneName);
43+
console.log('projectName');
44+
console.log(projectName);
3845
const { data: mcp, error } = useResource(
3946
ControlPlaneResource(
4047
projectName ?? '',
4148
workspaceName ?? '',
4249
controlPlaneName ?? '',
4350
),
4451
);
45-
52+
console.log('mcp');
53+
console.log(mcp);
4654
if (!projectName || !workspaceName || !controlPlaneName) {
4755
return <></>;
4856
}
@@ -89,7 +97,11 @@ export default function ControlPlaneView() {
8997
workspaceName={workspaceName ?? ''}
9098
mcpName={controlPlaneName}
9199
/>
92-
<YamlViewButton resourceObject={mcp} />
100+
<YamlViewButtonWithLoader
101+
workspaceName={mcp?.status?.access?.namespace}
102+
resourceType={'managedcontrolplanes'}
103+
resourceName={controlPlaneName}
104+
/>
93105
<CopyKubeconfigButton />
94106
</div>
95107
}

0 commit comments

Comments
 (0)