Skip to content

Commit d81fb6f

Browse files
committed
fix
1 parent 20ac8b3 commit d81fb6f

File tree

5 files changed

+22
-8
lines changed

5 files changed

+22
-8
lines changed

public/locales/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,8 @@
371371
"update": "Update"
372372
},
373373
"yaml": {
374-
"YAML": "File"
374+
"YAML": "File",
375+
"showOnlyImportant": "Show only important fields"
375376
},
376377
"createMCP": {
377378
"dialogTitle": "Create Managed Control Plane",

src/components/Yaml/YamlLoader.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export const YamlLoader: FC<YamlLoaderProps> = ({
3737
return (
3838
<YamlViewer
3939
yamlString={stringify(removeManagedFieldsProperty(data as Resource, showOnlyImportantData))}
40+
yamlStringToCopy={stringify(removeManagedFieldsProperty(data as Resource, false))}
4041
filename={`${workspaceName ? `${workspaceName}_` : ''}${resourceType}_${resourceName}`}
4142
setShowOnlyImportantData={setShowOnlyImportantData}
4243
showOnlyImportantData={showOnlyImportantData}

src/components/Yaml/YamlViewButton.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,18 @@ export const YamlViewButton: FC<YamlViewButtonProps> = ({ resourceObject }) => {
2020

2121
const yamlString = useMemo(() => {
2222
return stringify(removeManagedFieldsProperty(resource, showOnlyImportantData));
23-
}, [resource]);
23+
}, [resource, showOnlyImportantData]);
24+
const yamlStringToCopy = useMemo(() => {
25+
return stringify(removeManagedFieldsProperty(resource, false));
26+
}, [resource, showOnlyImportantData]);
2427
return (
2528
<span>
2629
<YamlViewDialog
2730
isOpen={isOpen}
2831
setIsOpen={setIsOpen}
2932
dialogContent={
3033
<YamlViewer
34+
yamlStringToCopy={yamlStringToCopy}
3135
yamlString={yamlString}
3236
filename={`${resource?.kind ?? ''}${resource?.metadata?.name ? '_' : ''}${resource?.metadata?.name ?? ''}`}
3337
setShowOnlyImportantData={setShowOnlyImportantData}

src/components/Yaml/YamlViewDialog.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export const YamlViewDialog: FC<YamlViewDialogProps> = ({
2626
<Dialog
2727
open={isOpen}
2828
stretch
29+
initialFocus={'closeButton'}
2930
footer={
3031
<Bar
3132
startContent={
@@ -39,7 +40,7 @@ export const YamlViewDialog: FC<YamlViewDialogProps> = ({
3940
}
4041
design="Footer"
4142
endContent={
42-
<Button design="Emphasized" onClick={() => setIsOpen(false)}>
43+
<Button design="Emphasized" id={'closeButton'} onClick={() => setIsOpen(false)}>
4344
{t('common.close')}
4445
</Button>
4546
}

src/components/Yaml/YamlViewer.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,16 @@ import { useTranslation } from 'react-i18next';
99
import { useTheme } from '../../hooks/useTheme.ts';
1010
type YamlViewerProps = {
1111
yamlString: string;
12+
yamlStringToCopy: string;
1213
filename: string;
1314
showOnlyImportantData?: boolean;
1415
setShowOnlyImportantData?: (showOnlyImportantData: boolean) => void;
1516
};
16-
const YamlViewer: FC<YamlViewerProps> = ({ yamlString, filename }) => {
17+
18+
// Download button is hidden now due to stakeholder request
19+
const SHOW_DOWNLOAD_BUTTON = false;
20+
21+
const YamlViewer: FC<YamlViewerProps> = ({ yamlString, filename, yamlStringToCopy }) => {
1722
const { t } = useTranslation();
1823
const { isDarkTheme } = useTheme();
1924
const { copyToClipboard } = useCopyToClipboard();
@@ -32,12 +37,14 @@ const YamlViewer: FC<YamlViewerProps> = ({ yamlString, filename }) => {
3237
return (
3338
<div className={styles.container}>
3439
<FlexBox className={styles.buttons} direction="Row" justifyContent="End" alignItems="Baseline" gap={16}>
35-
<Button icon="copy" onClick={() => copyToClipboard(yamlString)}>
40+
<Button icon="copy" onClick={() => copyToClipboard(yamlStringToCopy)}>
3641
{t('buttons.copy')}
3742
</Button>
38-
<Button icon="download" onClick={downloadYaml}>
39-
{t('buttons.download')}
40-
</Button>
43+
{SHOW_DOWNLOAD_BUTTON && (
44+
<Button icon="download" onClick={downloadYaml}>
45+
{t('buttons.download')}
46+
</Button>
47+
)}
4148
</FlexBox>
4249
<SyntaxHighlighter
4350
language="yaml"

0 commit comments

Comments
 (0)