Skip to content

Commit b6f7f2f

Browse files
committed
fix
1 parent d81fb6f commit b6f7f2f

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

src/components/Yaml/YamlLoader.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { YamlViewButtonProps } from './YamlViewButtonWithLoader.tsx';
2-
import { FC } from 'react';
2+
import { FC, useMemo } from 'react';
33

44
import { stringify } from 'yaml';
55

@@ -29,15 +29,24 @@ export const YamlLoader: FC<YamlLoaderProps> = ({
2929
true,
3030
);
3131
const { t } = useTranslation();
32+
const yamlString = useMemo(() => {
33+
if (isLoading || error) return '';
34+
return stringify(removeManagedFieldsProperty(data as Resource, showOnlyImportantData));
35+
}, [data, error, isLoading, showOnlyImportantData]);
36+
37+
const yamlStringToCopy = useMemo(() => {
38+
if (isLoading || error) return '';
39+
return stringify(removeManagedFieldsProperty(data as Resource, false));
40+
}, [data, error, isLoading]);
3241
if (isLoading) return <Loading />;
3342
if (error) {
3443
return <IllustratedError details={t('common.cannotLoadData')} />;
3544
}
3645

3746
return (
3847
<YamlViewer
39-
yamlString={stringify(removeManagedFieldsProperty(data as Resource, showOnlyImportantData))}
40-
yamlStringToCopy={stringify(removeManagedFieldsProperty(data as Resource, false))}
48+
yamlString={yamlString}
49+
yamlStringToCopy={yamlStringToCopy}
4150
filename={`${workspaceName ? `${workspaceName}_` : ''}${resourceType}_${resourceName}`}
4251
setShowOnlyImportantData={setShowOnlyImportantData}
4352
showOnlyImportantData={showOnlyImportantData}

src/components/Yaml/YamlViewButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export const YamlViewButton: FC<YamlViewButtonProps> = ({ resourceObject }) => {
2323
}, [resource, showOnlyImportantData]);
2424
const yamlStringToCopy = useMemo(() => {
2525
return stringify(removeManagedFieldsProperty(resource, false));
26-
}, [resource, showOnlyImportantData]);
26+
}, [resource]);
2727
return (
2828
<span>
2929
<YamlViewDialog

0 commit comments

Comments
 (0)