Skip to content

Commit 49c9ce1

Browse files
committed
refactor
1 parent 5a67fb4 commit 49c9ce1

File tree

3 files changed

+52
-55
lines changed

3 files changed

+52
-55
lines changed

src/components/ControlPlanes/ControlPlaneCard/ControlPlaneCard.tsx

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -85,21 +85,28 @@ export function ControlPlaneCard({
8585
className={styles.row}
8686
>
8787
<MCPHealthPopoverButton mcpStatus={controlPlane.status} />
88-
<YamlViewButton
89-
workspaceName={controlPlane.metadata.namespace}
90-
projectName={controlPlane.metadata.name}
91-
resourceName={controlPlane.metadata.name}
92-
resourceType={'managedcontrolplane'}
93-
/>
94-
<ConnectButton
95-
disabled={controlPlane.status?.status !== ReadyStatus.Ready}
96-
controlPlaneName={name}
97-
projectName={projectName}
98-
workspaceName={workspace.metadata.name ?? ''}
99-
namespace={controlPlane.status?.access?.namespace ?? ''}
100-
secretName={controlPlane.status?.access?.name ?? ''}
101-
secretKey={controlPlane.status?.access?.key ?? ''}
102-
/>
88+
<FlexBox
89+
direction="Row"
90+
justifyContent="SpaceBetween"
91+
alignItems="Center"
92+
gap={10}
93+
>
94+
<YamlViewButton
95+
workspaceName={controlPlane.metadata.namespace}
96+
projectName={controlPlane.metadata.name}
97+
resourceName={controlPlane.metadata.name}
98+
resourceType={'managedcontrolplane'}
99+
/>
100+
<ConnectButton
101+
disabled={controlPlane.status?.status !== ReadyStatus.Ready}
102+
controlPlaneName={name}
103+
projectName={projectName}
104+
workspaceName={workspace.metadata.name ?? ''}
105+
namespace={controlPlane.status?.access?.namespace ?? ''}
106+
secretName={controlPlane.status?.access?.name ?? ''}
107+
secretKey={controlPlane.status?.access?.key ?? ''}
108+
/>
109+
</FlexBox>
103110
</FlexBox>
104111
</FlexBox>
105112
</div>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.container {
2+
position: relative;
3+
}
4+
5+
.buttons {
6+
position: sticky;
7+
top: 0;
8+
right: 0;
9+
z-index: 1;
10+
}

src/components/Yaml/YamlViewer.tsx

Lines changed: 20 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import {
55
materialDark,
66
} from 'react-syntax-highlighter/dist/esm/styles/prism'; // You can choose different styles
77
import YAML from 'yaml';
8-
import { Button } from '@ui5/webcomponents-react';
9-
8+
import { Button, FlexBox } from '@ui5/webcomponents-react';
9+
import styles from './YamlViewer.module.css';
1010
type YamlViewerProps = { yamlString: string };
1111
const YamlViewer: FC<YamlViewerProps> = ({ yamlString }) => {
1212
const copyToClipboard = () => {
@@ -34,54 +34,33 @@ const YamlViewer: FC<YamlViewerProps> = ({ yamlString }) => {
3434
}
3535

3636
return (
37-
<div style={{ position: 'relative', width: '80%' }}>
38-
<Button
39-
style={{
40-
position: 'absolute',
41-
top: '10px',
42-
right: '10px',
43-
padding: '5px 10px',
44-
background: '#007bff',
45-
color: 'white',
46-
border: 'none',
47-
borderRadius: '4px',
48-
cursor: 'pointer',
49-
zIndex: 1,
50-
}}
51-
onClick={copyToClipboard}
37+
<div className={styles.container}>
38+
<FlexBox
39+
className={styles.buttons}
40+
direction="Row"
41+
justifyContent="End"
42+
alignItems="Baseline"
43+
gap={16}
5244
>
53-
Copy
54-
</Button>
55-
<Button
56-
// style={{
57-
// position: 'absolute',
58-
// top: '10px',
59-
// right: '90px',
60-
// padding: '5px 10px',
61-
// background: '#28a745',
62-
// color: 'white',
63-
// border: 'none',
64-
// borderRadius: '4px',
65-
// cursor: 'pointer',
66-
// zIndex: 1,
67-
// }}
68-
onClick={downloadYaml}
69-
>
70-
Download
71-
</Button>
72-
45+
<Button icon="copy" onClick={copyToClipboard}>
46+
Copy
47+
</Button>
48+
<Button icon="download" onClick={downloadYaml}>
49+
Download
50+
</Button>
51+
</FlexBox>
7352
<SyntaxHighlighter
7453
language="yaml"
7554
style={
7655
window.matchMedia('(prefers-color-scheme: dark)').matches
7756
? materialDark
7857
: materialLight
7958
}
80-
showLineNumbers={true}
81-
wrapLines={true}
59+
showLineNumbers
60+
wrapLines
61+
wrapLongLines
8262
lineNumberStyle={{
8363
paddingRight: '20px',
84-
color: '#888',
8564
minWidth: '40px',
8665
textAlign: 'right',
8766
}}
@@ -91,6 +70,7 @@ const YamlViewer: FC<YamlViewerProps> = ({ yamlString }) => {
9170
borderRadius: '4px',
9271
fontSize: '1rem',
9372
width: '100%',
73+
background: 'transparent',
9474
}}
9575
>
9676
{formattedYaml}

0 commit comments

Comments
 (0)