File tree Expand file tree Collapse file tree 3 files changed +57
-43
lines changed
Expand file tree Collapse file tree 3 files changed +57
-43
lines changed Original file line number Diff line number Diff line change 1- import { Bar , Button , Dialog } from '@ui5/webcomponents-react' ;
1+ import { Button } from '@ui5/webcomponents-react' ;
22import { FC , useState } from 'react' ;
33import styles from './YamlViewer.module.css' ;
44import { useTranslation } from 'react-i18next' ;
99 Resource ,
1010} from '../../utils/removeManagedFieldsProperty.ts' ;
1111import { YamlIcon } from './YamlIcon.tsx' ;
12+ import { YamlViewDialog } from './YamlViewDialog.tsx' ;
1213
1314export type YamlViewButtonProps = {
1415 resourceObject : unknown ;
@@ -20,31 +21,17 @@ export const YamlViewButton: FC<YamlViewButtonProps> = ({ resourceObject }) => {
2021 const resource = resourceObject as Resource ;
2122 return (
2223 < span >
23- < Dialog
24- open = { isOpen }
25- stretch
26- onClick = { ( e ) => e . stopPropagation ( ) }
27- footer = {
28- < Bar
29- design = "Footer"
30- endContent = {
31- < Button design = "Emphasized" onClick = { ( ) => setIsOpen ( false ) } >
32- { t ( 'common.close' ) }
33- </ Button >
34- }
35- />
36- }
37- onClose = { ( ) => {
38- setIsOpen ( false ) ;
39- } }
40- >
41- { isOpen && (
24+ < YamlViewDialog
25+ isOpen = { isOpen }
26+ setIsOpen = { setIsOpen }
27+ dialogContent = {
4228 < YamlViewer
4329 yamlString = { stringify ( removeManagedFieldsProperty ( resource ) ) }
4430 filename = { `${ resource . kind ?? '' } ${ resource . metadata . name ? '_' : '' } ${ resource . metadata . name ?? '' } ` }
4531 />
46- ) }
47- </ Dialog >
32+ }
33+ />
34+
4835 < Button
4936 className = { styles . button }
5037 design = { 'Transparent' }
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import { YamlLoader } from './YamlLoader.tsx';
44import { useTranslation } from 'react-i18next' ;
55import styles from './YamlViewer.module.css' ;
66import { YamlIcon } from './YamlIcon.tsx' ;
7+ import { YamlViewDialog } from './YamlViewDialog.tsx' ;
78
89export type YamlViewButtonProps = {
910 workspaceName ?: string ;
@@ -20,32 +21,18 @@ export const YamlViewButtonWithLoader: FC<YamlViewButtonProps> = ({
2021 const { t } = useTranslation ( ) ;
2122 return (
2223 < span >
23- < Dialog
24- open = { isOpen }
25- stretch
26- onClick = { ( e ) => e . stopPropagation ( ) }
27- footer = {
28- < Bar
29- design = "Footer"
30- endContent = {
31- < Button design = "Emphasized" onClick = { ( ) => setIsOpen ( false ) } >
32- { t ( 'common.close' ) }
33- </ Button >
34- }
35- />
36- }
37- onClose = { ( ) => {
38- setIsOpen ( false ) ;
39- } }
40- >
41- { isOpen && (
24+ < YamlViewDialog
25+ isOpen = { isOpen }
26+ setIsOpen = { setIsOpen }
27+ dialogContent = {
4228 < YamlLoader
4329 workspaceName = { workspaceName }
4430 resourceName = { resourceName }
4531 resourceType = { resourceType }
4632 />
47- ) }
48- </ Dialog >
33+ }
34+ />
35+
4936 < Button
5037 className = { styles . button }
5138 design = { 'Transparent' }
Original file line number Diff line number Diff line change 1+ import { Bar , Button , Dialog } from '@ui5/webcomponents-react' ;
2+
3+ import { FC , ReactNode } from 'react' ;
4+ import { useTranslation } from 'react-i18next' ;
5+
6+ export type YamlViewDialogProps = {
7+ isOpen : boolean ;
8+ setIsOpen : ( isOpen : boolean ) => void ;
9+ dialogContent : ReactNode ;
10+ } ;
11+
12+ export const YamlViewDialog : FC < YamlViewDialogProps > = ( {
13+ isOpen,
14+ setIsOpen,
15+ dialogContent,
16+ } ) => {
17+ const { t } = useTranslation ( ) ;
18+ return (
19+ < Dialog
20+ open = { isOpen }
21+ stretch
22+ onClick = { ( e ) => e . stopPropagation ( ) }
23+ footer = {
24+ < Bar
25+ design = "Footer"
26+ endContent = {
27+ < Button design = "Emphasized" onClick = { ( ) => setIsOpen ( false ) } >
28+ { t ( 'common.close' ) }
29+ </ Button >
30+ }
31+ />
32+ }
33+ onClose = { ( ) => {
34+ setIsOpen ( false ) ;
35+ } }
36+ >
37+ { isOpen && dialogContent }
38+ </ Dialog >
39+ ) ;
40+ } ;
You can’t perform that action at this time.
0 commit comments