Skip to content

Commit eb5a125

Browse files
committed
fix
1 parent d303b4a commit eb5a125

File tree

4 files changed

+23
-25
lines changed

4 files changed

+23
-25
lines changed

src/components/Graphs/Graph.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { NodeData, ColorBy } from './types';
88
import CustomNode from './CustomNode';
99
import { Legend, LegendItem } from './Legend';
1010
import { YamlViewDialog } from '../Yaml/YamlViewDialog';
11-
import YamlViewer from '../Yaml/YamlViewer';
11+
import { YamlViewer } from '../Yaml/YamlViewer';
1212
import { stringify } from 'yaml';
1313
import { removeManagedFieldsAndFilterData, Resource } from '../../utils/removeManagedFieldsAndFilterData.ts';
1414
import { useTranslation } from 'react-i18next';

src/components/Wizards/CreateManagedControlPlane/SummarizeStep.tsx

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
ComponentsListItem,
77
CreateManagedControlPlane,
88
} from '../../../lib/api/types/crate/createManagedControlPlane.ts';
9-
import YamlViewer from '../../Yaml/YamlViewer.tsx';
9+
import { YamlViewer } from '../../Yaml/YamlViewer.tsx';
1010
import { idpPrefix } from '../../../utils/idpPrefix.ts';
1111
import { UseFormWatch } from 'react-hook-form';
1212
import { CreateDialogProps } from '../../Dialogs/CreateWorkspaceDialogContainer.tsx';
@@ -30,7 +30,20 @@ export const SummarizeStep: React.FC<SummarizeStepProps> = ({
3030
isEditMode = false,
3131
}) => {
3232
const { t } = useTranslation();
33-
33+
const yamlString = stringify(
34+
CreateManagedControlPlane(
35+
watch('name'),
36+
`${projectName}--ws-${workspaceName}`,
37+
{
38+
displayName: watch('displayName'),
39+
chargingTarget: watch('chargingTarget'),
40+
members: watch('members'),
41+
componentsList: componentsList ?? [],
42+
chargingTargetType: watch('chargingTargetType'),
43+
},
44+
idpPrefix,
45+
),
46+
);
3447
return (
3548
<>
3649
<Title>{t('common.summarize')}</Title>
@@ -78,23 +91,7 @@ export const SummarizeStep: React.FC<SummarizeStepProps> = ({
7891
)}
7992
/>
8093
) : (
81-
<YamlViewer
82-
yamlString={stringify(
83-
CreateManagedControlPlane(
84-
watch('name'),
85-
`${projectName}--ws-${workspaceName}`,
86-
{
87-
displayName: watch('displayName'),
88-
chargingTarget: watch('chargingTarget'),
89-
members: watch('members'),
90-
componentsList: componentsList ?? [],
91-
chargingTargetType: watch('chargingTargetType'),
92-
},
93-
idpPrefix,
94-
),
95-
)}
96-
filename={`mcp_${projectName}--ws-${workspaceName}`}
97-
/>
94+
<YamlViewer yamlString={yamlString} filename={`mcp_${projectName}--ws-${workspaceName}`} />
9895
)}
9996
</div>
10097
</Grid>

src/components/Yaml/YamlViewButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Button } from '@ui5/webcomponents-react';
22
import { FC, useMemo, useState } from 'react';
33
import styles from './YamlViewer.module.css';
44
import { useTranslation } from 'react-i18next';
5-
import YamlViewer from './YamlViewer.tsx';
5+
import { YamlViewer } from './YamlViewer.tsx';
66
import { stringify } from 'yaml';
77
import { removeManagedFieldsAndFilterData, Resource } from '../../utils/removeManagedFieldsAndFilterData.ts';
88
import { YamlIcon } from './YamlIcon.tsx';

src/components/Yaml/YamlViewer.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import styles from './YamlViewer.module.css';
88

99
type YamlViewerProps = {
1010
yamlString: string;
11-
yamlStringToCopy: string;
11+
yamlStringToCopy?: string;
1212
filename: string;
1313
showOnlyImportantData?: boolean;
1414
setShowOnlyImportantData?: (showOnlyImportantData: boolean) => void;
@@ -32,11 +32,11 @@ export const YamlViewer: FC<YamlViewerProps> = ({ yamlString, filename, yamlStri
3232
document.body.removeChild(link);
3333
window.URL.revokeObjectURL(url);
3434
};
35-
35+
console.log(yamlString);
3636
return (
3737
<div className={styles.container}>
3838
<FlexBox className={styles.buttons} direction="Row" justifyContent="End" alignItems="Baseline" gap={16}>
39-
<Button icon="copy" onClick={() => copyToClipboard(yamlStringToCopy)}>
39+
<Button icon="copy" onClick={() => copyToClipboard(yamlStringToCopy ?? yamlString)}>
4040
{t('buttons.copy')}
4141
</Button>
4242
{SHOW_DOWNLOAD_BUTTON && (
@@ -45,7 +45,8 @@ export const YamlViewer: FC<YamlViewerProps> = ({ yamlString, filename, yamlStri
4545
</Button>
4646
)}
4747
</FlexBox>
48-
<YamlEditor height="90vh" defaultValue={yamlString} />
48+
49+
<YamlEditor key={yamlString} height="90vh" defaultValue={yamlString} />
4950
</div>
5051
);
5152
};

0 commit comments

Comments
 (0)