11import { FC } from 'react' ;
2- import { Button , FlexBox } from '@ui5/webcomponents-react' ;
3- import { useCopyToClipboard } from '../../hooks/useCopyToClipboard.ts' ;
4- import { useTranslation } from 'react-i18next' ;
2+
53import { YamlEditor } from '../YamlEditor/YamlEditor' ;
64
75import styles from './YamlViewer.module.css' ;
@@ -14,40 +12,12 @@ type YamlViewerProps = {
1412 setShowOnlyImportantData ?: ( showOnlyImportantData : boolean ) => void ;
1513} ;
1614
17- // Download button is hidden now due to stakeholder request
18- const SHOW_DOWNLOAD_BUTTON = false ;
19-
20- export const YamlViewer : FC < YamlViewerProps > = ( { yamlString, filename, yamlStringToCopy } ) => {
21- const { t } = useTranslation ( ) ;
22- const { copyToClipboard } = useCopyToClipboard ( ) ;
23- const downloadYaml = ( ) => {
24- const blob = new Blob ( [ yamlString ] , { type : 'text/yaml' } ) ;
25- const url = window . URL . createObjectURL ( blob ) ;
26- const link = document . createElement ( 'a' ) ;
27- link . href = url ;
28- link . download = `${ filename } .yaml` ;
29- document . body . appendChild ( link ) ;
30- link . click ( ) ;
31- document . body . removeChild ( link ) ;
32- window . URL . revokeObjectURL ( url ) ;
33- } ;
34-
15+ export const YamlViewer : FC < YamlViewerProps > = ( { yamlString, filename } ) => {
3516 return (
3617 < div className = { styles . container } >
37- < FlexBox className = { styles . buttons } direction = "Row" justifyContent = "End" alignItems = "Baseline" gap = { 16 } >
38- < Button icon = "copy" onClick = { ( ) => copyToClipboard ( yamlStringToCopy ?? yamlString ) } >
39- { t ( 'buttons.copy' ) }
40- </ Button >
41- { SHOW_DOWNLOAD_BUTTON && (
42- < Button icon = "download" onClick = { downloadYaml } >
43- { t ( 'buttons.download' ) }
44- </ Button >
45- ) }
46- </ FlexBox >
47-
4818 { /* Use controlled value with a stable model path to update content without remounting */ }
19+ < div > .</ div >
4920 < YamlEditor value = { yamlString } path = { `${ filename } .yaml` } options = { { readOnly : true } } />
5021 </ div >
5122 ) ;
5223} ;
53-
0 commit comments